mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[AMDGPU] Choose VMCNT, EXPCNT, LGKMCNT masks and shifts based on the isa version
Differential Revision: https://reviews.llvm.org/D24973 llvm-svn: 282877
This commit is contained in:
parent
bbe6c88c7e
commit
0d3cafde5b
@ -41,6 +41,7 @@
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::AMDGPU;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -2008,15 +2009,16 @@ bool AMDGPUAsmParser::parseCnt(int64_t &IntVal) {
|
||||
int CntShift;
|
||||
int CntMask;
|
||||
|
||||
IsaVersion IV = getIsaVersion(getSTI().getFeatureBits());
|
||||
if (CntName == "vmcnt") {
|
||||
CntMask = 0xf;
|
||||
CntShift = 0;
|
||||
CntMask = getVmcntMask(IV);
|
||||
CntShift = getVmcntShift(IV);
|
||||
} else if (CntName == "expcnt") {
|
||||
CntMask = 0x7;
|
||||
CntShift = 4;
|
||||
CntMask = getExpcntMask(IV);
|
||||
CntShift = getExpcntShift(IV);
|
||||
} else if (CntName == "lgkmcnt") {
|
||||
CntMask = 0xf;
|
||||
CntShift = 8;
|
||||
CntMask = getLgkmcntMask(IV);
|
||||
CntShift = getLgkmcntShift(IV);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
@ -9,19 +9,22 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "AMDGPUInstPrinter.h"
|
||||
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
||||
#include "SIDefines.h"
|
||||
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
||||
#include "Utils/AMDGPUAsmUtils.h"
|
||||
#include "Utils/AMDGPUBaseInfo.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCInstrInfo.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/MC/MCSubtargetInfo.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::AMDGPU;
|
||||
|
||||
void AMDGPUInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
|
||||
StringRef Annot, const MCSubtargetInfo &STI) {
|
||||
@ -864,10 +867,12 @@ void AMDGPUInstPrinter::printSendMsg(const MCInst *MI, unsigned OpNo,
|
||||
void AMDGPUInstPrinter::printWaitFlag(const MCInst *MI, unsigned OpNo,
|
||||
const MCSubtargetInfo &STI,
|
||||
raw_ostream &O) {
|
||||
IsaVersion IV = getIsaVersion(STI.getFeatureBits());
|
||||
|
||||
unsigned SImm16 = MI->getOperand(OpNo).getImm();
|
||||
unsigned Vmcnt = SImm16 & 0xF;
|
||||
unsigned Expcnt = (SImm16 >> 4) & 0x7;
|
||||
unsigned Lgkmcnt = (SImm16 >> 8) & 0xF;
|
||||
unsigned Vmcnt = (SImm16 >> getVmcntShift(IV)) & getVmcntMask(IV);
|
||||
unsigned Expcnt = (SImm16 >> getExpcntShift(IV)) & getExpcntMask(IV);
|
||||
unsigned Lgkmcnt = (SImm16 >> getLgkmcntShift(IV)) & getLgkmcntMask(IV);
|
||||
|
||||
bool NeedSpace = false;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "SIDefines.h"
|
||||
#include "SIInstrInfo.h"
|
||||
#include "SIMachineFunctionInfo.h"
|
||||
#include "Utils/AMDGPUBaseInfo.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
@ -29,6 +30,7 @@
|
||||
#define DEBUG_TYPE "si-insert-waits"
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::AMDGPU;
|
||||
|
||||
namespace {
|
||||
|
||||
@ -59,6 +61,7 @@ private:
|
||||
const SIInstrInfo *TII;
|
||||
const SIRegisterInfo *TRI;
|
||||
const MachineRegisterInfo *MRI;
|
||||
IsaVersion IV;
|
||||
|
||||
/// \brief Constant hardware limits
|
||||
static const Counters WaitCounts;
|
||||
@ -410,9 +413,9 @@ bool SIInsertWaits::insertWait(MachineBasicBlock &MBB,
|
||||
|
||||
// Build the wait instruction
|
||||
BuildMI(MBB, I, DebugLoc(), TII->get(AMDGPU::S_WAITCNT))
|
||||
.addImm((Counts.Named.VM & 0xF) |
|
||||
((Counts.Named.EXP & 0x7) << 4) |
|
||||
((Counts.Named.LGKM & 0xF) << 8));
|
||||
.addImm(((Counts.Named.VM & getVmcntMask(IV)) << getVmcntShift(IV)) |
|
||||
((Counts.Named.EXP & getExpcntMask(IV)) << getExpcntShift(IV)) |
|
||||
((Counts.Named.LGKM & getLgkmcntMask(IV)) << getLgkmcntShift(IV)));
|
||||
|
||||
LastOpcodeType = OTHER;
|
||||
LastInstWritesM0 = false;
|
||||
@ -440,9 +443,9 @@ void SIInsertWaits::handleExistingWait(MachineBasicBlock::iterator I) {
|
||||
unsigned Imm = I->getOperand(0).getImm();
|
||||
Counters Counts, WaitOn;
|
||||
|
||||
Counts.Named.VM = Imm & 0xF;
|
||||
Counts.Named.EXP = (Imm >> 4) & 0x7;
|
||||
Counts.Named.LGKM = (Imm >> 8) & 0xF;
|
||||
Counts.Named.VM = (Imm >> getVmcntShift(IV)) & getVmcntMask(IV);
|
||||
Counts.Named.EXP = (Imm >> getExpcntShift(IV)) & getExpcntMask(IV);
|
||||
Counts.Named.LGKM = (Imm >> getLgkmcntShift(IV)) & getLgkmcntMask(IV);
|
||||
|
||||
for (unsigned i = 0; i < 3; ++i) {
|
||||
if (Counts.Array[i] <= LastIssued.Array[i])
|
||||
@ -518,6 +521,7 @@ bool SIInsertWaits::runOnMachineFunction(MachineFunction &MF) {
|
||||
TII = ST->getInstrInfo();
|
||||
TRI = &TII->getRegisterInfo();
|
||||
MRI = &MF.getRegInfo();
|
||||
IV = getIsaVersion(ST->getFeatureBits());
|
||||
|
||||
WaitedOn = ZeroCounts;
|
||||
DelayedWaitOn = ZeroCounts;
|
||||
|
@ -152,6 +152,30 @@ std::pair<int, int> getIntegerPairAttribute(const Function &F,
|
||||
return Ints;
|
||||
}
|
||||
|
||||
unsigned getVmcntMask(IsaVersion Version) {
|
||||
return 0xf;
|
||||
}
|
||||
|
||||
unsigned getVmcntShift(IsaVersion Version) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned getExpcntMask(IsaVersion Version) {
|
||||
return 0x7;
|
||||
}
|
||||
|
||||
unsigned getExpcntShift(IsaVersion Version) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
unsigned getLgkmcntMask(IsaVersion Version) {
|
||||
return 0xf;
|
||||
}
|
||||
|
||||
unsigned getLgkmcntShift(IsaVersion Version) {
|
||||
return 8;
|
||||
}
|
||||
|
||||
unsigned getInitialPSInputAddr(const Function &F) {
|
||||
return getIntegerAttribute(F, "InitialPSInputAddr", 0);
|
||||
}
|
||||
|
@ -69,6 +69,24 @@ std::pair<int, int> getIntegerPairAttribute(const Function &F,
|
||||
std::pair<int, int> Default,
|
||||
bool OnlyFirstRequired = false);
|
||||
|
||||
/// \returns VMCNT bit mask for given isa \p Version.
|
||||
unsigned getVmcntMask(IsaVersion Version);
|
||||
|
||||
/// \returns VMCNT bit shift for given isa \p Version.
|
||||
unsigned getVmcntShift(IsaVersion Version);
|
||||
|
||||
/// \returns EXPCNT bit mask for given isa \p Version.
|
||||
unsigned getExpcntMask(IsaVersion Version);
|
||||
|
||||
/// \returns EXPCNT bit shift for given isa \p Version.
|
||||
unsigned getExpcntShift(IsaVersion Version);
|
||||
|
||||
/// \returns LGKMCNT bit mask for given isa \p Version.
|
||||
unsigned getLgkmcntMask(IsaVersion Version);
|
||||
|
||||
/// \returns LGKMCNT bit shift for given isa \p Version.
|
||||
unsigned getLgkmcntShift(IsaVersion Version);
|
||||
|
||||
unsigned getInitialPSInputAddr(const Function &F);
|
||||
|
||||
bool isShader(CallingConv::ID cc);
|
||||
|
Loading…
Reference in New Issue
Block a user