15 #define DEBUG_TYPE "hexagon-shuffle"
35 enum { MAX = 360360 };
43 bool isSold()
const {
return (Bid >= MAX); };
61 bool bid(
unsigned B) {
63 unsigned b = B & ~isSold;
69 isSold |= Scores[i].isSold() << i;
80 const unsigned SlotWeight = 8;
81 const unsigned MaskWeight = SlotWeight - 1;
85 assert(SlotWeight * s < 32 &&
"Argument to setWeight too large.");
98 : MCII(MCII), STI(STI) {
109 unsigned S,
bool X) {
118 const unsigned slotSingleLoad = 0x1, slotSingleStore = 0x1, slotOne = 0x2,
119 slotThree = 0x8, slotFirstJump = 0x8, slotLastJump = 0x4,
120 slotFirstLoadStore = 0x2, slotLastLoadStore = 0x1;
122 unsigned slotJump = slotFirstJump;
123 unsigned slotLoadStore = slotFirstLoadStore;
125 unsigned jumps = 0, jump1 = 0, jumpr = 0;
128 unsigned memory = 0, loads = 0, load0 = 0, stores = 0, store0 = 0, store1 = 0;
130 unsigned duplex = 0, solo = 0;
133 unsigned onlyAX = 0, neitherAnorX = 0;
135 unsigned onlyAin1 = 0;
137 unsigned onlyNo1 = 0;
138 unsigned xtypeFloat = 0;
139 unsigned pSlot3Cnt = 0;
147 solo += !ISJ->isSoloException();
149 onlyAX += !ISJ->isSoloException();
151 onlyAin1 += !ISJ->isSoloException();
174 if (ISJ->Core.getUnits() == slotSingleLoad)
182 if (ISJ->Core.getUnits() == slotSingleStore)
206 if ((load0 > 1 || store0 > 1) || (duplex > 1 || (duplex && memory)) ||
207 (solo &&
size() > 1) || (onlyAX && neitherAnorX > 1) ||
208 (onlyAX && xtypeFloat)) {
213 if (jump1 && jumps > 1) {
221 bool bOnlySlot3 =
false;
225 if (!ISJ->Core.getUnits()) {
234 ISJ->Core.setUnits(ISJ->Core.getUnits() & ~slotOne);
239 ISJ->Core.setUnits(ISJ->Core.getUnits() & ~slotOne);
245 if (jumpr || slotJump < slotLastJump) {
252 ISJ->Core.setUnits(ISJ->Core.getUnits() & slotJump);
259 if (loads == 1 && loads == memory)
261 ISJ->Core.setUnits(ISJ->Core.getUnits() & slotSingleLoad);
268 ISJ->Core.setUnits(ISJ->Core.getUnits() & slotSingleStore);
269 else if (stores > 1) {
270 if (slotLoadStore < slotLastLoadStore) {
276 ISJ->Core.setUnits(ISJ->Core.getUnits() & slotLoadStore);
281 if (store1 && stores > 1) {
289 if (ISJ->Core.getUnits() == slotThree)
292 if (!ISJ->Core.getUnits()) {
299 bool validateSlots =
true;
300 if (bOnlySlot3 ==
false && pSlot3Cnt == 1 && slot3ISJ !=
end()) {
303 unsigned saveUnits = slot3ISJ->Core.getUnits();
304 slot3ISJ->Core.setUnits(saveUnits & slotThree);
312 if (!AuctionCore.
bid(
I->Core.getUnits()))
317 validateSlots =
false;
322 ISJ->Core.setUnits(saveUnits);
334 if (!AuctionCore.
bid(
I->Core.getUnits())) {
358 unsigned slotSkip, slotWeight;
361 for (ISJ = ISK = Packet.
begin(), slotSkip = slotWeight = 0;
362 ISK != Packet.
end(); ++ISK, ++slotSkip)
363 if (slotSkip < nSlot - emptySlots)
368 slotWeight += ISK->Core.setWeight(HEXAGON_PACKET_SIZE - nSlot - 1);
373 std::sort(ISJ, Packet.
end());
bool isSoloAin1(MCInstrInfo const &MCII, MCInst const &MCI)
Return whether the insn can be packaged only with an A-type insn in slot #1.
void push_back(const T &Elt)
static bool lessCore(const HexagonInstr &A, const HexagonInstr &B)
unsigned getError() const
bool isReturn() const
Return true if the instruction is a return.
bool mayStore() const
Return true if this instruction could possibly modify memory.
bool isSolo(MCInstrInfo const &MCII, MCInst const &MCI)
HexagonBid & operator+=(const HexagonBid &B)
unsigned setWeight(unsigned s)
No free slots for store insns.
#define HEXAGON_PACKET_SIZE
bool isBranch() const
Returns true if this is a conditional, unconditional, or indirect branch.
bool isCall() const
Return true if the instruction is a call.
HexagonShuffler(MCInstrInfo const &MCII, MCSubtargetInfo const &STI)
unsigned getUnits() const
raw_ostream & write_hex(unsigned long long N)
Output N in hexadecimal, without any prefix or padding.
Instances of this class represent a single low-level machine instruction.
std::size_t countTrailingZeros(T Val, ZeroBehavior ZB=ZB_Width)
Count number of 0's from the least significant bit to the most stopping at the first 1...
Interface to description of machine instruction set.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
bool prefersSlot3(MCInstrInfo const &MCII, MCInst const &MCI)
unsigned getOpcode() const
Return the opcode number for this descriptor.
void append(MCInst const *ID, MCInst const *Extender, unsigned S, bool X=false)
unsigned countPopulation(T Value)
Count the number of set bits in a value.
No free slots for branch insns.
bool mayLoad() const
Return true if this instruction could possibly read memory.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isSoloAX(MCInstrInfo const &MCII, MCInst const &MCI)
Return whether the insn can be packaged only with A and X-type insns.
MCSubtargetInfo - Generic base class for all target subtargets.
MCInstrDesc const & getDesc(MCInstrInfo const &MCII, MCInst const &MCI)
bool isFloat(MCInstrInfo const &MCII, MCInst const &MCI)
Return whether it is a floating-point insn.
unsigned getType(MCInstrInfo const &MCII, MCInst const &MCI)
No free slots for other insns.
bool check()
Check that the packet is legal and enforce relative insn order.