forked from OSchip/llvm-project
[Codegen] Change PICLevel.
We convert `Default` to `NotPIC` so that target independent code can reason about this correctly. Differential Revision: http://reviews.llvm.org/D21394 llvm-svn: 273024
This commit is contained in:
parent
78eebe7756
commit
4cccc488b7
|
@ -29,7 +29,8 @@ namespace llvm {
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PICLevel {
|
namespace PICLevel {
|
||||||
enum Level { Default=0, Small=1, Large=2 };
|
// This is used to map -fpic/-fPIC.
|
||||||
|
enum Level { NotPIC=0, SmallPIC=1, BigPIC=2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PIELevel {
|
namespace PIELevel {
|
||||||
|
|
|
@ -487,7 +487,7 @@ PICLevel::Level Module::getPICLevel() const {
|
||||||
auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("PIC Level"));
|
auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("PIC Level"));
|
||||||
|
|
||||||
if (!Val)
|
if (!Val)
|
||||||
return PICLevel::Default;
|
return PICLevel::NotPIC;
|
||||||
|
|
||||||
return static_cast<PICLevel::Level>(
|
return static_cast<PICLevel::Level>(
|
||||||
cast<ConstantInt>(Val->getValue())->getZExtValue());
|
cast<ConstantInt>(Val->getValue())->getZExtValue());
|
||||||
|
|
|
@ -601,7 +601,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||||
else if (MO.isBlockAddress())
|
else if (MO.isBlockAddress())
|
||||||
MOSymbol = GetBlockAddressSymbol(MO.getBlockAddress());
|
MOSymbol = GetBlockAddressSymbol(MO.getBlockAddress());
|
||||||
|
|
||||||
if (PL == PICLevel::Small) {
|
if (PL == PICLevel::SmallPIC) {
|
||||||
const MCExpr *Exp =
|
const MCExpr *Exp =
|
||||||
MCSymbolRefExpr::create(MOSymbol, MCSymbolRefExpr::VK_GOT,
|
MCSymbolRefExpr::create(MOSymbol, MCSymbolRefExpr::VK_GOT,
|
||||||
OutContext);
|
OutContext);
|
||||||
|
@ -1045,7 +1045,7 @@ void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) {
|
||||||
TM.getRelocationModel() != Reloc::PIC_)
|
TM.getRelocationModel() != Reloc::PIC_)
|
||||||
return AsmPrinter::EmitStartOfAsmFile(M);
|
return AsmPrinter::EmitStartOfAsmFile(M);
|
||||||
|
|
||||||
if (M.getPICLevel() == PICLevel::Small)
|
if (M.getPICLevel() == PICLevel::SmallPIC)
|
||||||
return AsmPrinter::EmitStartOfAsmFile(M);
|
return AsmPrinter::EmitStartOfAsmFile(M);
|
||||||
|
|
||||||
OutStreamer->SwitchSection(OutContext.getELFSection(
|
OutStreamer->SwitchSection(OutContext.getELFSection(
|
||||||
|
@ -1072,7 +1072,7 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() {
|
||||||
// linux/ppc32 - Normal entry label.
|
// linux/ppc32 - Normal entry label.
|
||||||
if (!Subtarget->isPPC64() &&
|
if (!Subtarget->isPPC64() &&
|
||||||
(TM.getRelocationModel() != Reloc::PIC_ ||
|
(TM.getRelocationModel() != Reloc::PIC_ ||
|
||||||
MF->getFunction()->getParent()->getPICLevel() == PICLevel::Small))
|
MF->getFunction()->getParent()->getPICLevel() == PICLevel::SmallPIC))
|
||||||
return AsmPrinter::EmitFunctionEntryLabel();
|
return AsmPrinter::EmitFunctionEntryLabel();
|
||||||
|
|
||||||
if (!Subtarget->isPPC64()) {
|
if (!Subtarget->isPPC64()) {
|
||||||
|
|
|
@ -319,7 +319,7 @@ SDNode *PPCDAGToDAGISel::getGlobalBaseReg() {
|
||||||
if (PPCLowering->getPointerTy(CurDAG->getDataLayout()) == MVT::i32) {
|
if (PPCLowering->getPointerTy(CurDAG->getDataLayout()) == MVT::i32) {
|
||||||
if (PPCSubTarget->isTargetELF()) {
|
if (PPCSubTarget->isTargetELF()) {
|
||||||
GlobalBaseReg = PPC::R30;
|
GlobalBaseReg = PPC::R30;
|
||||||
if (M->getPICLevel() == PICLevel::Small) {
|
if (M->getPICLevel() == PICLevel::SmallPIC) {
|
||||||
BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::MoveGOTtoLR));
|
BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::MoveGOTtoLR));
|
||||||
BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::MFLR), GlobalBaseReg);
|
BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::MFLR), GlobalBaseReg);
|
||||||
MF->getInfo<PPCFunctionInfo>()->setUsesPICBase(true);
|
MF->getInfo<PPCFunctionInfo>()->setUsesPICBase(true);
|
||||||
|
|
|
@ -2172,7 +2172,7 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue Op,
|
||||||
GOTPtr = DAG.getNode(PPCISD::ADDIS_TLSGD_HA, dl, PtrVT,
|
GOTPtr = DAG.getNode(PPCISD::ADDIS_TLSGD_HA, dl, PtrVT,
|
||||||
GOTReg, TGA);
|
GOTReg, TGA);
|
||||||
} else {
|
} else {
|
||||||
if (picLevel == PICLevel::Small)
|
if (picLevel == PICLevel::SmallPIC)
|
||||||
GOTPtr = DAG.getNode(PPCISD::GlobalBaseReg, dl, PtrVT);
|
GOTPtr = DAG.getNode(PPCISD::GlobalBaseReg, dl, PtrVT);
|
||||||
else
|
else
|
||||||
GOTPtr = DAG.getNode(PPCISD::PPC32_PICGOT, dl, PtrVT);
|
GOTPtr = DAG.getNode(PPCISD::PPC32_PICGOT, dl, PtrVT);
|
||||||
|
@ -2190,7 +2190,7 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue Op,
|
||||||
GOTPtr = DAG.getNode(PPCISD::ADDIS_TLSLD_HA, dl, PtrVT,
|
GOTPtr = DAG.getNode(PPCISD::ADDIS_TLSLD_HA, dl, PtrVT,
|
||||||
GOTReg, TGA);
|
GOTReg, TGA);
|
||||||
} else {
|
} else {
|
||||||
if (picLevel == PICLevel::Small)
|
if (picLevel == PICLevel::SmallPIC)
|
||||||
GOTPtr = DAG.getNode(PPCISD::GlobalBaseReg, dl, PtrVT);
|
GOTPtr = DAG.getNode(PPCISD::GlobalBaseReg, dl, PtrVT);
|
||||||
else
|
else
|
||||||
GOTPtr = DAG.getNode(PPCISD::PPC32_PICGOT, dl, PtrVT);
|
GOTPtr = DAG.getNode(PPCISD::PPC32_PICGOT, dl, PtrVT);
|
||||||
|
|
Loading…
Reference in New Issue