[llvm] r297662 - AMDGPU: Re-use TM.getNullPointerValue
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 13 13:18:15 PDT 2017
Author: arsenm
Date: Mon Mar 13 15:18:14 2017
New Revision: 297662
URL: http://llvm.org/viewvc/llvm-project?rev=297662&view=rev
Log:
AMDGPU: Re-use TM.getNullPointerValue
Modified:
llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
Modified: llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp?rev=297662&r1=297661&r2=297662&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/SIISelLowering.cpp Mon Mar 13 15:18:14 2017
@@ -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 <cassert>
@@ -2374,11 +2374,6 @@ SDValue SITargetLowering::getSegmentAper
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::lowerADDRSPACE
SDValue Src = ASC->getOperand(0);
SDValue FlatNullPtr = DAG.getConstant(0, SL, MVT::i64);
+ const AMDGPUTargetMachine &TM =
+ static_cast<const AMDGPUTargetMachine &>(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::lowerADDRSPACE
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);
More information about the llvm-commits
mailing list