GlobalISel: support selecting G_GEP instructions.
authorTim Northover <tnorthover@apple.com>
Mon, 10 Oct 2016 21:49:49 +0000 (21:49 +0000)
committerTim Northover <tnorthover@apple.com>
Mon, 10 Oct 2016 21:49:49 +0000 (21:49 +0000)
They're basically just an alias for G_ADD on AArch64.

llvm-svn: 283807

llvm/lib/Target/AArch64/AArch64InstructionSelector.cpp
llvm/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir

index addf60a..628e170 100644 (file)
@@ -130,6 +130,7 @@ static unsigned selectBinaryOp(unsigned GenericOpc, unsigned RegBankID,
       case TargetOpcode::G_AND:
         return AArch64::ANDXrr;
       case TargetOpcode::G_ADD:
+      case TargetOpcode::G_GEP:
         return AArch64::ADDXrr;
       case TargetOpcode::G_SUB:
         return AArch64::SUBXrr;
@@ -340,7 +341,8 @@ bool AArch64InstructionSelector::select(MachineInstr &I) const {
   case TargetOpcode::G_SDIV:
   case TargetOpcode::G_UDIV:
   case TargetOpcode::G_ADD:
-  case TargetOpcode::G_SUB: {
+  case TargetOpcode::G_SUB:
+  case TargetOpcode::G_GEP: {
     // Reject the various things we don't support yet.
     if (unsupportedBinOp(I, RBI, MRI, TRI))
       return false;
index 5dbdc7e..dd12bc8 100644 (file)
@@ -70,6 +70,7 @@
   define i32 @const_s32() { ret i32 42 }
   define i64 @const_s64() { ret i64 1234567890123 }
 
+  define i8* @gep(i8* %in) { ret i8* undef }
 ...
 
 ---
@@ -1121,3 +1122,23 @@ body:             |
   bb.0:
     %0(s64) = G_CONSTANT 1234567890123
 ...
+
+---
+# CHECK-LABEL: name: gep
+name:            gep
+legalized:       true
+regBankSelected: true
+registers:
+  - { id: 0, class: gpr }
+  - { id: 1, class: gpr }
+  - { id: 2, class: gpr }
+
+# CHECK:  body:
+# CHECK: %1 = MOVi64imm 42
+# CHECK: %2 = ADDXrr %0, %1
+body:             |
+  bb.0:
+    %0(p0) = COPY %x0
+    %1(s64) = G_CONSTANT 42
+    %2(p0) = G_GEP %0, %1(s64)
+...