#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Assembly/Writer.h"
+#include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetOptions.h"
const Type* Ty = AI->getType();
// 'Dereference' type in case of byval parameter attribute
- if (F->paramHasAttr(argNum, ParamAttr::ByVal))
+ if (F->paramHasAttr(argNum, Attribute::ByVal))
Ty = cast<PointerType>(Ty)->getElementType();
// Size should be aligned to DWORD boundary
- Size += ((TD->getABITypeSize(Ty) + 3)/4)*4;
+ Size += ((TD->getTypePaddedSize(Ty) + 3)/4)*4;
}
// We're not supporting tooooo huge arguments :)
}
}
-
-std::string X86IntelAsmPrinter::getSectionForFunction(const Function &F) const {
- // Intel asm always emits functions to _text.
- return "_text";
-}
-
/// runOnMachineFunction - This uses the printMachineInstruction()
/// method to print assembly for each instruction.
///
bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
+ this->MF = &MF;
SetupMachineFunction(MF);
O << "\n\n";
decorateName(CurrentFnName, F);
- SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
+ SwitchToTextSection("_text", F);
- unsigned FnAlign = OptimizeForSize ? 1 : 4;
- if (!F->isDeclaration() && F->hasNote(FnAttr::OptimizeForSize))
+ unsigned FnAlign = 4;
+ if (F->hasFnAttr(Attribute::OptimizeForSize))
FnAlign = 1;
switch (F->getLinkage()) {
default: assert(0 && "Unsupported linkage type!");
+ case Function::PrivateLinkage:
case Function::InternalLinkage:
EmitAlignment(FnAlign);
break;
O << CurrentFnName << "\tendp\n";
+ O.flush();
+
// We didn't modify anything.
return false;
}
if (!isMemOp) O << "OFFSET ";
O << "[" << TAI->getPrivateGlobalPrefix() << "CPI"
<< getFunctionNumber() << "_" << MO.getIndex();
- int Offset = MO.getOffset();
- if (Offset > 0)
- O << " + " << Offset;
- else if (Offset < 0)
- O << Offset;
+ printOffset(MO.getOffset());
O << "]";
return;
}
O << "__imp_";
}
O << Name;
- int Offset = MO.getOffset();
- if (Offset > 0)
- O << " + " << Offset;
- else if (Offset < 0)
- O << Offset;
+ printOffset(MO.getOffset());
return;
}
case MachineOperand::MO_ExternalSymbol: {
NeedPlus = true;
}
- if (DispSpec.isGlobalAddress() || DispSpec.isConstantPoolIndex() ||
- DispSpec.isJumpTableIndex()) {
+ if (DispSpec.isGlobal() || DispSpec.isCPI() ||
+ DispSpec.isJTI()) {
if (NeedPlus)
O << " + ";
printOp(DispSpec, "mem");
switch (I->getLinkage()) {
case GlobalValue::CommonLinkage:
- case GlobalValue::LinkOnceLinkage:
- case GlobalValue::WeakLinkage:
+ case GlobalValue::LinkOnceAnyLinkage:
+ case GlobalValue::LinkOnceODRLinkage:
+ case GlobalValue::WeakAnyLinkage:
+ case GlobalValue::WeakODRLinkage:
SwitchToDataSection("");
O << name << "?\tsegment common 'COMMON'\n";
bCustomSegment = true;
O << "\tpublic " << name << "\n";
// FALL THROUGH
case GlobalValue::InternalLinkage:
- SwitchToDataSection(TAI->getDataSection(), I);
+ SwitchToSection(TAI->getDataSection());
break;
default:
assert(0 && "Unknown linkage type!");
if (!bCustomSegment)
EmitAlignment(Align, I);
- O << name << ":\t\t\t\t" << TAI->getCommentString()
- << " " << I->getName() << '\n';
+ O << name << ":";
+ if (VerboseAsm)
+ O << "\t\t\t\t" << TAI->getCommentString()
+ << " " << I->getName();
+ O << '\n';
EmitGlobalConstant(C);