[llvm-commits] CVS: llvm/lib/VMCore/AsmWriter.cpp InlineAsm.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jan 25 14:26:17 PST 2006
Changes in directory llvm/lib/VMCore:
AsmWriter.cpp updated: 1.190 -> 1.191
InlineAsm.cpp updated: 1.2 -> 1.3
---
Log message:
Print InlineAsm objects
---
Diffs of the changes: (+27 -9)
AsmWriter.cpp | 16 ++++++++++++----
InlineAsm.cpp | 20 +++++++++++++++-----
2 files changed, 27 insertions(+), 9 deletions(-)
Index: llvm/lib/VMCore/AsmWriter.cpp
diff -u llvm/lib/VMCore/AsmWriter.cpp:1.190 llvm/lib/VMCore/AsmWriter.cpp:1.191
--- llvm/lib/VMCore/AsmWriter.cpp:1.190 Wed Jan 25 12:57:27 2006
+++ llvm/lib/VMCore/AsmWriter.cpp Wed Jan 25 16:26:05 2006
@@ -556,9 +556,18 @@
Out << getLLVMName(V->getName());
else {
const Constant *CV = dyn_cast<Constant>(V);
- if (CV && !isa<GlobalValue>(CV))
+ if (CV && !isa<GlobalValue>(CV)) {
WriteConstantInt(Out, CV, PrintName, TypeTable, Machine);
- else {
+ } else if (const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
+ Out << "asm ";
+ if (IA->hasSideEffects())
+ Out << "sideeffect ";
+ Out << '"';
+ PrintEscapedString(IA->getAsmString(), Out);
+ Out << "\", \"";
+ PrintEscapedString(IA->getConstraintString(), Out);
+ Out << '"';
+ } else {
int Slot;
if (Machine) {
Slot = Machine->getSlot(V);
@@ -1271,8 +1280,7 @@
}
void InlineAsm::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
- assert(0 && "Inline asm printing unimplemented!");
- //W.write(this);
+ WriteAsOperand(o, this, true, true, 0);
}
void BasicBlock::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
Index: llvm/lib/VMCore/InlineAsm.cpp
diff -u llvm/lib/VMCore/InlineAsm.cpp:1.2 llvm/lib/VMCore/InlineAsm.cpp:1.3
--- llvm/lib/VMCore/InlineAsm.cpp:1.2 Wed Jan 25 12:57:27 2006
+++ llvm/lib/VMCore/InlineAsm.cpp Wed Jan 25 16:26:05 2006
@@ -13,20 +13,30 @@
#include "llvm/InlineAsm.h"
#include "llvm/DerivedTypes.h"
-#include "llvm/Module.h"
-#include "llvm/Support/LeakDetector.h"
using namespace llvm;
+// NOTE: when memoizing the function type, we have to be careful to handle the
+// case when the type gets refined.
+
+InlineAsm *InlineAsm::get(const FunctionType *Ty, const std::string &AsmString,
+ const std::string &Constraints, bool hasSideEffects) {
+ // FIXME: memoize!
+ return new InlineAsm(Ty, AsmString, Constraints, hasSideEffects);
+}
+
InlineAsm::InlineAsm(const FunctionType *Ty, const std::string &asmString,
const std::string &constraints, bool hasSideEffects)
: Value(PointerType::get(Ty), Value::InlineAsmVal), AsmString(asmString),
Constraints(constraints), HasSideEffects(hasSideEffects) {
- LeakDetector::addGarbageObject(this);
- // FIXME: do various checks on the constraint string and type.
-
+ // Do various checks on the constraint string and type.
+ assert(Verify(Ty, constraints) && "Function type not legal for constraints!");
}
const FunctionType *InlineAsm::getFunctionType() const {
return cast<FunctionType>(getType()->getElementType());
}
+
+bool InlineAsm::Verify(const FunctionType *Ty, const std::string &Constraints) {
+ return true;
+}
More information about the llvm-commits
mailing list