[llvm] r283806 - GlobalISel: support selecting constants on AArch64.
Tim Northover via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 10 14:49:42 PDT 2016
Author: tnorthover
Date: Mon Oct 10 16:49:42 2016
New Revision: 283806
URL: http://llvm.org/viewvc/llvm-project?rev=283806&view=rev
Log:
GlobalISel: support selecting constants on AArch64.
Modified:
llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir
Modified: llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp?rev=283806&r1=283805&r2=283806&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp Mon Oct 10 16:49:42 2016
@@ -229,6 +229,16 @@ bool AArch64InstructionSelector::select(
return true;
}
+ case TargetOpcode::G_CONSTANT: {
+ if (Ty.getSizeInBits() <= 32)
+ I.setDesc(TII.get(AArch64::MOVi32imm));
+ else if (Ty.getSizeInBits() <= 64)
+ I.setDesc(TII.get(AArch64::MOVi64imm));
+ else
+ return false;
+ return constrainSelectedInstRegOperands(I, TII, TRI, RBI);
+ }
+
case TargetOpcode::G_FRAME_INDEX: {
// allocas and G_FRAME_INDEX are only supported in addrspace(0).
if (Ty != LLT::pointer(0, 64)) {
Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir?rev=283806&r1=283805&r2=283806&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir Mon Oct 10 16:49:42 2016
@@ -67,6 +67,9 @@
define void @selected_property() { ret void }
+ define i32 @const_s32() { ret i32 42 }
+ define i64 @const_s64() { ret i64 1234567890123 }
+
...
---
@@ -1088,3 +1091,33 @@ selected: false
body: |
bb.0:
...
+
+---
+# CHECK-LABEL: name: const_s32
+name: const_s32
+legalized: true
+regBankSelected: true
+registers:
+ - { id: 0, class: gpr }
+
+# CHECK: body:
+# CHECK: %0 = MOVi32imm 42
+body: |
+ bb.0:
+ %0(s32) = G_CONSTANT 42
+...
+
+---
+# CHECK-LABEL: name: const_s64
+name: const_s64
+legalized: true
+regBankSelected: true
+registers:
+ - { id: 0, class: gpr }
+
+# CHECK: body:
+# CHECK: %0 = MOVi64imm 1234567890123
+body: |
+ bb.0:
+ %0(s64) = G_CONSTANT 1234567890123
+...
More information about the llvm-commits
mailing list