[PATCH] D45881: AMDGPU/GlobalISel: Implement select() for G_BITCAST s32 <--> <2 x s16>
Tom Stellard via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 10 14:23:56 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL332042: AMDGPU/GlobalISel: Implement select() for G_BITCAST s32 <--> <2 x s16> (authored by tstellar, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D45881?vs=143842&id=146226#toc
Repository:
rL LLVM
https://reviews.llvm.org/D45881
Files:
llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/inst-select-bitcast.mir
Index: llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/inst-select-bitcast.mir
===================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/inst-select-bitcast.mir
+++ llvm/trunk/test/CodeGen/AMDGPU/GlobalISel/inst-select-bitcast.mir
@@ -0,0 +1,26 @@
+# RUN: llc -march=amdgcn -run-pass=instruction-select -verify-machineinstrs -global-isel %s -o - | FileCheck %s -check-prefixes=GCN
+
+--- |
+ define amdgpu_kernel void @bitcast(i32 addrspace(1)* %global0) {ret void}
+...
+---
+
+name: bitcast
+legalized: true
+regBankSelected: true
+
+# GCN-LABEL: name: bitcast
+# GCN: [[A:%[0-9]+]]:vgpr_32 = COPY $vgpr0
+# GCN: [[B:%[0-9]+]]:vreg_64 = COPY $vgpr3_vgpr4
+# GCN: FLAT_STORE_DWORD [[B]], [[A]]
+
+body: |
+ bb.0:
+ liveins: $sgpr0, $vgpr3_vgpr4
+ %0:vgpr(s32) = COPY $vgpr0
+ %1:vgpr(s64) = COPY $vgpr3_vgpr4
+ %2:vgpr(<2 x s16>) = G_BITCAST %0
+ %3:vgpr(s32) = G_BITCAST %2
+ G_STORE %3, %1 :: (store 4 into %ir.global0)
+...
+---
Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -57,6 +57,24 @@
const char *AMDGPUInstructionSelector::getName() { return DEBUG_TYPE; }
+bool AMDGPUInstructionSelector::selectCOPY(MachineInstr &I) const {
+ MachineBasicBlock *BB = I.getParent();
+ MachineFunction *MF = BB->getParent();
+ MachineRegisterInfo &MRI = MF->getRegInfo();
+ I.setDesc(TII.get(TargetOpcode::COPY));
+ for (const MachineOperand &MO : I.operands()) {
+ if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()))
+ continue;
+
+ const TargetRegisterClass *RC =
+ TRI.getConstrainedRegClassForOperand(MO, MRI);
+ if (!RC)
+ continue;
+ RBI.constrainGenericRegister(MO.getReg(), *RC, MRI);
+ }
+ return true;
+}
+
MachineOperand
AMDGPUInstructionSelector::getSubOperand64(MachineOperand &MO,
unsigned SubIdx) const {
@@ -441,6 +459,8 @@
return selectImpl(I, CoverageInfo);
case TargetOpcode::G_ADD:
return selectG_ADD(I);
+ case TargetOpcode::G_BITCAST:
+ return selectCOPY(I);
case TargetOpcode::G_CONSTANT:
return selectG_CONSTANT(I);
case TargetOpcode::G_GEP:
Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
===================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructionSelector.h
@@ -59,6 +59,7 @@
bool selectImpl(MachineInstr &I, CodeGenCoverage &CoverageInfo) const;
MachineOperand getSubOperand64(MachineOperand &MO, unsigned SubIdx) const;
+ bool selectCOPY(MachineInstr &I) const;
bool selectG_CONSTANT(MachineInstr &I) const;
bool selectG_ADD(MachineInstr &I) const;
bool selectG_GEP(MachineInstr &I) const;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45881.146226.patch
Type: text/x-patch
Size: 2993 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180510/085470ea/attachment.bin>
More information about the llvm-commits
mailing list