mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-14 15:19:33 +00:00
Make ARM and Mips use TargetMachine::getTLSModel()
This moves the logic for selecting a TLS model to a single place, instead of the previous three (ARM, Mips, and X86 which already uses this function). llvm-svn: 156162
This commit is contained in:
parent
88bf1f4404
commit
b3c41d012d
@ -2108,7 +2108,8 @@ ARMTargetLowering::LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
|
||||
// "local exec" model.
|
||||
SDValue
|
||||
ARMTargetLowering::LowerToTLSExecModels(GlobalAddressSDNode *GA,
|
||||
SelectionDAG &DAG) const {
|
||||
SelectionDAG &DAG,
|
||||
TLSModel::Model model) const {
|
||||
const GlobalValue *GV = GA->getGlobal();
|
||||
DebugLoc dl = GA->getDebugLoc();
|
||||
SDValue Offset;
|
||||
@ -2117,7 +2118,7 @@ ARMTargetLowering::LowerToTLSExecModels(GlobalAddressSDNode *GA,
|
||||
// Get the Thread Pointer
|
||||
SDValue ThreadPointer = DAG.getNode(ARMISD::THREAD_POINTER, dl, PtrVT);
|
||||
|
||||
if (GV->isDeclaration()) {
|
||||
if (model == TLSModel::InitialExec) {
|
||||
MachineFunction &MF = DAG.getMachineFunction();
|
||||
ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
|
||||
unsigned ARMPCLabelIndex = AFI->createPICLabelUId();
|
||||
@ -2142,6 +2143,7 @@ ARMTargetLowering::LowerToTLSExecModels(GlobalAddressSDNode *GA,
|
||||
false, false, false, 0);
|
||||
} else {
|
||||
// local exec model
|
||||
assert(model == TLSModel::LocalExec);
|
||||
ARMConstantPoolValue *CPV =
|
||||
ARMConstantPoolConstant::Create(GV, ARMCP::TPOFF);
|
||||
Offset = DAG.getTargetConstantPool(CPV, PtrVT, 4);
|
||||
@ -2162,12 +2164,17 @@ ARMTargetLowering::LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const {
|
||||
assert(Subtarget->isTargetELF() &&
|
||||
"TLS not implemented for non-ELF targets");
|
||||
GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(Op);
|
||||
// If the relocation model is PIC, use the "General Dynamic" TLS Model,
|
||||
// otherwise use the "Local Exec" TLS Model
|
||||
if (getTargetMachine().getRelocationModel() == Reloc::PIC_)
|
||||
return LowerToTLSGeneralDynamicModel(GA, DAG);
|
||||
else
|
||||
return LowerToTLSExecModels(GA, DAG);
|
||||
|
||||
TLSModel::Model model = getTargetMachine().getTLSModel(GA->getGlobal());
|
||||
|
||||
switch (model) {
|
||||
case TLSModel::GeneralDynamic:
|
||||
case TLSModel::LocalDynamic:
|
||||
return LowerToTLSGeneralDynamicModel(GA, DAG);
|
||||
case TLSModel::InitialExec:
|
||||
case TLSModel::LocalExec:
|
||||
return LowerToTLSExecModels(GA, DAG, model);
|
||||
}
|
||||
}
|
||||
|
||||
SDValue ARMTargetLowering::LowerGlobalAddressELF(SDValue Op,
|
||||
|
@ -422,7 +422,8 @@ namespace llvm {
|
||||
SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
|
||||
SelectionDAG &DAG) const;
|
||||
SDValue LowerToTLSExecModels(GlobalAddressSDNode *GA,
|
||||
SelectionDAG &DAG) const;
|
||||
SelectionDAG &DAG,
|
||||
TLSModel::Model model) const;
|
||||
SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const;
|
||||
SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
|
||||
SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const;
|
||||
|
@ -1614,7 +1614,9 @@ LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const
|
||||
const GlobalValue *GV = GA->getGlobal();
|
||||
EVT PtrVT = getPointerTy();
|
||||
|
||||
if (getTargetMachine().getRelocationModel() == Reloc::PIC_) {
|
||||
TLSModel::Model model = getTargetMachine().getTLSModel(GV);
|
||||
|
||||
if (model == TLSModel::GeneralDynamic || model == TLSModel::LocalDynamic) {
|
||||
// General Dynamic TLS Model
|
||||
bool LocalDynamic = GV->hasInternalLinkage();
|
||||
unsigned Flag = LocalDynamic ? MipsII::MO_TLSLDM :MipsII::MO_TLSGD;
|
||||
@ -1641,7 +1643,7 @@ LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const
|
||||
|
||||
SDValue Ret = CallResult.first;
|
||||
|
||||
if (!LocalDynamic)
|
||||
if (model != TLSModel::LocalDynamic)
|
||||
return Ret;
|
||||
|
||||
SDValue TGAHi = DAG.getTargetGlobalAddress(GV, dl, PtrVT, 0,
|
||||
@ -1655,7 +1657,7 @@ LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const
|
||||
}
|
||||
|
||||
SDValue Offset;
|
||||
if (GV->isDeclaration()) {
|
||||
if (model == TLSModel::InitialExec) {
|
||||
// Initial Exec TLS Model
|
||||
SDValue TGA = DAG.getTargetGlobalAddress(GV, dl, PtrVT, 0,
|
||||
MipsII::MO_GOTTPREL);
|
||||
@ -1666,6 +1668,7 @@ LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const
|
||||
false, false, false, 0);
|
||||
} else {
|
||||
// Local Exec TLS Model
|
||||
assert(model == TLSModel::LocalExec);
|
||||
SDValue TGAHi = DAG.getTargetGlobalAddress(GV, dl, PtrVT, 0,
|
||||
MipsII::MO_TPREL_HI);
|
||||
SDValue TGALo = DAG.getTargetGlobalAddress(GV, dl, PtrVT, 0,
|
||||
|
Loading…
Reference in New Issue
Block a user