24#define GET_INSTRINFO_CTOR_DTOR
25#include "PISAGenInstrInfo.inc"
40 switch (
MI.getOpcode()) {
41 case PISA::functionParameter_i8:
42 case PISA::functionParameter_i16:
43 case PISA::functionParameter_i32:
44 case PISA::functionParameter_i64:
45 case PISA::functionParameter_v2i8:
46 case PISA::functionParameter_v3i8:
47 case PISA::functionParameter_v4i8:
48 case PISA::functionParameter_v2i16:
49 case PISA::functionParameter_v3i16:
50 case PISA::functionParameter_v4i16:
51 case PISA::functionParameter_v2i32:
52 case PISA::functionParameter_v3i32:
53 case PISA::functionParameter_v4i32:
54 case PISA::functionParameter_v5i32:
55 case PISA::functionParameter_v6i32:
56 case PISA::functionParameter_v7i32:
57 case PISA::functionParameter_v8i32:
58 case PISA::functionParameter_v16i32:
59 case PISA::functionParameter_v32i32:
60 case PISA::functionParameter_v64i32:
61 case PISA::functionParameter_v2i64:
62 case PISA::functionParameter_v3i64:
63 case PISA::functionParameter_v4i64:
73 int16_t Idx = getNamedOperandIdx(
MI.getOpcode(), Name);
74 assert(Idx >= 0 &&
"name not present!");
76 return MI.getOperand(Idx);
85 Reg.isPhysical() ? RI.getMinimalPhysRegClass(Reg) :
MRI.getRegClass(Reg);
89 return RI.getSubRegisterClass(SuperRC, SubReg);
102 if (
I ==
MBB.end() || !isUnpredicatedTerminator(*
I))
109 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
111 if (LastInst->
getOpcode() != PISA::gotolabel)
117 if (LastInst->
getOpcode() != PISA::predgoto)
135 (
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I)))
138 if (SecondLastInst->
getOpcode() != PISA::predgoto ||
139 LastInst->
getOpcode() != PISA::gotolabel)
154 int *BytesRemoved)
const {
155 assert(!BytesRemoved &&
"not supported!");
159 assert(
MI.isBranch() &&
"not a branch?");
160 MI.eraseFromParent();
172 assert(!BytesAdded &&
"not supported!");
173 assert(
TBB &&
"Should have at least one branch!");
179 assert(
Cond.size() == 2 &&
"wrong number of args?");
189 assert(
Cond.size() == 2 &&
"wrong number of args?");
200 uint64_t DoNegate =
Cond[0].getImm();
201 Cond[0].setImm(!DoNegate);
222 MI.eraseFromParent();
233 if (
MI.isConvergent())
242 bool RenamableDest,
bool RenamableSrc)
const {
244 assert(
I->isCopy() &&
"Copy instruction is expected");
254 const unsigned DstSubNumElts = RI.getNumEltsFromRegClass(DstSubRC);
255 const unsigned DstSubEltSize = RI.getBitSizeFromRegClass(DstSubRC);
256 const unsigned SrcSubNumElts = RI.getNumEltsFromRegClass(SrcSubRC);
257 const unsigned SrcSubEltSize = RI.getBitSizeFromRegClass(SrcSubRC);
258 const bool DstSubIsVector = DstSubNumElts > 1;
259 const bool SrcSubIsVector = SrcSubNumElts > 1;
260 const bool DstSubIsScalar = !DstSubIsVector;
261 const bool SrcSubIsScalar = !SrcSubIsVector;
263 if (DstSubIsVector && SrcSubIsVector) {
264 if (DstSubNumElts == 4 && DstSubEltSize == 8 && SrcSubNumElts == 2 &&
266 Op = PISA::mov_v4i8_v2i16_r;
267 else if (DstSubNumElts == 2 && DstSubEltSize == 16 && SrcSubNumElts == 4 &&
269 Op = PISA::mov_v2i16_v4i8_r;
270 else if (DstSubNumElts == 4 && DstSubEltSize == 16 && SrcSubNumElts == 2 &&
272 Op = PISA::mov_v4i16_v2i32_r;
273 else if (DstSubNumElts == 2 && DstSubEltSize == 32 && SrcSubNumElts == 4 &&
275 Op = PISA::mov_v2i32_v4i16_r;
276 else if (DstSubNumElts == 4 && DstSubEltSize == 32 && SrcSubNumElts == 2 &&
278 Op = PISA::mov_v4i32_v2i64_r;
279 else if (DstSubNumElts == 2 && DstSubEltSize == 64 && SrcSubNumElts == 4 &&
281 Op = PISA::mov_v2i64_v4i32_r;
283 assert(DstSubNumElts == SrcSubNumElts &&
"num elts mismatch!");
284 if (DstSubNumElts == 2) {
285 switch (DstSubEltSize) {
287 Op = PISA::mov_v2i8_r;
290 Op = PISA::mov_v2i16_r;
293 Op = PISA::mov_v2i32_r;
296 Op = PISA::mov_v2i64_r;
301 }
else if (DstSubNumElts == 3) {
302 switch (DstSubEltSize) {
304 Op = PISA::mov_v3i8_r;
307 Op = PISA::mov_v3i16_r;
312 }
else if (DstSubNumElts == 4) {
313 switch (DstSubEltSize) {
315 Op = PISA::mov_v4i8_r;
318 Op = PISA::mov_v4i16_r;
321 Op = PISA::mov_v4i32_r;
330 }
else if (DstSubIsVector && SrcSubIsScalar) {
331 if (DstSubNumElts == 2 && DstSubEltSize == 8 && SrcSubEltSize == 16)
332 Op = PISA::mov_v2i8_i16_r;
333 else if (DstSubNumElts == 4 && DstSubEltSize == 8 && SrcSubEltSize == 32)
334 Op = PISA::mov_v4i8_i32_r;
335 else if (DstSubNumElts == 2 && DstSubEltSize == 16 && SrcSubEltSize == 32)
336 Op = PISA::mov_v2i16_i32_r;
337 else if (DstSubNumElts == 4 && DstSubEltSize == 16 && SrcSubEltSize == 64)
338 Op = PISA::mov_v4i16_i64_r;
339 else if (DstSubNumElts == 2 && DstSubEltSize == 32 && SrcSubEltSize == 64)
340 Op = PISA::mov_v2i32_i64_r;
341 else if (DstSubNumElts == 4 && DstSubEltSize == 32 && SrcSubEltSize == 128)
342 Op = PISA::mov_v4i32_i128_r;
343 else if (DstSubNumElts == 2 && DstSubEltSize == 64 && SrcSubEltSize == 128)
344 Op = PISA::mov_v2i64_i128_r;
347 }
else if (DstSubIsScalar && SrcSubIsVector) {
348 if (DstSubEltSize == 16 && SrcSubNumElts == 2 && SrcSubEltSize == 8)
349 Op = PISA::mov_i16_v2i8_r;
350 else if (DstSubEltSize == 32 && SrcSubNumElts == 2 && SrcSubEltSize == 16)
351 Op = PISA::mov_i32_v2i16_r;
352 else if (DstSubEltSize == 32 && SrcSubNumElts == 4 && SrcSubEltSize == 8)
353 Op = PISA::mov_i32_v4i8_r;
354 else if (DstSubEltSize == 64 && SrcSubNumElts == 2 && SrcSubEltSize == 32)
355 Op = PISA::mov_i64_v2i32_r;
356 else if (DstSubEltSize == 64 && SrcSubNumElts == 4 && SrcSubEltSize == 16)
357 Op = PISA::mov_i64_v4i16_r;
358 else if (DstSubEltSize == 128 && SrcSubNumElts == 2 && SrcSubEltSize == 64)
359 Op = PISA::mov_i128_v2i64_r;
360 else if (DstSubEltSize == 128 && SrcSubNumElts == 4 && SrcSubEltSize == 32)
361 Op = PISA::mov_i128_v4i32_r;
364 }
else if (DstSubIsScalar && SrcSubIsScalar) {
369 if ((DstSubEltSize == 1) && (SrcSubEltSize == 1)) {
372 Register TmpReg =
MRI.createGenericVirtualRegister(I16);
373 MRI.setRegClass(TmpReg,
TRI->getRegClassFromLLT(I16));
374 Op = PISA::sel_16_iip;
380 Op = PISA::ucmp_ne_16b_pri;
387 if (DstSubEltSize == 1) {
390 if (SrcSubEltSize == 8) {
391 TmpReg =
MRI.createGenericVirtualRegister(I16);
392 MRI.setRegClass(TmpReg,
TRI->getRegClassFromLLT(I16));
393 Op = PISA::zext_16b_8b_r;
396 switch (SrcSubEltSize) {
401 Op = PISA::ucmp_ne_16b_pri;
404 Op = PISA::ucmp_ne_32b_pri;
407 Op = PISA::ucmp_ne_64b_pri;
416 if (SrcSubEltSize == 1) {
419 if (DstSubEltSize == 8) {
420 TmpReg =
MRI.createGenericVirtualRegister(I16);
421 MRI.setRegClass(TmpReg,
TRI->getRegClassFromLLT(I16));
423 switch (DstSubEltSize) {
428 Op = PISA::sel_16_iip;
431 Op = PISA::sel_32_iip;
434 Op = PISA::sel_64_iip;
442 if (DstSubEltSize == 8) {
443 Op = PISA::trunc_8b_16b_r;
448 switch (DstSubEltSize) {
453 Op = PISA::mov_i16_r;
456 Op = PISA::mov_i32_r;
459 Op = PISA::mov_i64_r;
466 unsigned DstSubreg =
DstOp.getSubReg();
467 unsigned SrcSubreg =
SrcOp.getSubReg();
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
SmallVector< MachineOperand, 4 > Cond
This file declares the MachineIRBuilder class.
Register const TargetRegisterInfo * TRI
This file declares instruction information for the PISA target.
This file declares the PISA subtarget.
This file declares the top-level interfaces for the PISA target.
MachineRegisterInfo & MRI
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
static LLT integer(unsigned SizeInBits)
MachineInstrBundleIterator< MachineInstr > iterator
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & add(const MachineOperand &MO) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addDef(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a virtual register definition operand.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool isConditionalBranch(QueryType Type=AnyInBundle) const
Return true if this is a branch which may fall through to the next instruction or may transfer contro...
bool isUnconditionalBranch(QueryType Type=AnyInBundle) const
Return true if this is a branch which always transfers control flow to some other block.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
unsigned getSubReg() const
MachineBasicBlock * getMBB() const
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool isSafeToMove(const MachineInstr &MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const override
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
PISAInstrInfo(const PISASubtarget &STI)
bool isNoEmissionInstr(const MachineInstr &MI) const
bool expandPostRAPseudo(MachineInstr &MI) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
bool isFunctionParamInstr(const MachineInstr &MI) const
const PISARegisterInfo & getRegisterInfo() const
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const MachineOperand & getMO(const MachineInstr &MI, PISA::OpName Name)
static const TargetRegisterClass * getSubRegClass(const PISARegisterInfo &RI, MachineRegisterInfo &MRI, MachineOperand &MO)
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.
RegState
Flags to represent properties of register accesses.
@ Undef
Value of the register doesn't matter.
@ NoFlags
No Specific Flags.
constexpr RegState getKillRegState(bool B)
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
DWARFExpression::Operation Op
MCRegisterClass TargetRegisterClass