From f9e63ee8f38c90d09cfde7b776f88e74515ab2f3 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Sat, 2 Feb 2019 23:33:49 +0000 Subject: [PATCH] AMDGPU/GlobalISel: Legalize constant for pointer types git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352975 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | 7 +- .../AMDGPU/GlobalISel/legalize-constant.mir | 84 +++++++++++++++++++ 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp index 1565659f48c..2c4c8d9580d 100644 --- a/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ b/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -134,11 +134,12 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST, // FIXME: i1 operands to intrinsics should always be legal, but other i1 // values may not be legal. We need to figure out how to distinguish // between these two scenarios. - // FIXME: Pointer types getActionDefinitionsBuilder(G_CONSTANT) - .legalFor({S1, S32, S64}) + .legalFor({S1, S32, S64, GlobalPtr, + LocalPtr, ConstantPtr, PrivatePtr, FlatPtr }) .clampScalar(0, S32, S64) - .widenScalarToNextPow2(0); + .widenScalarToNextPow2(0) + .legalIf(isPointer(0)); setAction({G_FRAME_INDEX, PrivatePtr}, Legal); diff --git a/test/CodeGen/AMDGPU/GlobalISel/legalize-constant.mir b/test/CodeGen/AMDGPU/GlobalISel/legalize-constant.mir index c25f329261d..a38ef998a9e 100644 --- a/test/CodeGen/AMDGPU/GlobalISel/legalize-constant.mir +++ b/test/CodeGen/AMDGPU/GlobalISel/legalize-constant.mir @@ -92,3 +92,87 @@ body: | %0:_(s128) = G_CONSTANT i128 5 $vgpr0_vgpr1_vgpr2_vgpr3 = COPY %0 ... + +--- +name: test_constant_p0 +body: | + bb.0: + + ; CHECK-LABEL: name: test_constant_p0 + ; CHECK: [[C:%[0-9]+]]:_(p0) = G_CONSTANT i64 0 + ; CHECK: $vgpr0_vgpr1 = COPY [[C]](p0) + %0:_(p0) = G_CONSTANT i64 0 + $vgpr0_vgpr1 = COPY %0 +... + +--- +name: test_constant_p1 +body: | + bb.0: + + ; CHECK-LABEL: name: test_constant_p1 + ; CHECK: [[C:%[0-9]+]]:_(p1) = G_CONSTANT i64 0 + ; CHECK: $vgpr0_vgpr1 = COPY [[C]](p1) + %0:_(p1) = G_CONSTANT i64 0 + $vgpr0_vgpr1 = COPY %0 +... + +--- +name: test_constant_p2 +body: | + bb.0: + + ; CHECK-LABEL: name: test_constant_p2 + ; CHECK: [[C:%[0-9]+]]:_(p2) = G_CONSTANT i32 0 + ; CHECK: $vgpr0 = COPY [[C]](p2) + %0:_(p2) = G_CONSTANT i32 0 + $vgpr0 = COPY %0 +... + +--- +name: test_constant_p3 +body: | + bb.0: + + ; CHECK-LABEL: name: test_constant_p3 + ; CHECK: [[C:%[0-9]+]]:_(p2) = G_CONSTANT i32 0 + ; CHECK: $vgpr0 = COPY [[C]](p2) + %0:_(p2) = G_CONSTANT i32 0 + $vgpr0 = COPY %0 +... + +--- +name: test_constant_p4 +body: | + bb.0: + + ; CHECK-LABEL: name: test_constant_p4 + ; CHECK: [[C:%[0-9]+]]:_(p4) = G_CONSTANT i64 0 + ; CHECK: $vgpr0_vgpr1 = COPY [[C]](p4) + %0:_(p4) = G_CONSTANT i64 0 + $vgpr0_vgpr1 = COPY %0 +... + +--- +name: test_constant_p5 +body: | + bb.0: + + ; CHECK-LABEL: name: test_constant_p5 + ; CHECK: [[C:%[0-9]+]]:_(p5) = G_CONSTANT i32 0 + ; CHECK: $vgpr0 = COPY [[C]](p5) + %0:_(p5) = G_CONSTANT i32 0 + $vgpr0 = COPY %0 +... + +--- +name: test_constant_p999 +body: | + bb.0: + + ; CHECK-LABEL: name: test_constant_p999 + ; CHECK: [[C:%[0-9]+]]:_(p999) = G_CONSTANT i64 0 + ; CHECK: $vgpr0_vgpr1 = COPY [[C]](p999) + %0:_(p999) = G_CONSTANT i64 0 + $vgpr0_vgpr1 = COPY %0 +... -- 2.40.0