X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FX86%2FAsmPrinter%2FX86ATTAsmPrinter.cpp;h=c88af21784c34eb3705469607a141995d7ea4452;hb=777d2306b36816a53bc1ae1244c0dc7d998ae691;hp=d8a33957d5cf998c498e3382da465b70453e4c15;hpb=e67f5e42734199a1f4771773417699262491eb86;p=oota-llvm.git diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index d8a33957d5c..c88af21784c 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -76,7 +76,7 @@ static X86MachineFunctionInfo calculateFunctionInfo(const Function *F, Ty = cast(Ty)->getElementType(); // Size should be aligned to DWORD boundary - Size += ((TD->getTypePaddedSize(Ty) + 3)/4)*4; + Size += ((TD->getTypeAllocSize(Ty) + 3)/4)*4; } // We're not supporting tooooo huge arguments :) @@ -241,8 +241,6 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) { if (!VerboseAsm && (I->pred_empty() || I->isOnlyReachableByFallthrough())) { // This is an entry block or a block that's only reachable via a // fallthrough edge. In non-VerboseAsm mode, don't print the label. - assert((I->pred_empty() || (*I->pred_begin())->isLayoutSuccessor(I)) && - "Fall-through predecessor not adjacent to its successor!"); } else { printBasicBlockLabel(I, true, true, VerboseAsm); O << '\n'; @@ -456,14 +454,16 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, O << "@TLSGD"; break; case TLSModel::InitialExec: - if (Subtarget->is64Bit()) - O << "@TLSGD"; // 64 bit intial exec not implemented - else + if (Subtarget->is64Bit()) { + assert (!NotRIPRel); + O << "@GOTTPOFF(%rip)"; + } else { O << "@INDNTPOFF"; + } break; case TLSModel::LocalExec: if (Subtarget->is64Bit()) - O << "@TLSGD"; // 64 bit local exec not implemented + O << "@TPOFF"; else O << "@NTPOFF"; break; @@ -501,6 +501,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, } case MachineOperand::MO_ExternalSymbol: { bool isCallOp = Modifier && !strcmp(Modifier, "call"); + bool isMemOp = Modifier && !strcmp(Modifier, "mem"); bool needCloseParen = false; std::string Name(TAI->getGlobalPrefix()); Name += MO.getSymbolName(); @@ -511,7 +512,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, printSuffixedName(Name, "$stub"); return; } - if (!isCallOp) + if (!isMemOp && !isCallOp) O << '$'; else if (Name[0] == '$') { // The name begins with a dollar-sign. In order to avoid having it look @@ -568,17 +569,18 @@ void X86ATTAsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) { } } -void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op, - const char *Modifier){ - assert(isMem(MI, Op) && "Invalid memory reference!"); +void X86ATTAsmPrinter::printLeaMemReference(const MachineInstr *MI, unsigned Op, + const char *Modifier, + bool NotRIPRel) { MachineOperand BaseReg = MI->getOperand(Op); MachineOperand IndexReg = MI->getOperand(Op+2); const MachineOperand &DispSpec = MI->getOperand(Op+3); - bool NotRIPRel = IndexReg.getReg() || BaseReg.getReg(); + NotRIPRel |= IndexReg.getReg() || BaseReg.getReg(); if (DispSpec.isGlobal() || DispSpec.isCPI() || - DispSpec.isJTI()) { + DispSpec.isJTI() || + DispSpec.isSymbol()) { printOperand(MI, Op+3, "mem", NotRIPRel); } else { int DispVal = DispSpec.getImm(); @@ -613,6 +615,17 @@ void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op, } } +void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op, + const char *Modifier, bool NotRIPRel){ + 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, NotRIPRel); +} + void X86ATTAsmPrinter::printPICJumpTableSetLabel(unsigned uid, const MachineBasicBlock *MBB) const { if (!TAI->getSetDirective()) @@ -711,7 +724,7 @@ bool X86ATTAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, return false; case 'P': // Don't print @PLT, but do print as memory. - printOperand(MI, OpNo, "mem"); + printOperand(MI, OpNo, "mem", /*NotRIPRel=*/true); return false; } } @@ -737,7 +750,7 @@ bool X86ATTAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, // These only apply to registers, ignore on mem. break; case 'P': // Don't print @PLT, but do print as memory. - printOperand(MI, OpNo, "mem"); + printMemReference(MI, OpNo, "mem", /*NotRIPRel=*/true); return false; } } @@ -798,7 +811,7 @@ void X86ATTAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) { std::string name = Mang->getValueName(GVar); Constant *C = GVar->getInitializer(); const Type *Type = C->getType(); - unsigned Size = TD->getTypePaddedSize(Type); + unsigned Size = TD->getTypeAllocSize(Type); unsigned Align = TD->getPreferredAlignmentLog(GVar); printVisibility(name, GVar->getVisibility());