[llvm] r267544 - [SPARC] Add support for llvm.thread.pointer.

Marcin Koscielnicki via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 26 03:37:01 PDT 2016


Author: koriakin
Date: Tue Apr 26 05:37:01 2016
New Revision: 267544

URL: http://llvm.org/viewvc/llvm-project?rev=267544&view=rev
Log:
[SPARC] Add support for llvm.thread.pointer.

Differential Revision: http://reviews.llvm.org/D19387

Added:
    llvm/trunk/test/CodeGen/SPARC/thread-pointer.ll
Modified:
    llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp
    llvm/trunk/lib/Target/Sparc/SparcISelLowering.h

Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp?rev=267544&r1=267543&r2=267544&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/SparcISelLowering.cpp Tue Apr 26 05:37:01 2016
@@ -1799,6 +1799,8 @@ SparcTargetLowering::SparcTargetLowering
     }
   }
 
+  setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);
+
   setMinFunctionAlignment(2);
 
   computeRegisterProperties(Subtarget->getRegisterInfo());
@@ -2960,6 +2962,19 @@ static SDValue LowerATOMIC_LOAD_STORE(SD
   return Op;
 }
 
+SDValue SparcTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
+                                                     SelectionDAG &DAG) const {
+  unsigned IntNo = cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
+  SDLoc dl(Op);
+  switch (IntNo) {
+  default: return SDValue();    // Don't custom lower most intrinsics.
+  case Intrinsic::thread_pointer: {
+    EVT PtrVT = getPointerTy(DAG.getDataLayout());
+    return DAG.getRegister(SP::G7, PtrVT);
+  }
+  }
+}
+
 SDValue SparcTargetLowering::
 LowerOperation(SDValue Op, SelectionDAG &DAG) const {
 
@@ -3018,6 +3033,7 @@ LowerOperation(SDValue Op, SelectionDAG
   case ISD::SMULO:              return LowerUMULO_SMULO(Op, DAG, *this);
   case ISD::ATOMIC_LOAD:
   case ISD::ATOMIC_STORE:       return LowerATOMIC_LOAD_STORE(Op, DAG);
+  case ISD::INTRINSIC_WO_CHAIN: return LowerINTRINSIC_WO_CHAIN(Op, DAG);
   }
 }
 

Modified: llvm/trunk/lib/Target/Sparc/SparcISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcISelLowering.h?rev=267544&r1=267543&r2=267544&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcISelLowering.h (original)
+++ llvm/trunk/lib/Target/Sparc/SparcISelLowering.h Tue Apr 26 05:37:01 2016
@@ -174,6 +174,8 @@ namespace llvm {
                              SDLoc DL,
                              SelectionDAG &DAG) const;
 
+    SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
+
     bool ShouldShrinkFPConstant(EVT VT) const override {
       // Do not shrink FP constpool if VT == MVT::f128.
       // (ldd, call _Q_fdtoq) is more expensive than two ldds.

Added: llvm/trunk/test/CodeGen/SPARC/thread-pointer.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/thread-pointer.ll?rev=267544&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/SPARC/thread-pointer.ll (added)
+++ llvm/trunk/test/CodeGen/SPARC/thread-pointer.ll Tue Apr 26 05:37:01 2016
@@ -0,0 +1,11 @@
+; RUN: llc < %s -mtriple=sparc-unknown-linux-gnu | FileCheck %s
+; RUN: llc < %s -mtriple=sparc64-unknown-linux-gnu | FileCheck %s
+
+; Function Attrs: nounwind readnone
+declare i8* @llvm.thread.pointer() #1
+
+define i8* @thread_pointer() {
+; CHECK: mov %g7, %o0
+  %1 = tail call i8* @llvm.thread.pointer()
+  ret i8* %1
+}




More information about the llvm-commits mailing list