[llvm] r278802 - [AArch64][GlobalISel] Select p0 G_FRAME_INDEX.
Ahmed Bougacha via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 16 07:02:42 PDT 2016
Author: ab
Date: Tue Aug 16 09:02:42 2016
New Revision: 278802
URL: http://llvm.org/viewvc/llvm-project?rev=278802&view=rev
Log:
[AArch64][GlobalISel] Select p0 G_FRAME_INDEX.
And mark it as legal.
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp
llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
llvm/trunk/lib/Target/AArch64/AArch64MachineLegalizer.cpp
llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir
Modified: llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp?rev=278802&r1=278801&r2=278802&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/InstructionSelector.cpp Tue Aug 16 09:02:42 2016
@@ -32,8 +32,8 @@ bool InstructionSelector::constrainSelec
for (unsigned OpI = 0, OpE = I.getNumExplicitOperands(); OpI != OpE; ++OpI) {
MachineOperand &MO = I.getOperand(OpI);
- // There's nothing to be done on immediates.
- if (MO.isImm())
+ // There's nothing to be done on immediates and frame indexes.
+ if (MO.isImm() || MO.isFI())
continue;
DEBUG(dbgs() << "Converting operand: " << MO << '\n');
Modified: llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp?rev=278802&r1=278801&r2=278802&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64InstructionSelector.cpp Tue Aug 16 09:02:42 2016
@@ -133,6 +133,24 @@ bool AArch64InstructionSelector::select(
return true;
}
+ case TargetOpcode::G_FRAME_INDEX: {
+ // allocas and G_FRAME_INDEX are only supported in addrspace(0).
+ if (I.getType() != LLT::pointer(0)) {
+ DEBUG(dbgs() << "G_FRAME_INDEX pointer has type: " << I.getType()
+ << ", expected: " << LLT::pointer(0) << '\n');
+ return false;
+ }
+
+ I.setDesc(TII.get(AArch64::ADDXri));
+ I.removeTypes();
+
+ // MOs for a #0 shifted immediate.
+ I.addOperand(MachineOperand::CreateImm(0));
+ I.addOperand(MachineOperand::CreateImm(0));
+
+ return constrainSelectedInstRegOperands(I, TII, TRI, RBI);
+ }
+
case TargetOpcode::G_LOAD:
case TargetOpcode::G_STORE: {
LLT MemTy = I.getType(0);
Modified: llvm/trunk/lib/Target/AArch64/AArch64MachineLegalizer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64MachineLegalizer.cpp?rev=278802&r1=278801&r2=278802&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64MachineLegalizer.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64MachineLegalizer.cpp Tue Aug 16 09:02:42 2016
@@ -49,5 +49,7 @@ AArch64MachineLegalizer::AArch64MachineL
setAction(G_BR, LLT::unsized(), Legal);
+ setAction(G_FRAME_INDEX, LLT::pointer(0), Legal);
+
computeTables();
}
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=278802&r1=278801&r2=278802&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-instructionselect.mir Tue Aug 16 09:02:42 2016
@@ -30,6 +30,11 @@
define void @store_s64_gpr(i64* %addr) { ret void }
define void @store_s32_gpr(i32* %addr) { ret void }
+ define void @frame_index() {
+ %ptr0 = alloca i64
+ ret void
+ }
+
define void @selected_property() { ret void }
...
@@ -422,6 +427,28 @@ body: |
...
---
+# CHECK-LABEL: name: frame_index
+name: frame_index
+isSSA: true
+legalized: true
+regBankSelected: true
+
+# CHECK: registers:
+# CHECK-NEXT: - { id: 0, class: gpr64sp }
+registers:
+ - { id: 0, class: gpr }
+
+stack:
+ - { id: 0, name: ptr0, offset: 0, size: 8, alignment: 8 }
+
+# CHECK: body:
+# CHECK: %0 = ADDXri %stack.0.ptr0, 0, 0
+body: |
+ bb.0:
+ %0(64) = G_FRAME_INDEX p0 %stack.0.ptr0
+...
+
+---
# Check that we set the "selected" property.
# CHECK-LABEL: name: selected_property
# CHECK: legalized: true
More information about the llvm-commits
mailing list