OSDN Git Service

X86 TLS: fix and optimize the implementation of "initial exec" model.
authorLauro Ramos Venancio <lauro.venancio@gmail.com>
Sun, 22 Apr 2007 22:50:52 +0000 (22:50 +0000)
committerLauro Ramos Venancio <lauro.venancio@gmail.com>
Sun, 22 Apr 2007 22:50:52 +0000 (22:50 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36355 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ATTAsmPrinter.cpp
lib/Target/X86/X86ISelLowering.cpp
lib/Target/X86/X86InstrInfo.td

index f36de92..e595750 100755 (executable)
@@ -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);
index ec86924..e63545d 100644 (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);
index fdc2bc9..1885547 100644 (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)]>;