#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->getTypeAllocSize(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;
+ 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: {
}
}
-void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
- const char *Modifier) {
- assert(isMem(MI, Op) && "Invalid memory reference!");
-
+void X86IntelAsmPrinter::printLeaMemReference(const MachineInstr *MI,
+ unsigned Op,
+ const char *Modifier) {
const MachineOperand &BaseReg = MI->getOperand(Op);
int ScaleVal = MI->getOperand(Op+1).getImm();
const MachineOperand &IndexReg = MI->getOperand(Op+2);
NeedPlus = true;
}
- if (DispSpec.isGlobalAddress() || DispSpec.isConstantPoolIndex() ||
- DispSpec.isJumpTableIndex()) {
+ if (DispSpec.isGlobal() || DispSpec.isCPI() ||
+ DispSpec.isJTI()) {
if (NeedPlus)
O << " + ";
printOp(DispSpec, "mem");
O << "]";
}
+void X86IntelAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
+ const char *Modifier) {
+ assert(isMem(MI, Op) && "Invalid memory reference!");
+ MachineOperand Segment = MI->getOperand(Op+4);
+ if (Segment.getReg()) {
+ printOperand(MI, Op+4, Modifier);
+ O << ':';
+ }
+ printLeaMemReference(MI, Op, Modifier);
+}
+
void X86IntelAsmPrinter::printPICJumpTableSetLabel(unsigned uid,
const MachineBasicBlock *MBB) const {
if (!TAI->getSetDirective())
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);
// Output linker support code for dllexported globals
if (!DLLExportedGVs.empty() || !DLLExportedFns.empty()) {
SwitchToDataSection("");
- O << "; WARNING: The following code is valid only with MASM v8.x and (possible) higher\n"
- << "; This version of MASM is usually shipped with Microsoft Visual Studio 2005\n"
- << "; or (possible) further versions. Unfortunately, there is no way to support\n"
- << "; dllexported symbols in the earlier versions of MASM in fully automatic way\n\n";
+ O << "; WARNING: The following code is valid only with MASM v8.x"
+ << "and (possible) higher\n"
+ << "; This version of MASM is usually shipped with Microsoft "
+ << "Visual Studio 2005\n"
+ << "; or (possible) further versions. Unfortunately, there is no "
+ << "way to support\n"
+ << "; dllexported symbols in the earlier versions of MASM in fully "
+ << "automatic way\n\n";
O << "_drectve\t segment info alias('.drectve')\n";
}