Skip to content

Commit

Permalink
[SPARC] Add support for llvm.thread.pointer.
Browse files Browse the repository at this point in the history
Differential Revision: http://reviews.llvm.org/D19387

llvm-svn: 267544
  • Loading branch information
mwkmwkmwk committed Apr 26, 2016
1 parent aa309b1 commit fafb449
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
16 changes: 16 additions & 0 deletions llvm/lib/Target/Sparc/SparcISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,8 @@ SparcTargetLowering::SparcTargetLowering(TargetMachine &TM,
}
}

setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::Other, Custom);

setMinFunctionAlignment(2);

computeRegisterProperties(Subtarget->getRegisterInfo());
Expand Down Expand Up @@ -2960,6 +2962,19 @@ static SDValue LowerATOMIC_LOAD_STORE(SDValue Op, SelectionDAG &DAG) {
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 {

Expand Down Expand Up @@ -3018,6 +3033,7 @@ LowerOperation(SDValue Op, SelectionDAG &DAG) const {
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);
}
}

Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/Sparc/SparcISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions llvm/test/CodeGen/SPARC/thread-pointer.ll
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit fafb449

Please sign in to comment.