23#define GET_INSTRINFO_CTOR_DTOR
24#include "NVPTXGenInstrInfo.inc"
27void NVPTXInstrInfo::anchor() {}
36 bool RenamableDest,
bool RenamableSrc)
const {
45 if (DestRC == &NVPTX::B1RegClass)
47 else if (DestRC == &NVPTX::B16RegClass)
48 Op = NVPTX::MOV_B16_r;
49 else if (DestRC == &NVPTX::B32RegClass)
50 Op = NVPTX::MOV_B32_r;
51 else if (DestRC == &NVPTX::B64RegClass)
52 Op = NVPTX::MOV_B64_r;
53 else if (DestRC == &NVPTX::B128RegClass)
54 Op = NVPTX::MOV_B128_r;
89 bool AllowModify)
const {
92 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I))
99 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
100 if (LastInst.
getOpcode() == NVPTX::GOTO) {
103 }
else if (LastInst.
getOpcode() == NVPTX::CBranch) {
118 if (
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
122 if (SecondLastInst.
getOpcode() == NVPTX::CBranch &&
133 if (SecondLastInst.
getOpcode() == NVPTX::GOTO &&
138 I->eraseFromParent();
147 int *BytesRemoved)
const {
148 assert(!BytesRemoved &&
"code size not handled");
150 if (
I ==
MBB.begin())
153 if (
I->getOpcode() != NVPTX::GOTO &&
I->getOpcode() != NVPTX::CBranch)
157 I->eraseFromParent();
161 if (
I ==
MBB.begin())
164 if (
I->getOpcode() != NVPTX::CBranch)
168 I->eraseFromParent();
177 int *BytesAdded)
const {
178 assert(!BytesAdded &&
"code size not handled");
181 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
183 "NVPTX branch conditions have two components!");
205 assert(
Cond.size() == 2 &&
"Invalid NVPTX branch condition!");
226 switch (
MI.getOpcode()) {
227 case NVPTX::SETP_i16rr:
228 case NVPTX::SETP_i16ri:
229 case NVPTX::SETP_i16ir:
230 case NVPTX::SETP_i32rr:
231 case NVPTX::SETP_i32ri:
232 case NVPTX::SETP_i32ir:
233 case NVPTX::SETP_i64rr:
234 case NVPTX::SETP_i64ri:
235 case NVPTX::SETP_i64ir:
243 switch (
MI.getOpcode()) {
244 case NVPTX::SETP_bf16rr:
245 case NVPTX::SETP_f16rr:
246 case NVPTX::SETP_f32rr:
247 case NVPTX::SETP_f32ri:
248 case NVPTX::SETP_f32ir:
249 case NVPTX::SETP_f64rr:
250 case NVPTX::SETP_f64ri:
251 case NVPTX::SETP_f64ir:
333 case NVPTX::SELP_b16ri:
334 return NVPTX::SELP_b16ir;
335 case NVPTX::SELP_b16ir:
336 return NVPTX::SELP_b16ri;
337 case NVPTX::SELP_b32ri:
338 return NVPTX::SELP_b32ir;
339 case NVPTX::SELP_b32ir:
340 return NVPTX::SELP_b32ri;
341 case NVPTX::SELP_b64ri:
342 return NVPTX::SELP_b64ir;
343 case NVPTX::SELP_b64ir:
344 return NVPTX::SELP_b64ri;
345 case NVPTX::SELP_f16ri:
346 return NVPTX::SELP_f16ir;
347 case NVPTX::SELP_f16ir:
348 return NVPTX::SELP_f16ri;
349 case NVPTX::SELP_f32ri:
350 return NVPTX::SELP_f32ir;
351 case NVPTX::SELP_f32ir:
352 return NVPTX::SELP_f32ri;
353 case NVPTX::SELP_f64ri:
354 return NVPTX::SELP_f64ir;
355 case NVPTX::SELP_f64ir:
356 return NVPTX::SELP_f64ri;
357 case NVPTX::SELP_bf16ri:
358 return NVPTX::SELP_bf16ir;
359 case NVPTX::SELP_bf16ir:
360 return NVPTX::SELP_bf16ri;
361 case NVPTX::SELP_b16rr:
362 case NVPTX::SELP_b16ii:
363 case NVPTX::SELP_b32rr:
364 case NVPTX::SELP_b32ii:
365 case NVPTX::SELP_b64rr:
366 case NVPTX::SELP_b64ii:
367 case NVPTX::SELP_f16rr:
368 case NVPTX::SELP_f16ii:
369 case NVPTX::SELP_f32rr:
370 case NVPTX::SELP_f32ii:
371 case NVPTX::SELP_f64rr:
372 case NVPTX::SELP_f64ii:
373 case NVPTX::SELP_bf16rr:
374 case NVPTX::SELP_bf16ii:
385 MI.insert(
MI.operands_begin() + 2, {Src0});
390 unsigned &SrcOpIdx2)
const {
392 return fixCommutedOpIndices(SrcOpIdx1, SrcOpIdx2, 1, 2);
399 unsigned OpIdx2)
const {
400 assert(!NewMI &&
"this should never be used");
412 if (
UseMI.isConditionalBranch())
414 else if (
UseMI.isSelect())
423 return !invertPredicateBranchInstr(*
MBB);
430 invertPredicateBranchInstr(*
MBB);
MachineInstrBuilder & UseMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const HexagonInstrInfo * TII
static bool isIntegerSetp(const MachineInstr &MI)
static int64_t invertScalarFloatCmpMode(int64_t Mode)
static void invertSelpInstr(MachineInstr &MI, const NVPTXInstrInfo &TII)
static void invertScalarCompareInstr(MachineInstr &MI)
static bool isScalarFloatSetp(const MachineInstr &MI)
static unsigned getInvertedSelpOpcode(unsigned Opcode)
static int64_t invertIntegerCmpMode(int64_t Mode)
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
Represent a constant reference to an array (0 or more elements consecutively in memory),...
MachineInstrBundleIterator< MachineInstr > iterator
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
void setImm(int64_t immVal)
MachineBasicBlock * getMBB() const
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
iterator_range< use_instr_nodbg_iterator > use_nodbg_instructions(Register Reg) const
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
NVPTXInstrInfo(const NVPTXSubtarget &STI)
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
analyzeBranch - Analyze the branching code at the end of MBB, returning true if it cannot be understo...
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const override
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
virtual bool findCommutedOpIndices(const MachineInstr &MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const
Returns true iff the routine could find two commutable operands in the given machine instruction.
virtual MachineInstr * commuteInstructionImpl(MachineInstr &MI, bool NewMI, unsigned OpIdx1, unsigned OpIdx2) const
This method commutes the operands of the given machine instruction MI.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
constexpr RegState getKillRegState(bool B)
testing::Matcher< const detail::ErrorHolder & > Failed()
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
DWARFExpression::Operation Op
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
MCRegisterClass TargetRegisterClass