[PATCH] D19387: [SPARC] Add support for llvm.thread.pointer.

Marcin Koƛcielnicki via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 21 13:44:26 PDT 2016


koriakin created this revision.
koriakin added reviewers: venkatra, jyknight.
koriakin added a subscriber: llvm-commits.
koriakin set the repository for this revision to rL LLVM.
Herald added a subscriber: jyknight.

Repository:
  rL LLVM

http://reviews.llvm.org/D19387

Files:
  lib/Target/Sparc/SparcISelLowering.cpp
  lib/Target/Sparc/SparcISelLowering.h
  test/CodeGen/SPARC/thread-pointer.ll

Index: test/CodeGen/SPARC/thread-pointer.ll
===================================================================
--- /dev/null
+++ test/CodeGen/SPARC/thread-pointer.ll
@@ -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
+}
Index: lib/Target/Sparc/SparcISelLowering.h
===================================================================
--- lib/Target/Sparc/SparcISelLowering.h
+++ lib/Target/Sparc/SparcISelLowering.h
@@ -174,6 +174,8 @@
                              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.
Index: lib/Target/Sparc/SparcISelLowering.cpp
===================================================================
--- lib/Target/Sparc/SparcISelLowering.cpp
+++ lib/Target/Sparc/SparcISelLowering.cpp
@@ -1799,6 +1799,8 @@
     }
   }
 
+  setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);
+
   setMinFunctionAlignment(2);
 
   computeRegisterProperties(Subtarget->getRegisterInfo());
@@ -2944,6 +2946,19 @@
   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 {
 
@@ -3002,6 +3017,7 @@
   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);
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19387.54569.patch
Type: text/x-patch
Size: 2369 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160421/c13fa717/attachment.bin>


More information about the llvm-commits mailing list