diff options
author | Tom Stellard <tstellar@redhat.com> | 2018-05-10 21:20:10 +0000 |
---|---|---|
committer | Tom Stellard <tstellar@redhat.com> | 2018-05-10 21:20:10 +0000 |
commit | 1e0edad4bbe1794d5713f29a092db76a98011aec (patch) | |
tree | 9699667ca606f3969da66c892dd3129e5f5cd7b1 /llvm/lib | |
parent | 4b0084bfcf4a7997c962af228257b7e9d22bcfdd (diff) | |
download | bcm5719-llvm-1e0edad4bbe1794d5713f29a092db76a98011aec.tar.gz bcm5719-llvm-1e0edad4bbe1794d5713f29a092db76a98011aec.zip |
AMDGPU/GlobalISel: Implement select() for G_BITCAST s32 <--> <2 x s16>
Reviewers: arsenm, nhaehnle
Subscribers: kzhuravl, wdng, yaxunl, rovka, kristof.beyls, dstuttard, tpr, t-tye, llvm-commits
Differential Revision: https://reviews.llvm.org/D45881
llvm-svn: 332042
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp | 20 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h | 1 |
2 files changed, 21 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp index 42d91c09e3b..085a9c2f6fa 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp @@ -57,6 +57,24 @@ AMDGPUInstructionSelector::AMDGPUInstructionSelector( 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 @@ bool AMDGPUInstructionSelector::select(MachineInstr &I, 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: diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h index a8c5a15f85b..f9ab4d0d68f 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h +++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h @@ -59,6 +59,7 @@ private: 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; |