30using namespace Hexagon;
32#define DEBUG_TYPE "hexagon-mcduplex-info"
35static const std::pair<unsigned, unsigned>
opcodeData[] = {
36 std::make_pair((
unsigned)SA1_addi, 0),
37 std::make_pair((
unsigned)SA1_addrx, 6144),
38 std::make_pair((
unsigned)SA1_addsp, 3072),
39 std::make_pair((
unsigned)SA1_and1, 4608),
40 std::make_pair((
unsigned)SA1_clrf, 6768),
41 std::make_pair((
unsigned)SA1_clrfnew, 6736),
42 std::make_pair((
unsigned)SA1_clrt, 6752),
43 std::make_pair((
unsigned)SA1_clrtnew, 6720),
44 std::make_pair((
unsigned)SA1_cmpeqi, 6400),
45 std::make_pair((
unsigned)SA1_combine0i, 7168),
46 std::make_pair((
unsigned)SA1_combine1i, 7176),
47 std::make_pair((
unsigned)SA1_combine2i, 7184),
48 std::make_pair((
unsigned)SA1_combine3i, 7192),
49 std::make_pair((
unsigned)SA1_combinerz, 7432),
50 std::make_pair((
unsigned)SA1_combinezr, 7424),
51 std::make_pair((
unsigned)SA1_dec, 4864),
52 std::make_pair((
unsigned)SA1_inc, 4352),
53 std::make_pair((
unsigned)SA1_seti, 2048),
54 std::make_pair((
unsigned)SA1_setin1, 6656),
55 std::make_pair((
unsigned)SA1_sxtb, 5376),
56 std::make_pair((
unsigned)SA1_sxth, 5120),
57 std::make_pair((
unsigned)SA1_tfr, 4096),
58 std::make_pair((
unsigned)SA1_zxtb, 5888),
59 std::make_pair((
unsigned)SA1_zxth, 5632),
60 std::make_pair((
unsigned)SL1_loadri_io, 0),
61 std::make_pair((
unsigned)SL1_loadrub_io, 4096),
62 std::make_pair((
unsigned)SL2_deallocframe, 7936),
63 std::make_pair((
unsigned)SL2_jumpr31, 8128),
64 std::make_pair((
unsigned)SL2_jumpr31_f, 8133),
65 std::make_pair((
unsigned)SL2_jumpr31_fnew, 8135),
66 std::make_pair((
unsigned)SL2_jumpr31_t, 8132),
67 std::make_pair((
unsigned)SL2_jumpr31_tnew, 8134),
68 std::make_pair((
unsigned)SL2_loadrb_io, 4096),
69 std::make_pair((
unsigned)SL2_loadrd_sp, 7680),
70 std::make_pair((
unsigned)SL2_loadrh_io, 0),
71 std::make_pair((
unsigned)SL2_loadri_sp, 7168),
72 std::make_pair((
unsigned)SL2_loadruh_io, 2048),
73 std::make_pair((
unsigned)SL2_return, 8000),
74 std::make_pair((
unsigned)SL2_return_f, 8005),
75 std::make_pair((
unsigned)SL2_return_fnew, 8007),
76 std::make_pair((
unsigned)SL2_return_t, 8004),
77 std::make_pair((
unsigned)SL2_return_tnew, 8006),
78 std::make_pair((
unsigned)SS1_storeb_io, 4096),
79 std::make_pair((
unsigned)SS1_storew_io, 0),
80 std::make_pair((
unsigned)SS2_allocframe, 7168),
81 std::make_pair((
unsigned)SS2_storebi0, 4608),
82 std::make_pair((
unsigned)SS2_storebi1, 4864),
83 std::make_pair((
unsigned)SS2_stored_sp, 2560),
84 std::make_pair((
unsigned)SS2_storeh_io, 0),
85 std::make_pair((
unsigned)SS2_storew_sp, 2048),
86 std::make_pair((
unsigned)SS2_storewi0, 4096),
87 std::make_pair((
unsigned)SS2_storewi1, 4352)};
190 unsigned DstReg, PredReg, SrcReg, Src1Reg, Src2Reg;
200 case Hexagon::L2_loadri_io:
207 Hexagon::R29 == SrcReg && inRange<5, 2>(MCI, 2)) {
212 inRange<4, 2>(MCI, 2)) {
217 case Hexagon::L2_loadrub_io:
223 inRange<4>(MCI, 2)) {
237 case Hexagon::L2_loadrh_io:
238 case Hexagon::L2_loadruh_io:
244 inRange<3, 1>(MCI, 2)) {
248 case Hexagon::L2_loadrb_io:
254 inRange<3>(MCI, 2)) {
258 case Hexagon::L2_loadrd_io:
264 inRange<5, 3>(MCI, 2)) {
269 case Hexagon::L4_return:
270 case Hexagon::L2_deallocframe:
273 case Hexagon::EH_RETURN_JMPR:
274 case Hexagon::J2_jumpr:
275 case Hexagon::PS_jmpret:
279 if (Hexagon::R31 == DstReg)
283 case Hexagon::J2_jumprt:
284 case Hexagon::J2_jumprf:
285 case Hexagon::J2_jumprtnew:
286 case Hexagon::J2_jumprfnew:
287 case Hexagon::PS_jmprett:
288 case Hexagon::PS_jmpretf:
289 case Hexagon::PS_jmprettnew:
290 case Hexagon::PS_jmpretfnew:
291 case Hexagon::PS_jmprettnewpt:
292 case Hexagon::PS_jmpretfnewpt:
296 if ((Hexagon::P0 == SrcReg) && (Hexagon::R31 == DstReg)) {
300 case Hexagon::L4_return_t:
301 case Hexagon::L4_return_f:
302 case Hexagon::L4_return_tnew_pnt:
303 case Hexagon::L4_return_fnew_pnt:
306 if (Hexagon::P0 == SrcReg) {
315 case Hexagon::S2_storeri_io:
322 Hexagon::R29 == Src1Reg && inRange<5, 2>(MCI, 1)) {
328 inRange<4, 2>(MCI, 1)) {
332 case Hexagon::S2_storerb_io:
338 inRange<4>(MCI, 1)) {
351 case Hexagon::S2_storerh_io:
357 inRange<3, 1>(MCI, 1)) {
361 case Hexagon::S2_storerd_io:
367 inSRange<6, 3>(MCI, 1)) {
371 case Hexagon::S4_storeiri_io:
375 inRange<4, 2>(MCI, 1) && inRange<1>(MCI, 2)) {
379 case Hexagon::S4_storeirb_io:
383 inRange<4>(MCI, 1) && inRange<1>(MCI, 2)) {
387 case Hexagon::S2_allocframe:
388 if (inRange<5, 3>(MCI, 2))
409 case Hexagon::A2_addi:
415 inRange<6, 2>(MCI, 2)) {
419 if (DstReg == SrcReg) {
430 case Hexagon::A2_add:
440 case Hexagon::A2_andir:
449 case Hexagon::A2_tfr:
458 case Hexagon::A2_tfrsi:
465 case Hexagon::C2_cmoveit:
466 case Hexagon::C2_cmovenewit:
467 case Hexagon::C2_cmoveif:
468 case Hexagon::C2_cmovenewif:
475 Hexagon::P0 == PredReg &&
minConstant(MCI, 2) == 0) {
479 case Hexagon::C2_cmpeqi:
483 if (Hexagon::P0 == DstReg &&
485 inRange<2>(MCI, 2)) {
489 case Hexagon::A2_combineii:
490 case Hexagon::A4_combineii:
494 inRange<2>(MCI, 1) && inRange<2>(MCI, 2)) {
498 case Hexagon::A4_combineri:
508 case Hexagon::A4_combineir:
518 case Hexagon::A2_sxtb:
519 case Hexagon::A2_sxth:
520 case Hexagon::A2_zxtb:
521 case Hexagon::A2_zxth:
536 unsigned DstReg, SrcReg;
538 case Hexagon::A2_addi:
546 if (!isShiftedInt<7, 0>(
Value))
550 case Hexagon::A2_tfrsi:
561 if (!isShiftedUInt<6, 0>(
Value))
573 MCInst const &MIa,
bool ExtendedA,
574 MCInst const &MIb,
bool ExtendedB,
583 if ((Opcode != Hexagon::A2_addi) && (Opcode != Hexagon::A2_tfrsi))
589 static std::map<unsigned, unsigned> subinstOpcodeMap(std::begin(
opcodeData),
598 unsigned zeroedSubInstS0 =
599 subinstOpcodeMap.find(SubInst0.
getOpcode())->second;
600 unsigned zeroedSubInstS1 =
601 subinstOpcodeMap.find(SubInst1.
getOpcode())->second;
603 if (zeroedSubInstS0 < zeroedSubInstS1)
610 if (MIb.
getOpcode() == Hexagon::S2_allocframe)
698 Result.setLoc(Inst.
getLoc());
706 case Hexagon::A2_addi:
710 Result.setOpcode(Hexagon::SA1_inc);
716 Result.setOpcode(Hexagon::SA1_dec);
723 Result.setOpcode(Hexagon::SA1_addsp);
729 Result.setOpcode(Hexagon::SA1_addi);
734 case Hexagon::A2_add:
735 Result.setOpcode(Hexagon::SA1_addrx);
740 case Hexagon::S2_allocframe:
741 Result.setOpcode(Hexagon::SS2_allocframe);
744 case Hexagon::A2_andir:
746 Result.setOpcode(Hexagon::SA1_zxtb);
751 Result.setOpcode(Hexagon::SA1_and1);
756 case Hexagon::C2_cmpeqi:
757 Result.setOpcode(Hexagon::SA1_cmpeqi);
761 case Hexagon::A4_combineii:
762 case Hexagon::A2_combineii:
764 assert(Absolute);(void)Absolute;
766 Result.setOpcode(Hexagon::SA1_combine1i);
772 Result.setOpcode(Hexagon::SA1_combine3i);
778 Result.setOpcode(Hexagon::SA1_combine0i);
784 Result.setOpcode(Hexagon::SA1_combine2i);
790 case Hexagon::A4_combineir:
791 Result.setOpcode(Hexagon::SA1_combinezr);
795 case Hexagon::A4_combineri:
796 Result.setOpcode(Hexagon::SA1_combinerz);
800 case Hexagon::L4_return_tnew_pnt:
801 case Hexagon::L4_return_tnew_pt:
802 Result.setOpcode(Hexagon::SL2_return_tnew);
804 case Hexagon::L4_return_fnew_pnt:
805 case Hexagon::L4_return_fnew_pt:
806 Result.setOpcode(Hexagon::SL2_return_fnew);
808 case Hexagon::L4_return_f:
809 Result.setOpcode(Hexagon::SL2_return_f);
811 case Hexagon::L4_return_t:
812 Result.setOpcode(Hexagon::SL2_return_t);
814 case Hexagon::L4_return:
815 Result.setOpcode(Hexagon::SL2_return);
817 case Hexagon::L2_deallocframe:
818 Result.setOpcode(Hexagon::SL2_deallocframe);
820 case Hexagon::EH_RETURN_JMPR:
821 case Hexagon::J2_jumpr:
822 case Hexagon::PS_jmpret:
823 Result.setOpcode(Hexagon::SL2_jumpr31);
825 case Hexagon::J2_jumprf:
826 case Hexagon::PS_jmpretf:
827 Result.setOpcode(Hexagon::SL2_jumpr31_f);
829 case Hexagon::J2_jumprfnew:
830 case Hexagon::PS_jmpretfnewpt:
831 case Hexagon::PS_jmpretfnew:
832 Result.setOpcode(Hexagon::SL2_jumpr31_fnew);
834 case Hexagon::J2_jumprt:
835 case Hexagon::PS_jmprett:
836 Result.setOpcode(Hexagon::SL2_jumpr31_t);
838 case Hexagon::J2_jumprtnew:
839 case Hexagon::PS_jmprettnewpt:
840 case Hexagon::PS_jmprettnew:
841 Result.setOpcode(Hexagon::SL2_jumpr31_tnew);
843 case Hexagon::L2_loadrb_io:
844 Result.setOpcode(Hexagon::SL2_loadrb_io);
849 case Hexagon::L2_loadrd_io:
850 Result.setOpcode(Hexagon::SL2_loadrd_sp);
854 case Hexagon::L2_loadrh_io:
855 Result.setOpcode(Hexagon::SL2_loadrh_io);
860 case Hexagon::L2_loadrub_io:
861 Result.setOpcode(Hexagon::SL1_loadrub_io);
866 case Hexagon::L2_loadruh_io:
867 Result.setOpcode(Hexagon::SL2_loadruh_io);
872 case Hexagon::L2_loadri_io:
874 Result.setOpcode(Hexagon::SL2_loadri_sp);
879 Result.setOpcode(Hexagon::SL1_loadri_io);
885 case Hexagon::S4_storeirb_io:
887 assert(Absolute);(void)Absolute;
889 Result.setOpcode(Hexagon::SS2_storebi0);
893 }
else if (
Value == 1) {
894 Result.setOpcode(Hexagon::SS2_storebi1);
900 case Hexagon::S2_storerb_io:
901 Result.setOpcode(Hexagon::SS1_storeb_io);
906 case Hexagon::S2_storerd_io:
907 Result.setOpcode(Hexagon::SS2_stored_sp);
911 case Hexagon::S2_storerh_io:
912 Result.setOpcode(Hexagon::SS2_storeh_io);
917 case Hexagon::S4_storeiri_io:
919 assert(Absolute);(void)Absolute;
921 Result.setOpcode(Hexagon::SS2_storewi0);
925 }
else if (
Value == 1) {
926 Result.setOpcode(Hexagon::SS2_storewi1);
931 Result.setOpcode(Hexagon::SS2_storew_sp);
937 case Hexagon::S2_storeri_io:
939 Result.setOpcode(Hexagon::SS2_storew_sp);
943 Result.setOpcode(Hexagon::SS1_storew_io);
949 case Hexagon::A2_sxtb:
950 Result.setOpcode(Hexagon::SA1_sxtb);
954 case Hexagon::A2_sxth:
955 Result.setOpcode(Hexagon::SA1_sxth);
959 case Hexagon::A2_tfr:
960 Result.setOpcode(Hexagon::SA1_tfr);
964 case Hexagon::C2_cmovenewif:
965 Result.setOpcode(Hexagon::SA1_clrfnew);
969 case Hexagon::C2_cmovenewit:
970 Result.setOpcode(Hexagon::SA1_clrtnew);
974 case Hexagon::C2_cmoveif:
975 Result.setOpcode(Hexagon::SA1_clrf);
979 case Hexagon::C2_cmoveit:
980 Result.setOpcode(Hexagon::SA1_clrt);
984 case Hexagon::A2_tfrsi:
986 if (Absolute &&
Value == -1) {
987 Result.setOpcode(Hexagon::SA1_setin1);
992 Result.setOpcode(Hexagon::SA1_seti);
997 case Hexagon::A2_zxtb:
998 Result.setOpcode(Hexagon::SA1_zxtb);
1003 case Hexagon::A2_zxth:
1004 Result.setOpcode(Hexagon::SA1_zxth);
1014 case Hexagon::S2_storeri_io:
1015 case Hexagon::S2_storerb_io:
1016 case Hexagon::S2_storerh_io:
1017 case Hexagon::S2_storerd_io:
1018 case Hexagon::S4_storeiri_io:
1019 case Hexagon::S4_storeirb_io:
1020 case Hexagon::S2_allocframe:
1036 for (
unsigned distance = 1; distance < numInstrInPacket; ++distance) {
1039 (j < numInstrInPacket) && (k < numInstrInPacket); ++j, ++k) {
1042 bool bisReversable =
true;
1045 LLVM_DEBUG(
dbgs() <<
"skip out of order write pair: " << k <<
"," << j
1047 bisReversable =
false;
1050 bisReversable =
false;
1058 bisReversable, STI)) {
1077 if (bisReversable) {
1083 bisReversable, STI)) {
1092 <<
"adding pair:" << k <<
"," << j <<
":"
1097 <<
"skipping pair: " << k <<
"," << j <<
":"
static bool isDuplexPairMatch(unsigned Ga, unsigned Gb)
static const std::pair< unsigned, unsigned > opcodeData[]
static void addOps(MCInst &subInstPtr, MCInst const &Inst, unsigned opNum)
static bool isStoreInst(unsigned opCode)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
Instances of this class represent a single low-level machine instruction.
unsigned getNumOperands() const
unsigned getOpcode() const
void addOperand(const MCOperand Op)
const MCOperand & getOperand(unsigned i) const
Interface to description of machine instruction set.
unsigned getReg() const
Returns the register number.
const MCInst * getInst() const
const MCExpr * getExpr() const
Generic base class for all target subtargets.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
bool equals_insensitive(StringRef RHS) const
Check for string equality, ignoring case.
LLVM Value Representation.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isDblRegForSubInst(unsigned Reg)
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.
bool isDuplexPairMatch(unsigned Ga, unsigned Gb)
bool subInstWouldBeExtended(MCInst const &potentialDuplex)
MCInst deriveSubInst(MCInst const &Inst)
SmallVector< DuplexCandidate, 8 > getDuplexPossibilties(MCInstrInfo const &MCII, MCSubtargetInfo const &STI, MCInst const &MCB)
bool isIntRegForSubInst(unsigned Reg)
bool isMemReorderDisabled(MCInst const &MCI)
bool isBundle(MCInst const &MCI)
int64_t minConstant(MCInst const &MCI, size_t Index)
bool isDuplexPair(MCInst const &MIa, MCInst const &MIb)
Symmetrical. See if these two instructions are fit for duplex pair.
bool isIntReg(unsigned Reg)
constexpr size_t bundleInstructionsOffset
bool hasExtenderForIndex(MCInst const &MCB, size_t Index)
unsigned getDuplexCandidateGroup(MCInst const &MI)
unsigned iClassOfDuplexPair(unsigned Ga, unsigned Gb)
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.