[llvm] r204651 - R600/SI: Move splitting 64-bit immediates to separate function.
Matt Arsenault
Matthew.Arsenault at amd.com
Mon Mar 24 11:26:52 PDT 2014
Author: arsenm
Date: Mon Mar 24 13:26:52 2014
New Revision: 204651
URL: http://llvm.org/viewvc/llvm-project?rev=204651&view=rev
Log:
R600/SI: Move splitting 64-bit immediates to separate function.
Modified:
llvm/trunk/lib/Target/R600/SIInstrInfo.cpp
llvm/trunk/lib/Target/R600/SIInstrInfo.h
Modified: llvm/trunk/lib/Target/R600/SIInstrInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/SIInstrInfo.cpp?rev=204651&r1=204650&r2=204651&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/SIInstrInfo.cpp (original)
+++ llvm/trunk/lib/Target/R600/SIInstrInfo.cpp Mon Mar 24 13:26:52 2014
@@ -591,6 +591,36 @@ unsigned SIInstrInfo::buildExtractSubReg
return SubReg;
}
+unsigned SIInstrInfo::split64BitImm(SmallVectorImpl<MachineInstr *> &Worklist,
+ MachineBasicBlock::iterator MI,
+ MachineRegisterInfo &MRI,
+ const TargetRegisterClass *RC,
+ const MachineOperand &Op) const {
+ MachineBasicBlock *MBB = MI->getParent();
+ DebugLoc DL = MI->getDebugLoc();
+ unsigned LoDst = MRI.createVirtualRegister(&AMDGPU::SGPR_32RegClass);
+ unsigned HiDst = MRI.createVirtualRegister(&AMDGPU::SGPR_32RegClass);
+ unsigned Dst = MRI.createVirtualRegister(RC);
+
+ MachineInstr *Lo = BuildMI(*MBB, MI, DL, get(AMDGPU::S_MOV_B32),
+ LoDst)
+ .addImm(Op.getImm() & 0xFFFFFFFF);
+ MachineInstr *Hi = BuildMI(*MBB, MI, DL, get(AMDGPU::S_MOV_B32),
+ HiDst)
+ .addImm(Op.getImm() >> 32);
+
+ BuildMI(*MBB, MI, DL, get(TargetOpcode::REG_SEQUENCE), Dst)
+ .addReg(LoDst)
+ .addImm(AMDGPU::sub0)
+ .addReg(HiDst)
+ .addImm(AMDGPU::sub1);
+
+ Worklist.push_back(Lo);
+ Worklist.push_back(Hi);
+
+ return Dst;
+}
+
void SIInstrInfo::legalizeOperands(MachineInstr *MI) const {
MachineRegisterInfo &MRI = MI->getParent()->getParent()->getRegInfo();
int Src0Idx = AMDGPU::getNamedOperandIdx(MI->getOpcode(),
@@ -825,46 +855,30 @@ void SIInstrInfo::moveToVALU(MachineInst
// Handle some special cases
switch(Inst->getOpcode()) {
- case AMDGPU::S_MOV_B64: {
- DebugLoc DL = Inst->getDebugLoc();
+ case AMDGPU::S_MOV_B64: {
+ DebugLoc DL = Inst->getDebugLoc();
- // If the source operand is a register we can replace this with a
- // copy
- if (Inst->getOperand(1).isReg()) {
- MachineInstr *Copy = BuildMI(*MBB, Inst, DL,
- get(TargetOpcode::COPY))
- .addOperand(Inst->getOperand(0))
- .addOperand(Inst->getOperand(1));
- Worklist.push_back(Copy);
- } else {
- // Otherwise, we need to split this into two movs, because there is
- // no 64-bit VALU move instruction.
- unsigned LoDst, HiDst, Dst;
- LoDst = MRI.createVirtualRegister(&AMDGPU::SGPR_32RegClass);
- HiDst = MRI.createVirtualRegister(&AMDGPU::SGPR_32RegClass);
- Dst = MRI.createVirtualRegister(
- MRI.getRegClass(Inst->getOperand(0).getReg()));
-
- MachineInstr *Lo = BuildMI(*MBB, Inst, DL, get(AMDGPU::S_MOV_B32),
- LoDst)
- .addImm(Inst->getOperand(1).getImm() & 0xFFFFFFFF);
- MachineInstr *Hi = BuildMI(*MBB, Inst, DL, get(AMDGPU::S_MOV_B32),
- HiDst)
- .addImm(Inst->getOperand(1).getImm() >> 32);
-
- BuildMI(*MBB, Inst, DL, get(TargetOpcode::REG_SEQUENCE), Dst)
- .addReg(LoDst)
- .addImm(AMDGPU::sub0)
- .addReg(HiDst)
- .addImm(AMDGPU::sub1);
-
- MRI.replaceRegWith(Inst->getOperand(0).getReg(), Dst);
- Worklist.push_back(Lo);
- Worklist.push_back(Hi);
- }
- Inst->eraseFromParent();
- continue;
+ // If the source operand is a register we can replace this with a
+ // copy.
+ if (Inst->getOperand(1).isReg()) {
+ MachineInstr *Copy = BuildMI(*MBB, Inst, DL, get(TargetOpcode::COPY))
+ .addOperand(Inst->getOperand(0))
+ .addOperand(Inst->getOperand(1));
+ Worklist.push_back(Copy);
+ } else {
+ // Otherwise, we need to split this into two movs, because there is
+ // no 64-bit VALU move instruction.
+ unsigned Reg = Inst->getOperand(0).getReg();
+ unsigned Dst = split64BitImm(Worklist,
+ Inst,
+ MRI,
+ MRI.getRegClass(Reg),
+ Inst->getOperand(1));
+ MRI.replaceRegWith(Reg, Dst);
}
+ Inst->eraseFromParent();
+ continue;
+ }
}
unsigned NewOpcode = getVALUOp(*Inst);
Modified: llvm/trunk/lib/Target/R600/SIInstrInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/SIInstrInfo.h?rev=204651&r1=204650&r2=204651&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/SIInstrInfo.h (original)
+++ llvm/trunk/lib/Target/R600/SIInstrInfo.h Mon Mar 24 13:26:52 2014
@@ -32,6 +32,12 @@ private:
unsigned SubIdx,
const TargetRegisterClass *SubRC) const;
+ unsigned split64BitImm(SmallVectorImpl<MachineInstr *> &Worklist,
+ MachineBasicBlock::iterator MI,
+ MachineRegisterInfo &MRI,
+ const TargetRegisterClass *RC,
+ const MachineOperand &Op) const;
+
public:
explicit SIInstrInfo(AMDGPUTargetMachine &tm);
More information about the llvm-commits
mailing list