diff options
author | Chris Lattner <sabre@nondot.org> | 2006-01-24 04:13:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-01-24 04:13:11 +0000 |
commit | cc041ba03aed685400197fb938b7a583713d25af (patch) | |
tree | 002b884baab37ed1918904254b86eb9f3d39a50f /lib/VMCore | |
parent | 52060a0e7190d7713042f18b1b949d1ae953638f (diff) | |
download | external_llvm-cc041ba03aed685400197fb938b7a583713d25af.zip external_llvm-cc041ba03aed685400197fb938b7a583713d25af.tar.gz external_llvm-cc041ba03aed685400197fb938b7a583713d25af.tar.bz2 |
Initial checkin of the InlineAsm class
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25570 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/AsmWriter.cpp | 12 | ||||
-rw-r--r-- | lib/VMCore/Globals.cpp | 4 | ||||
-rw-r--r-- | lib/VMCore/InlineAsm.cpp | 50 | ||||
-rw-r--r-- | lib/VMCore/Module.cpp | 19 |
4 files changed, 80 insertions, 5 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index d0b8478..c6a3845 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -775,9 +775,9 @@ void AssemblyWriter::printModule(const Module *M) { if (!M->getTargetTriple().empty()) Out << "target triple = \"" << M->getTargetTriple() << "\"\n"; - if (!M->getInlineAsm().empty()) { + if (!M->getModuleInlineAsm().empty()) { // Split the string into lines, to make it easier to read the .ll file. - std::string Asm = M->getInlineAsm(); + std::string Asm = M->getModuleInlineAsm(); size_t CurPos = 0; size_t NewLine = Asm.find_first_of('\n', CurPos); while (NewLine != std::string::npos) { @@ -1269,6 +1269,14 @@ void Function::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const { W.write(this); } +void InlineAsm::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const { + SlotMachine SlotTable(getParent()); + AssemblyWriter W(o, SlotTable, getParent(), AAW); + + assert(0 && "Inline asm printing unimplemented!"); + //W.write(this); +} + void BasicBlock::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const { SlotMachine SlotTable(getParent()); AssemblyWriter W(o, SlotTable, diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp index be6c6eb..3ea8265 100644 --- a/lib/VMCore/Globals.cpp +++ b/lib/VMCore/Globals.cpp @@ -1,4 +1,4 @@ -//===-- Globals.cpp - Implement the Global object classes -----------------===// +//===-- Globals.cpp - Implement the GlobalValue & GlobalVariable class ----===// // // The LLVM Compiler Infrastructure // @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/DerivedTypes.h" #include "llvm/GlobalVariable.h" +#include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/SymbolTable.h" #include "llvm/Support/LeakDetector.h" diff --git a/lib/VMCore/InlineAsm.cpp b/lib/VMCore/InlineAsm.cpp new file mode 100644 index 0000000..1eed894 --- /dev/null +++ b/lib/VMCore/InlineAsm.cpp @@ -0,0 +1,50 @@ +//===-- InlineAsm.cpp - Implement the InlineAsm class ---------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Chris Lattner and is distributed under the +// University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements the InlineAsm class. +// +//===----------------------------------------------------------------------===// + +#include "llvm/InlineAsm.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Module.h" +#include "llvm/Support/LeakDetector.h" +using namespace llvm; + +InlineAsm::InlineAsm(const FunctionType *Ty, const std::string &asmString, + const std::string &constraints, bool hasSideEffects, + const std::string &name, Module *ParentModule) + : Value(PointerType::get(Ty), Value::InlineAsmVal, name), + Parent(0), AsmString(asmString), Constraints(constraints), + AsmHasSideEffects(hasSideEffects) { + LeakDetector::addGarbageObject(this); + + if (ParentModule) + ParentModule->getInlineAsmList().push_back(this); +} + +const FunctionType *InlineAsm::getFunctionType() const { + return cast<FunctionType>(getType()->getElementType()); +} + +void InlineAsm::setParent(Module *parent) { + if (getParent()) + LeakDetector::addGarbageObject(this); + Parent = parent; + if (getParent()) + LeakDetector::removeGarbageObject(this); +} + +void InlineAsm::removeFromParent() { + getParent()->getInlineAsmList().remove(this); +} + +void InlineAsm::eraseFromParent() { + getParent()->getInlineAsmList().erase(this); +} diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index de63b4b..e9b28f9 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -44,17 +44,30 @@ GlobalVariable *ilist_traits<GlobalVariable>::createSentinel() { return Ret; } +InlineAsm *ilist_traits<InlineAsm>::createSentinel() { + InlineAsm *Ret = new InlineAsm(FunctionType::get(Type::VoidTy, + std::vector<const Type*>(), false), "", "", + false); + // This should not be garbage monitored. + LeakDetector::removeGarbageObject(Ret); + return Ret; +} + iplist<Function> &ilist_traits<Function>::getList(Module *M) { return M->getFunctionList(); } iplist<GlobalVariable> &ilist_traits<GlobalVariable>::getList(Module *M) { return M->getGlobalList(); } +iplist<InlineAsm> &ilist_traits<InlineAsm>::getList(Module *M) { + return M->getInlineAsmList(); +} // Explicit instantiations of SymbolTableListTraits since some of the methods -// are not in the public header file... +// are not in the public header file. template class SymbolTableListTraits<GlobalVariable, Module, Module>; template class SymbolTableListTraits<Function, Module, Module>; +template class SymbolTableListTraits<InlineAsm, Module, Module>; //===----------------------------------------------------------------------===// // Primitive Module methods. @@ -66,6 +79,8 @@ Module::Module(const std::string &MID) FunctionList.setParent(this); GlobalList.setItemParent(this); GlobalList.setParent(this); + InlineAsmList.setItemParent(this); + InlineAsmList.setParent(this); SymTab = new SymbolTable(); } @@ -75,6 +90,8 @@ Module::~Module() { GlobalList.setParent(0); FunctionList.clear(); FunctionList.setParent(0); + InlineAsmList.clear(); + InlineAsmList.setParent(0); LibraryList.clear(); delete SymTab; } |