[llvm] r267546 - [PowerPC] Add support for llvm.thread.pointer

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


Author: koriakin
Date: Tue Apr 26 05:37:22 2016
New Revision: 267546

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

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

Added:
    llvm/trunk/test/CodeGen/PowerPC/thread-pointer.ll
Modified:
    llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp

Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp?rev=267546&r1=267545&r2=267546&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.cpp Tue Apr 26 05:37:22 2016
@@ -7715,6 +7715,16 @@ static bool getVectorCompareInfo(SDValue
 /// lower, do it, otherwise return null.
 SDValue PPCTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
                                                    SelectionDAG &DAG) const {
+  unsigned IntrinsicID =
+    cast<ConstantSDNode>(Op.getOperand(0))->getZExtValue();
+
+  if (IntrinsicID == Intrinsic::thread_pointer) {
+    // Reads the thread pointer register, used for __builtin_thread_pointer.
+    bool is64bit = Subtarget.isPPC64();
+    return DAG.getRegister(is64bit ? PPC::X13 : PPC::R2,
+                           is64bit ? MVT::i64 : MVT::i32);
+  }
+
   // If this is a lowered altivec predicate compare, CompareOpc is set to the
   // opcode number of the comparison.
   SDLoc dl(Op);

Added: llvm/trunk/test/CodeGen/PowerPC/thread-pointer.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/thread-pointer.ll?rev=267546&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/thread-pointer.ll (added)
+++ llvm/trunk/test/CodeGen/PowerPC/thread-pointer.ll Tue Apr 26 05:37:22 2016
@@ -0,0 +1,17 @@
+; RUN: llc < %s -mtriple=powerpc-unknown-linux-gnu | FileCheck %s --check-prefix=CHECK-32
+; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s --check-prefix=CHECK-64
+; RUN: llc < %s -mtriple=powerpc64le-unknown-linux-gnu | FileCheck %s --check-prefix=CHECK-64
+
+; Function Attrs: nounwind readnone
+declare i8* @llvm.thread.pointer() #1
+
+define i8* @thread_pointer() {
+; CHECK-32-LABEL: @thread_pointer
+; CHECK-32: mr 3, 2
+; CHECK-32: blr
+; CHECK-64-LABEL: @thread_pointer
+; CHECK-64: mr 3, 13
+; CHECK-64: blr
+  %1 = tail call i8* @llvm.thread.pointer()
+  ret i8* %1
+}




More information about the llvm-commits mailing list