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 {
|
||||
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 {
|
||||
|
|
|
@ -487,7 +487,7 @@ PICLevel::Level Module::getPICLevel() const {
|
|||
auto *Val = cast_or_null<ConstantAsMetadata>(getModuleFlag("PIC Level"));
|
||||
|
||||
if (!Val)
|
||||
return PICLevel::Default;
|
||||
return PICLevel::NotPIC;
|
||||
|
||||
return static_cast<PICLevel::Level>(
|
||||
cast<ConstantInt>(Val->getValue())->getZExtValue());
|
||||
|
|
|
@ -601,7 +601,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
|||
else if (MO.isBlockAddress())
|
||||
MOSymbol = GetBlockAddressSymbol(MO.getBlockAddress());
|
||||
|
||||
if (PL == PICLevel::Small) {
|
||||
if (PL == PICLevel::SmallPIC) {
|
||||
const MCExpr *Exp =
|
||||
MCSymbolRefExpr::create(MOSymbol, MCSymbolRefExpr::VK_GOT,
|
||||
OutContext);
|
||||
|
@ -1045,7 +1045,7 @@ void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) {
|
|||
TM.getRelocationModel() != Reloc::PIC_)
|
||||
return AsmPrinter::EmitStartOfAsmFile(M);
|
||||
|
||||
if (M.getPICLevel() == PICLevel::Small)
|
||||
if (M.getPICLevel() == PICLevel::SmallPIC)
|
||||
return AsmPrinter::EmitStartOfAsmFile(M);
|
||||
|
||||
OutStreamer->SwitchSection(OutContext.getELFSection(
|
||||
|
@ -1072,7 +1072,7 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() {
|
|||
// linux/ppc32 - Normal entry label.
|
||||
if (!Subtarget->isPPC64() &&
|
||||
(TM.getRelocationModel() != Reloc::PIC_ ||
|
||||
MF->getFunction()->getParent()->getPICLevel() == PICLevel::Small))
|
||||
MF->getFunction()->getParent()->getPICLevel() == PICLevel::SmallPIC))
|
||||
return AsmPrinter::EmitFunctionEntryLabel();
|
||||
|
||||
if (!Subtarget->isPPC64()) {
|
||||
|
|
|
@ -319,7 +319,7 @@ SDNode *PPCDAGToDAGISel::getGlobalBaseReg() {
|
|||
if (PPCLowering->getPointerTy(CurDAG->getDataLayout()) == MVT::i32) {
|
||||
if (PPCSubTarget->isTargetELF()) {
|
||||
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::MFLR), GlobalBaseReg);
|
||||
MF->getInfo<PPCFunctionInfo>()->setUsesPICBase(true);
|
||||
|
|
|
@ -2172,7 +2172,7 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue Op,
|
|||
GOTPtr = DAG.getNode(PPCISD::ADDIS_TLSGD_HA, dl, PtrVT,
|
||||
GOTReg, TGA);
|
||||
} else {
|
||||
if (picLevel == PICLevel::Small)
|
||||
if (picLevel == PICLevel::SmallPIC)
|
||||
GOTPtr = DAG.getNode(PPCISD::GlobalBaseReg, dl, PtrVT);
|
||||
else
|
||||
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,
|
||||
GOTReg, TGA);
|
||||
} else {
|
||||
if (picLevel == PICLevel::Small)
|
||||
if (picLevel == PICLevel::SmallPIC)
|
||||
GOTPtr = DAG.getNode(PPCISD::GlobalBaseReg, dl, PtrVT);
|
||||
else
|
||||
GOTPtr = DAG.getNode(PPCISD::PPC32_PICGOT, dl, PtrVT);
|
||||
|
|
Loading…
Reference in New Issue