[PATCH] D21394: [Codegen] Reorganize PICLevel

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 16 09:39:25 PDT 2016


LGTM with a comment in CodeGen.h saying this maps -fpic/-fPIC. Please
also improve the commit message to mention that Default is being
converted to NotPIC so that target independent code can reason about
this.

On 15 June 2016 at 14:56, Davide Italiano <dccitaliano at gmail.com> wrote:
> davide created this revision.
> davide added reviewers: rafael, jhibbits, hfinkel.
> davide added a subscriber: llvm-commits.
>
> See  http://reviews.llvm.org/D21100 for context/rationale behind this change.
> CC:ing PPC as it seems to be the only user of this feature.
>
> http://reviews.llvm.org/D21394
>
> Files:
>   include/llvm/Support/CodeGen.h
>   lib/IR/Module.cpp
>   lib/Target/PowerPC/PPCAsmPrinter.cpp
>   lib/Target/PowerPC/PPCISelDAGToDAG.cpp
>   lib/Target/PowerPC/PPCISelLowering.cpp
>
> Index: lib/Target/PowerPC/PPCISelLowering.cpp
> ===================================================================
> --- lib/Target/PowerPC/PPCISelLowering.cpp
> +++ lib/Target/PowerPC/PPCISelLowering.cpp
> @@ -2172,7 +2172,7 @@
>        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 @@
>        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);
> Index: lib/Target/PowerPC/PPCISelDAGToDAG.cpp
> ===================================================================
> --- lib/Target/PowerPC/PPCISelDAGToDAG.cpp
> +++ lib/Target/PowerPC/PPCISelDAGToDAG.cpp
> @@ -319,7 +319,7 @@
>      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);
> Index: lib/Target/PowerPC/PPCAsmPrinter.cpp
> ===================================================================
> --- lib/Target/PowerPC/PPCAsmPrinter.cpp
> +++ lib/Target/PowerPC/PPCAsmPrinter.cpp
> @@ -601,7 +601,7 @@
>      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 @@
>        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 @@
>    // 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()) {
> Index: lib/IR/Module.cpp
> ===================================================================
> --- lib/IR/Module.cpp
> +++ lib/IR/Module.cpp
> @@ -487,7 +487,7 @@
>    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());
> Index: include/llvm/Support/CodeGen.h
> ===================================================================
> --- include/llvm/Support/CodeGen.h
> +++ include/llvm/Support/CodeGen.h
> @@ -29,7 +29,7 @@
>    }
>
>    namespace PICLevel {
> -    enum Level { Default=0, Small=1, Large=2 };
> +    enum Level { NotPIC=0, SmallPIC=1, BigPic=2 };
>    }
>
>    namespace PIELevel {
>
>


More information about the llvm-commits mailing list