};
}
+/// MSILTargetMachineModule - 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 MSILTargetMachineModule;
+int MSILTargetMachineModule = 0;
static RegisterTarget<MSILTarget> X("msil", "MSIL backend");
return ArgumentVT;
// Function
else if (const Function* F = dyn_cast<Function>(V))
- return F->hasInternalLinkage() ? InternalVT : GlobalVT;
+ return F->hasLocalLinkage() ? InternalVT : GlobalVT;
// Variable
else if (const GlobalVariable* G = dyn_cast<GlobalVariable>(V))
- return G->hasInternalLinkage() ? InternalVT : GlobalVT;
+ return G->hasLocalLinkage() ? InternalVT : GlobalVT;
// Constant
else if (isa<Constant>(V))
return isa<ConstantExpr>(V) ? ConstExprVT : ConstVT;
case Type::DoubleTyID:
return "r8";
case Type::PointerTyID:
- return "i"+utostr(TD->getABITypeSize(Ty));
+ return "i"+utostr(TD->getTypePaddedSize(Ty));
default:
cerr << "TypeID = " << Ty->getTypeID() << '\n';
assert(0 && "Invalid type in TypeToPostfix()");
uint64_t FieldIndex = cast<ConstantInt>(IndexValue)->getZExtValue();
// Offset is the sum of all previous structure fields.
for (uint64_t F = 0; F<FieldIndex; ++F)
- Size += TD->getABITypeSize(StrucTy->getContainedType((unsigned)F));
+ Size += TD->getTypePaddedSize(StrucTy->getContainedType((unsigned)F));
printPtrLoad(Size);
printSimpleInstruction("add");
continue;
} else if (const SequentialType* SeqTy = dyn_cast<SequentialType>(*I)) {
- Size = TD->getABITypeSize(SeqTy->getElementType());
+ Size = TD->getTypePaddedSize(SeqTy->getElementType());
} else {
- Size = TD->getABITypeSize(*I);
+ Size = TD->getTypePaddedSize(*I);
}
// Add offset of current element to stack top.
if (!isZeroValue(IndexValue)) {
void MSILWriter::printAllocaInstruction(const AllocaInst* Inst) {
- uint64_t Size = TD->getABITypeSize(Inst->getAllocatedType());
+ uint64_t Size = TD->getTypePaddedSize(Inst->getAllocatedType());
// Constant optimization.
if (const ConstantInt* CInt = dyn_cast<ConstantInt>(Inst->getOperand(0))) {
printPtrLoad(CInt->getZExtValue()*Size);
void MSILWriter::printFunction(const Function& F) {
bool isSigned = F.paramHasAttr(0, Attribute::SExt);
Out << "\n.method static ";
- Out << (F.hasInternalLinkage() ? "private " : "public ");
+ Out << (F.hasLocalLinkage() ? "private " : "public ");
if (F.isVarArg()) Out << "vararg ";
Out << getTypeName(F.getReturnType(),isSigned) <<
getConvModopt(F.getCallingConv()) << getValueName(&F) << '\n';
// Print not duplicated type
if (Printed.insert(Ty).second) {
Out << ".class value explicit ansi sealed '" << Name << "'";
- Out << " { .pack " << 1 << " .size " << TD->getABITypeSize(Ty)<< " }\n\n";
+ Out << " { .pack " << 1 << " .size " << TD->getTypePaddedSize(Ty);
+ Out << " }\n\n";
}
}
}
const Type* Ty = C->getType();
// Print zero initialized constant.
if (isa<ConstantAggregateZero>(C) || C->isNullValue()) {
- TySize = TD->getABITypeSize(C->getType());
+ TySize = TD->getTypePaddedSize(C->getType());
Offset += TySize;
Out << "int8 (0) [" << TySize << "]";
return;
// Print constant initializer
switch (Ty->getTypeID()) {
case Type::IntegerTyID: {
- TySize = TD->getABITypeSize(Ty);
+ TySize = TD->getTypePaddedSize(Ty);
const ConstantInt* Int = cast<ConstantInt>(C);
Out << getPrimitiveTypeName(Ty,true) << "(" << Int->getSExtValue() << ")";
break;
}
case Type::FloatTyID:
case Type::DoubleTyID: {
- TySize = TD->getABITypeSize(Ty);
+ TySize = TD->getTypePaddedSize(Ty);
const ConstantFP* FP = cast<ConstantFP>(C);
if (Ty->getTypeID() == Type::FloatTyID)
Out << "int32 (" <<
}
break;
case Type::PointerTyID:
- TySize = TD->getABITypeSize(C->getType());
+ TySize = TD->getTypePaddedSize(C->getType());
// Initialize with global variable address
if (const GlobalVariable *G = dyn_cast<GlobalVariable>(C)) {
std::string name = getValueName(G);