28 using namespace Hexagon;
30 #define DEBUG_TYPE "hexagon-mccompound"
44 J4_tstbit0_fp0_jump_nt, J4_tstbit0_fp0_jump_t, J4_tstbit0_fp1_jump_nt,
45 J4_tstbit0_fp1_jump_t, J4_tstbit0_tp0_jump_nt, J4_tstbit0_tp0_jump_t,
46 J4_tstbit0_tp1_jump_nt, J4_tstbit0_tp1_jump_t};
48 J4_cmpeq_fp0_jump_nt, J4_cmpeq_fp0_jump_t, J4_cmpeq_fp1_jump_nt,
49 J4_cmpeq_fp1_jump_t, J4_cmpeq_tp0_jump_nt, J4_cmpeq_tp0_jump_t,
50 J4_cmpeq_tp1_jump_nt, J4_cmpeq_tp1_jump_t};
52 J4_cmpgt_fp0_jump_nt, J4_cmpgt_fp0_jump_t, J4_cmpgt_fp1_jump_nt,
53 J4_cmpgt_fp1_jump_t, J4_cmpgt_tp0_jump_nt, J4_cmpgt_tp0_jump_t,
54 J4_cmpgt_tp1_jump_nt, J4_cmpgt_tp1_jump_t};
56 J4_cmpgtu_fp0_jump_nt, J4_cmpgtu_fp0_jump_t, J4_cmpgtu_fp1_jump_nt,
57 J4_cmpgtu_fp1_jump_t, J4_cmpgtu_tp0_jump_nt, J4_cmpgtu_tp0_jump_t,
58 J4_cmpgtu_tp1_jump_nt, J4_cmpgtu_tp1_jump_t};
60 J4_cmpeqi_fp0_jump_nt, J4_cmpeqi_fp0_jump_t, J4_cmpeqi_fp1_jump_nt,
61 J4_cmpeqi_fp1_jump_t, J4_cmpeqi_tp0_jump_nt, J4_cmpeqi_tp0_jump_t,
62 J4_cmpeqi_tp1_jump_nt, J4_cmpeqi_tp1_jump_t};
64 J4_cmpgti_fp0_jump_nt, J4_cmpgti_fp0_jump_t, J4_cmpgti_fp1_jump_nt,
65 J4_cmpgti_fp1_jump_t, J4_cmpgti_tp0_jump_nt, J4_cmpgti_tp0_jump_t,
66 J4_cmpgti_tp1_jump_nt, J4_cmpgti_tp1_jump_t};
68 J4_cmpgtui_fp0_jump_nt, J4_cmpgtui_fp0_jump_t, J4_cmpgtui_fp1_jump_nt,
69 J4_cmpgtui_fp1_jump_t, J4_cmpgtui_tp0_jump_nt, J4_cmpgtui_tp0_jump_t,
70 J4_cmpgtui_tp1_jump_nt, J4_cmpgtui_tp1_jump_t};
72 J4_cmpeqn1_fp0_jump_nt, J4_cmpeqn1_fp0_jump_t, J4_cmpeqn1_fp1_jump_nt,
73 J4_cmpeqn1_fp1_jump_t, J4_cmpeqn1_tp0_jump_nt, J4_cmpeqn1_tp0_jump_t,
74 J4_cmpeqn1_tp1_jump_nt, J4_cmpeqn1_tp1_jump_t};
76 J4_cmpgtn1_fp0_jump_nt, J4_cmpgtn1_fp0_jump_t, J4_cmpgtn1_fp1_jump_nt,
77 J4_cmpgtn1_fp1_jump_t, J4_cmpgtn1_tp0_jump_nt, J4_cmpgtn1_tp0_jump_t,
78 J4_cmpgtn1_tp1_jump_nt, J4_cmpgtn1_tp1_jump_t,
83 unsigned getCompoundCandidateGroup(
MCInst const &
MI,
bool IsExtended) {
84 unsigned DstReg, SrcReg, Src1Reg, Src2Reg;
95 case Hexagon::C2_cmpeq:
96 case Hexagon::C2_cmpgt:
97 case Hexagon::C2_cmpgtu:
103 if ((Hexagon::P0 == DstReg || Hexagon::P1 == DstReg) &&
108 case Hexagon::C2_cmpeqi:
109 case Hexagon::C2_cmpgti:
110 case Hexagon::C2_cmpgtui:
116 if ((Hexagon::P0 == DstReg || Hexagon::P1 == DstReg) &&
122 case Hexagon::A2_tfr:
132 case Hexagon::A2_tfrsi:
142 case Hexagon::S2_tstbit_i:
147 if ((Hexagon::P0 == DstReg || Hexagon::P1 == DstReg) &&
157 case Hexagon::J2_jumptnew:
158 case Hexagon::J2_jumpfnew:
159 case Hexagon::J2_jumptnewpt:
160 case Hexagon::J2_jumpfnewpt:
162 if (Hexagon::P0 == Src1Reg || Hexagon::P1 == Src1Reg)
169 case Hexagon::J2_jump:
170 case Hexagon::RESTORE_DEALLOC_RET_JMP_V4:
181 unsigned getCompoundOp(
MCInst const &HMCI) {
183 unsigned PredReg = Predicate.
getReg();
185 assert((PredReg == Hexagon::P0) || (PredReg == Hexagon::P1) ||
186 (PredReg == Hexagon::P2) || (PredReg == Hexagon::P3));
192 case Hexagon::J2_jumpfnew:
194 case Hexagon::J2_jumpfnewpt:
196 case Hexagon::J2_jumptnew:
198 case Hexagon::J2_jumptnewpt:
207 unsigned compoundOpcode;
212 DEBUG(
dbgs() <<
"Possible compound ignored\n");
215 case Hexagon::A2_tfrsi:
217 compoundOpcode = J4_jumpseti;
218 CompoundInsn =
new (Context)
MCInst;
226 case Hexagon::A2_tfr:
230 compoundOpcode = J4_jumpsetr;
231 CompoundInsn =
new (Context)
MCInst;
239 case Hexagon::C2_cmpeq:
245 CompoundInsn =
new (Context)
MCInst;
252 case Hexagon::C2_cmpgt:
258 CompoundInsn =
new (Context)
MCInst;
265 case Hexagon::C2_cmpgtu:
271 CompoundInsn =
new (Context)
MCInst;
278 case Hexagon::C2_cmpeqi:
286 CompoundInsn =
new (Context)
MCInst;
294 case Hexagon::C2_cmpgti:
302 CompoundInsn =
new (Context)
MCInst;
310 case Hexagon::C2_cmpgtui:
314 CompoundInsn =
new (Context)
MCInst;
321 case Hexagon::S2_tstbit_i:
325 CompoundInsn =
new (Context)
MCInst;
338 bool isOrderedCompoundPair(
MCInst const &MIa,
bool IsExtendedA,
339 MCInst const &MIb,
bool IsExtendedB) {
340 unsigned MIaG = getCompoundCandidateGroup(MIa, IsExtendedA);
341 unsigned MIbG = getCompoundCandidateGroup(MIb, IsExtendedB);
346 (Opca == Hexagon::A2_tfr || Opca == Hexagon::A2_tfrsi))
356 bool JExtended =
false;
359 J != MCI.
end(); ++J) {
360 MCInst const *JumpInst = J->getInst();
368 bool BExtended =
false;
371 B != MCI.
end(); ++B) {
372 MCInst const *Inst = B->getInst();
373 if (JumpInst == Inst)
381 if (isOrderedCompoundPair(*Inst, BExtended, *JumpInst, JExtended)) {
382 MCInst *CompoundInsn = getCompoundInsn(Context, *Inst, *JumpInst);
385 << JumpInst->
getOpcode() <<
" Compounds to "
387 J->setInst(CompoundInsn);
408 "Non-Bundle where Bundle expected");
416 while (lookForCompound(MCII, Context, MCI))
void tryCompound(MCInstrInfo const &MCII, MCContext &Context, MCInst &MCI)
tryCompound - Given a bundle check for compound insns when one is found update the contents fo the bu...
bool isIntRegForSubInst(unsigned Reg)
bool isBundle(MCInst const &MCI)
static const unsigned tstBitOpcode[8]
bool isImmext(MCInst const &MCI)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static const unsigned cmpeqBitOpcode[8]
Context object for machine code objects.
unsigned getReg() const
Returns the register number.
Instances of this class represent a single low-level machine instruction.
static const unsigned cmpgtuBitOpcode[8]
static const unsigned cmpeqiBitOpcode[8]
Interface to description of machine instruction set.
void setOpcode(unsigned Op)
size_t const bundleInstructionsOffset
static const unsigned cmpgtn1BitOpcode[8]
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
BUNDLE - This instruction represents an instruction bundle.
unsigned getOpcode() const
static const unsigned cmpeqn1BitOpcode[8]
static const unsigned cmpgtiBitOpcode[8]
static const unsigned cmpgtuiBitOpcode[8]
static const unsigned cmpgtBitOpcode[8]
void addOperand(const MCOperand &Op)
unsigned getType(MCInstrInfo const &MCII, MCInst const &MCI)
Instances of this class represent operands of the MCInst class.
const MCOperand & getOperand(unsigned i) const