#include "llvm/Support/MathExtras.h"
using namespace llvm;
+using namespace llvm::AMDGPU;
namespace {
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;
}
//===----------------------------------------------------------------------===//
#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) {
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;
#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"
#define DEBUG_TYPE "si-insert-waits"
using namespace llvm;
+using namespace llvm::AMDGPU;
namespace {
const SIInstrInfo *TII;
const SIRegisterInfo *TRI;
const MachineRegisterInfo *MRI;
+ IsaVersion IV;
/// \brief Constant hardware limits
static const Counters WaitCounts;
// 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;
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])
TII = ST->getInstrInfo();
TRI = &TII->getRegisterInfo();
MRI = &MF.getRegInfo();
+ IV = getIsaVersion(ST->getFeatureBits());
WaitedOn = ZeroCounts;
DelayedWaitOn = ZeroCounts;
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);
}
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);