From 94db2e288b82a163d2aeabada1ac37fd0f518319 Mon Sep 17 00:00:00 2001 From: Diana Picus Date: Mon, 13 Mar 2017 14:28:34 +0000 Subject: [PATCH] [ARM] GlobalISel: Support SP in regbankselect We used to hit an unreachable in getRegBankFromRegClass when dealing with the stack pointer. This commit adds support for the GPRsp reg class. llvm-svn: 297621 --- llvm/lib/Target/ARM/ARMRegisterBankInfo.cpp | 1 + .../ARM/GlobalISel/arm-regbankselect.mir | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/llvm/lib/Target/ARM/ARMRegisterBankInfo.cpp b/llvm/lib/Target/ARM/ARMRegisterBankInfo.cpp index 8eb13235de1a..08f3da738868 100644 --- a/llvm/lib/Target/ARM/ARMRegisterBankInfo.cpp +++ b/llvm/lib/Target/ARM/ARMRegisterBankInfo.cpp @@ -180,6 +180,7 @@ const RegisterBank &ARMRegisterBankInfo::getRegBankFromRegClass( switch (RC.getID()) { case GPRRegClassID: case GPRnopcRegClassID: + case GPRspRegClassID: case tGPR_and_tcGPRRegClassID: case tGPRRegClassID: return getRegBank(ARM::GPRRegBankID); diff --git a/llvm/test/CodeGen/ARM/GlobalISel/arm-regbankselect.mir b/llvm/test/CodeGen/ARM/GlobalISel/arm-regbankselect.mir index b06a5b6fa4f3..fbf8d81322f8 100644 --- a/llvm/test/CodeGen/ARM/GlobalISel/arm-regbankselect.mir +++ b/llvm/test/CodeGen/ARM/GlobalISel/arm-regbankselect.mir @@ -8,6 +8,8 @@ define void @test_loads() #0 { ret void } define void @test_stores() #0 { ret void } + define void @test_stack() { ret void } + define void @test_gep() { ret void } define void @test_constants() { ret void } @@ -200,6 +202,39 @@ body: | G_STORE %6(s64), %0 :: (store 8) BX_RET 14, _, implicit %r0 +... +--- +name: test_stack +# CHECK-LABEL: name: test_stack +legalized: true +regBankSelected: false +selected: false +# CHECK: registers: +# CHECK: - { id: 0, class: gprb } +# CHECK: - { id: 1, class: gprb } +# CHECK: - { id: 2, class: gprb } +# CHECK: - { id: 3, class: gprb } +# CHECK: - { id: 4, class: gprb } +registers: + - { id: 0, class: _ } + - { id: 1, class: _ } + - { id: 2, class: _ } + - { id: 3, class: _ } + - { id: 4, class: _ } +fixedStack: + - { id: 0, offset: 0, size: 4, alignment: 4, isImmutable: true, isAliased: false } +body: | + bb.0: + %0(p0) = G_FRAME_INDEX %fixed-stack.0 + %1(s32) = G_LOAD %0(p0) :: (load 4 from %fixed-stack.0, align 0) + + %2(p0) = COPY %sp + %3(s32) = G_CONSTANT i32 8 + %4(p0) = G_GEP %2, %3(s32) + G_STORE %1(s32), %4(p0) :: (store 4) + + BX_RET 14, _ + ... --- name: test_gep