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_i16:
228 case NVPTX::SETP_i32:
229 case NVPTX::SETP_i64:
237 switch (
MI.getOpcode()) {
238 case NVPTX::SETP_bf16:
239 case NVPTX::SETP_f16:
240 case NVPTX::SETP_f32:
241 case NVPTX::SETP_f64:
323 case NVPTX::SELP_b16ri:
324 return NVPTX::SELP_b16ir;
325 case NVPTX::SELP_b16ir:
326 return NVPTX::SELP_b16ri;
327 case NVPTX::SELP_b32ri:
328 return NVPTX::SELP_b32ir;
329 case NVPTX::SELP_b32ir:
330 return NVPTX::SELP_b32ri;
331 case NVPTX::SELP_b64ri:
332 return NVPTX::SELP_b64ir;
333 case NVPTX::SELP_b64ir:
334 return NVPTX::SELP_b64ri;
335 case NVPTX::SELP_f16ri:
336 return NVPTX::SELP_f16ir;
337 case NVPTX::SELP_f16ir:
338 return NVPTX::SELP_f16ri;
339 case NVPTX::SELP_f32ri:
340 return NVPTX::SELP_f32ir;
341 case NVPTX::SELP_f32ir:
342 return NVPTX::SELP_f32ri;
343 case NVPTX::SELP_f64ri:
344 return NVPTX::SELP_f64ir;
345 case NVPTX::SELP_f64ir:
346 return NVPTX::SELP_f64ri;
347 case NVPTX::SELP_bf16ri:
348 return NVPTX::SELP_bf16ir;
349 case NVPTX::SELP_bf16ir:
350 return NVPTX::SELP_bf16ri;
351 case NVPTX::SELP_b16rr:
352 case NVPTX::SELP_b16ii:
353 case NVPTX::SELP_b32rr:
354 case NVPTX::SELP_b32ii:
355 case NVPTX::SELP_b64rr:
356 case NVPTX::SELP_b64ii:
357 case NVPTX::SELP_f16rr:
358 case NVPTX::SELP_f16ii:
359 case NVPTX::SELP_f32rr:
360 case NVPTX::SELP_f32ii:
361 case NVPTX::SELP_f64rr:
362 case NVPTX::SELP_f64ii:
363 case NVPTX::SELP_bf16rr:
364 case NVPTX::SELP_bf16ii:
375 MI.insert(
MI.operands_begin() + 2, {Src0});
380 unsigned &SrcOpIdx2)
const {
382 return fixCommutedOpIndices(SrcOpIdx1, SrcOpIdx2, 1, 2);
389 unsigned OpIdx2)
const {
390 assert(!NewMI &&
"this should never be used");
402 if (
UseMI.isConditionalBranch())
404 else if (
UseMI.isSelect())
413 return !invertPredicateBranchInstr(*
MBB);
420 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