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)};
192 unsigned DstReg, PredReg, SrcReg, Src1Reg, Src2Reg;
202 case Hexagon::L2_loadri_io:
209 Hexagon::R29 == SrcReg && inRange<5, 2>(MCI, 2)) {
214 inRange<4, 2>(MCI, 2)) {
219 case Hexagon::L2_loadrub_io:
225 inRange<4>(MCI, 2)) {
239 case Hexagon::L2_loadrh_io:
240 case Hexagon::L2_loadruh_io:
246 inRange<3, 1>(MCI, 2)) {
250 case Hexagon::L2_loadrb_io:
256 inRange<3>(MCI, 2)) {
260 case Hexagon::L2_loadrd_io:
266 inRange<5, 3>(MCI, 2)) {
271 case Hexagon::L4_return:
272 case Hexagon::L2_deallocframe:
275 case Hexagon::EH_RETURN_JMPR:
276 case Hexagon::J2_jumpr:
277 case Hexagon::PS_jmpret:
281 if (Hexagon::R31 == DstReg)
285 case Hexagon::J2_jumprt:
286 case Hexagon::J2_jumprf:
287 case Hexagon::J2_jumprtnew:
288 case Hexagon::J2_jumprfnew:
289 case Hexagon::J2_jumprtnewpt:
290 case Hexagon::J2_jumprfnewpt:
291 case Hexagon::PS_jmprett:
292 case Hexagon::PS_jmpretf:
293 case Hexagon::PS_jmprettnew:
294 case Hexagon::PS_jmpretfnew:
295 case Hexagon::PS_jmprettnewpt:
296 case Hexagon::PS_jmpretfnewpt:
301 (Hexagon::R31 == DstReg)) {
305 case Hexagon::L4_return_t:
306 case Hexagon::L4_return_f:
307 case Hexagon::L4_return_tnew_pnt:
308 case Hexagon::L4_return_fnew_pnt:
309 case Hexagon::L4_return_tnew_pt:
310 case Hexagon::L4_return_fnew_pt:
313 if (Hexagon::P0 == SrcReg) {
322 case Hexagon::S2_storeri_io:
329 Hexagon::R29 == Src1Reg && inRange<5, 2>(MCI, 1)) {
335 inRange<4, 2>(MCI, 1)) {
339 case Hexagon::S2_storerb_io:
345 inRange<4>(MCI, 1)) {
358 case Hexagon::S2_storerh_io:
364 inRange<3, 1>(MCI, 1)) {
368 case Hexagon::S2_storerd_io:
374 inSRange<6, 3>(MCI, 1)) {
378 case Hexagon::S4_storeiri_io:
382 inRange<4, 2>(MCI, 1) && inRange<1>(MCI, 2)) {
386 case Hexagon::S4_storeirb_io:
390 inRange<4>(MCI, 1) && inRange<1>(MCI, 2)) {
394 case Hexagon::S2_allocframe:
395 if (inRange<5, 3>(MCI, 2))
416 case Hexagon::A2_addi:
422 inRange<6, 2>(MCI, 2)) {
426 if (DstReg == SrcReg) {
437 case Hexagon::A2_add:
447 case Hexagon::A2_andir:
456 case Hexagon::A2_tfr:
465 case Hexagon::A2_tfrsi:
472 case Hexagon::C2_cmoveit:
473 case Hexagon::C2_cmovenewit:
474 case Hexagon::C2_cmoveif:
475 case Hexagon::C2_cmovenewif:
482 Hexagon::P0 == PredReg &&
minConstant(MCI, 2) == 0) {
486 case Hexagon::C2_cmpeqi:
490 if (Hexagon::P0 == DstReg &&
492 inRange<2>(MCI, 2)) {
496 case Hexagon::A2_combineii:
497 case Hexagon::A4_combineii:
501 inRange<2>(MCI, 1) && inRange<2>(MCI, 2)) {
505 case Hexagon::A4_combineri:
515 case Hexagon::A4_combineir:
525 case Hexagon::A2_sxtb:
526 case Hexagon::A2_sxth:
527 case Hexagon::A2_zxtb:
528 case Hexagon::A2_zxth:
543 unsigned DstReg, SrcReg;
545 case Hexagon::A2_addi:
553 if (!isShiftedInt<7, 0>(Value))
557 case Hexagon::A2_tfrsi:
568 if (!isShiftedUInt<6, 0>(Value))
580 MCInst const &MIa,
bool ExtendedA,
581 MCInst const &MIb,
bool ExtendedB,
590 if ((Opcode != Hexagon::A2_addi) && (Opcode != Hexagon::A2_tfrsi))
605 unsigned zeroedSubInstS0 =
607 unsigned zeroedSubInstS1 =
610 if (zeroedSubInstS0 < zeroedSubInstS1)
617 if (MIb.
getOpcode() == Hexagon::S2_allocframe)
712 case Hexagon::A2_addi:
740 case Hexagon::A2_add:
746 case Hexagon::S2_allocframe:
747 Result.
setOpcode(Hexagon::SS2_allocframe);
750 case Hexagon::A2_andir:
762 case Hexagon::C2_cmpeqi:
767 case Hexagon::A4_combineii:
768 case Hexagon::A2_combineii:
770 assert(Absolute);(void)Absolute;
772 Result.
setOpcode(Hexagon::SA1_combine1i);
778 Result.
setOpcode(Hexagon::SA1_combine3i);
784 Result.
setOpcode(Hexagon::SA1_combine0i);
790 Result.
setOpcode(Hexagon::SA1_combine2i);
796 case Hexagon::A4_combineir:
797 Result.
setOpcode(Hexagon::SA1_combinezr);
801 case Hexagon::A4_combineri:
802 Result.
setOpcode(Hexagon::SA1_combinerz);
806 case Hexagon::L4_return_tnew_pnt:
807 case Hexagon::L4_return_tnew_pt:
808 Result.
setOpcode(Hexagon::SL2_return_tnew);
810 case Hexagon::L4_return_fnew_pnt:
811 case Hexagon::L4_return_fnew_pt:
812 Result.
setOpcode(Hexagon::SL2_return_fnew);
814 case Hexagon::L4_return_f:
817 case Hexagon::L4_return_t:
820 case Hexagon::L4_return:
823 case Hexagon::L2_deallocframe:
824 Result.
setOpcode(Hexagon::SL2_deallocframe);
826 case Hexagon::EH_RETURN_JMPR:
827 case Hexagon::J2_jumpr:
828 case Hexagon::PS_jmpret:
831 case Hexagon::J2_jumprf:
832 case Hexagon::PS_jmpretf:
833 Result.
setOpcode(Hexagon::SL2_jumpr31_f);
835 case Hexagon::J2_jumprfnew:
836 case Hexagon::J2_jumprfnewpt:
837 case Hexagon::PS_jmpretfnewpt:
838 case Hexagon::PS_jmpretfnew:
839 Result.
setOpcode(Hexagon::SL2_jumpr31_fnew);
841 case Hexagon::J2_jumprt:
842 case Hexagon::PS_jmprett:
843 Result.
setOpcode(Hexagon::SL2_jumpr31_t);
845 case Hexagon::J2_jumprtnew:
846 case Hexagon::J2_jumprtnewpt:
847 case Hexagon::PS_jmprettnewpt:
848 case Hexagon::PS_jmprettnew:
849 Result.
setOpcode(Hexagon::SL2_jumpr31_tnew);
851 case Hexagon::L2_loadrb_io:
852 Result.
setOpcode(Hexagon::SL2_loadrb_io);
857 case Hexagon::L2_loadrd_io:
858 Result.
setOpcode(Hexagon::SL2_loadrd_sp);
862 case Hexagon::L2_loadrh_io:
863 Result.
setOpcode(Hexagon::SL2_loadrh_io);
868 case Hexagon::L2_loadrub_io:
869 Result.
setOpcode(Hexagon::SL1_loadrub_io);
874 case Hexagon::L2_loadruh_io:
875 Result.
setOpcode(Hexagon::SL2_loadruh_io);
880 case Hexagon::L2_loadri_io:
882 Result.
setOpcode(Hexagon::SL2_loadri_sp);
887 Result.
setOpcode(Hexagon::SL1_loadri_io);
893 case Hexagon::S4_storeirb_io:
895 assert(Absolute);(void)Absolute;
901 }
else if (Value == 1) {
908 case Hexagon::S2_storerb_io:
909 Result.
setOpcode(Hexagon::SS1_storeb_io);
914 case Hexagon::S2_storerd_io:
915 Result.
setOpcode(Hexagon::SS2_stored_sp);
919 case Hexagon::S2_storerh_io:
920 Result.
setOpcode(Hexagon::SS2_storeh_io);
925 case Hexagon::S4_storeiri_io:
927 assert(Absolute);(void)Absolute;
933 }
else if (Value == 1) {
939 Result.
setOpcode(Hexagon::SS2_storew_sp);
945 case Hexagon::S2_storeri_io:
947 Result.
setOpcode(Hexagon::SS2_storew_sp);
951 Result.
setOpcode(Hexagon::SS1_storew_io);
957 case Hexagon::A2_sxtb:
962 case Hexagon::A2_sxth:
967 case Hexagon::A2_tfr:
972 case Hexagon::C2_cmovenewif:
977 case Hexagon::C2_cmovenewit:
982 case Hexagon::C2_cmoveif:
987 case Hexagon::C2_cmoveit:
992 case Hexagon::A2_tfrsi:
994 if (Absolute && Value == -1) {
1005 case Hexagon::A2_zxtb:
1011 case Hexagon::A2_zxth:
1022 case Hexagon::S2_storeri_io:
1023 case Hexagon::S2_storerb_io:
1024 case Hexagon::S2_storerh_io:
1025 case Hexagon::S2_storerd_io:
1026 case Hexagon::S4_storeiri_io:
1027 case Hexagon::S4_storeirb_io:
1028 case Hexagon::S2_allocframe:
1044 for (
unsigned distance = 1; distance < numInstrInPacket; ++distance) {
1047 (j < numInstrInPacket) && (k < numInstrInPacket); ++j, ++k) {
1050 bool bisReversable =
true;
1053 LLVM_DEBUG(
dbgs() <<
"skip out of order write pair: " << k <<
"," << j
1055 bisReversable =
false;
1058 bisReversable =
false;
1066 bisReversable, STI)) {
1085 if (bisReversable) {
1091 bisReversable, STI)) {
1100 <<
"adding pair:" << k <<
"," << j <<
":" 1105 <<
"skipping pair: " << k <<
"," << j <<
":"
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.
This class represents lattice values for constants.
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.
void push_back(const T &Elt)
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.