[llvm-commits] CVS: llvm/lib/VMCore/InlineAsm.cpp AsmWriter.cpp Globals.cpp Module.cpp

Chris Lattner lattner at cs.uiuc.edu
Mon Jan 23 20:13:23 PST 2006



Changes in directory llvm/lib/VMCore:

InlineAsm.cpp added (r1.1)
AsmWriter.cpp updated: 1.188 -> 1.189
Globals.cpp updated: 1.12 -> 1.13
Module.cpp updated: 1.62 -> 1.63
---
Log message:

Initial checkin of the InlineAsm class


---
Diffs of the changes:  (+80 -5)

 AsmWriter.cpp |   12 ++++++++++--
 Globals.cpp   |    4 ++--
 InlineAsm.cpp |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 Module.cpp    |   19 ++++++++++++++++++-
 4 files changed, 80 insertions(+), 5 deletions(-)


Index: llvm/lib/VMCore/InlineAsm.cpp
diff -c /dev/null llvm/lib/VMCore/InlineAsm.cpp:1.1
*** /dev/null	Mon Jan 23 22:13:21 2006
--- llvm/lib/VMCore/InlineAsm.cpp	Mon Jan 23 22:13:11 2006
***************
*** 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);
+ }


Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.188 llvm/lib/VMCore/AsmWriter.cpp:1.189
--- llvm/lib/VMCore/AsmWriter.cpp:1.188	Mon Jan 23 18:45:30 2006
+++ llvm/lib/VMCore/AsmWriter.cpp	Mon Jan 23 22:13:11 2006
@@ -775,9 +775,9 @@
   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 @@
   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,


Index: llvm/lib/VMCore/Globals.cpp
diff -u llvm/lib/VMCore/Globals.cpp:1.12 llvm/lib/VMCore/Globals.cpp:1.13
--- llvm/lib/VMCore/Globals.cpp:1.12	Tue Oct  4 13:13:04 2005
+++ llvm/lib/VMCore/Globals.cpp	Mon Jan 23 22:13:11 2006
@@ -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"


Index: llvm/lib/VMCore/Module.cpp
diff -u llvm/lib/VMCore/Module.cpp:1.62 llvm/lib/VMCore/Module.cpp:1.63
--- llvm/lib/VMCore/Module.cpp:1.62	Sun Dec  4 23:30:21 2005
+++ llvm/lib/VMCore/Module.cpp	Mon Jan 23 22:13:11 2006
@@ -44,17 +44,30 @@
   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 @@
   FunctionList.setParent(this);
   GlobalList.setItemParent(this);
   GlobalList.setParent(this);
+  InlineAsmList.setItemParent(this);
+  InlineAsmList.setParent(this);
   SymTab = new SymbolTable();
 }
 
@@ -75,6 +90,8 @@
   GlobalList.setParent(0);
   FunctionList.clear();
   FunctionList.setParent(0);
+  InlineAsmList.clear();
+  InlineAsmList.setParent(0);
   LibraryList.clear();
   delete SymTab;
 }






More information about the llvm-commits mailing list