mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Get the CPP backend into some semblance of working by updating for numerous LLVMContext changes,
as well as the StringRef change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79006 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
94d38e561b
commit
267a0ff045
@ -353,7 +353,7 @@ namespace {
|
||||
case Type::VoidTyID: return "Type::VoidTy";
|
||||
case Type::IntegerTyID: {
|
||||
unsigned BitWidth = cast<IntegerType>(Ty)->getBitWidth();
|
||||
return "IntegerType::get(" + utostr(BitWidth) + ")";
|
||||
return "IntegerType::get(getGlobalContext(), " + utostr(BitWidth) + ")";
|
||||
}
|
||||
case Type::X86_FP80TyID: return "Type::X86_FP80Ty";
|
||||
case Type::FloatTyID: return "Type::FloatTy";
|
||||
@ -750,9 +750,10 @@ namespace {
|
||||
|
||||
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
|
||||
std::string constValue = CI->getValue().toString(10, true);
|
||||
Out << "ConstantInt* " << constName << " = ConstantInt::get(APInt("
|
||||
<< cast<IntegerType>(CI->getType())->getBitWidth() << ", \""
|
||||
<< constValue << "\", " << constValue.length() << ", 10));";
|
||||
Out << "ConstantInt* " << constName
|
||||
<< " = ConstantInt::get(getGlobalContext(), APInt("
|
||||
<< cast<IntegerType>(CI->getType())->getBitWidth()
|
||||
<< ", StringRef(\"" << constValue << "\"), 10));";
|
||||
} else if (isa<ConstantAggregateZero>(CV)) {
|
||||
Out << "ConstantAggregateZero* " << constName
|
||||
<< " = ConstantAggregateZero::get(" << typeName << ");";
|
||||
@ -767,7 +768,8 @@ namespace {
|
||||
if (CA->isString() &&
|
||||
CA->getType()->getElementType() ==
|
||||
Type::getInt8Ty(CA->getContext())) {
|
||||
Out << "Constant* " << constName << " = ConstantArray::get(\"";
|
||||
Out << "Constant* " << constName <<
|
||||
" = ConstantArray::get(getGlobalContext(), \"";
|
||||
std::string tmp = CA->getAsString();
|
||||
bool nullTerminate = false;
|
||||
if (tmp[tmp.length()-1] == 0) {
|
||||
@ -994,13 +996,13 @@ namespace {
|
||||
void CppWriter::printVariableHead(const GlobalVariable *GV) {
|
||||
nl(Out) << "GlobalVariable* " << getCppName(GV);
|
||||
if (is_inline) {
|
||||
Out << " = mod->getGlobalVariable(";
|
||||
Out << " = mod->getGlobalVariable(getGlobalContext(), ";
|
||||
printEscapedString(GV->getName());
|
||||
Out << ", " << getCppName(GV->getType()->getElementType()) << ",true)";
|
||||
nl(Out) << "if (!" << getCppName(GV) << ") {";
|
||||
in(); nl(Out) << getCppName(GV);
|
||||
}
|
||||
Out << " = new GlobalVariable(/*Module=*/*mod";
|
||||
Out << " = new GlobalVariable(/*Module=*/*mod, ";
|
||||
nl(Out) << "/*Type=*/";
|
||||
printCppName(GV->getType()->getElementType());
|
||||
Out << ",";
|
||||
@ -1093,7 +1095,7 @@ namespace {
|
||||
|
||||
case Instruction::Ret: {
|
||||
const ReturnInst* ret = cast<ReturnInst>(I);
|
||||
Out << "ReturnInst::Create("
|
||||
Out << "ReturnInst::Create(getGlobalContext(), "
|
||||
<< (ret->getReturnValue() ? opNames[0] + ", " : "") << bbname << ");";
|
||||
break;
|
||||
}
|
||||
@ -1678,7 +1680,8 @@ namespace {
|
||||
for (Function::const_iterator BI = F->begin(), BE = F->end();
|
||||
BI != BE; ++BI) {
|
||||
std::string bbname(getCppName(BI));
|
||||
Out << "BasicBlock* " << bbname << " = BasicBlock::Create(\"";
|
||||
Out << "BasicBlock* " << bbname <<
|
||||
" = BasicBlock::Create(getGlobalContext(), \"";
|
||||
if (BI->hasName())
|
||||
printEscapedString(BI->getName());
|
||||
Out << "\"," << getCppName(BI->getParent()) << ",0);";
|
||||
@ -1797,6 +1800,7 @@ namespace {
|
||||
|
||||
void CppWriter::printProgram(const std::string& fname,
|
||||
const std::string& mName) {
|
||||
Out << "#include <llvm/LLVMContext.h>\n";
|
||||
Out << "#include <llvm/Module.h>\n";
|
||||
Out << "#include <llvm/DerivedTypes.h>\n";
|
||||
Out << "#include <llvm/Constants.h>\n";
|
||||
@ -1833,7 +1837,7 @@ namespace {
|
||||
nl(Out,1) << "// Module Construction";
|
||||
nl(Out) << "Module* mod = new Module(\"";
|
||||
printEscapedString(mName);
|
||||
Out << "\");";
|
||||
Out << "\", getGlobalContext());";
|
||||
if (!TheModule->getTargetTriple().empty()) {
|
||||
nl(Out) << "mod->setDataLayout(\"" << TheModule->getDataLayout() << "\");";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user