32 using namespace Hexagon;
34 #define DEBUG_TYPE "hexagon-mcduplex-info" 37 static const std::pair<unsigned, unsigned>
opcodeData[] = {
38 std::make_pair((
unsigned)SA1_addi, 0),
39 std::make_pair((
unsigned)SA1_addrx, 6144),
40 std::make_pair((
unsigned)SA1_addsp, 3072),
41 std::make_pair((
unsigned)SA1_and1, 4608),
42 std::make_pair((
unsigned)SA1_clrf, 6768),
43 std::make_pair((
unsigned)SA1_clrfnew, 6736),
44 std::make_pair((
unsigned)SA1_clrt, 6752),
45 std::make_pair((
unsigned)SA1_clrtnew, 6720),
46 std::make_pair((
unsigned)SA1_cmpeqi, 6400),
47 std::make_pair((
unsigned)SA1_combine0i, 7168),
48 std::make_pair((
unsigned)SA1_combine1i, 7176),
49 std::make_pair((
unsigned)SA1_combine2i, 7184),
50 std::make_pair((
unsigned)SA1_combine3i, 7192),
51 std::make_pair((
unsigned)SA1_combinerz, 7432),
52 std::make_pair((
unsigned)SA1_combinezr, 7424),
53 std::make_pair((
unsigned)SA1_dec, 4864),
54 std::make_pair((
unsigned)SA1_inc, 4352),
55 std::make_pair((
unsigned)SA1_seti, 2048),
56 std::make_pair((
unsigned)SA1_setin1, 6656),
57 std::make_pair((
unsigned)SA1_sxtb, 5376),
58 std::make_pair((
unsigned)SA1_sxth, 5120),
59 std::make_pair((
unsigned)SA1_tfr, 4096),
60 std::make_pair((
unsigned)SA1_zxtb, 5888),
61 std::make_pair((
unsigned)SA1_zxth, 5632),
62 std::make_pair((
unsigned)SL1_loadri_io, 0),
63 std::make_pair((
unsigned)SL1_loadrub_io, 4096),
64 std::make_pair((
unsigned)SL2_deallocframe, 7936),
65 std::make_pair((
unsigned)SL2_jumpr31, 8128),
66 std::make_pair((
unsigned)SL2_jumpr31_f, 8133),
67 std::make_pair((
unsigned)SL2_jumpr31_fnew, 8135),
68 std::make_pair((
unsigned)SL2_jumpr31_t, 8132),
69 std::make_pair((
unsigned)SL2_jumpr31_tnew, 8134),
70 std::make_pair((
unsigned)SL2_loadrb_io, 4096),
71 std::make_pair((
unsigned)SL2_loadrd_sp, 7680),
72 std::make_pair((
unsigned)SL2_loadrh_io, 0),
73 std::make_pair((
unsigned)SL2_loadri_sp, 7168),
74 std::make_pair((
unsigned)SL2_loadruh_io, 2048),
75 std::make_pair((
unsigned)SL2_return, 8000),
76 std::make_pair((
unsigned)SL2_return_f, 8005),
77 std::make_pair((
unsigned)SL2_return_fnew, 8007),
78 std::make_pair((
unsigned)SL2_return_t, 8004),
79 std::make_pair((
unsigned)SL2_return_tnew, 8006),
80 std::make_pair((
unsigned)SS1_storeb_io, 4096),
81 std::make_pair((
unsigned)SS1_storew_io, 0),
82 std::make_pair((
unsigned)SS2_allocframe, 7168),
83 std::make_pair((
unsigned)SS2_storebi0, 4608),
84 std::make_pair((
unsigned)SS2_storebi1, 4864),
85 std::make_pair((
unsigned)SS2_stored_sp, 2560),
86 std::make_pair((
unsigned)SS2_storeh_io, 0),
87 std::make_pair((
unsigned)SS2_storew_sp, 2048),
88 std::make_pair((
unsigned)SS2_storewi0, 4096),
89 std::make_pair((
unsigned)SS2_storewi1, 4352)};
186 unsigned DstReg, PredReg, SrcReg, Src1Reg, Src2Reg;
196 case Hexagon::L2_loadri_io:
203 Hexagon::R29 == SrcReg && inRange<5, 2>(MCI, 2)) {
208 inRange<4, 2>(MCI, 2)) {
213 case Hexagon::L2_loadrub_io:
219 inRange<4>(MCI, 2)) {
233 case Hexagon::L2_loadrh_io:
234 case Hexagon::L2_loadruh_io:
240 inRange<3, 1>(MCI, 2)) {
244 case Hexagon::L2_loadrb_io:
250 inRange<3>(MCI, 2)) {
254 case Hexagon::L2_loadrd_io:
260 inRange<5, 3>(MCI, 2)) {
265 case Hexagon::L4_return:
266 case Hexagon::L2_deallocframe:
269 case Hexagon::EH_RETURN_JMPR:
270 case Hexagon::J2_jumpr:
271 case Hexagon::PS_jmpret:
275 if (Hexagon::R31 == DstReg)
279 case Hexagon::J2_jumprt:
280 case Hexagon::J2_jumprf:
281 case Hexagon::J2_jumprtnew:
282 case Hexagon::J2_jumprfnew:
283 case Hexagon::J2_jumprtnewpt:
284 case Hexagon::J2_jumprfnewpt:
285 case Hexagon::PS_jmprett:
286 case Hexagon::PS_jmpretf:
287 case Hexagon::PS_jmprettnew:
288 case Hexagon::PS_jmpretfnew:
289 case Hexagon::PS_jmprettnewpt:
290 case Hexagon::PS_jmpretfnewpt:
295 (Hexagon::R31 == DstReg)) {
299 case Hexagon::L4_return_t:
300 case Hexagon::L4_return_f:
301 case Hexagon::L4_return_tnew_pnt:
302 case Hexagon::L4_return_fnew_pnt:
303 case Hexagon::L4_return_tnew_pt:
304 case Hexagon::L4_return_fnew_pt:
307 if (Hexagon::P0 == SrcReg) {
316 case Hexagon::S2_storeri_io:
323 Hexagon::R29 == Src1Reg && inRange<5, 2>(MCI, 1)) {
329 inRange<4, 2>(MCI, 1)) {
333 case Hexagon::S2_storerb_io:
339 inRange<4>(MCI, 1)) {
352 case Hexagon::S2_storerh_io:
358 inRange<3, 1>(MCI, 1)) {
362 case Hexagon::S2_storerd_io:
368 inSRange<6, 3>(MCI, 1)) {
372 case Hexagon::S4_storeiri_io:
376 inRange<4, 2>(MCI, 1) && inRange<1>(MCI, 2)) {
380 case Hexagon::S4_storeirb_io:
384 inRange<4>(MCI, 1) && inRange<1>(MCI, 2)) {
388 case Hexagon::S2_allocframe:
389 if (inRange<5, 3>(MCI, 2))
410 case Hexagon::A2_addi:
416 inRange<6, 2>(MCI, 2)) {
420 if (DstReg == SrcReg) {
431 case Hexagon::A2_add:
441 case Hexagon::A2_andir:
450 case Hexagon::A2_tfr:
459 case Hexagon::A2_tfrsi:
466 case Hexagon::C2_cmoveit:
467 case Hexagon::C2_cmovenewit:
468 case Hexagon::C2_cmoveif:
469 case Hexagon::C2_cmovenewif:
476 Hexagon::P0 == PredReg &&
minConstant(MCI, 2) == 0) {
480 case Hexagon::C2_cmpeqi:
484 if (Hexagon::P0 == DstReg &&
486 inRange<2>(MCI, 2)) {
490 case Hexagon::A2_combineii:
491 case Hexagon::A4_combineii:
495 inRange<2>(MCI, 1) && inRange<2>(MCI, 2)) {
499 case Hexagon::A4_combineri:
509 case Hexagon::A4_combineir:
519 case Hexagon::A2_sxtb:
520 case Hexagon::A2_sxth:
521 case Hexagon::A2_zxtb:
522 case Hexagon::A2_zxth:
537 unsigned DstReg, SrcReg;
539 case Hexagon::A2_addi:
547 if (!isShiftedInt<7, 0>(Value))
551 case Hexagon::A2_tfrsi:
562 if (!isShiftedUInt<6, 0>(Value))
574 MCInst const &MIa,
bool ExtendedA,
575 MCInst const &MIb,
bool ExtendedB,
584 if ((Opcode != Hexagon::A2_addi) && (Opcode != Hexagon::A2_tfrsi))
599 unsigned zeroedSubInstS0 =
601 unsigned zeroedSubInstS1 =
604 if (zeroedSubInstS0 < zeroedSubInstS1)
611 if (MIb.
getOpcode() == Hexagon::S2_allocframe)
707 case Hexagon::A2_addi:
735 case Hexagon::A2_add:
741 case Hexagon::S2_allocframe:
742 Result.
setOpcode(Hexagon::SS2_allocframe);
745 case Hexagon::A2_andir:
757 case Hexagon::C2_cmpeqi:
762 case Hexagon::A4_combineii:
763 case Hexagon::A2_combineii:
765 assert(Absolute);(void)Absolute;
767 Result.
setOpcode(Hexagon::SA1_combine1i);
773 Result.
setOpcode(Hexagon::SA1_combine3i);
779 Result.
setOpcode(Hexagon::SA1_combine0i);
785 Result.
setOpcode(Hexagon::SA1_combine2i);
791 case Hexagon::A4_combineir:
792 Result.
setOpcode(Hexagon::SA1_combinezr);
796 case Hexagon::A4_combineri:
797 Result.
setOpcode(Hexagon::SA1_combinerz);
801 case Hexagon::L4_return_tnew_pnt:
802 case Hexagon::L4_return_tnew_pt:
803 Result.
setOpcode(Hexagon::SL2_return_tnew);
805 case Hexagon::L4_return_fnew_pnt:
806 case Hexagon::L4_return_fnew_pt:
807 Result.
setOpcode(Hexagon::SL2_return_fnew);
809 case Hexagon::L4_return_f:
812 case Hexagon::L4_return_t:
815 case Hexagon::L4_return:
818 case Hexagon::L2_deallocframe:
819 Result.
setOpcode(Hexagon::SL2_deallocframe);
821 case Hexagon::EH_RETURN_JMPR:
822 case Hexagon::J2_jumpr:
823 case Hexagon::PS_jmpret:
826 case Hexagon::J2_jumprf:
827 case Hexagon::PS_jmpretf:
828 Result.
setOpcode(Hexagon::SL2_jumpr31_f);
830 case Hexagon::J2_jumprfnew:
831 case Hexagon::J2_jumprfnewpt:
832 case Hexagon::PS_jmpretfnewpt:
833 case Hexagon::PS_jmpretfnew:
834 Result.
setOpcode(Hexagon::SL2_jumpr31_fnew);
836 case Hexagon::J2_jumprt:
837 case Hexagon::PS_jmprett:
838 Result.
setOpcode(Hexagon::SL2_jumpr31_t);
840 case Hexagon::J2_jumprtnew:
841 case Hexagon::J2_jumprtnewpt:
842 case Hexagon::PS_jmprettnewpt:
843 case Hexagon::PS_jmprettnew:
844 Result.
setOpcode(Hexagon::SL2_jumpr31_tnew);
846 case Hexagon::L2_loadrb_io:
847 Result.
setOpcode(Hexagon::SL2_loadrb_io);
852 case Hexagon::L2_loadrd_io:
853 Result.
setOpcode(Hexagon::SL2_loadrd_sp);
857 case Hexagon::L2_loadrh_io:
858 Result.
setOpcode(Hexagon::SL2_loadrh_io);
863 case Hexagon::L2_loadrub_io:
864 Result.
setOpcode(Hexagon::SL1_loadrub_io);
869 case Hexagon::L2_loadruh_io:
870 Result.
setOpcode(Hexagon::SL2_loadruh_io);
875 case Hexagon::L2_loadri_io:
877 Result.
setOpcode(Hexagon::SL2_loadri_sp);
882 Result.
setOpcode(Hexagon::SL1_loadri_io);
888 case Hexagon::S4_storeirb_io:
890 assert(Absolute);(void)Absolute;
896 }
else if (Value == 1) {
903 case Hexagon::S2_storerb_io:
904 Result.
setOpcode(Hexagon::SS1_storeb_io);
909 case Hexagon::S2_storerd_io:
910 Result.
setOpcode(Hexagon::SS2_stored_sp);
914 case Hexagon::S2_storerh_io:
915 Result.
setOpcode(Hexagon::SS2_storeh_io);
920 case Hexagon::S4_storeiri_io:
922 assert(Absolute);(void)Absolute;
928 }
else if (Value == 1) {
934 Result.
setOpcode(Hexagon::SS2_storew_sp);
940 case Hexagon::S2_storeri_io:
942 Result.
setOpcode(Hexagon::SS2_storew_sp);
946 Result.
setOpcode(Hexagon::SS1_storew_io);
952 case Hexagon::A2_sxtb:
957 case Hexagon::A2_sxth:
962 case Hexagon::A2_tfr:
967 case Hexagon::C2_cmovenewif:
972 case Hexagon::C2_cmovenewit:
977 case Hexagon::C2_cmoveif:
982 case Hexagon::C2_cmoveit:
987 case Hexagon::A2_tfrsi:
989 if (Absolute && Value == -1) {
1000 case Hexagon::A2_zxtb:
1006 case Hexagon::A2_zxth:
1017 case Hexagon::S2_storeri_io:
1018 case Hexagon::S2_storerb_io:
1019 case Hexagon::S2_storerh_io:
1020 case Hexagon::S2_storerd_io:
1021 case Hexagon::S4_storeiri_io:
1022 case Hexagon::S4_storeirb_io:
1023 case Hexagon::S2_allocframe:
1039 for (
unsigned distance = 1; distance < numInstrInPacket; ++distance) {
1042 (j < numInstrInPacket) && (k < numInstrInPacket); ++j, ++k) {
1045 bool bisReversable =
true;
1048 LLVM_DEBUG(
dbgs() <<
"skip out of order write pair: " << k <<
"," << j
1050 bisReversable =
false;
1053 bisReversable =
false;
1061 bisReversable, STI)) {
1080 if (bisReversable) {
1086 bisReversable, STI)) {
1095 <<
"adding pair:" << k <<
"," << j <<
":" 1100 <<
"skipping pair: " << k <<
"," << j <<
":" void push_back(const T &Elt)
const_iterator end(StringRef path)
Get end iterator over path.
bool subInstWouldBeExtended(MCInst const &potentialDuplex)
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Compute iterated dominance frontiers using a linear time algorithm.
LLVM_NODISCARD bool equals_lower(StringRef RHS) const
equals_lower - Check for string equality, ignoring case.
bool isDuplexPair(MCInst const &MIa, MCInst const &MIb)
Symmetrical. See if these two instructions are fit for duplex pair.
static const std::pair< unsigned, unsigned > opcodeData[]
bool isIntRegForSubInst(unsigned Reg)
bool isBundle(MCInst const &MCI)
bool isDblRegForSubInst(unsigned Reg)
unsigned getReg() const
Returns the register number.
const MCInst * getInst() const
const MCExpr * getExpr() const
Instances of this class represent a single low-level machine instruction.
bool isDuplexPairMatch(unsigned Ga, unsigned Gb)
unsigned getDuplexCandidateGroup(MCInst const &MI)
Interface to description of machine instruction set.
unsigned getNumOperands() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static void addOps(MCInst &subInstPtr, MCInst const &Inst, unsigned opNum)
void setOpcode(unsigned Op)
size_t const bundleInstructionsOffset
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
const MCOperand & getOperand(unsigned i) const
int64_t minConstant(MCInst const &MCI, size_t Index)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static bool isDuplexPairMatch(unsigned Ga, unsigned Gb)
bool isMemReorderDisabled(MCInst const &MCI)
MCInst deriveSubInst(MCInst const &Inst)
bool hasExtenderForIndex(MCInst const &MCB, size_t Index)
Generic base class for all target subtargets.
static bool isStoreInst(unsigned opCode)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
bool isPredReg(unsigned Reg)
SmallVector< DuplexCandidate, 8 > getDuplexPossibilties(MCInstrInfo const &MCII, MCSubtargetInfo const &STI, MCInst const &MCB)
bool isIntReg(unsigned Reg)
void addOperand(const MCOperand &Op)
unsigned getOpcode() const
unsigned iClassOfDuplexPair(unsigned Ga, unsigned Gb)
bool isOrderedDuplexPair(MCInstrInfo const &MCII, MCInst const &MIa, bool ExtendedA, MCInst const &MIb, bool ExtendedB, bool bisReversable, MCSubtargetInfo const &STI)
non-Symmetrical. See if these two instructions are fit for duplex pair.