From 7efdca5622cfd472ccca6fd2b0b830e526abbd48 Mon Sep 17 00:00:00 2001 From: Marcin Koscielnicki Date: Wed, 27 Apr 2016 17:21:49 +0000 Subject: [PATCH] [Mips] Add support for llvm.thread.pointer intrinsic. This will be used to implement __builtin_thread_pointer in clang. Differential Revision: http://reviews.llvm.org/D19569 llvm-svn: 267743 --- llvm/lib/Target/Mips/MipsSEISelLowering.cpp | 4 ++++ llvm/test/CodeGen/Mips/thread-pointer.ll | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 llvm/test/CodeGen/Mips/thread-pointer.ll diff --git a/llvm/lib/Target/Mips/MipsSEISelLowering.cpp b/llvm/lib/Target/Mips/MipsSEISelLowering.cpp index 1f5ef2fc8d8f..9812a9793182 100644 --- a/llvm/lib/Target/Mips/MipsSEISelLowering.cpp +++ b/llvm/lib/Target/Mips/MipsSEISelLowering.cpp @@ -2166,6 +2166,10 @@ SDValue MipsSETargetLowering::lowerINTRINSIC_WO_CHAIN(SDValue Op, case Intrinsic::mips_xori_b: return DAG.getNode(ISD::XOR, DL, Op->getValueType(0), Op->getOperand(1), lowerMSASplatImm(Op, 2, DAG)); + case Intrinsic::thread_pointer: { + EVT PtrVT = getPointerTy(DAG.getDataLayout()); + return DAG.getNode(MipsISD::ThreadPointer, DL, PtrVT); + } } } diff --git a/llvm/test/CodeGen/Mips/thread-pointer.ll b/llvm/test/CodeGen/Mips/thread-pointer.ll new file mode 100644 index 000000000000..60bee3d03031 --- /dev/null +++ b/llvm/test/CodeGen/Mips/thread-pointer.ll @@ -0,0 +1,12 @@ +; RUN: llc -march=mips < %s | FileCheck %s +; RUN: llc -march=mips64 < %s | FileCheck %s +; RUN: llc -march=mipsel < %s | FileCheck %s +; RUN: llc -march=mips64el < %s | FileCheck %s + +declare i8* @llvm.thread.pointer() nounwind readnone + +define i8* @thread_pointer() { +; CHECK: rdhwr $3, $29 + %1 = tail call i8* @llvm.thread.pointer() + ret i8* %1 +}