#include "llvm/Instructions.h"
#include "llvm/Module.h"
#include "llvm/SymbolTable.h"
-#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CFG.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/STLExtras.h"
bool PrintName,
std::map<const Type *, std::string> &TypeTable,
SlotMachine *Machine) {
+ const int IndentSize = 4;
+ static std::string Indent = "\n";
if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) {
Out << (CB == ConstantBool::True ? "true" : "false");
} else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV)) {
}
} else if (const ConstantStruct *CS = dyn_cast<ConstantStruct>(CV)) {
Out << '{';
- if (CS->getNumOperands()) {
- Out << ' ';
+ unsigned N = CS->getNumOperands();
+ if (N) {
+ if (N > 2) {
+ Indent += std::string(IndentSize, ' ');
+ Out << Indent;
+ } else {
+ Out << ' ';
+ }
printTypeInt(Out, CS->getOperand(0)->getType(), TypeTable);
WriteAsOperandInternal(Out, CS->getOperand(0),
PrintName, TypeTable, Machine);
- for (unsigned i = 1; i < CS->getNumOperands(); i++) {
+ for (unsigned i = 1; i < N; i++) {
Out << ", ";
+ if (N > 2) Out << Indent;
printTypeInt(Out, CS->getOperand(i)->getType(), TypeTable);
WriteAsOperandInternal(Out, CS->getOperand(i),
PrintName, TypeTable, Machine);
}
+ if (N > 2) Indent.resize(Indent.size() - IndentSize);
}
-
+
Out << " }";
} else if (const ConstantPacked *CP = dyn_cast<ConstantPacked>(CV)) {
const Type *ETy = CP->getType()->getElementType();
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);
}
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 {
if (this == 0) { o << "<null> constant value\n"; return; }
o << ' ' << getType()->getDescription() << ' ';
-
- std::map<const Type *, std::string> TypeTable;
- WriteConstantInt(o, this, false, TypeTable, 0);
}
void Type::print(std::ostream &o) const {