46 #define DEBUG_TYPE "hexinsert" 103 unsigned find_first()
const {
110 unsigned find_next(
unsigned Prev)
const {
118 unsigned Idx = v2x(R);
123 unsigned Idx = v2x(R);
136 reference operator[](
unsigned R) {
137 unsigned Idx = v2x(R);
141 bool operator[](
unsigned R)
const {
142 unsigned Idx = v2x(R);
146 bool has(
unsigned R)
const {
147 unsigned Idx = v2x(R);
158 return !Rs.BitVector::test(*
this);
165 void ensure(
unsigned Idx) {
170 static inline unsigned v2x(
unsigned v) {
174 static inline unsigned x2v(
unsigned x) {
184 const PrintRegSet &
P);
193 for (
unsigned R = P.RS.find_first(); R; R = P.RS.find_next(R))
201 struct UnsignedMap :
public DenseMap<unsigned,unsigned> {
202 UnsignedMap() =
default;
213 struct RegisterOrdering :
public UnsignedMap {
214 RegisterOrdering() =
default;
216 unsigned operator[](
unsigned VR)
const {
217 const_iterator
F =
find(VR);
224 bool operator() (
unsigned VR1,
unsigned VR2)
const {
225 return operator[](VR1) < operator[](VR2);
235 struct BitValueOrdering {
236 BitValueOrdering(
const RegisterOrdering &RB) : BaseOrd(RB) {}
241 const RegisterOrdering &BaseOrd;
251 if (V1.
is(0) || V2.
is(0))
255 if (V2.
is(1) || V1.
is(1))
258 unsigned Ind1 = BaseOrd[V1.
RefI.
Reg], Ind2 = BaseOrd[V2.
RefI.
Reg];
271 struct CellMapShadow {
277 if (RInd >= CVect.size())
278 CVect.resize(
std::max(RInd+16, 32U),
nullptr);
288 using CellVectType = std::vector<const BitTracker::RegisterCell *>;
295 struct RegisterCellLexCompare {
296 RegisterCellLexCompare(
const BitValueOrdering &BO, CellMapShadow &M)
297 : BitOrd(BO), CM(M) {}
299 bool operator() (
unsigned VR1,
unsigned VR2)
const;
302 const BitValueOrdering &BitOrd;
312 struct RegisterCellBitCompareSel {
313 RegisterCellBitCompareSel(
unsigned R,
unsigned B,
unsigned N,
314 const BitValueOrdering &BO, CellMapShadow &M)
315 : SelR(R), SelB(B), BitN(N), BitOrd(BO), CM(M) {}
317 bool operator() (
unsigned VR1,
unsigned VR2)
const;
320 const unsigned SelR, SelB;
322 const BitValueOrdering &BitOrd;
328 bool RegisterCellLexCompare::operator() (
unsigned VR1,
unsigned VR2)
const {
343 for (
uint16_t i = 0, w = std::min(W1, W2); i < w; ++i) {
346 return BitOrd(V1, V2);
352 return BitOrd.BaseOrd[VR1] < BitOrd.BaseOrd[VR2];
355 bool RegisterCellBitCompareSel::operator() (
unsigned VR1,
unsigned VR2)
const {
361 uint16_t Bit1 = (VR1 == SelR) ? SelB : BitN;
362 uint16_t Bit2 = (VR2 == SelR) ? SelB : BitN;
376 return BitOrd(V1, V2);
382 class OrderedRegisterList {
383 using ListType = std::vector<unsigned>;
384 const unsigned MaxSize;
387 OrderedRegisterList(
const RegisterOrdering &RO)
390 void insert(
unsigned VR);
391 void remove(
unsigned VR);
393 unsigned operator[](
unsigned Idx)
const {
398 unsigned size()
const {
402 using iterator = ListType::iterator;
403 using const_iterator = ListType::const_iterator;
405 iterator
begin() {
return Seq.begin(); }
406 iterator
end() {
return Seq.end(); }
407 const_iterator
begin()
const {
return Seq.begin(); }
408 const_iterator
end()
const {
return Seq.end(); }
411 unsigned idx(iterator It)
const {
return It-
begin(); }
415 const RegisterOrdering &Ord;
425 const OrderedRegisterList &RL;
431 OrderedRegisterList::const_iterator
B = P.RL.begin(),
E = P.RL.end();
432 for (OrderedRegisterList::const_iterator
I = B;
I !=
E; ++
I) {
443 void OrderedRegisterList::insert(
unsigned VR) {
450 unsigned S = Seq.size();
453 assert(Seq.size() <= MaxSize);
469 : SrcR(SR), InsR(
IR), Wdh(
W), Off(
O) {}
487 unsigned SrcR = P.IFR.SrcR, InsR = P.IFR.InsR;
489 <<
",#" << P.IFR.Wdh <<
",#" << P.IFR.Off <<
')';
493 using IFRecordWithRegSet = std::pair<IFRecord, RegisterSet>;
515 return "Hexagon generate \"insert\" instructions";
529 void buildOrderingMF(RegisterOrdering &RO)
const;
530 void buildOrderingBT(RegisterOrdering &RB, RegisterOrdering &RO)
const;
533 bool isSmallConstant(
unsigned VR)
const;
534 bool isValidInsertForm(
unsigned DstR,
unsigned SrcR,
unsigned InsR,
536 bool findSelfReference(
unsigned VR)
const;
537 bool findNonSelfReference(
unsigned VR)
const;
542 PairMapType &M)
const;
545 PairMapType &M)
const;
546 bool findRecordInsertForms(
unsigned VR, OrderedRegisterList &AVs);
548 void findRemovableRegisters(
unsigned VR, IFRecord
IF,
550 void computeRemovableRegisters();
552 void pruneEmptyLists();
553 void pruneCoveredSets(
unsigned VR);
554 void pruneUsesTooFar(
unsigned VR,
const UnsignedMap &RPO, PairMapType &M);
555 void pruneRegCopies(
unsigned VR);
556 void pruneCandidates();
557 void selectCandidates();
558 bool generateInserts();
563 using IFListType = std::vector<IFRecordWithRegSet>;
566 void dump_map()
const;
576 RegisterOrdering BaseOrd;
577 RegisterOrdering CellOrd;
585 void HexagonGenInsert::dump_map()
const {
586 using iterator = IFMapType::const_iterator;
588 for (iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
590 const IFListType &LL =
I->second;
591 for (
unsigned i = 0, n = LL.size(); i < n; ++i)
592 dbgs() <<
" " << PrintIFR(LL[i].
first, HRI) <<
", " 593 << PrintRegSet(LL[i].
second, HRI) <<
'\n';
597 void HexagonGenInsert::buildOrderingMF(RegisterOrdering &RO)
const {
602 for (mf_iterator A = MFN->begin(),
Z = MFN->end(); A !=
Z; ++A) {
604 if (!CMS->BT.reached(&B))
617 RO.insert(std::make_pair(R, Index++));
627 void HexagonGenInsert::buildOrderingBT(RegisterOrdering &RB,
628 RegisterOrdering &RO)
const {
631 BitValueOrdering BVO(RB);
632 RegisterCellLexCompare LexCmp(BVO, *CMS);
634 using SortableVectorType = std::vector<unsigned>;
636 SortableVectorType VRs;
637 for (RegisterOrdering::iterator
I = RB.begin(),
E = RB.end();
I !=
E; ++
I)
638 VRs.push_back(
I->first);
641 for (
unsigned i = 0, n = VRs.size(); i < n; ++i)
642 RO.insert(std::make_pair(VRs[i], i));
646 return RC == &Hexagon::IntRegsRegClass || RC == &Hexagon::DoubleRegsRegClass;
654 if (BV.
is(0) || BV.
is(1))
661 bool HexagonGenInsert::isSmallConstant(
unsigned VR)
const {
666 uint64_t V = 0,
B = 1;
684 bool HexagonGenInsert::isValidInsertForm(
unsigned DstR,
unsigned SrcR,
690 if (!isIntClass(DstRC) || !isIntClass(SrcRC) || !isIntClass(InsRC))
698 if (DstRC == &Hexagon::DoubleRegsRegClass)
701 if (S < 32 && S+L > 32)
706 bool HexagonGenInsert::findSelfReference(
unsigned VR)
const {
716 bool HexagonGenInsert::findNonSelfReference(
unsigned VR)
const {
739 void HexagonGenInsert::getInstrUses(
const MachineInstr *MI,
754 PairMapType &M)
const {
761 PairMapType::iterator
F = M.find(std::make_pair(FromN, ToN));
764 unsigned ToRPO = RPO.lookup(ToN);
775 if (PB == FromB || RPO.lookup(PB->
getNumber()) >= ToRPO)
777 unsigned D = PB->
size() + distance(FromB, PB, RPO, M);
783 M.insert(std::make_pair(std::make_pair(FromN, ToN), MaxD));
789 PairMapType &M)
const {
792 return std::distance(FromI, ToI);
793 unsigned D1 = std::distance(
TB->begin(), ToI);
794 unsigned D2 = distance(FB,
TB, RPO, M);
795 unsigned D3 = std::distance(FromI, FB->
end());
799 bool HexagonGenInsert::findRecordInsertForms(
unsigned VR,
800 OrderedRegisterList &AVs) {
803 <<
" AVs: " << PrintORL(AVs, HRI) <<
"\n";
808 using iterator = OrderedRegisterList::iterator;
810 BitValueOrdering BVO(BaseOrd);
814 using RSRecord = std::pair<unsigned, uint16_t>;
815 using RSListType = std::vector<RSRecord>;
826 iterator
B = AVs.begin(),
E = AVs.end();
834 for (L = 0; L < W-S; ++L) {
837 RegisterCellBitCompareSel RCB(VR, S+L, L, BVO, *CMS);
845 for (iterator
I = B;
I != NewB; ++
I)
846 LM[L].push_back(std::make_pair(*
I, S));
847 for (iterator
I = NewE;
I !=
E; ++
I)
848 LM[L].push_back(std::make_pair(*
I, S));
858 for (iterator
I = B;
I !=
E; ++
I)
859 LM[L].push_back(std::make_pair(*
I, S));
867 dbgs() <<
"Prefixes matching register " <<
printReg(VR, HRI) <<
"\n";
868 for (LRSMapType::iterator
I = LM.begin(),
E = LM.end();
I !=
E; ++
I) {
869 dbgs() <<
" L=" <<
I->first <<
':';
870 const RSListType &LL =
I->second;
871 for (
unsigned i = 0, n = LL.size(); i < n; ++i)
873 << LL[i].second <<
')';
878 bool Recorded =
false;
880 for (iterator
I = AVs.begin(),
E = AVs.end();
I !=
E; ++
I) {
882 int FDi = -1, LDi = -1;
885 for (
uint16_t i = 0, w = std::min(W, AW); i < w; ++i) {
899 LRSMapType::iterator
F = LM.find(L);
902 RSListType &LL = F->second;
903 for (
unsigned i = 0, n = LL.size(); i < n; ++i) {
912 uint16_t LowS = (EL < FD) ? FD-EL : 0;
915 unsigned InsR = LL[i].first;
916 if (!isValidInsertForm(VR, SrcR, InsR, L, S))
920 <<
',' <<
printReg(InsR, HRI) <<
",#" << L <<
",#" 923 IFRecordWithRegSet RR(IFRecord(SrcR, InsR, L, S),
RegisterSet());
924 IFMap[VR].push_back(RR);
934 OrderedRegisterList &AVs) {
940 if (!CMS->BT.reached(B))
951 getInstrDefs(MI, InsDefs);
958 for (
unsigned VR = InsDefs.find_first(); VR; VR = InsDefs.find_next(VR)) {
967 if (findSelfReference(VR) || isSmallConstant(VR))
970 findRecordInsertForms(VR, AVs);
979 for (
unsigned VR = InsDefs.find_first(); VR; VR = InsDefs.find_next(VR))
981 BlockDefs.insert(InsDefs);
984 for (
auto *DTN : children<MachineDomTreeNode*>(MDT->getNode(B))) {
986 collectInBlock(SB, AVs);
989 for (
unsigned VR = BlockDefs.find_first(); VR; VR = BlockDefs.find_next(VR))
993 void HexagonGenInsert::findRemovableRegisters(
unsigned VR, IFRecord
IF,
1004 while (!Regs[S].
empty()) {
1006 unsigned OtherS = 1-S;
1007 Regs[OtherS].clear();
1008 for (
unsigned R = Regs[S].find_first(); R; R = Regs[S].find_next(R)) {
1010 if (R == IF.SrcR || R == IF.InsR)
1022 if (!findNonSelfReference(R))
1032 getInstrUses(DefI, Regs[OtherS]);
1044 void HexagonGenInsert::computeRemovableRegisters() {
1045 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1046 IFListType &LL =
I->second;
1047 for (
unsigned i = 0, n = LL.size(); i < n; ++i)
1048 findRemovableRegisters(
I->first, LL[i].first, LL[i].second);
1052 void HexagonGenInsert::pruneEmptyLists() {
1057 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1058 if (
I->second.empty())
1061 for (
unsigned i = 0, n = Prune.size(); i < n; ++i)
1062 IFMap.erase(Prune[i]);
1065 void HexagonGenInsert::pruneCoveredSets(
unsigned VR) {
1066 IFMapType::iterator
F = IFMap.find(VR);
1067 assert(F != IFMap.end());
1068 IFListType &LL = F->second;
1078 bool DefEx = HII->isConstExtended(*DefVR);
1080 for (
unsigned i = 0, n = LL.size(); i < n; ++i) {
1081 if (LL[i].
second.empty())
1086 if (!DefEx || HasNE) {
1089 auto IsEmpty = [] (
const IFRecordWithRegSet &
IR) ->
bool {
1090 return IR.second.empty();
1093 if (End != LL.end())
1094 LL.erase(End, LL.end());
1101 IFRecord MaxIF = LL[0].first;
1102 for (
unsigned i = 1, n = LL.size(); i < n; ++i) {
1104 const IFRecord &IF = LL[i].first;
1105 unsigned M0 = BaseOrd[MaxIF.SrcR], M1 = BaseOrd[MaxIF.InsR];
1106 unsigned R0 = BaseOrd[IF.SrcR], R1 = BaseOrd[IF.InsR];
1113 if (MaxIF.Wdh > IF.Wdh)
1115 if (MaxIF.Wdh == IF.Wdh && MaxIF.Off >= IF.Off)
1125 LL.push_back(std::make_pair(MaxIF,
RegisterSet()));
1135 for (
unsigned i = 0, n = LL.size(); i < n; ) {
1139 if (j != i && LL[j].
second.includes(RMi))
1147 LL.erase(LL.begin()+i);
1152 void HexagonGenInsert::pruneUsesTooFar(
unsigned VR,
const UnsignedMap &RPO,
1154 IFMapType::iterator
F = IFMap.find(VR);
1155 assert(F != IFMap.end());
1156 IFListType &LL = F->second;
1160 for (
unsigned i = LL.size(); i > 0; --i) {
1161 unsigned SR = LL[i-1].first.SrcR,
IR = LL[i-1].first.InsR;
1164 unsigned DSV = distance(DefS, DefV, RPO, M);
1166 unsigned DIV = distance(DefI, DefV, RPO, M);
1170 LL.erase(LL.begin()+(i-1));
1174 void HexagonGenInsert::pruneRegCopies(
unsigned VR) {
1175 IFMapType::iterator
F = IFMap.find(VR);
1176 assert(F != IFMap.end());
1177 IFListType &LL = F->second;
1179 auto IsCopy = [] (
const IFRecordWithRegSet &
IR) ->
bool {
1180 return IR.first.Wdh == 32 && (
IR.first.Off == 0 ||
IR.first.Off == 32);
1183 if (End != LL.end())
1184 LL.erase(End, LL.end());
1187 void HexagonGenInsert::pruneCandidates() {
1192 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I)
1193 pruneCoveredSets(
I->first);
1201 for (RPOTType::rpo_iterator
I = RPOT.begin(),
E = RPOT.end();
I !=
E; ++
I)
1202 RPO[(*I)->getNumber()] = RPON++;
1206 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I)
1207 pruneUsesTooFar(
I->first, RPO, Memo);
1211 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I)
1212 pruneRegCopies(
I->first);
1226 IFOrdering(
const UnsignedMap &UC,
const RegisterOrdering &BO)
1227 : UseC(UC), BaseOrd(BO) {}
1229 bool operator() (
const IFRecordWithRegSet &A,
1230 const IFRecordWithRegSet &B)
const;
1234 unsigned &Sum)
const;
1236 const UnsignedMap &UseC;
1237 const RegisterOrdering &BaseOrd;
1242 bool IFOrdering::operator() (
const IFRecordWithRegSet &A,
1243 const IFRecordWithRegSet &B)
const {
1244 unsigned SizeA = 0, ZeroA = 0, SumA = 0;
1245 unsigned SizeB = 0, ZeroB = 0, SumB = 0;
1246 stats(A.second, SizeA, ZeroA, SumA);
1247 stats(B.second, SizeB, ZeroB, SumB);
1251 return ZeroA > ZeroB;
1253 uint64_t AvgA = SumA*SizeB, AvgB = SumB*SizeA;
1259 unsigned OSA = BaseOrd[A.first.SrcR], OSB = BaseOrd[B.first.SrcR];
1262 unsigned OIA = BaseOrd[A.first.InsR], OIB = BaseOrd[B.first.InsR];
1265 if (A.first.Wdh != B.first.Wdh)
1266 return A.first.Wdh < B.first.Wdh;
1267 return A.first.Off < B.first.Off;
1271 unsigned &Sum)
const {
1272 for (
unsigned R = Rs.find_first(); R; R = Rs.find_next(R)) {
1273 UnsignedMap::const_iterator
F = UseC.find(R);
1275 unsigned UC = F->second;
1283 void HexagonGenInsert::selectCandidates() {
1291 UnsignedMap UseC, RemC;
1292 IFMapType::iterator End = IFMap.end();
1294 for (IFMapType::iterator
I = IFMap.begin();
I != End; ++
I) {
1295 const IFListType &LL =
I->second;
1297 for (
unsigned i = 0, n = LL.size(); i < n; ++i)
1298 TT.insert(LL[i].second);
1299 for (
unsigned R = TT.find_first(); R; R = TT.find_next(R))
1304 for (
unsigned R = AllRMs.find_first(); R; R = AllRMs.find_next(R)) {
1311 use_iterator
E =
MRI->use_nodbg_end();
1312 for (use_iterator
I =
MRI->use_nodbg_begin(R);
I !=
E; ++
I)
1313 UIs.insert(
I->getParent());
1314 unsigned C = UIs.size();
1317 unsigned D = RemC[R];
1318 UseC[R] = (C >
D) ? C-D : 0;
1322 if (!SelectAll0 && !SelectHas0)
1330 IFOrdering IFO(UseC, BaseOrd);
1331 for (IFMapType::iterator
I = IFMap.begin();
I != End; ++
I) {
1332 IFListType &LL =
I->second;
1339 IFListType::iterator MinI = std::min_element(LL.begin(), LL.end(), IFO);
1340 assert(MinI != LL.end());
1341 IFRecordWithRegSet M = *MinI;
1352 getInstrUses(DefI, Us);
1353 bool Accept =
false;
1357 for (
unsigned R = Us.find_first(); R; R = Us.find_next(R)) {
1364 }
else if (SelectHas0) {
1366 for (
unsigned R = Us.find_first(); R; R = Us.find_next(R)) {
1383 for (IFMapType::iterator
I = IFMap.begin();
I != End; ++
I) {
1384 const IFListType &LL =
I->second;
1386 AllRMs.insert(LL[0].second);
1388 for (IFMapType::iterator
I = IFMap.begin();
I != End; ++
I) {
1389 IFListType &LL =
I->second;
1392 unsigned SR = LL[0].first.SrcR,
IR = LL[0].first.InsR;
1393 if (AllRMs[SR] || AllRMs[
IR])
1400 bool HexagonGenInsert::generateInserts() {
1404 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1405 unsigned VR =
I->first;
1414 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1418 unsigned NewR = RegMap[
I->first];
1419 bool R32 =
MRI->getRegClass(NewR) == &Hexagon::IntRegsRegClass;
1420 const MCInstrDesc &
D = R32 ? HII->get(Hexagon::S2_insert)
1421 : HII->get(Hexagon::S2_insertp);
1422 IFRecord IF =
I->second[0].first;
1423 unsigned Wdh = IF.Wdh, Off = IF.Off;
1425 if (R32 &&
MRI->getRegClass(IF.InsR) == &Hexagon::DoubleRegsRegClass) {
1426 InsS = Hexagon::isub_lo;
1428 InsS = Hexagon::isub_hi;
1440 .
addReg(IF.InsR, 0, InsS)
1444 MRI->clearKillFlags(IF.SrcR);
1445 MRI->clearKillFlags(IF.InsR);
1448 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1450 MRI->replaceRegWith(
I->first, RegMap[
I->first]);
1458 bool Changed =
false;
1460 for (
auto *DTN : children<MachineDomTreeNode*>(N))
1461 Changed |= removeDeadCode(DTN);
1464 std::vector<MachineInstr*> Instrs;
1466 Instrs.push_back(&*
I);
1468 for (
auto I = Instrs.begin(),
E = Instrs.end();
I !=
E; ++
I) {
1480 bool AllDead =
true;
1483 if (!MO.isReg() || !MO.isDef())
1496 for (
unsigned I = 0, N = Regs.
size();
I !=
N; ++
I)
1497 MRI->markUsesInDebugValueAsUndef(Regs[
I]);
1509 bool Changed =
false;
1519 HII =
ST.getInstrInfo();
1520 HRI =
ST.getRegisterInfo();
1523 MDT = &getAnalysis<MachineDominatorTree>();
1530 Changed = removeDeadCode(MDT->getRootNode());
1536 CellMapShadow MS(BTLoc);
1539 buildOrderingMF(BaseOrd);
1540 buildOrderingBT(BaseOrd, CellOrd);
1543 dbgs() <<
"Cell ordering:\n";
1544 for (RegisterOrdering::iterator
I = CellOrd.begin(),
E = CellOrd.end();
1546 unsigned VR =
I->first, Pos =
I->second;
1553 OrderedRegisterList AvailR(CellOrd);
1555 const char *
const TGName =
"hexinsert";
1556 const char *
const TGDesc =
"Generate Insert Instructions";
1561 collectInBlock(RootB, AvailR);
1563 computeRemovableRegisters();
1567 dbgs() <<
"Candidates after collection:\n";
1580 dbgs() <<
"Candidates after pruning:\n";
1588 NamedRegionTimer _T(
"selection",
"selection", TGName, TGDesc, TimingDetail);
1593 dbgs() <<
"Candidates after selection:\n";
1604 for (IFMapType::iterator
I = IFMap.begin(),
E = IFMap.end();
I !=
E; ++
I) {
1609 for (
unsigned i = 0, n = Out.size(); i < n; ++i)
1610 IFMap.erase(Out[i]);
1625 return new HexagonGenInsert();
1633 "Hexagon generate \"insert\" instructions",
false,
false)
auto lower_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range))
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
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...
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
static unsigned virtReg2Index(unsigned Reg)
Convert a virtual register number to a 0-based index.
void initializeHexagonGenInsertPass(PassRegistry &)
void trace(bool On=false)
This class represents lattice values for constants.
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.
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
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
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
static unsigned index2VirtReg(unsigned Index)
Convert a 0-based index to a virtual register number.
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.
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.
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.
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.
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
SmallSet< unsigned, 4 > RegisterSet
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)
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.
const BitVector & operator=(const BitVector &RHS)
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.
Align max(MaybeAlign Lhs, Align Rhs)
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.
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isSafeToMove(AAResults *AA, bool &SawStore) const
Return true if it is safe to move this instruction.
constexpr uint32_t Hi_32(uint64_t Value)
Return the high 32 bits of a 64 bit value.
rpo Deduce function attributes in RPO
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
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)
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
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...
Wrapper class representing virtual and physical registers.
auto upper_bound(R &&Range, T &&Value) -> decltype(adl_begin(Range))
Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...