[llvm-commits] [llvm] r68947 - in /llvm/trunk: lib/Target/X86/ lib/Target/X86/AsmPrinter/ test/CodeGen/X86/

Rafael Espindola rafael.espindola at gmail.com
Mon Apr 13 06:02:51 PDT 2009


Author: rafael
Date: Mon Apr 13 08:02:49 2009
New Revision: 68947

URL: http://llvm.org/viewvc/llvm-project?rev=68947&view=rev
Log:
X86-64 TLS support for local exec and initial exec.

Modified:
    llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
    llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
    llvm/trunk/test/CodeGen/X86/tls1.ll
    llvm/trunk/test/CodeGen/X86/tls10.ll
    llvm/trunk/test/CodeGen/X86/tls11.ll
    llvm/trunk/test/CodeGen/X86/tls12.ll
    llvm/trunk/test/CodeGen/X86/tls13.ll
    llvm/trunk/test/CodeGen/X86/tls14.ll
    llvm/trunk/test/CodeGen/X86/tls15.ll
    llvm/trunk/test/CodeGen/X86/tls2.ll
    llvm/trunk/test/CodeGen/X86/tls3.ll
    llvm/trunk/test/CodeGen/X86/tls4.ll
    llvm/trunk/test/CodeGen/X86/tls5.ll
    llvm/trunk/test/CodeGen/X86/tls6.ll
    llvm/trunk/test/CodeGen/X86/tls7.ll
    llvm/trunk/test/CodeGen/X86/tls8.ll
    llvm/trunk/test/CodeGen/X86/tls9.ll

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Mon Apr 13 08:02:49 2009
@@ -454,14 +454,16 @@
 	O << "@TLSGD";
         break;
       case TLSModel::InitialExec:
-        if (Subtarget->is64Bit())
-          O << "@TLSGD"; // 64 bit intial exec not implemented
-        else
+        if (Subtarget->is64Bit()) {
+          assert (!NotRIPRel);
+          O << "@GOTTPOFF(%rip)";
+        } else {
           O << "@INDNTPOFF";
+        }
         break;
       case TLSModel::LocalExec:
         if (Subtarget->is64Bit())
-          O << "@TLSGD"; // 64 bit local exec not implemented
+          O << "@TPOFF";
         else
 	  O << "@NTPOFF";
         break;

Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Mon Apr 13 08:02:49 2009
@@ -808,9 +808,16 @@
     uint64_t Offset = G->getOffset();
     if (!is64Bit || isInt32(AM.Disp + Offset)) {
       GlobalValue *GV = G->getGlobal();
+      bool isRIPRel = TM.symbolicAddressesAreRIPRel();
+      if (N0.getOpcode() == llvm::ISD::TargetGlobalTLSAddress) {
+        TLSModel::Model model =
+          getTLSModel (GV, TM.getRelocationModel());
+        if (is64Bit && model == TLSModel::InitialExec)
+          isRIPRel = true;
+      }
       AM.GV = GV;
       AM.Disp += Offset;
-      AM.isRIPRel = TM.symbolicAddressesAreRIPRel();
+      AM.isRIPRel = isRIPRel;
       return false;
     }
   } else if (ConstantPoolSDNode *CP = dyn_cast<ConstantPoolSDNode>(N0)) {

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Apr 13 08:02:49 2009
@@ -4831,12 +4831,14 @@
 // Lower ISD::GlobalTLSAddress using the "initial exec" (for no-pic) or
 // "local exec" model.
 static SDValue LowerToTLSExecModel(GlobalAddressSDNode *GA, SelectionDAG &DAG,
-                                   const MVT PtrVT, TLSModel::Model model) {
+                                   const MVT PtrVT, TLSModel::Model model,
+                                   bool is64Bit) {
   DebugLoc dl = GA->getDebugLoc();
   // Get the Thread Pointer
   SDValue Base = DAG.getNode(X86ISD::SegmentBaseAddress,
                              DebugLoc::getUnknownLoc(), PtrVT,
-                             DAG.getRegister(X86::GS, MVT::i32));
+                             DAG.getRegister(is64Bit? X86::FS : X86::GS,
+                                             MVT::i32));
 
   SDValue ThreadPointer = DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), Base,
                                       NULL, 0);
@@ -4871,9 +4873,11 @@
     switch (model) {
     case TLSModel::GeneralDynamic:
     case TLSModel::LocalDynamic: // not implemented
-    case TLSModel::InitialExec:  // not implemented
-    case TLSModel::LocalExec:    // not implemented
       return LowerToTLSGeneralDynamicModel64(GA, DAG, getPointerTy());
+
+    case TLSModel::InitialExec:
+    case TLSModel::LocalExec:
+      return LowerToTLSExecModel(GA, DAG, getPointerTy(), model, true);
     }
   } else {
     switch (model) {
@@ -4883,7 +4887,7 @@
 
     case TLSModel::InitialExec:
     case TLSModel::LocalExec:
-      return LowerToTLSExecModel(GA, DAG, getPointerTy(), model);
+      return LowerToTLSExecModel(GA, DAG, getPointerTy(), model, false);
     }
   }
   assert(0 && "Unreachable");

Modified: llvm/trunk/test/CodeGen/X86/tls1.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls1.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls1.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls1.ll Mon Apr 13 08:02:49 2009
@@ -1,5 +1,7 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movl	%gs:i at NTPOFF, %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movl	%fs:i at TPOFF, %eax} %t2
 
 @i = thread_local global i32 15
 

Modified: llvm/trunk/test/CodeGen/X86/tls10.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls10.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls10.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls10.ll Mon Apr 13 08:02:49 2009
@@ -1,6 +1,9 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movl	%gs:0, %eax} %t
 ; RUN: grep {leal	i at NTPOFF(%eax), %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movq	%fs:0, %rax} %t2
+; RUN: grep {leaq	i at TPOFF(%rax), %rax} %t2
 
 @i = external hidden thread_local global i32
 

Modified: llvm/trunk/test/CodeGen/X86/tls11.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls11.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls11.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls11.ll Mon Apr 13 08:02:49 2009
@@ -1,5 +1,7 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movw	%gs:i at NTPOFF, %ax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movw	%fs:i at TPOFF, %ax} %t2
 
 @i = thread_local global i16 15
 

Modified: llvm/trunk/test/CodeGen/X86/tls12.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls12.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls12.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls12.ll Mon Apr 13 08:02:49 2009
@@ -1,5 +1,7 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movb	%gs:i at NTPOFF, %al} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movb	%fs:i at TPOFF, %al} %t2
 
 @i = thread_local global i8 15
 

Modified: llvm/trunk/test/CodeGen/X86/tls13.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls13.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls13.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls13.ll Mon Apr 13 08:02:49 2009
@@ -1,6 +1,9 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movswl	%gs:i at NTPOFF, %eax} %t
 ; RUN: grep {movzwl	%gs:j at NTPOFF, %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movswl	%fs:i at TPOFF, %edi} %t2
+; RUN: grep {movzwl	%fs:j at TPOFF, %edi} %t2
 
 @i = thread_local global i16 0
 @j = thread_local global i16 0

Modified: llvm/trunk/test/CodeGen/X86/tls14.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls14.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls14.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls14.ll Mon Apr 13 08:02:49 2009
@@ -1,6 +1,9 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movsbl	%gs:i at NTPOFF, %eax} %t
 ; RUN: grep {movzbl	%gs:j at NTPOFF, %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movsbl	%fs:i at TPOFF, %edi} %t2
+; RUN: grep {movzbl	%fs:j at TPOFF, %edi} %t2
 
 @i = thread_local global i8 0
 @j = thread_local global i8 0

Modified: llvm/trunk/test/CodeGen/X86/tls15.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls15.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls15.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls15.ll Mon Apr 13 08:02:49 2009
@@ -2,6 +2,10 @@
 ; RUN: grep {movl	%gs:0, %eax} %t | count 1
 ; RUN: grep {leal	i at NTPOFF(%eax), %ecx} %t
 ; RUN: grep {leal	j at NTPOFF(%eax), %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movq	%fs:0, %rax} %t2 | count 1
+; RUN: grep {leaq	i at TPOFF(%rax), %rcx} %t2
+; RUN: grep {leaq	j at TPOFF(%rax), %rax} %t2
 
 @i = thread_local global i32 0
 @j = thread_local global i32 0

Modified: llvm/trunk/test/CodeGen/X86/tls2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls2.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls2.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls2.ll Mon Apr 13 08:02:49 2009
@@ -1,6 +1,9 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movl	%gs:0, %eax} %t
 ; RUN: grep {leal	i at NTPOFF(%eax), %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movq	%fs:0, %rax} %t2
+; RUN: grep {leaq	i at TPOFF(%rax), %rax} %t2
 
 @i = thread_local global i32 15
 

Modified: llvm/trunk/test/CodeGen/X86/tls3.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls3.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls3.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls3.ll Mon Apr 13 08:02:49 2009
@@ -1,6 +1,9 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movl	i at INDNTPOFF, %eax} %t
 ; RUN: grep {movl	%gs:(%eax), %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movq	i at GOTTPOFF(%rip), %rax} %t2
+; RUN: grep {movl	%fs:(%rax), %eax} %t2
 
 @i = external thread_local global i32		; <i32*> [#uses=2]
 

Modified: llvm/trunk/test/CodeGen/X86/tls4.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls4.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls4.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls4.ll Mon Apr 13 08:02:49 2009
@@ -1,6 +1,9 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movl	%gs:0, %eax} %t
 ; RUN: grep {addl	i at INDNTPOFF, %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movq	%fs:0, %rax} %t2
+; RUN: grep {addq	i at GOTTPOFF(%rip), %rax} %t2
 
 @i = external thread_local global i32		; <i32*> [#uses=2]
 

Modified: llvm/trunk/test/CodeGen/X86/tls5.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls5.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls5.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls5.ll Mon Apr 13 08:02:49 2009
@@ -1,5 +1,7 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movl	%gs:i at NTPOFF, %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movl	%fs:i at TPOFF, %eax} %t2
 
 @i = internal thread_local global i32 15
 

Modified: llvm/trunk/test/CodeGen/X86/tls6.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls6.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls6.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls6.ll Mon Apr 13 08:02:49 2009
@@ -1,6 +1,9 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movl	%gs:0, %eax} %t
 ; RUN: grep {leal	i at NTPOFF(%eax), %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movq	%fs:0, %rax} %t2
+; RUN: grep {leaq	i at TPOFF(%rax), %rax} %t2
 
 @i = internal thread_local global i32 15
 

Modified: llvm/trunk/test/CodeGen/X86/tls7.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls7.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls7.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls7.ll Mon Apr 13 08:02:49 2009
@@ -1,5 +1,7 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movl	%gs:i at NTPOFF, %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movl	%fs:i at TPOFF, %eax} %t2
 
 @i = hidden thread_local global i32 15
 

Modified: llvm/trunk/test/CodeGen/X86/tls8.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls8.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls8.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls8.ll Mon Apr 13 08:02:49 2009
@@ -1,6 +1,9 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movl	%gs:0, %eax} %t
 ; RUN: grep {leal	i at NTPOFF(%eax), %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movq	%fs:0, %rax} %t2
+; RUN: grep {leaq	i at TPOFF(%rax), %rax} %t2
 
 @i = hidden thread_local global i32 15
 

Modified: llvm/trunk/test/CodeGen/X86/tls9.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls9.ll?rev=68947&r1=68946&r2=68947&view=diff

==============================================================================
--- llvm/trunk/test/CodeGen/X86/tls9.ll (original)
+++ llvm/trunk/test/CodeGen/X86/tls9.ll Mon Apr 13 08:02:49 2009
@@ -1,5 +1,7 @@
 ; RUN: llvm-as < %s | llc -march=x86 -mtriple=i386-linux-gnu > %t
 ; RUN: grep {movl	%gs:i at NTPOFF, %eax} %t
+; RUN: llvm-as < %s | llc -march=x86-64 -mtriple=x86_64-linux-gnu > %t2
+; RUN: grep {movl	%fs:i at TPOFF, %eax} %t2
 
 @i = external hidden thread_local global i32
 





More information about the llvm-commits mailing list