X86 TLS: fix and optimize the implementation of "initial exec" model.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36355 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Lauro Ramos Venancio 2007-04-22 22:50:52 +00:00
parent 032507d989
commit 7d2cc2b983
3 changed files with 11 additions and 2 deletions

View File

@ -277,7 +277,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
bool isThreadLocal = GVar && GVar->isThreadLocal();
if (!isMemOp && !isCallOp && !isThreadLocal) O << '$';
if (!isMemOp && !isCallOp) O << '$';
std::string Name = Mang->getValueName(GV);
X86SharedAsmPrinter::decorateName(Name, GV);

View File

@ -2996,6 +2996,10 @@ LowerToTLSExecModel(GlobalAddressSDNode *GA, SelectionDAG &DAG,
GA->getValueType(0),
GA->getOffset());
SDOperand Offset = DAG.getNode(X86ISD::Wrapper, PtrVT, TGA);
if (GA->getGlobal()->isDeclaration()) // initial exec TLS model
Offset = DAG.getLoad(PtrVT, DAG.getEntryNode(), Offset, NULL, 0);
// The address of the thread local variable is the add of the thread
// pointer with the offset of the variable.
return DAG.getNode(ISD::ADD, PtrVT, ThreadPointer, Offset);

View File

@ -2462,10 +2462,15 @@ def MOV32_mr : I<0x89, MRMDestMem, (ops i32mem:$dst, GR32_:$src),
//
def TLS_addr : I<0, Pseudo, (ops GR32:$dst, i32imm:$sym),
"leal $sym(,%ebx,1), $dst",
"leal ${sym:mem}(,%ebx,1), $dst",
[(set GR32:$dst, (X86tlsaddr tglobaltlsaddr:$sym))]>,
Imp<[EBX],[]>;
let AddedComplexity = 10 in
def TLS_gs : I<0, Pseudo, (ops GR32:$dst, GR32:$src),
"movl %gs:($src), $dst",
[(set GR32:$dst, (load (add X86TLStp, GR32:$src)))]>;
def TLS_tp : I<0, Pseudo, (ops GR32:$dst),
"movl %gs:0, $dst",
[(set GR32:$dst, X86TLStp)]>;