From c94e26c71d1a3c9bd85826e7d62940b2c10114a9 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 18 Dec 2018 09:46:13 +0000 Subject: [PATCH] AMDGPU: Legalize/regbankselect frame_index llvm-svn: 349468 --- .../lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp | 2 ++ .../Target/AMDGPU/AMDGPURegisterBankInfo.cpp | 1 + .../GlobalISel/regbankselect-frame-index.mir | 23 +++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-frame-index.mir diff --git a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp index c2ca67558778..62fe0f3a8b91 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp @@ -90,6 +90,8 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST, // between these two scenarios. setAction({G_CONSTANT, S1}, Legal); + setAction({G_FRAME_INDEX, PrivatePtr}, Legal); + getActionDefinitionsBuilder( { G_FADD, G_FMUL, G_FNEG, G_FABS, G_FMA}) .legalFor({S32, S64}); diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp index 21672f29acfe..a2f4dac436c2 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp @@ -366,6 +366,7 @@ AMDGPURegisterBankInfo::getInstrMapping(const MachineInstr &MI) const { } case AMDGPU::G_FCONSTANT: case AMDGPU::G_CONSTANT: + case AMDGPU::G_FRAME_INDEX: case AMDGPU::G_BLOCK_ADDR: { unsigned Size = MRI.getType(MI.getOperand(0).getReg()).getSizeInBits(); OpdsMapping[0] = AMDGPU::getValueMapping(AMDGPU::SGPRRegBankID, Size); diff --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-frame-index.mir b/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-frame-index.mir new file mode 100644 index 000000000000..77a444d6d14e --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/regbankselect-frame-index.mir @@ -0,0 +1,23 @@ +# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py +# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=regbankselect %s -verify-machineinstrs -o - -regbankselect-fast | FileCheck %s +# RUN: llc -march=amdgcn -mcpu=fiji -run-pass=regbankselect %s -verify-machineinstrs -o - -regbankselect-greedy | FileCheck %s + +--- | + target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5" + define void @test_frame_index_p5() { + %ptr0 = alloca i32, addrspace(5) + ret void + } +... +--- +name: test_frame_index_p5 +legalized: true +stack: + - { id: 0, name: ptr0, offset: 0, size: 4, alignment: 4 } +body: | + bb.0: + ; CHECK-LABEL: name: test_frame_index_p5 + ; CHECK: [[FRAME_INDEX:%[0-9]+]]:sgpr(p5) = G_FRAME_INDEX %stack.0.ptr0 + %0:_(p5) = G_FRAME_INDEX %stack.0.ptr0 + +...