[llvm] r273871 - Simplify getLabelAccessInfo.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 27 05:56:02 PDT 2016
Author: rafael
Date: Mon Jun 27 07:56:02 2016
New Revision: 273871
URL: http://llvm.org/viewvc/llvm-project?rev=273871&view=rev
Log:
Simplify getLabelAccessInfo.
It now takes a IsPIC flag instead of computing and returning it.
Modified:
llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=273871&r1=273870&r2=273871&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Mon Jun 27 07:56:02 2016
@@ -1962,19 +1962,16 @@ bool PPCTargetLowering::getPreIndexedAdd
// LowerOperation implementation
//===----------------------------------------------------------------------===//
-/// GetLabelAccessInfo - Return true if we should reference labels using a
-/// PICBase, set the HiOpFlags and LoOpFlags to the target MO flags.
-static bool GetLabelAccessInfo(const TargetMachine &TM,
- const PPCSubtarget &Subtarget,
+/// Return true if we should reference labels using a PICBase, set the HiOpFlags
+/// and LoOpFlags to the target MO flags.
+static void getLabelAccessInfo(bool IsPIC, const PPCSubtarget &Subtarget,
unsigned &HiOpFlags, unsigned &LoOpFlags,
const GlobalValue *GV = nullptr) {
HiOpFlags = PPCII::MO_HA;
LoOpFlags = PPCII::MO_LO;
// Don't use the pic base if not in PIC relocation model.
- bool isPIC = TM.getRelocationModel() == Reloc::PIC_;
-
- if (isPIC) {
+ if (IsPIC) {
HiOpFlags |= PPCII::MO_PIC_FLAG;
LoOpFlags |= PPCII::MO_PIC_FLAG;
}
@@ -1990,8 +1987,6 @@ static bool GetLabelAccessInfo(const Tar
LoOpFlags |= PPCII::MO_NLP_HIDDEN_FLAG;
}
}
-
- return isPIC;
}
static SDValue LowerLabelRef(SDValue HiPart, SDValue LoPart, bool isPIC,
@@ -2050,10 +2045,10 @@ SDValue PPCTargetLowering::LowerConstant
}
unsigned MOHiFlag, MOLoFlag;
- bool isPIC =
- GetLabelAccessInfo(DAG.getTarget(), Subtarget, MOHiFlag, MOLoFlag);
+ bool IsPIC = isPositionIndependent();
+ getLabelAccessInfo(IsPIC, Subtarget, MOHiFlag, MOLoFlag);
- if (isPIC && Subtarget.isSVR4ABI()) {
+ if (IsPIC && Subtarget.isSVR4ABI()) {
SDValue GA = DAG.getTargetConstantPool(C, PtrVT, CP->getAlignment(),
PPCII::MO_PIC_FLAG);
return getTOCEntry(DAG, SDLoc(CP), false, GA);
@@ -2063,7 +2058,7 @@ SDValue PPCTargetLowering::LowerConstant
DAG.getTargetConstantPool(C, PtrVT, CP->getAlignment(), 0, MOHiFlag);
SDValue CPILo =
DAG.getTargetConstantPool(C, PtrVT, CP->getAlignment(), 0, MOLoFlag);
- return LowerLabelRef(CPIHi, CPILo, isPIC, DAG);
+ return LowerLabelRef(CPIHi, CPILo, IsPIC, DAG);
}
SDValue PPCTargetLowering::LowerJumpTable(SDValue Op, SelectionDAG &DAG) const {
@@ -2079,10 +2074,10 @@ SDValue PPCTargetLowering::LowerJumpTabl
}
unsigned MOHiFlag, MOLoFlag;
- bool isPIC =
- GetLabelAccessInfo(DAG.getTarget(), Subtarget, MOHiFlag, MOLoFlag);
+ bool IsPIC = isPositionIndependent();
+ getLabelAccessInfo(IsPIC, Subtarget, MOHiFlag, MOLoFlag);
- if (isPIC && Subtarget.isSVR4ABI()) {
+ if (IsPIC && Subtarget.isSVR4ABI()) {
SDValue GA = DAG.getTargetJumpTable(JT->getIndex(), PtrVT,
PPCII::MO_PIC_FLAG);
return getTOCEntry(DAG, SDLoc(GA), false, GA);
@@ -2090,7 +2085,7 @@ SDValue PPCTargetLowering::LowerJumpTabl
SDValue JTIHi = DAG.getTargetJumpTable(JT->getIndex(), PtrVT, MOHiFlag);
SDValue JTILo = DAG.getTargetJumpTable(JT->getIndex(), PtrVT, MOLoFlag);
- return LowerLabelRef(JTIHi, JTILo, isPIC, DAG);
+ return LowerLabelRef(JTIHi, JTILo, IsPIC, DAG);
}
SDValue PPCTargetLowering::LowerBlockAddress(SDValue Op,
@@ -2108,11 +2103,11 @@ SDValue PPCTargetLowering::LowerBlockAdd
}
unsigned MOHiFlag, MOLoFlag;
- bool isPIC =
- GetLabelAccessInfo(DAG.getTarget(), Subtarget, MOHiFlag, MOLoFlag);
+ bool IsPIC = isPositionIndependent();
+ getLabelAccessInfo(IsPIC, Subtarget, MOHiFlag, MOLoFlag);
SDValue TgtBAHi = DAG.getTargetBlockAddress(BA, PtrVT, 0, MOHiFlag);
SDValue TgtBALo = DAG.getTargetBlockAddress(BA, PtrVT, 0, MOLoFlag);
- return LowerLabelRef(TgtBAHi, TgtBALo, isPIC, DAG);
+ return LowerLabelRef(TgtBAHi, TgtBALo, IsPIC, DAG);
}
SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue Op,
@@ -2221,10 +2216,10 @@ SDValue PPCTargetLowering::LowerGlobalAd
}
unsigned MOHiFlag, MOLoFlag;
- bool isPIC =
- GetLabelAccessInfo(DAG.getTarget(), Subtarget, MOHiFlag, MOLoFlag, GV);
+ bool IsPIC = isPositionIndependent();
+ getLabelAccessInfo(IsPIC, Subtarget, MOHiFlag, MOLoFlag, GV);
- if (isPIC && Subtarget.isSVR4ABI()) {
+ if (IsPIC && Subtarget.isSVR4ABI()) {
SDValue GA = DAG.getTargetGlobalAddress(GV, DL, PtrVT,
GSDN->getOffset(),
PPCII::MO_PIC_FLAG);
@@ -2236,7 +2231,7 @@ SDValue PPCTargetLowering::LowerGlobalAd
SDValue GALo =
DAG.getTargetGlobalAddress(GV, DL, PtrVT, GSDN->getOffset(), MOLoFlag);
- SDValue Ptr = LowerLabelRef(GAHi, GALo, isPIC, DAG);
+ SDValue Ptr = LowerLabelRef(GAHi, GALo, IsPIC, DAG);
// If the global reference is actually to a non-lazy-pointer, we have to do an
// extra load to get the address of the global.
More information about the llvm-commits
mailing list