cl::desc("Specify the name of the thing to generate"),
cl::init("!bad!"));
+/// CppBackendTargetMachineModule - Note that this is used on hosts
+/// that cannot link in a library unless there are references into the
+/// library. In particular, it seems that it is not possible to get
+/// things to work on Win32 without this. Though it is unused, do not
+/// remove it.
+extern "C" int CppBackendTargetMachineModule;
+int CppBackendTargetMachineModule = 0;
+
// Register the target.
static RegisterTarget<CPPTargetMachine> X("cpp", "C++ backend");
switch (LT) {
case GlobalValue::InternalLinkage:
Out << "GlobalValue::InternalLinkage"; break;
+ case GlobalValue::PrivateLinkage:
+ Out << "GlobalValue::PrivateLinkage"; break;
case GlobalValue::LinkOnceLinkage:
Out << "GlobalValue::LinkOnceLinkage "; break;
case GlobalValue::WeakLinkage:
unsigned index = PAL.getSlot(i).Index;
Attributes attrs = PAL.getSlot(i).Attrs;
Out << "PAWI.Index = " << index << "U; PAWI.Attrs = 0 ";
- if (attrs & Attribute::SExt)
- Out << " | Attribute::SExt";
- if (attrs & Attribute::ZExt)
- Out << " | Attribute::ZExt";
- if (attrs & Attribute::StructRet)
- Out << " | Attribute::StructRet";
- if (attrs & Attribute::InReg)
- Out << " | Attribute::InReg";
- if (attrs & Attribute::NoReturn)
- Out << " | Attribute::NoReturn";
- if (attrs & Attribute::NoUnwind)
- Out << " | Attribute::NoUnwind";
- if (attrs & Attribute::ByVal)
- Out << " | Attribute::ByVal";
- if (attrs & Attribute::NoAlias)
- Out << " | Attribute::NoAlias";
- if (attrs & Attribute::Nest)
- Out << " | Attribute::Nest";
- if (attrs & Attribute::ReadNone)
- Out << " | Attribute::ReadNone";
- if (attrs & Attribute::ReadOnly)
- Out << " | Attribute::ReadOnly";
+#define HANDLE_ATTR(X) \
+ if (attrs & Attribute::X) \
+ Out << " | Attribute::" #X; \
+ attrs &= ~Attribute::X;
+
+ HANDLE_ATTR(SExt);
+ HANDLE_ATTR(ZExt);
+ HANDLE_ATTR(StructRet);
+ HANDLE_ATTR(InReg);
+ HANDLE_ATTR(NoReturn);
+ HANDLE_ATTR(NoUnwind);
+ HANDLE_ATTR(ByVal);
+ HANDLE_ATTR(NoAlias);
+ HANDLE_ATTR(Nest);
+ HANDLE_ATTR(ReadNone);
+ HANDLE_ATTR(ReadOnly);
+ HANDLE_ATTR(NoCapture);
+#undef HANDLE_ATTR
+ assert(attrs == 0 && "Unhandled attribute!");
Out << ";";
nl(Out);
Out << "Attrs.push_back(PAWI);";
}
case Instruction::Store: {
const StoreInst* store = cast<StoreInst>(I);
- Out << " = new StoreInst("
+ Out << " new StoreInst("
<< opNames[0] << ", "
<< opNames[1] << ", "
<< (store->isVolatile() ? "true" : "false")
Out << "#include <llvm/Instructions.h>\n";
Out << "#include <llvm/InlineAsm.h>\n";
Out << "#include <llvm/Support/MathExtras.h>\n";
+ Out << "#include <llvm/Support/raw_ostream.h>\n";
Out << "#include <llvm/Pass.h>\n";
Out << "#include <llvm/PassManager.h>\n";
Out << "#include <llvm/ADT/SmallVector.h>\n";
Out << "#include <llvm/Analysis/Verifier.h>\n";
Out << "#include <llvm/Assembly/PrintModulePass.h>\n";
Out << "#include <algorithm>\n";
- Out << "#include <iostream>\n\n";
Out << "using namespace llvm;\n\n";
Out << "Module* " << fname << "();\n\n";
Out << "int main(int argc, char**argv) {\n";
Out << " Module* Mod = " << fname << "();\n";
Out << " verifyModule(*Mod, PrintMessageAction);\n";
- Out << " std::cerr.flush();\n";
- Out << " std::cout.flush();\n";
+ Out << " errs().flush();\n";
+ Out << " outs().flush();\n";
Out << " PassManager PM;\n";
- Out << " PM.add(new PrintModulePass(&llvm::cout));\n";
+ Out << " PM.add(createPrintModulePass(&outs()));\n";
Out << " PM.run(*Mod);\n";
Out << " return 0;\n";
Out << "}\n\n";