From 747bf8afa87d29081bf2a6a3a63172a11e1c4429 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 13 Mar 2017 20:18:14 +0000 Subject: [PATCH] AMDGPU: Re-use TM.getNullPointerValue llvm-svn: 297662 --- llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index 8a6219529bc5..117c22ac2d59 100644 --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -19,6 +19,7 @@ #include "AMDGPU.h" #include "AMDGPUIntrinsicInfo.h" +#include "AMDGPUTargetMachine.h" #include "AMDGPUSubtarget.h" #include "SIDefines.h" #include "SIISelLowering.h" @@ -68,7 +69,6 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include "llvm/Target/TargetCallingConv.h" -#include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegisterInfo.h" #include @@ -2374,11 +2374,6 @@ SDValue SITargetLowering::getSegmentAperture(unsigned AS, MachineMemOperand::MOInvariant); } -// FIXME: Really support non-0 null pointers. -static int getSegmentNullPtrValue(unsigned AS) { - return AS == AMDGPUAS::LOCAL_ADDRESS ? -1 : 0; -} - SDValue SITargetLowering::lowerADDRSPACECAST(SDValue Op, SelectionDAG &DAG) const { SDLoc SL(Op); @@ -2387,12 +2382,15 @@ SDValue SITargetLowering::lowerADDRSPACECAST(SDValue Op, SDValue Src = ASC->getOperand(0); SDValue FlatNullPtr = DAG.getConstant(0, SL, MVT::i64); + const AMDGPUTargetMachine &TM = + static_cast(getTargetMachine()); + // flat -> local/private if (ASC->getSrcAddressSpace() == AMDGPUAS::FLAT_ADDRESS) { unsigned DestAS = ASC->getDestAddressSpace(); if (DestAS == AMDGPUAS::LOCAL_ADDRESS || DestAS == AMDGPUAS::PRIVATE_ADDRESS) { - SDValue SegmentNullPtr - = DAG.getConstant(getSegmentNullPtrValue(DestAS), SL, MVT::i32); + unsigned NullVal = TM.getNullPointerValue(DestAS); + SDValue SegmentNullPtr = DAG.getConstant(NullVal, SL, MVT::i32); SDValue NonNull = DAG.getSetCC(SL, MVT::i1, Src, FlatNullPtr, ISD::SETNE); SDValue Ptr = DAG.getNode(ISD::TRUNCATE, SL, MVT::i32, Src); @@ -2405,8 +2403,8 @@ SDValue SITargetLowering::lowerADDRSPACECAST(SDValue Op, if (ASC->getDestAddressSpace() == AMDGPUAS::FLAT_ADDRESS) { unsigned SrcAS = ASC->getSrcAddressSpace(); if (SrcAS == AMDGPUAS::LOCAL_ADDRESS || SrcAS == AMDGPUAS::PRIVATE_ADDRESS) { - SDValue SegmentNullPtr - = DAG.getConstant(getSegmentNullPtrValue(SrcAS), SL, MVT::i32); + unsigned NullVal = TM.getNullPointerValue(SrcAS); + SDValue SegmentNullPtr = DAG.getConstant(NullVal, SL, MVT::i32); SDValue NonNull = DAG.getSetCC(SL, MVT::i1, Src, SegmentNullPtr, ISD::SETNE);