2012-12-11 21:25:42 +00:00
|
|
|
//===-- SIInstrInfo.cpp - SI Instruction Information ---------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// \file
|
|
|
|
/// \brief SI Implementation of TargetInstrInfo.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
|
|
#include "SIInstrInfo.h"
|
|
|
|
#include "AMDGPUTargetMachine.h"
|
2013-08-14 23:24:17 +00:00
|
|
|
#include "SIDefines.h"
|
2013-11-27 21:23:35 +00:00
|
|
|
#include "SIMachineFunctionInfo.h"
|
2012-12-11 21:25:42 +00:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
|
|
|
#include "llvm/MC/MCInstrDesc.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
SIInstrInfo::SIInstrInfo(AMDGPUTargetMachine &tm)
|
|
|
|
: AMDGPUInstrInfo(tm),
|
2014-03-11 00:01:34 +00:00
|
|
|
RI(tm) { }
|
2012-12-11 21:25:42 +00:00
|
|
|
|
2013-11-13 23:36:37 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// TargetInstrInfo callbacks
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-11 21:25:42 +00:00
|
|
|
void
|
|
|
|
SIInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
|
2013-03-01 09:46:27 +00:00
|
|
|
MachineBasicBlock::iterator MI, DebugLoc DL,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
|
|
|
bool KillSrc) const {
|
|
|
|
|
2012-12-11 21:25:42 +00:00
|
|
|
// If we are trying to copy to or from SCC, there is a bug somewhere else in
|
|
|
|
// the backend. While it may be theoretically possible to do this, it should
|
|
|
|
// never be necessary.
|
|
|
|
assert(DestReg != AMDGPU::SCC && SrcReg != AMDGPU::SCC);
|
|
|
|
|
2013-07-15 06:39:13 +00:00
|
|
|
static const int16_t Sub0_15[] = {
|
2013-03-01 09:46:27 +00:00
|
|
|
AMDGPU::sub0, AMDGPU::sub1, AMDGPU::sub2, AMDGPU::sub3,
|
|
|
|
AMDGPU::sub4, AMDGPU::sub5, AMDGPU::sub6, AMDGPU::sub7,
|
|
|
|
AMDGPU::sub8, AMDGPU::sub9, AMDGPU::sub10, AMDGPU::sub11,
|
|
|
|
AMDGPU::sub12, AMDGPU::sub13, AMDGPU::sub14, AMDGPU::sub15, 0
|
|
|
|
};
|
|
|
|
|
2013-07-15 06:39:13 +00:00
|
|
|
static const int16_t Sub0_7[] = {
|
2013-03-01 09:46:27 +00:00
|
|
|
AMDGPU::sub0, AMDGPU::sub1, AMDGPU::sub2, AMDGPU::sub3,
|
|
|
|
AMDGPU::sub4, AMDGPU::sub5, AMDGPU::sub6, AMDGPU::sub7, 0
|
|
|
|
};
|
|
|
|
|
2013-07-15 06:39:13 +00:00
|
|
|
static const int16_t Sub0_3[] = {
|
2013-03-01 09:46:27 +00:00
|
|
|
AMDGPU::sub0, AMDGPU::sub1, AMDGPU::sub2, AMDGPU::sub3, 0
|
|
|
|
};
|
|
|
|
|
2013-07-15 06:39:13 +00:00
|
|
|
static const int16_t Sub0_2[] = {
|
2013-04-10 08:39:16 +00:00
|
|
|
AMDGPU::sub0, AMDGPU::sub1, AMDGPU::sub2, 0
|
|
|
|
};
|
|
|
|
|
2013-07-15 06:39:13 +00:00
|
|
|
static const int16_t Sub0_1[] = {
|
2013-03-01 09:46:27 +00:00
|
|
|
AMDGPU::sub0, AMDGPU::sub1, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
unsigned Opcode;
|
|
|
|
const int16_t *SubIndices;
|
|
|
|
|
2013-03-26 14:04:12 +00:00
|
|
|
if (AMDGPU::M0 == DestReg) {
|
|
|
|
// Check if M0 isn't already set to this value
|
|
|
|
for (MachineBasicBlock::reverse_iterator E = MBB.rend(),
|
|
|
|
I = MachineBasicBlock::reverse_iterator(MI); I != E; ++I) {
|
|
|
|
|
|
|
|
if (!I->definesRegister(AMDGPU::M0))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
unsigned Opc = I->getOpcode();
|
|
|
|
if (Opc != TargetOpcode::COPY && Opc != AMDGPU::S_MOV_B32)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!I->readsRegister(SrcReg))
|
|
|
|
break;
|
|
|
|
|
|
|
|
// The copy isn't necessary
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-01 09:46:27 +00:00
|
|
|
if (AMDGPU::SReg_32RegClass.contains(DestReg)) {
|
|
|
|
assert(AMDGPU::SReg_32RegClass.contains(SrcReg));
|
|
|
|
BuildMI(MBB, MI, DL, get(AMDGPU::S_MOV_B32), DestReg)
|
|
|
|
.addReg(SrcReg, getKillRegState(KillSrc));
|
|
|
|
return;
|
|
|
|
|
2013-02-07 19:39:43 +00:00
|
|
|
} else if (AMDGPU::SReg_64RegClass.contains(DestReg)) {
|
2012-12-11 21:25:42 +00:00
|
|
|
assert(AMDGPU::SReg_64RegClass.contains(SrcReg));
|
|
|
|
BuildMI(MBB, MI, DL, get(AMDGPU::S_MOV_B64), DestReg)
|
|
|
|
.addReg(SrcReg, getKillRegState(KillSrc));
|
2013-03-01 09:46:27 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
} else if (AMDGPU::SReg_128RegClass.contains(DestReg)) {
|
|
|
|
assert(AMDGPU::SReg_128RegClass.contains(SrcReg));
|
|
|
|
Opcode = AMDGPU::S_MOV_B32;
|
|
|
|
SubIndices = Sub0_3;
|
|
|
|
|
|
|
|
} else if (AMDGPU::SReg_256RegClass.contains(DestReg)) {
|
|
|
|
assert(AMDGPU::SReg_256RegClass.contains(SrcReg));
|
|
|
|
Opcode = AMDGPU::S_MOV_B32;
|
|
|
|
SubIndices = Sub0_7;
|
|
|
|
|
|
|
|
} else if (AMDGPU::SReg_512RegClass.contains(DestReg)) {
|
|
|
|
assert(AMDGPU::SReg_512RegClass.contains(SrcReg));
|
|
|
|
Opcode = AMDGPU::S_MOV_B32;
|
|
|
|
SubIndices = Sub0_15;
|
|
|
|
|
2012-12-11 21:25:42 +00:00
|
|
|
} else if (AMDGPU::VReg_32RegClass.contains(DestReg)) {
|
|
|
|
assert(AMDGPU::VReg_32RegClass.contains(SrcReg) ||
|
2013-10-28 04:07:23 +00:00
|
|
|
AMDGPU::SReg_32RegClass.contains(SrcReg));
|
2012-12-11 21:25:42 +00:00
|
|
|
BuildMI(MBB, MI, DL, get(AMDGPU::V_MOV_B32_e32), DestReg)
|
|
|
|
.addReg(SrcReg, getKillRegState(KillSrc));
|
2013-03-01 09:46:27 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
} else if (AMDGPU::VReg_64RegClass.contains(DestReg)) {
|
|
|
|
assert(AMDGPU::VReg_64RegClass.contains(SrcReg) ||
|
2013-10-28 04:07:23 +00:00
|
|
|
AMDGPU::SReg_64RegClass.contains(SrcReg));
|
2013-03-01 09:46:27 +00:00
|
|
|
Opcode = AMDGPU::V_MOV_B32_e32;
|
|
|
|
SubIndices = Sub0_1;
|
|
|
|
|
2013-04-10 08:39:16 +00:00
|
|
|
} else if (AMDGPU::VReg_96RegClass.contains(DestReg)) {
|
|
|
|
assert(AMDGPU::VReg_96RegClass.contains(SrcReg));
|
|
|
|
Opcode = AMDGPU::V_MOV_B32_e32;
|
|
|
|
SubIndices = Sub0_2;
|
|
|
|
|
2013-03-01 09:46:27 +00:00
|
|
|
} else if (AMDGPU::VReg_128RegClass.contains(DestReg)) {
|
|
|
|
assert(AMDGPU::VReg_128RegClass.contains(SrcReg) ||
|
2013-10-28 04:07:23 +00:00
|
|
|
AMDGPU::SReg_128RegClass.contains(SrcReg));
|
2013-03-01 09:46:27 +00:00
|
|
|
Opcode = AMDGPU::V_MOV_B32_e32;
|
|
|
|
SubIndices = Sub0_3;
|
|
|
|
|
|
|
|
} else if (AMDGPU::VReg_256RegClass.contains(DestReg)) {
|
|
|
|
assert(AMDGPU::VReg_256RegClass.contains(SrcReg) ||
|
2013-10-28 04:07:23 +00:00
|
|
|
AMDGPU::SReg_256RegClass.contains(SrcReg));
|
2013-03-01 09:46:27 +00:00
|
|
|
Opcode = AMDGPU::V_MOV_B32_e32;
|
|
|
|
SubIndices = Sub0_7;
|
|
|
|
|
|
|
|
} else if (AMDGPU::VReg_512RegClass.contains(DestReg)) {
|
|
|
|
assert(AMDGPU::VReg_512RegClass.contains(SrcReg) ||
|
2013-10-28 04:07:23 +00:00
|
|
|
AMDGPU::SReg_512RegClass.contains(SrcReg));
|
2013-03-01 09:46:27 +00:00
|
|
|
Opcode = AMDGPU::V_MOV_B32_e32;
|
|
|
|
SubIndices = Sub0_15;
|
|
|
|
|
2012-12-11 21:25:42 +00:00
|
|
|
} else {
|
2013-03-01 09:46:27 +00:00
|
|
|
llvm_unreachable("Can't copy register!");
|
|
|
|
}
|
|
|
|
|
|
|
|
while (unsigned SubIdx = *SubIndices++) {
|
|
|
|
MachineInstrBuilder Builder = BuildMI(MBB, MI, DL,
|
|
|
|
get(Opcode), RI.getSubReg(DestReg, SubIdx));
|
|
|
|
|
|
|
|
Builder.addReg(RI.getSubReg(SrcReg, SubIdx), getKillRegState(KillSrc));
|
|
|
|
|
|
|
|
if (*SubIndices)
|
|
|
|
Builder.addReg(DestReg, RegState::Define | RegState::Implicit);
|
2012-12-11 21:25:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-27 09:12:59 +00:00
|
|
|
unsigned SIInstrInfo::commuteOpcode(unsigned Opcode) const {
|
|
|
|
int NewOpc;
|
|
|
|
|
|
|
|
// Try to map original to commuted opcode
|
|
|
|
if ((NewOpc = AMDGPU::getCommuteRev(Opcode)) != -1)
|
|
|
|
return NewOpc;
|
|
|
|
|
|
|
|
// Try to map commuted to original opcode
|
|
|
|
if ((NewOpc = AMDGPU::getCommuteOrig(Opcode)) != -1)
|
|
|
|
return NewOpc;
|
|
|
|
|
|
|
|
return Opcode;
|
|
|
|
}
|
|
|
|
|
2013-11-27 21:23:35 +00:00
|
|
|
void SIInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned SrcReg, bool isKill,
|
|
|
|
int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
|
|
|
MachineRegisterInfo &MRI = MBB.getParent()->getRegInfo();
|
|
|
|
SIMachineFunctionInfo *MFI = MBB.getParent()->getInfo<SIMachineFunctionInfo>();
|
|
|
|
DebugLoc DL = MBB.findDebugLoc(MI);
|
|
|
|
unsigned KillFlag = isKill ? RegState::Kill : 0;
|
|
|
|
|
|
|
|
if (TRI->getCommonSubClass(RC, &AMDGPU::SGPR_32RegClass)) {
|
|
|
|
unsigned Lane = MFI->SpillTracker.getNextLane(MRI);
|
|
|
|
BuildMI(MBB, MI, DL, get(AMDGPU::V_WRITELANE_B32),
|
|
|
|
MFI->SpillTracker.LaneVGPR)
|
|
|
|
.addReg(SrcReg, KillFlag)
|
|
|
|
.addImm(Lane);
|
|
|
|
MFI->SpillTracker.addSpilledReg(FrameIndex, MFI->SpillTracker.LaneVGPR,
|
|
|
|
Lane);
|
|
|
|
} else {
|
|
|
|
for (unsigned i = 0, e = RC->getSize() / 4; i != e; ++i) {
|
|
|
|
unsigned SubReg = MRI.createVirtualRegister(&AMDGPU::SReg_32RegClass);
|
|
|
|
BuildMI(MBB, MI, MBB.findDebugLoc(MI), get(AMDGPU::COPY), SubReg)
|
|
|
|
.addReg(SrcReg, 0, RI.getSubRegFromChannel(i));
|
|
|
|
storeRegToStackSlot(MBB, MI, SubReg, isKill, FrameIndex + i,
|
|
|
|
&AMDGPU::SReg_32RegClass, TRI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SIInstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
|
|
|
MachineRegisterInfo &MRI = MBB.getParent()->getRegInfo();
|
|
|
|
SIMachineFunctionInfo *MFI = MBB.getParent()->getInfo<SIMachineFunctionInfo>();
|
|
|
|
DebugLoc DL = MBB.findDebugLoc(MI);
|
|
|
|
if (TRI->getCommonSubClass(RC, &AMDGPU::SReg_32RegClass)) {
|
|
|
|
SIMachineFunctionInfo::SpilledReg Spill =
|
|
|
|
MFI->SpillTracker.getSpilledReg(FrameIndex);
|
|
|
|
assert(Spill.VGPR);
|
|
|
|
BuildMI(MBB, MI, DL, get(AMDGPU::V_READLANE_B32), DestReg)
|
|
|
|
.addReg(Spill.VGPR)
|
|
|
|
.addImm(Spill.Lane);
|
|
|
|
} else {
|
|
|
|
for (unsigned i = 0, e = RC->getSize() / 4; i != e; ++i) {
|
|
|
|
unsigned Flags = RegState::Define;
|
|
|
|
if (i == 0) {
|
|
|
|
Flags |= RegState::Undef;
|
|
|
|
}
|
|
|
|
unsigned SubReg = MRI.createVirtualRegister(&AMDGPU::SReg_32RegClass);
|
|
|
|
loadRegFromStackSlot(MBB, MI, SubReg, FrameIndex + i,
|
|
|
|
&AMDGPU::SReg_32RegClass, TRI);
|
|
|
|
BuildMI(MBB, MI, DL, get(AMDGPU::COPY))
|
|
|
|
.addReg(DestReg, Flags, RI.getSubRegFromChannel(i))
|
|
|
|
.addReg(SubReg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-26 17:52:29 +00:00
|
|
|
MachineInstr *SIInstrInfo::commuteInstruction(MachineInstr *MI,
|
|
|
|
bool NewMI) const {
|
|
|
|
|
2013-11-13 23:36:37 +00:00
|
|
|
MachineRegisterInfo &MRI = MI->getParent()->getParent()->getRegInfo();
|
|
|
|
if (MI->getNumOperands() < 3 || !MI->getOperand(1).isReg())
|
2013-02-26 17:52:29 +00:00
|
|
|
return 0;
|
|
|
|
|
2013-11-13 23:36:37 +00:00
|
|
|
// Cannot commute VOP2 if src0 is SGPR.
|
|
|
|
if (isVOP2(MI->getOpcode()) && MI->getOperand(1).isReg() &&
|
|
|
|
RI.isSGPRClass(MRI.getRegClass(MI->getOperand(1).getReg())))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (!MI->getOperand(2).isReg()) {
|
|
|
|
// XXX: Commute instructions with FPImm operands
|
|
|
|
if (NewMI || MI->getOperand(2).isFPImm() ||
|
|
|
|
(!isVOP2(MI->getOpcode()) && !isVOP3(MI->getOpcode()))) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXX: Commute VOP3 instructions with abs and neg set.
|
|
|
|
if (isVOP3(MI->getOpcode()) &&
|
|
|
|
(MI->getOperand(AMDGPU::getNamedOperandIdx(MI->getOpcode(),
|
|
|
|
AMDGPU::OpName::abs)).getImm() ||
|
|
|
|
MI->getOperand(AMDGPU::getNamedOperandIdx(MI->getOpcode(),
|
|
|
|
AMDGPU::OpName::neg)).getImm()))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
unsigned Reg = MI->getOperand(1).getReg();
|
2013-12-17 04:50:45 +00:00
|
|
|
unsigned SubReg = MI->getOperand(1).getSubReg();
|
2013-11-13 23:36:37 +00:00
|
|
|
MI->getOperand(1).ChangeToImmediate(MI->getOperand(2).getImm());
|
|
|
|
MI->getOperand(2).ChangeToRegister(Reg, false);
|
2013-12-17 04:50:45 +00:00
|
|
|
MI->getOperand(2).setSubReg(SubReg);
|
2013-11-13 23:36:37 +00:00
|
|
|
} else {
|
|
|
|
MI = TargetInstrInfo::commuteInstruction(MI, NewMI);
|
|
|
|
}
|
2013-03-27 09:12:59 +00:00
|
|
|
|
|
|
|
if (MI)
|
|
|
|
MI->setDesc(get(commuteOpcode(MI->getOpcode())));
|
|
|
|
|
|
|
|
return MI;
|
2013-02-26 17:52:29 +00:00
|
|
|
}
|
|
|
|
|
2013-10-22 18:19:10 +00:00
|
|
|
MachineInstr *SIInstrInfo::buildMovInstr(MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned DstReg,
|
|
|
|
unsigned SrcReg) const {
|
2013-11-13 23:36:50 +00:00
|
|
|
return BuildMI(*MBB, I, MBB->findDebugLoc(I), get(AMDGPU::V_MOV_B32_e32),
|
|
|
|
DstReg) .addReg(SrcReg);
|
2013-10-22 18:19:10 +00:00
|
|
|
}
|
|
|
|
|
2012-12-11 21:25:42 +00:00
|
|
|
bool SIInstrInfo::isMov(unsigned Opcode) const {
|
|
|
|
switch(Opcode) {
|
|
|
|
default: return false;
|
|
|
|
case AMDGPU::S_MOV_B32:
|
|
|
|
case AMDGPU::S_MOV_B64:
|
|
|
|
case AMDGPU::V_MOV_B32_e32:
|
|
|
|
case AMDGPU::V_MOV_B32_e64:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SIInstrInfo::isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const {
|
|
|
|
return RC != &AMDGPU::EXECRegRegClass;
|
|
|
|
}
|
2013-02-06 17:32:29 +00:00
|
|
|
|
2014-02-10 16:58:30 +00:00
|
|
|
namespace llvm {
|
|
|
|
namespace AMDGPU {
|
|
|
|
// Helper function generated by tablegen. We are wrapping this with
|
|
|
|
// an SIInstrInfo function that reutrns bool rather than int.
|
|
|
|
int isDS(uint16_t Opcode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SIInstrInfo::isDS(uint16_t Opcode) const {
|
|
|
|
return ::AMDGPU::isDS(Opcode) != -1;
|
|
|
|
}
|
|
|
|
|
2013-08-14 23:24:17 +00:00
|
|
|
int SIInstrInfo::isMIMG(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::MIMG;
|
|
|
|
}
|
|
|
|
|
2013-08-16 16:19:24 +00:00
|
|
|
int SIInstrInfo::isSMRD(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::SMRD;
|
|
|
|
}
|
|
|
|
|
2013-10-10 17:11:55 +00:00
|
|
|
bool SIInstrInfo::isVOP1(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VOP1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SIInstrInfo::isVOP2(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VOP2;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SIInstrInfo::isVOP3(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VOP3;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SIInstrInfo::isVOPC(uint16_t Opcode) const {
|
|
|
|
return get(Opcode).TSFlags & SIInstrFlags::VOPC;
|
|
|
|
}
|
|
|
|
|
2013-11-13 23:36:37 +00:00
|
|
|
bool SIInstrInfo::isSALUInstr(const MachineInstr &MI) const {
|
|
|
|
return get(MI.getOpcode()).TSFlags & SIInstrFlags::SALU;
|
|
|
|
}
|
|
|
|
|
2013-10-10 17:11:55 +00:00
|
|
|
bool SIInstrInfo::isInlineConstant(const MachineOperand &MO) const {
|
|
|
|
if(MO.isImm()) {
|
|
|
|
return MO.getImm() >= -16 && MO.getImm() <= 64;
|
|
|
|
}
|
|
|
|
if (MO.isFPImm()) {
|
|
|
|
return MO.getFPImm()->isExactlyValue(0.0) ||
|
|
|
|
MO.getFPImm()->isExactlyValue(0.5) ||
|
|
|
|
MO.getFPImm()->isExactlyValue(-0.5) ||
|
|
|
|
MO.getFPImm()->isExactlyValue(1.0) ||
|
|
|
|
MO.getFPImm()->isExactlyValue(-1.0) ||
|
|
|
|
MO.getFPImm()->isExactlyValue(2.0) ||
|
|
|
|
MO.getFPImm()->isExactlyValue(-2.0) ||
|
|
|
|
MO.getFPImm()->isExactlyValue(4.0) ||
|
|
|
|
MO.getFPImm()->isExactlyValue(-4.0);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SIInstrInfo::isLiteralConstant(const MachineOperand &MO) const {
|
|
|
|
return (MO.isImm() || MO.isFPImm()) && !isInlineConstant(MO);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SIInstrInfo::verifyInstruction(const MachineInstr *MI,
|
|
|
|
StringRef &ErrInfo) const {
|
|
|
|
uint16_t Opcode = MI->getOpcode();
|
|
|
|
int Src0Idx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::src0);
|
|
|
|
int Src1Idx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::src1);
|
|
|
|
int Src2Idx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::src2);
|
|
|
|
|
|
|
|
// Verify VOP*
|
|
|
|
if (isVOP1(Opcode) || isVOP2(Opcode) || isVOP3(Opcode) || isVOPC(Opcode)) {
|
|
|
|
unsigned ConstantBusCount = 0;
|
|
|
|
unsigned SGPRUsed = AMDGPU::NoRegister;
|
|
|
|
for (int i = 0, e = MI->getNumOperands(); i != e; ++i) {
|
|
|
|
const MachineOperand &MO = MI->getOperand(i);
|
|
|
|
if (MO.isReg() && MO.isUse() &&
|
|
|
|
!TargetRegisterInfo::isVirtualRegister(MO.getReg())) {
|
|
|
|
|
|
|
|
// EXEC register uses the constant bus.
|
|
|
|
if (!MO.isImplicit() && MO.getReg() == AMDGPU::EXEC)
|
|
|
|
++ConstantBusCount;
|
|
|
|
|
|
|
|
// SGPRs use the constant bus
|
|
|
|
if (MO.getReg() == AMDGPU::M0 || MO.getReg() == AMDGPU::VCC ||
|
|
|
|
(!MO.isImplicit() &&
|
|
|
|
(AMDGPU::SGPR_32RegClass.contains(MO.getReg()) ||
|
|
|
|
AMDGPU::SGPR_64RegClass.contains(MO.getReg())))) {
|
|
|
|
if (SGPRUsed != MO.getReg()) {
|
|
|
|
++ConstantBusCount;
|
|
|
|
SGPRUsed = MO.getReg();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Literal constants use the constant bus.
|
|
|
|
if (isLiteralConstant(MO))
|
|
|
|
++ConstantBusCount;
|
|
|
|
}
|
|
|
|
if (ConstantBusCount > 1) {
|
|
|
|
ErrInfo = "VOP* instruction uses the constant bus more than once";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify SRC1 for VOP2 and VOPC
|
|
|
|
if (Src1Idx != -1 && (isVOP2(Opcode) || isVOPC(Opcode))) {
|
|
|
|
const MachineOperand &Src1 = MI->getOperand(Src1Idx);
|
2013-11-13 23:36:37 +00:00
|
|
|
if (Src1.isImm() || Src1.isFPImm()) {
|
2013-10-10 17:11:55 +00:00
|
|
|
ErrInfo = "VOP[2C] src1 cannot be an immediate.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Verify VOP3
|
|
|
|
if (isVOP3(Opcode)) {
|
|
|
|
if (Src0Idx != -1 && isLiteralConstant(MI->getOperand(Src0Idx))) {
|
|
|
|
ErrInfo = "VOP3 src0 cannot be a literal constant.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (Src1Idx != -1 && isLiteralConstant(MI->getOperand(Src1Idx))) {
|
|
|
|
ErrInfo = "VOP3 src1 cannot be a literal constant.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (Src2Idx != -1 && isLiteralConstant(MI->getOperand(Src2Idx))) {
|
|
|
|
ErrInfo = "VOP3 src2 cannot be a literal constant.";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-11-15 22:02:28 +00:00
|
|
|
unsigned SIInstrInfo::getVALUOp(const MachineInstr &MI) {
|
2013-11-13 23:36:37 +00:00
|
|
|
switch (MI.getOpcode()) {
|
|
|
|
default: return AMDGPU::INSTRUCTION_LIST_END;
|
|
|
|
case AMDGPU::REG_SEQUENCE: return AMDGPU::REG_SEQUENCE;
|
|
|
|
case AMDGPU::COPY: return AMDGPU::COPY;
|
|
|
|
case AMDGPU::PHI: return AMDGPU::PHI;
|
2013-11-18 20:09:29 +00:00
|
|
|
case AMDGPU::S_ADD_I32: return AMDGPU::V_ADD_I32_e32;
|
|
|
|
case AMDGPU::S_ADDC_U32: return AMDGPU::V_ADDC_U32_e32;
|
|
|
|
case AMDGPU::S_SUB_I32: return AMDGPU::V_SUB_I32_e32;
|
|
|
|
case AMDGPU::S_SUBB_U32: return AMDGPU::V_SUBB_U32_e32;
|
2013-11-13 23:36:37 +00:00
|
|
|
case AMDGPU::S_ASHR_I32: return AMDGPU::V_ASHR_I32_e32;
|
|
|
|
case AMDGPU::S_ASHR_I64: return AMDGPU::V_ASHR_I64;
|
|
|
|
case AMDGPU::S_LSHL_B32: return AMDGPU::V_LSHL_B32_e32;
|
|
|
|
case AMDGPU::S_LSHL_B64: return AMDGPU::V_LSHL_B64;
|
|
|
|
case AMDGPU::S_LSHR_B32: return AMDGPU::V_LSHR_B32_e32;
|
|
|
|
case AMDGPU::S_LSHR_B64: return AMDGPU::V_LSHR_B64;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SIInstrInfo::isSALUOpSupportedOnVALU(const MachineInstr &MI) const {
|
|
|
|
return getVALUOp(MI) != AMDGPU::INSTRUCTION_LIST_END;
|
|
|
|
}
|
|
|
|
|
|
|
|
const TargetRegisterClass *SIInstrInfo::getOpRegClass(const MachineInstr &MI,
|
|
|
|
unsigned OpNo) const {
|
|
|
|
const MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo();
|
|
|
|
const MCInstrDesc &Desc = get(MI.getOpcode());
|
|
|
|
if (MI.isVariadic() || OpNo >= Desc.getNumOperands() ||
|
|
|
|
Desc.OpInfo[OpNo].RegClass == -1)
|
|
|
|
return MRI.getRegClass(MI.getOperand(OpNo).getReg());
|
|
|
|
|
|
|
|
unsigned RCID = Desc.OpInfo[OpNo].RegClass;
|
|
|
|
return RI.getRegClass(RCID);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SIInstrInfo::canReadVGPR(const MachineInstr &MI, unsigned OpNo) const {
|
|
|
|
switch (MI.getOpcode()) {
|
|
|
|
case AMDGPU::COPY:
|
|
|
|
case AMDGPU::REG_SEQUENCE:
|
|
|
|
return RI.hasVGPRs(getOpRegClass(MI, 0));
|
|
|
|
default:
|
|
|
|
return RI.hasVGPRs(getOpRegClass(MI, OpNo));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SIInstrInfo::legalizeOpWithMove(MachineInstr *MI, unsigned OpIdx) const {
|
|
|
|
MachineBasicBlock::iterator I = MI;
|
|
|
|
MachineOperand &MO = MI->getOperand(OpIdx);
|
|
|
|
MachineRegisterInfo &MRI = MI->getParent()->getParent()->getRegInfo();
|
|
|
|
unsigned RCID = get(MI->getOpcode()).OpInfo[OpIdx].RegClass;
|
|
|
|
const TargetRegisterClass *RC = RI.getRegClass(RCID);
|
|
|
|
unsigned Opcode = AMDGPU::V_MOV_B32_e32;
|
|
|
|
if (MO.isReg()) {
|
|
|
|
Opcode = AMDGPU::COPY;
|
|
|
|
} else if (RI.isSGPRClass(RC)) {
|
2013-11-14 10:08:50 +00:00
|
|
|
Opcode = AMDGPU::S_MOV_B32;
|
2013-11-13 23:36:37 +00:00
|
|
|
}
|
|
|
|
|
2013-11-18 20:09:55 +00:00
|
|
|
const TargetRegisterClass *VRC = RI.getEquivalentVGPRClass(RC);
|
|
|
|
unsigned Reg = MRI.createVirtualRegister(VRC);
|
2013-11-13 23:36:37 +00:00
|
|
|
BuildMI(*MI->getParent(), I, MI->getParent()->findDebugLoc(I), get(Opcode),
|
|
|
|
Reg).addOperand(MO);
|
|
|
|
MO.ChangeToRegister(Reg, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SIInstrInfo::legalizeOperands(MachineInstr *MI) const {
|
|
|
|
MachineRegisterInfo &MRI = MI->getParent()->getParent()->getRegInfo();
|
|
|
|
int Src0Idx = AMDGPU::getNamedOperandIdx(MI->getOpcode(),
|
|
|
|
AMDGPU::OpName::src0);
|
|
|
|
int Src1Idx = AMDGPU::getNamedOperandIdx(MI->getOpcode(),
|
|
|
|
AMDGPU::OpName::src1);
|
|
|
|
int Src2Idx = AMDGPU::getNamedOperandIdx(MI->getOpcode(),
|
|
|
|
AMDGPU::OpName::src2);
|
|
|
|
|
|
|
|
// Legalize VOP2
|
|
|
|
if (isVOP2(MI->getOpcode()) && Src1Idx != -1) {
|
2013-11-18 20:09:50 +00:00
|
|
|
MachineOperand &Src0 = MI->getOperand(Src0Idx);
|
2013-11-13 23:36:37 +00:00
|
|
|
MachineOperand &Src1 = MI->getOperand(Src1Idx);
|
2013-11-14 08:06:38 +00:00
|
|
|
|
2013-11-18 20:09:50 +00:00
|
|
|
// If the instruction implicitly reads VCC, we can't have any SGPR operands,
|
|
|
|
// so move any.
|
|
|
|
bool ReadsVCC = MI->readsRegister(AMDGPU::VCC, &RI);
|
|
|
|
if (ReadsVCC && Src0.isReg() &&
|
|
|
|
RI.isSGPRClass(MRI.getRegClass(Src0.getReg()))) {
|
|
|
|
legalizeOpWithMove(MI, Src0Idx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ReadsVCC && Src1.isReg() &&
|
|
|
|
RI.isSGPRClass(MRI.getRegClass(Src1.getReg()))) {
|
|
|
|
legalizeOpWithMove(MI, Src1Idx);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-14 08:06:38 +00:00
|
|
|
// Legalize VOP2 instructions where src1 is not a VGPR. An SGPR input must
|
|
|
|
// be the first operand, and there can only be one.
|
2013-11-13 23:36:37 +00:00
|
|
|
if (Src1.isImm() || Src1.isFPImm() ||
|
|
|
|
(Src1.isReg() && RI.isSGPRClass(MRI.getRegClass(Src1.getReg())))) {
|
|
|
|
if (MI->isCommutable()) {
|
|
|
|
if (commuteInstruction(MI))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
legalizeOpWithMove(MI, Src1Idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-18 20:09:50 +00:00
|
|
|
// XXX - Do any VOP3 instructions read VCC?
|
2013-11-13 23:36:37 +00:00
|
|
|
// Legalize VOP3
|
|
|
|
if (isVOP3(MI->getOpcode())) {
|
|
|
|
int VOP3Idx[3] = {Src0Idx, Src1Idx, Src2Idx};
|
|
|
|
unsigned SGPRReg = AMDGPU::NoRegister;
|
|
|
|
for (unsigned i = 0; i < 3; ++i) {
|
|
|
|
int Idx = VOP3Idx[i];
|
|
|
|
if (Idx == -1)
|
|
|
|
continue;
|
|
|
|
MachineOperand &MO = MI->getOperand(Idx);
|
|
|
|
|
|
|
|
if (MO.isReg()) {
|
|
|
|
if (!RI.isSGPRClass(MRI.getRegClass(MO.getReg())))
|
|
|
|
continue; // VGPRs are legal
|
|
|
|
|
2013-11-18 20:09:21 +00:00
|
|
|
assert(MO.getReg() != AMDGPU::SCC && "SCC operand to VOP3 instruction");
|
|
|
|
|
2013-11-13 23:36:37 +00:00
|
|
|
if (SGPRReg == AMDGPU::NoRegister || SGPRReg == MO.getReg()) {
|
|
|
|
SGPRReg = MO.getReg();
|
|
|
|
// We can use one SGPR in each VOP3 instruction.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else if (!isLiteralConstant(MO)) {
|
|
|
|
// If it is not a register and not a literal constant, then it must be
|
|
|
|
// an inline constant which is always legal.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// If we make it this far, then the operand is not legal and we must
|
|
|
|
// legalize it.
|
|
|
|
legalizeOpWithMove(MI, Idx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Legalize REG_SEQUENCE
|
|
|
|
// The register class of the operands much be the same type as the register
|
|
|
|
// class of the output.
|
|
|
|
if (MI->getOpcode() == AMDGPU::REG_SEQUENCE) {
|
|
|
|
const TargetRegisterClass *RC = NULL, *SRC = NULL, *VRC = NULL;
|
|
|
|
for (unsigned i = 1, e = MI->getNumOperands(); i != e; i+=2) {
|
|
|
|
if (!MI->getOperand(i).isReg() ||
|
|
|
|
!TargetRegisterInfo::isVirtualRegister(MI->getOperand(i).getReg()))
|
|
|
|
continue;
|
|
|
|
const TargetRegisterClass *OpRC =
|
|
|
|
MRI.getRegClass(MI->getOperand(i).getReg());
|
|
|
|
if (RI.hasVGPRs(OpRC)) {
|
|
|
|
VRC = OpRC;
|
|
|
|
} else {
|
|
|
|
SRC = OpRC;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// If any of the operands are VGPR registers, then they all most be
|
|
|
|
// otherwise we will create illegal VGPR->SGPR copies when legalizing
|
|
|
|
// them.
|
|
|
|
if (VRC || !RI.isSGPRClass(getOpRegClass(*MI, 0))) {
|
|
|
|
if (!VRC) {
|
|
|
|
assert(SRC);
|
|
|
|
VRC = RI.getEquivalentVGPRClass(SRC);
|
|
|
|
}
|
|
|
|
RC = VRC;
|
|
|
|
} else {
|
|
|
|
RC = SRC;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update all the operands so they have the same type.
|
|
|
|
for (unsigned i = 1, e = MI->getNumOperands(); i != e; i+=2) {
|
|
|
|
if (!MI->getOperand(i).isReg() ||
|
|
|
|
!TargetRegisterInfo::isVirtualRegister(MI->getOperand(i).getReg()))
|
|
|
|
continue;
|
|
|
|
unsigned DstReg = MRI.createVirtualRegister(RC);
|
|
|
|
BuildMI(*MI->getParent(), MI, MI->getDebugLoc(),
|
|
|
|
get(AMDGPU::COPY), DstReg)
|
|
|
|
.addOperand(MI->getOperand(i));
|
|
|
|
MI->getOperand(i).setReg(DstReg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void SIInstrInfo::moveToVALU(MachineInstr &TopInst) const {
|
|
|
|
SmallVector<MachineInstr *, 128> Worklist;
|
|
|
|
Worklist.push_back(&TopInst);
|
|
|
|
|
|
|
|
while (!Worklist.empty()) {
|
|
|
|
MachineInstr *Inst = Worklist.pop_back_val();
|
|
|
|
unsigned NewOpcode = getVALUOp(*Inst);
|
|
|
|
if (NewOpcode == AMDGPU::INSTRUCTION_LIST_END)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
MachineRegisterInfo &MRI = Inst->getParent()->getParent()->getRegInfo();
|
|
|
|
|
|
|
|
// Use the new VALU Opcode.
|
|
|
|
const MCInstrDesc &NewDesc = get(NewOpcode);
|
|
|
|
Inst->setDesc(NewDesc);
|
|
|
|
|
2013-11-18 20:09:21 +00:00
|
|
|
// Remove any references to SCC. Vector instructions can't read from it, and
|
|
|
|
// We're just about to add the implicit use / defs of VCC, and we don't want
|
|
|
|
// both.
|
|
|
|
for (unsigned i = Inst->getNumOperands() - 1; i > 0; --i) {
|
|
|
|
MachineOperand &Op = Inst->getOperand(i);
|
|
|
|
if (Op.isReg() && Op.getReg() == AMDGPU::SCC)
|
|
|
|
Inst->RemoveOperand(i);
|
|
|
|
}
|
|
|
|
|
2013-11-13 23:36:37 +00:00
|
|
|
// Add the implict and explicit register definitions.
|
|
|
|
if (NewDesc.ImplicitUses) {
|
|
|
|
for (unsigned i = 0; NewDesc.ImplicitUses[i]; ++i) {
|
2013-11-18 20:09:21 +00:00
|
|
|
unsigned Reg = NewDesc.ImplicitUses[i];
|
|
|
|
Inst->addOperand(MachineOperand::CreateReg(Reg, false, true));
|
2013-11-13 23:36:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NewDesc.ImplicitDefs) {
|
|
|
|
for (unsigned i = 0; NewDesc.ImplicitDefs[i]; ++i) {
|
2013-11-18 20:09:21 +00:00
|
|
|
unsigned Reg = NewDesc.ImplicitDefs[i];
|
|
|
|
Inst->addOperand(MachineOperand::CreateReg(Reg, true, true));
|
2013-11-13 23:36:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
legalizeOperands(Inst);
|
|
|
|
|
|
|
|
// Update the destination register class.
|
|
|
|
const TargetRegisterClass *NewDstRC = getOpRegClass(*Inst, 0);
|
|
|
|
|
|
|
|
switch (Inst->getOpcode()) {
|
|
|
|
// For target instructions, getOpRegClass just returns the virtual
|
|
|
|
// register class associated with the operand, so we need to find an
|
|
|
|
// equivalent VGPR register class in order to move the instruction to the
|
|
|
|
// VALU.
|
|
|
|
case AMDGPU::COPY:
|
|
|
|
case AMDGPU::PHI:
|
|
|
|
case AMDGPU::REG_SEQUENCE:
|
|
|
|
if (RI.hasVGPRs(NewDstRC))
|
|
|
|
continue;
|
|
|
|
NewDstRC = RI.getEquivalentVGPRClass(NewDstRC);
|
|
|
|
if (!NewDstRC)
|
|
|
|
continue;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned DstReg = Inst->getOperand(0).getReg();
|
|
|
|
unsigned NewDstReg = MRI.createVirtualRegister(NewDstRC);
|
|
|
|
MRI.replaceRegWith(DstReg, NewDstReg);
|
|
|
|
|
|
|
|
for (MachineRegisterInfo::use_iterator I = MRI.use_begin(NewDstReg),
|
|
|
|
E = MRI.use_end(); I != E; ++I) {
|
|
|
|
MachineInstr &UseMI = *I;
|
|
|
|
if (!canReadVGPR(UseMI, I.getOperandNo())) {
|
|
|
|
Worklist.push_back(&UseMI);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-06 17:32:29 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Indirect addressing callbacks
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
unsigned SIInstrInfo::calculateIndirectAddress(unsigned RegIndex,
|
|
|
|
unsigned Channel) const {
|
|
|
|
assert(Channel == 0);
|
|
|
|
return RegIndex;
|
|
|
|
}
|
|
|
|
|
2013-10-22 18:19:10 +00:00
|
|
|
const TargetRegisterClass *SIInstrInfo::getIndirectAddrRegClass() const {
|
2013-11-13 23:36:50 +00:00
|
|
|
return &AMDGPU::VReg_32RegClass;
|
2013-02-06 17:32:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MachineInstrBuilder SIInstrInfo::buildIndirectWrite(
|
|
|
|
MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned ValueReg,
|
|
|
|
unsigned Address, unsigned OffsetReg) const {
|
2013-11-13 23:36:50 +00:00
|
|
|
const DebugLoc &DL = MBB->findDebugLoc(I);
|
|
|
|
unsigned IndirectBaseReg = AMDGPU::VReg_32RegClass.getRegister(
|
|
|
|
getIndirectIndexBegin(*MBB->getParent()));
|
|
|
|
|
|
|
|
return BuildMI(*MBB, I, DL, get(AMDGPU::SI_INDIRECT_DST_V1))
|
|
|
|
.addReg(IndirectBaseReg, RegState::Define)
|
|
|
|
.addOperand(I->getOperand(0))
|
|
|
|
.addReg(IndirectBaseReg)
|
|
|
|
.addReg(OffsetReg)
|
|
|
|
.addImm(0)
|
|
|
|
.addReg(ValueReg);
|
2013-02-06 17:32:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MachineInstrBuilder SIInstrInfo::buildIndirectRead(
|
|
|
|
MachineBasicBlock *MBB,
|
|
|
|
MachineBasicBlock::iterator I,
|
|
|
|
unsigned ValueReg,
|
|
|
|
unsigned Address, unsigned OffsetReg) const {
|
2013-11-13 23:36:50 +00:00
|
|
|
const DebugLoc &DL = MBB->findDebugLoc(I);
|
|
|
|
unsigned IndirectBaseReg = AMDGPU::VReg_32RegClass.getRegister(
|
|
|
|
getIndirectIndexBegin(*MBB->getParent()));
|
|
|
|
|
|
|
|
return BuildMI(*MBB, I, DL, get(AMDGPU::SI_INDIRECT_SRC))
|
|
|
|
.addOperand(I->getOperand(0))
|
|
|
|
.addOperand(I->getOperand(1))
|
|
|
|
.addReg(IndirectBaseReg)
|
|
|
|
.addReg(OffsetReg)
|
|
|
|
.addImm(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void SIInstrInfo::reserveIndirectRegisters(BitVector &Reserved,
|
|
|
|
const MachineFunction &MF) const {
|
|
|
|
int End = getIndirectIndexEnd(MF);
|
|
|
|
int Begin = getIndirectIndexBegin(MF);
|
|
|
|
|
|
|
|
if (End == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
for (int Index = Begin; Index <= End; ++Index)
|
|
|
|
Reserved.set(AMDGPU::VReg_32RegClass.getRegister(Index));
|
|
|
|
|
2013-11-13 23:58:51 +00:00
|
|
|
for (int Index = std::max(0, Begin - 1); Index <= End; ++Index)
|
2013-11-13 23:36:50 +00:00
|
|
|
Reserved.set(AMDGPU::VReg_64RegClass.getRegister(Index));
|
|
|
|
|
2013-11-13 23:58:51 +00:00
|
|
|
for (int Index = std::max(0, Begin - 2); Index <= End; ++Index)
|
2013-11-13 23:36:50 +00:00
|
|
|
Reserved.set(AMDGPU::VReg_96RegClass.getRegister(Index));
|
|
|
|
|
2013-11-13 23:58:51 +00:00
|
|
|
for (int Index = std::max(0, Begin - 3); Index <= End; ++Index)
|
2013-11-13 23:36:50 +00:00
|
|
|
Reserved.set(AMDGPU::VReg_128RegClass.getRegister(Index));
|
|
|
|
|
2013-11-13 23:58:51 +00:00
|
|
|
for (int Index = std::max(0, Begin - 7); Index <= End; ++Index)
|
2013-11-13 23:36:50 +00:00
|
|
|
Reserved.set(AMDGPU::VReg_256RegClass.getRegister(Index));
|
|
|
|
|
2013-11-13 23:58:51 +00:00
|
|
|
for (int Index = std::max(0, Begin - 15); Index <= End; ++Index)
|
2013-11-13 23:36:50 +00:00
|
|
|
Reserved.set(AMDGPU::VReg_512RegClass.getRegister(Index));
|
2013-02-06 17:32:29 +00:00
|
|
|
}
|