46 #define DEBUG_TYPE "hexinsert" 99 unsigned find_first()
const {
106 unsigned find_next(
unsigned Prev)
const {
114 unsigned Idx = v2x(R);
119 unsigned Idx = v2x(R);
132 reference operator[](
unsigned R) {
133 unsigned Idx = v2x(R);
137 bool operator[](
unsigned R)
const {
138 unsigned Idx = v2x(R);
142 bool has(
unsigned R)
const {
143 unsigned Idx = v2x(R);
154 return !Rs.BitVector::test(*
this);
161 void ensure(
unsigned Idx) {
166 static inline unsigned v2x(
unsigned v) {
170 static inline unsigned x2v(
unsigned x) {
180 const PrintRegSet &
P);
189 for (
unsigned R = P.RS.find_first(); R; R = P.RS.find_next(R))
197 struct UnsignedMap :
public DenseMap<unsigned,unsigned> {
198 UnsignedMap() =
default;
209 struct RegisterOrdering :
public UnsignedMap {
210 RegisterOrdering() =
default;
212 unsigned operator[](
unsigned VR)
const {
213 const_iterator
F =
find(VR);
220 bool operator() (
unsigned VR1,
unsigned VR2)
const {
221 return operator[](VR1) < operator[](VR2);
231 struct BitValueOrdering {
232 BitValueOrdering(
const RegisterOrdering &RB) : BaseOrd(RB) {}
237 const RegisterOrdering &BaseOrd;
247 if (V1.
is(0) || V2.
is(0))
251 if (V2.
is(1) || V1.
is(1))
254 unsigned Ind1 = BaseOrd[V1.
RefI.
Reg], Ind2 = BaseOrd[V2.
RefI.
Reg];
267 struct CellMapShadow {
273 if (RInd >= CVect.size())
274 CVect.resize(
std::max(RInd+16, 32U),
nullptr);
284 using CellVectType = std::vector<const BitTracker::RegisterCell *>;
291 struct RegisterCellLexCompare {
292 RegisterCellLexCompare(
const BitValueOrdering &BO, CellMapShadow &M)
293 : BitOrd(BO), CM(M) {}
295 bool operator() (
unsigned VR1,
unsigned VR2)
const;
298 const BitValueOrdering &BitOrd;
308 struct RegisterCellBitCompareSel {
309 RegisterCellBitCompareSel(
unsigned R,
unsigned B,
unsigned N,
310 const BitValueOrdering &BO, CellMapShadow &M)
311 : SelR(R), SelB(B), BitN(N), BitOrd(BO), CM(M) {}
313 bool operator() (
unsigned VR1,
unsigned VR2)
const;
316 const unsigned SelR, SelB;
318 const BitValueOrdering &BitOrd;
324 bool RegisterCellLexCompare::operator() (
unsigned VR1,
unsigned VR2)
const {
338 uint16_t W1 = RC1.
width(), W2 = RC2.width();
339 for (uint16_t i = 0, w = std::min(W1, W2); i < w; ++i) {
342 return BitOrd(V1, V2);
348 return BitOrd.BaseOrd[VR1] < BitOrd.BaseOrd[VR2];
351 bool RegisterCellBitCompareSel::operator() (
unsigned VR1,
unsigned VR2)
const {
357 uint16_t Bit1 = (VR1 == SelR) ? SelB : BitN;
358 uint16_t Bit2 = (VR2 == SelR) ? SelB : BitN;
372 return BitOrd(V1, V2);
378 class OrderedRegisterList {
379 using ListType = std::vector<unsigned>;
380 const unsigned MaxSize;
383 OrderedRegisterList(
const RegisterOrdering &RO)
386 void insert(
unsigned VR);
387 void remove(
unsigned VR);
389 unsigned operator[](
unsigned Idx)
const {
394 unsigned size()
const {
398 using iterator = ListType::iterator;
399 using const_iterator = ListType::const_iterator;
402 iterator
end() {
return Seq.
end(); }
403 const_iterator
begin()
const {
return Seq.
begin(); }
404 const_iterator
end()
const {
return Seq.
end(); }
407 unsigned idx(iterator It)
const {
return It-
begin(); }
411 const RegisterOrdering &Ord;
421 const OrderedRegisterList &RL;
427 OrderedRegisterList::const_iterator
B = P.RL.begin(),
E = P.RL.end();
428 for (OrderedRegisterList::const_iterator
I = B;
I !=
E; ++
I) {
439 void OrderedRegisterList::insert(
unsigned VR) {
446 unsigned S = Seq.size();
449 assert(Seq.size() <= MaxSize);
464 IFRecord(
unsigned SR = 0,
unsigned IR = 0, uint16_t
W = 0, uint16_t
O = 0)
465 : SrcR(SR), InsR(
IR), Wdh(
W), Off(
O) {}
483 unsigned SrcR = P.IFR.SrcR, InsR = P.IFR.InsR;
485 <<
",#" << P.IFR.Wdh <<
",#" << P.IFR.Off <<
')';
489 using IFRecordWithRegSet = std::pair<IFRecord, RegisterSet>;
511 return "Hexagon generate \"insert\" instructions";
525 void buildOrderingMF(RegisterOrdering &RO)
const;
526 void buildOrderingBT(RegisterOrdering &RB, RegisterOrdering &RO)
const;
529 bool isSmallConstant(
unsigned VR)
const;
530 bool isValidInsertForm(
unsigned DstR,
unsigned SrcR,
unsigned InsR,
531 uint16_t L, uint16_t S)
const;
532 bool findSelfReference(
unsigned VR)
const;
533 bool findNonSelfReference(
unsigned VR)
const;
538 PairMapType &M)
const;
541 PairMapType &M)
const;
542 bool findRecordInsertForms(
unsigned VR, OrderedRegisterList &AVs);
544 void findRemovableRegisters(
unsigned VR, IFRecord
IF,
546 void computeRemovableRegisters();
548 void pruneEmptyLists();
549 void pruneCoveredSets(
unsigned VR);
550 void pruneUsesTooFar(
unsigned VR,
const UnsignedMap &RPO, PairMapType &M);
551 void pruneRegCopies(
unsigned VR);
552 void pruneCandidates();
553 void selectCandidates();
554 bool generateInserts();
559 using IFListType = std::vector<IFRecordWithRegSet>;
562 void dump_map()
const;
572 RegisterOrdering BaseOrd;
573 RegisterOrdering CellOrd;
581 void HexagonGenInsert::dump_map()
const {
582 using iterator = IFMapType::const_iterator;
584 for (iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
586 const IFListType &LL =
I->second;
587 for (
unsigned i = 0, n = LL.size(); i < n; ++i)
588 dbgs() <<
" " << PrintIFR(LL[i].
first, HRI) <<
", " 589 << PrintRegSet(LL[i].
second, HRI) <<
'\n';
593 void HexagonGenInsert::buildOrderingMF(RegisterOrdering &RO)
const {
598 for (mf_iterator A = MFN->begin(),
Z = MFN->end(); A !=
Z; ++A) {
600 if (!CMS->BT.reached(&B))
613 RO.insert(std::make_pair(R, Index++));
623 void HexagonGenInsert::buildOrderingBT(RegisterOrdering &RB,
624 RegisterOrdering &RO)
const {
627 BitValueOrdering BVO(RB);
628 RegisterCellLexCompare LexCmp(BVO, *CMS);
630 using SortableVectorType = std::vector<unsigned>;
632 SortableVectorType VRs;
633 for (RegisterOrdering::iterator
I = RB.begin(),
E = RB.end();
I !=
E; ++
I)
634 VRs.push_back(
I->first);
637 for (
unsigned i = 0, n = VRs.size(); i < n; ++i)
638 RO.insert(std::make_pair(VRs[i], i));
642 return RC == &Hexagon::IntRegsRegClass || RC == &Hexagon::DoubleRegsRegClass;
648 for (uint16_t i = 0; i <
W; ++i) {
650 if (BV.
is(0) || BV.
is(1))
657 bool HexagonGenInsert::isSmallConstant(
unsigned VR)
const {
662 uint64_t V = 0,
B = 1;
663 for (uint16_t i = 0; i <
W; ++i) {
680 bool HexagonGenInsert::isValidInsertForm(
unsigned DstR,
unsigned SrcR,
681 unsigned InsR, uint16_t L, uint16_t S)
const {
686 if (!isIntClass(DstRC) || !isIntClass(SrcRC) || !isIntClass(InsRC))
694 if (DstRC == &Hexagon::DoubleRegsRegClass)
697 if (S < 32 && S+L > 32)
702 bool HexagonGenInsert::findSelfReference(
unsigned VR)
const {
704 for (uint16_t i = 0, w = RC.
width(); i < w; ++i) {
712 bool HexagonGenInsert::findNonSelfReference(
unsigned VR)
const {
714 for (uint16_t i = 0, w = RC.
width(); i < w; ++i) {
735 void HexagonGenInsert::getInstrUses(
const MachineInstr *MI,
750 PairMapType &M)
const {
757 PairMapType::iterator
F = M.find(std::make_pair(FromN, ToN));
760 unsigned ToRPO = RPO.lookup(ToN);
771 if (PB == FromB || RPO.lookup(PB->
getNumber()) >= ToRPO)
773 unsigned D = PB->
size() + distance(FromB, PB, RPO, M);
779 M.insert(std::make_pair(std::make_pair(FromN, ToN), MaxD));
785 PairMapType &M)
const {
788 return std::distance(FromI, ToI);
789 unsigned D1 = std::distance(
TB->begin(), ToI);
790 unsigned D2 = distance(FB,
TB, RPO, M);
791 unsigned D3 = std::distance(FromI, FB->
end());
795 bool HexagonGenInsert::findRecordInsertForms(
unsigned VR,
796 OrderedRegisterList &AVs) {
799 <<
" AVs: " << PrintORL(AVs, HRI) <<
"\n";
804 using iterator = OrderedRegisterList::iterator;
806 BitValueOrdering BVO(BaseOrd);
810 using RSRecord = std::pair<unsigned, uint16_t>;
811 using RSListType = std::vector<RSRecord>;
821 for (uint16_t S = 0; S <
W; ++S) {
822 iterator
B = AVs.begin(),
E = AVs.end();
830 for (L = 0; L < W-S; ++L) {
833 RegisterCellBitCompareSel RCB(VR, S+L, L, BVO, *CMS);
841 for (iterator
I = B;
I != NewB; ++
I)
842 LM[L].push_back(std::make_pair(*
I, S));
843 for (iterator
I = NewE;
I !=
E; ++
I)
844 LM[L].push_back(std::make_pair(*
I, S));
854 for (iterator
I = B;
I !=
E; ++
I)
855 LM[L].push_back(std::make_pair(*
I, S));
863 dbgs() <<
"Prefixes matching register " <<
printReg(VR, HRI) <<
"\n";
864 for (LRSMapType::iterator
I = LM.begin(),
E = LM.end();
I !=
E; ++
I) {
865 dbgs() <<
" L=" <<
I->first <<
':';
866 const RSListType &LL =
I->second;
867 for (
unsigned i = 0, n = LL.size(); i < n; ++i)
869 << LL[i].second <<
')';
874 bool Recorded =
false;
876 for (iterator
I = AVs.begin(),
E = AVs.end();
I !=
E; ++
I) {
878 int FDi = -1, LDi = -1;
880 uint16_t AW = AC.
width();
881 for (uint16_t i = 0, w = std::min(W, AW); i < w; ++i) {
892 uint16_t FD = FDi,
LD = LDi;
893 uint16_t MinL = LD-FD+1;
894 for (uint16_t L = MinL; L <
W; ++L) {
895 LRSMapType::iterator
F = LM.find(L);
898 RSListType &LL = F->second;
899 for (
unsigned i = 0, n = LL.size(); i < n; ++i) {
900 uint16_t S = LL[i].second;
907 uint16_t EL = L-MinL;
908 uint16_t LowS = (EL < FD) ? FD-EL : 0;
911 unsigned InsR = LL[i].first;
912 if (!isValidInsertForm(VR, SrcR, InsR, L, S))
916 <<
',' <<
printReg(InsR, HRI) <<
",#" << L <<
",#" 919 IFRecordWithRegSet RR(IFRecord(SrcR, InsR, L, S),
RegisterSet());
920 IFMap[VR].push_back(RR);
930 OrderedRegisterList &AVs) {
936 if (!CMS->BT.reached(B))
947 getInstrDefs(MI, InsDefs);
954 for (
unsigned VR = InsDefs.find_first(); VR; VR = InsDefs.find_next(VR)) {
963 if (findSelfReference(VR) || isSmallConstant(VR))
966 findRecordInsertForms(VR, AVs);
975 for (
unsigned VR = InsDefs.find_first(); VR; VR = InsDefs.find_next(VR))
977 BlockDefs.insert(InsDefs);
980 for (
auto *DTN : children<MachineDomTreeNode*>(MDT->getNode(B))) {
982 collectInBlock(SB, AVs);
985 for (
unsigned VR = BlockDefs.find_first(); VR; VR = BlockDefs.find_next(VR))
989 void HexagonGenInsert::findRemovableRegisters(
unsigned VR, IFRecord
IF,
1000 while (!Regs[S].
empty()) {
1002 unsigned OtherS = 1-S;
1003 Regs[OtherS].clear();
1004 for (
unsigned R = Regs[S].find_first(); R; R = Regs[S].find_next(R)) {
1006 if (R == IF.SrcR || R == IF.InsR)
1018 if (!findNonSelfReference(R))
1028 getInstrUses(DefI, Regs[OtherS]);
1040 void HexagonGenInsert::computeRemovableRegisters() {
1041 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1042 IFListType &LL =
I->second;
1043 for (
unsigned i = 0, n = LL.size(); i < n; ++i)
1044 findRemovableRegisters(
I->first, LL[i].first, LL[i].second);
1048 void HexagonGenInsert::pruneEmptyLists() {
1053 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1054 if (
I->second.empty())
1057 for (
unsigned i = 0, n = Prune.size(); i < n; ++i)
1058 IFMap.erase(Prune[i]);
1061 void HexagonGenInsert::pruneCoveredSets(
unsigned VR) {
1062 IFMapType::iterator
F = IFMap.find(VR);
1063 assert(F != IFMap.end());
1064 IFListType &LL = F->second;
1074 bool DefEx = HII->isConstExtended(*DefVR);
1076 for (
unsigned i = 0, n = LL.size(); i < n; ++i) {
1077 if (LL[i].
second.empty())
1082 if (!DefEx || HasNE) {
1085 auto IsEmpty = [] (
const IFRecordWithRegSet &
IR) ->
bool {
1086 return IR.second.empty();
1089 if (End != LL.end())
1090 LL.erase(End, LL.end());
1097 IFRecord MaxIF = LL[0].first;
1098 for (
unsigned i = 1, n = LL.size(); i < n; ++i) {
1100 const IFRecord &IF = LL[i].first;
1101 unsigned M0 = BaseOrd[MaxIF.SrcR], M1 = BaseOrd[MaxIF.InsR];
1102 unsigned R0 = BaseOrd[IF.SrcR], R1 = BaseOrd[IF.InsR];
1109 if (MaxIF.Wdh > IF.Wdh)
1111 if (MaxIF.Wdh == IF.Wdh && MaxIF.Off >= IF.Off)
1121 LL.push_back(std::make_pair(MaxIF,
RegisterSet()));
1131 for (
unsigned i = 0, n = LL.size(); i < n; ) {
1135 if (j != i && LL[j].
second.includes(RMi))
1143 LL.erase(LL.begin()+i);
1148 void HexagonGenInsert::pruneUsesTooFar(
unsigned VR,
const UnsignedMap &RPO,
1150 IFMapType::iterator
F = IFMap.find(VR);
1151 assert(F != IFMap.end());
1152 IFListType &LL = F->second;
1156 for (
unsigned i = LL.size(); i > 0; --i) {
1157 unsigned SR = LL[i-1].first.SrcR,
IR = LL[i-1].first.InsR;
1160 unsigned DSV = distance(DefS, DefV, RPO, M);
1162 unsigned DIV = distance(DefI, DefV, RPO, M);
1166 LL.erase(LL.begin()+(i-1));
1170 void HexagonGenInsert::pruneRegCopies(
unsigned VR) {
1171 IFMapType::iterator
F = IFMap.find(VR);
1172 assert(F != IFMap.end());
1173 IFListType &LL = F->second;
1175 auto IsCopy = [] (
const IFRecordWithRegSet &
IR) ->
bool {
1176 return IR.first.Wdh == 32 && (
IR.first.Off == 0 ||
IR.first.Off == 32);
1179 if (End != LL.end())
1180 LL.erase(End, LL.end());
1183 void HexagonGenInsert::pruneCandidates() {
1188 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I)
1189 pruneCoveredSets(
I->first);
1197 for (RPOTType::rpo_iterator
I = RPOT.begin(),
E = RPOT.end();
I !=
E; ++
I)
1198 RPO[(*I)->getNumber()] = RPON++;
1202 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I)
1203 pruneUsesTooFar(
I->first, RPO, Memo);
1207 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I)
1208 pruneRegCopies(
I->first);
1222 IFOrdering(
const UnsignedMap &UC,
const RegisterOrdering &BO)
1223 : UseC(UC), BaseOrd(BO) {}
1225 bool operator() (
const IFRecordWithRegSet &A,
1226 const IFRecordWithRegSet &B)
const;
1230 unsigned &Sum)
const;
1232 const UnsignedMap &UseC;
1233 const RegisterOrdering &BaseOrd;
1238 bool IFOrdering::operator() (
const IFRecordWithRegSet &A,
1239 const IFRecordWithRegSet &B)
const {
1240 unsigned SizeA = 0, ZeroA = 0, SumA = 0;
1241 unsigned SizeB = 0, ZeroB = 0, SumB = 0;
1242 stats(A.second, SizeA, ZeroA, SumA);
1243 stats(B.second, SizeB, ZeroB, SumB);
1247 return ZeroA > ZeroB;
1249 uint64_t AvgA = SumA*SizeB, AvgB = SumB*SizeA;
1255 unsigned OSA = BaseOrd[A.first.SrcR], OSB = BaseOrd[B.first.SrcR];
1258 unsigned OIA = BaseOrd[A.first.InsR], OIB = BaseOrd[B.first.InsR];
1261 if (A.first.Wdh != B.first.Wdh)
1262 return A.first.Wdh < B.first.Wdh;
1263 return A.first.Off < B.first.Off;
1267 unsigned &Sum)
const {
1268 for (
unsigned R = Rs.find_first(); R; R = Rs.find_next(R)) {
1269 UnsignedMap::const_iterator
F = UseC.find(R);
1271 unsigned UC = F->second;
1279 void HexagonGenInsert::selectCandidates() {
1287 UnsignedMap UseC, RemC;
1288 IFMapType::iterator End = IFMap.end();
1290 for (IFMapType::iterator
I = IFMap.begin();
I != End; ++
I) {
1291 const IFListType &LL =
I->second;
1293 for (
unsigned i = 0, n = LL.size(); i < n; ++i)
1294 TT.insert(LL[i].second);
1295 for (
unsigned R = TT.find_first(); R; R = TT.find_next(R))
1300 for (
unsigned R = AllRMs.find_first(); R; R = AllRMs.find_next(R)) {
1307 use_iterator
E =
MRI->use_nodbg_end();
1308 for (use_iterator
I =
MRI->use_nodbg_begin(R);
I !=
E; ++
I)
1309 UIs.insert(
I->getParent());
1310 unsigned C = UIs.size();
1313 unsigned D = RemC[R];
1314 UseC[R] = (C >
D) ? C-D : 0;
1318 if (!SelectAll0 && !SelectHas0)
1326 IFOrdering IFO(UseC, BaseOrd);
1327 for (IFMapType::iterator
I = IFMap.begin();
I != End; ++
I) {
1328 IFListType &LL =
I->second;
1335 IFListType::iterator MinI = std::min_element(LL.begin(), LL.end(), IFO);
1336 assert(MinI != LL.end());
1337 IFRecordWithRegSet M = *MinI;
1348 getInstrUses(DefI, Us);
1349 bool Accept =
false;
1353 for (
unsigned R = Us.find_first(); R; R = Us.find_next(R)) {
1360 }
else if (SelectHas0) {
1362 for (
unsigned R = Us.find_first(); R; R = Us.find_next(R)) {
1379 for (IFMapType::iterator
I = IFMap.begin();
I != End; ++
I) {
1380 const IFListType &LL =
I->second;
1382 AllRMs.insert(LL[0].second);
1384 for (IFMapType::iterator
I = IFMap.begin();
I != End; ++
I) {
1385 IFListType &LL =
I->second;
1388 unsigned SR = LL[0].first.SrcR,
IR = LL[0].first.InsR;
1389 if (AllRMs[SR] || AllRMs[
IR])
1396 bool HexagonGenInsert::generateInserts() {
1400 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1401 unsigned VR =
I->first;
1403 unsigned NewVR =
MRI->createVirtualRegister(RC);
1410 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1414 unsigned NewR = RegMap[
I->first];
1415 bool R32 =
MRI->getRegClass(NewR) == &Hexagon::IntRegsRegClass;
1416 const MCInstrDesc &
D = R32 ? HII->get(Hexagon::S2_insert)
1417 : HII->get(Hexagon::S2_insertp);
1418 IFRecord IF =
I->second[0].first;
1419 unsigned Wdh = IF.Wdh, Off = IF.Off;
1421 if (R32 &&
MRI->getRegClass(IF.InsR) == &Hexagon::DoubleRegsRegClass) {
1422 InsS = Hexagon::isub_lo;
1424 InsS = Hexagon::isub_hi;
1436 .
addReg(IF.InsR, 0, InsS)
1440 MRI->clearKillFlags(IF.SrcR);
1441 MRI->clearKillFlags(IF.InsR);
1444 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1446 MRI->replaceRegWith(
I->first, RegMap[
I->first]);
1454 bool Changed =
false;
1456 for (
auto *DTN : children<MachineDomTreeNode*>(N))
1457 Changed |= removeDeadCode(DTN);
1460 std::vector<MachineInstr*> Instrs;
1462 Instrs.push_back(&*
I);
1464 for (
auto I = Instrs.begin(),
E = Instrs.end();
I !=
E; ++
I) {
1476 bool AllDead =
true;
1479 if (!MO.isReg() || !MO.isDef())
1481 unsigned R = MO.getReg();
1483 !
MRI->use_nodbg_empty(R)) {
1493 for (
unsigned I = 0, N = Regs.
size();
I !=
N; ++
I)
1494 MRI->markUsesInDebugValueAsUndef(Regs[
I]);
1506 bool Changed =
false;
1516 HII =
ST.getInstrInfo();
1517 HRI =
ST.getRegisterInfo();
1520 MDT = &getAnalysis<MachineDominatorTree>();
1527 Changed = removeDeadCode(MDT->getRootNode());
1533 CellMapShadow MS(BTLoc);
1536 buildOrderingMF(BaseOrd);
1537 buildOrderingBT(BaseOrd, CellOrd);
1540 dbgs() <<
"Cell ordering:\n";
1541 for (RegisterOrdering::iterator
I = CellOrd.begin(),
E = CellOrd.end();
1543 unsigned VR =
I->first, Pos =
I->second;
1550 OrderedRegisterList AvailR(CellOrd);
1552 const char *
const TGName =
"hexinsert";
1553 const char *
const TGDesc =
"Generate Insert Instructions";
1558 collectInBlock(RootB, AvailR);
1560 computeRemovableRegisters();
1564 dbgs() <<
"Candidates after collection:\n";
1577 dbgs() <<
"Candidates after pruning:\n";
1585 NamedRegionTimer _T(
"selection",
"selection", TGName, TGDesc, TimingDetail);
1590 dbgs() <<
"Candidates after selection:\n";
1601 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1606 for (
unsigned i = 0, n = Out.size(); i < n; ++i)
1607 IFMap.erase(Out[i]);
1622 return new HexagonGenInsert();
1630 "Hexagon generate \"insert\" instructions",
false,
false)
static cl::opt< bool > OptSelectHas0("insert-has0", cl::init(false), cl::Hidden, cl::ZeroOrMore)
const_iterator end(StringRef path)
Get end iterator over path.
static bool isConstant(const MachineInstr &MI)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
void initializeHexagonGenInsertPass(PassRegistry &)
void trace(bool On=false)
static unsigned virtReg2Index(unsigned Reg)
Convert a virtual register number to a 0-based index.
This class represents lattice values for constants.
static unsigned index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
static cl::opt< unsigned > VRegDistCutoff("insert-dist-cutoff", cl::init(30U), cl::Hidden, cl::ZeroOrMore, cl::desc("Vreg distance cutoff for insert " "generation."))
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
constexpr uint32_t Lo_32(uint64_t Value)
Return the low 32 bits of a 64 bit value.
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Describe properties that are true of each instruction in the target description file.
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
unsigned getSubReg() const
bool test(unsigned Idx) const
bool isRegSequence() const
constexpr bool isInt< 8 >(int64_t x)
constexpr bool isInt< 16 >(int64_t x)
unsigned const TargetRegisterInfo * TRI
MachineInstrBundleIterator< const MachineInstr > const_iterator
INITIALIZE_PASS_BEGIN(HexagonGenInsert, "hexinsert", "Hexagon generate \nsert\instructions", false, false) INITIALIZE_PASS_END(HexagonGenInsert
std::vector< MachineBasicBlock * >::const_iterator const_pred_iterator
iterator_range< mop_iterator > operands()
BasicBlockListType::const_iterator const_iterator
static cl::opt< bool > OptTiming("insert-timing", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Enable timing of insert generation"))
AnalysisUsage & addRequired()
#define INITIALIZE_PASS_DEPENDENCY(depName)
void clear()
clear - Removes all bits from the bitvector. Does not change capacity.
instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
Printable printMBBReference(const MachineBasicBlock &MBB)
Prints a machine basic block reference.
unsigned getNumOperands() const
Retuns the total number of operands.
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
int find_first() const
find_first - Returns the index of the first set bit, -1 if none of the bits are set.
This class is basically a combination of TimeRegion and Timer.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
std::set< RegisterRef > RegisterSet
int find_next(unsigned Prev) const
find_next - Returns the index of the next set bit following the "Prev" bit.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
friend const_iterator begin(StringRef path, Style style)
Get begin iterator over path.
static const uint16_t * lookup(unsigned opcode, unsigned domain, ArrayRef< uint16_t[3]> Table)
zlib-gnu style compression
defusechain_iterator< true, false, true, true, false, false > use_nodbg_iterator
use_nodbg_iterator/use_nodbg_begin/use_nodbg_end - Walk all uses of the specified register...
BitVector & operator|=(const BitVector &RHS)
static cl::opt< unsigned > MaxORLSize("insert-max-orl", cl::init(4096), cl::Hidden, cl::ZeroOrMore, cl::desc("Maximum size of OrderedRegisterList"))
Base class for the actual dominator tree node.
auto lower_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
reverse_iterator rbegin()
This corresponds to the llvm.lifetime.
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
initializer< Ty > init(const Ty &Val)
friend const_iterator end(StringRef path)
Get end iterator over path.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
bool anyCommon(const BitVector &RHS) const
Test if any common bits are set.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const RegisterCell & lookup(unsigned Reg) const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
bool any() const
any - Returns true if any bit is set.
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
auto remove_if(R &&Range, UnaryPredicate P) -> decltype(adl_begin(Range))
Provide wrappers to std::remove_if which take ranges instead of having to pass begin/end explicitly...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
pred_iterator pred_begin()
auto find(R &&Range, const T &Val) -> decltype(adl_begin(Range))
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly...
INITIALIZE_PASS_END(RegBankSelect, DEBUG_TYPE, "Assign register bank of generic virtual registers", false, false) RegBankSelect
void sort(IteratorTy Start, IteratorTy End)
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
static cl::opt< unsigned > MaxIFMSize("insert-max-ifmap", cl::init(1024), cl::Hidden, cl::ZeroOrMore, cl::desc("Maximum size of IFMap"))
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
reference operator[](unsigned Idx)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
bool is(unsigned T) const
FunctionPass * createHexagonGenInsert()
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static cl::opt< bool > OptConst("insert-const", cl::init(false), cl::Hidden, cl::ZeroOrMore)
iterator getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
static cl::opt< unsigned > VRegIndexCutoff("insert-vreg-cutoff", cl::init(~0U), cl::Hidden, cl::ZeroOrMore, cl::desc("Vreg# cutoff for insert generation."))
bool isReg() const
isReg - Tests if this is a MO_Register operand.
auto upper_bound(R &&Range, ForwardIt I) -> decltype(adl_begin(Range))
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
rpo Deduce function attributes in RPO
This class implements an extremely fast bulk output stream that can only output to a stream...
StringRef - Represent a constant reference to a string, i.e.
inst_range instructions(Function *F)
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
static cl::opt< bool > OptTimingDetail("insert-timing-detail", cl::init(false), cl::Hidden, cl::ZeroOrMore, cl::desc("Enable detailed timing of insert " "generation"))
static cl::opt< bool > OptSelectAll0("insert-all0", cl::init(false), cl::Hidden, cl::ZeroOrMore)
const MachineOperand & getOperand(unsigned i) const
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
bool isSafeToMove(AliasAnalysis *AA, bool &SawStore) const
Return true if it is safe to move this instruction.
Statically lint checks LLVM IR
bool DebugFlag
This boolean is set to true if the '-debug' command line option is specified.
bool isCurrentDebugType(const char *Type)
isCurrentDebugType - Return true if the specified string is the debug type specified on the command l...