]> granicus.if.org Git - llvm/commitdiff
AMDGPU/GlobalISel: Legalize constant for pointer types
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 2 Feb 2019 23:33:49 +0000 (23:33 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 2 Feb 2019 23:33:49 +0000 (23:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@352975 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
test/CodeGen/AMDGPU/GlobalISel/legalize-constant.mir

index 1565659f48cb4dfad5c7a7eaebd15990962f77cf..2c4c8d9580d0891ed1119c3fec438fb968cd11bc 100644 (file)
@@ -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);
 
index c25f329261de693322a6e00f60973dcd5d16a1f0..a38ef998a9ec714a5656ab2123a10c07b0082409 100644 (file)
@@ -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
+...