//===-- MSILWriter.cpp - Library for converting LLVM code to MSIL ---------===//
//
-// The LLVM Compiler Infrastructure
+// The LLVM Compiler Infrastructure
//
-// This file was developed by Roman Samoilov and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
#include "llvm/Support/MathExtras.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/CodeGen/Passes.h"
namespace {
// TargetMachine for the MSIL
}
-RegisterTarget<MSILTarget> X("msil", " MSIL backend");
+static RegisterTarget<MSILTarget> X("msil", " MSIL backend");
bool MSILModule::runOnModule(Module &M) {
ModulePtr = &M;
}
bool RetVoid = (F->getReturnType()->getTypeID() == Type::VoidTyID);
- if (BadSig || !F->getReturnType()->isInteger() && !RetVoid) {
+ if (BadSig || (!F->getReturnType()->isInteger() && !RetVoid)) {
Out << "\tldc.i4.0\n";
} else {
Out << "\tcall\t" << getTypeName(F->getReturnType()) <<
cerr << "CallingConvID = " << CallingConvID << '\n';
assert(0 && "Unsupported calling convention");
}
+ return ""; // Not reached
}
cerr << "Type = " << *Ty << '\n';
assert(0 && "Invalid primitive type");
}
+ return ""; // Not reached
}
cerr << "Type = " << *Ty << '\n';
assert(0 && "Invalid type in getTypeName()");
}
+ return ""; // Not reached
}
cerr << "TypeID = " << Ty->getTypeID() << '\n';
assert(0 && "Invalid type in TypeToPostfix()");
}
+ return ""; // Not reached
}
// Save as pointer type "void*"
printValueLoad(Inst->getOperand(1));
printSimpleInstruction("ldloca",Name.c_str());
- printIndirectSave(PointerType::get(IntegerType::get(8)));
+ printIndirectSave(PointerType::getUnqual(IntegerType::get(8)));
break;
case Intrinsic::vaend:
// Close argument list handle.
printSimpleInstruction("call",
"instance typedref [mscorlib]System.ArgIterator::GetNextArg()");
printSimpleInstruction("refanyval","void*");
- std::string Name = "ldind."+getTypePostfix(PointerType::get(IntegerType::get(8)),false);
+ std::string Name =
+ "ldind."+getTypePostfix(PointerType::getUnqual(IntegerType::get(8)),false);
printSimpleInstruction(Name.c_str());
}
const AllocaInst* AI = dyn_cast<AllocaInst>(&*I);
if (AI && !isa<GlobalVariable>(AI)) {
// Local variable allocation.
- Ty = PointerType::get(AI->getAllocatedType());
+ Ty = PointerType::getUnqual(AI->getAllocatedType());
Name = getValueName(AI);
Out << "\t.locals (" << getTypeName(Ty) << Name << ")\n";
} else if (I->getType()!=Type::VoidTy) {
void MSILWriter::printFunction(const Function& F) {
- const ParamAttrsList *Attrs = F.getParamAttrs();
- bool isSigned = Attrs && Attrs->paramHasAttr(0, ParamAttr::SExt);
+ bool isSigned = F.paramHasAttr(0, ParamAttr::SExt);
Out << "\n.method static ";
Out << (F.hasInternalLinkage() ? "private " : "public ");
if (F.isVarArg()) Out << "vararg ";
unsigned ArgIdx = 1;
for (Function::const_arg_iterator I = F.arg_begin(), E = F.arg_end(); I!=E;
++I, ++ArgIdx) {
- isSigned = Attrs && Attrs->paramHasAttr(ArgIdx, ParamAttr::SExt);
+ isSigned = F.paramHasAttr(ArgIdx, ParamAttr::SExt);
if (I!=F.arg_begin()) Out << ", ";
Out << getTypeName(I->getType(),isSigned) << getValueName(I);
}
cerr << "Bits = " << N << '\n';
assert(0 && "Unsupported integer width");
}
+ return 0; // Not reached
}
// Functions.
for (I=ModulePtr->begin(),E=ModulePtr->end(); I!=E; ++I) {
// Skip intrisics
- if (I->getIntrinsicID()) continue;
+ if (I->isIntrinsic()) continue;
if (I->isDeclaration()) {
const Function* F = I;
std::string Name = getConvModopt(F->getCallingConv())+getValueName(F);
//===----------------------------------------------------------------------===//
-// External Interface declaration
+// External Interface declaration
//===----------------------------------------------------------------------===//
bool MSILTarget::addPassesToEmitWholeFile(PassManager &PM, std::ostream &o,
{
if (FileType != TargetMachine::AssemblyFile) return true;
MSILWriter* Writer = new MSILWriter(o);
- PM.add(createLowerGCPass());
+ PM.add(createGCLoweringPass());
PM.add(createLowerAllocationsPass(true));
// FIXME: Handle switch trougth native IL instruction "switch"
PM.add(createLowerSwitchPass());
PM.add(createCFGSimplificationPass());
PM.add(new MSILModule(Writer->UsedTypes,Writer->TD));
PM.add(Writer);
+ PM.add(createCollectorMetadataDeleter());
return false;
}