Index: llvm/trunk/lib/Target/Mips/MipsSEISelLowering.cpp =================================================================== --- llvm/trunk/lib/Target/Mips/MipsSEISelLowering.cpp +++ llvm/trunk/lib/Target/Mips/MipsSEISelLowering.cpp @@ -2166,6 +2166,10 @@ 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); + } } } Index: llvm/trunk/test/CodeGen/Mips/thread-pointer.ll =================================================================== --- llvm/trunk/test/CodeGen/Mips/thread-pointer.ll +++ llvm/trunk/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 +}