32 #define DEBUG_TYPE "hbr" 39 bool SbAE = (S < AE) || (S == AE && A.
TiedEnd);
40 bool ASbE = (AS <
E) || (AS ==
E &&
TiedEnd);
41 if ((AS < S && SbAE) || (S < AS && ASbE))
88 iterator Iter =
begin();
90 while (Iter !=
end()-1) {
91 iterator Next = std::next(Iter);
94 bool Merge = MergeAdjacent && (Iter->end() == Next->start());
95 if (Merge || Iter->overlaps(*Next)) {
105 void HexagonBlockRanges::RangeList::addsub(
const IndexRange &A,
145 for (iterator Next,
I =
begin();
I !=
end();
I = Next) {
149 Next = this->erase(
I);
162 if (
In.isDebugInstr())
165 Map.insert(std::make_pair(Idx, &
In));
172 auto F = Map.find(Idx);
173 return (
F != Map.end()) ?
F->second :
nullptr;
208 for (
auto &
I : Map) {
209 if (
I.second != OldMI)
211 if (NewMI !=
nullptr)
221 TII(*HST.getInstrInfo()),
TRI(*HST.getRegisterInfo()),
222 Reserved(
TRI.getReservedRegs(mf)) {
225 if (RC->isAllocatable())
227 for (
unsigned R : *RC)
240 if (
I.LaneMask.all() || (
I.LaneMask.any() && !S.
isValid())) {
241 Tmp.insert({
I.PhysReg, 0});
247 Tmp.insert({S.getSubReg(), 0});
252 if (!Reserved[R.Reg])
255 if (!Reserved[S.Reg])
274 SRs.insert({R.Reg, 0});
280 unsigned PReg = *RC.
begin();
283 SRs.insert({R.Reg, 0});
285 SRs.insert({R.Reg, I.getSubRegIndex()});
290 void HexagonBlockRanges::computeInitialLiveRanges(
InstrIndexMap &IndexMap,
292 std::map<RegisterRef,IndexType> LastDef, LastUse;
297 for (
auto R : getLiveIns(B, MRI, TRI))
298 LiveOnEntry.insert(R);
300 for (
auto R : LiveOnEntry)
303 auto closeRange = [&LastUse,&LastDef,&LiveMap] (
RegisterRef R) ->
void {
304 auto LD = LastDef[R], LU = LastUse[R];
309 LiveMap[R].add(
LD, LU,
false,
false);
316 if (
In.isDebugInstr())
320 for (
auto &
Op :
In.operands()) {
321 if (!
Op.isReg() || !
Op.isUse() ||
Op.isUndef())
326 bool IsKill =
Op.isKill();
336 for (
auto &
Op :
In.operands()) {
337 if (!
Op.isReg() || !
Op.isDef() ||
Op.isUndef())
350 for (
auto &
Op :
In.operands()) {
354 for (
unsigned PR = 1,
N = TRI.
getNumRegs(); PR !=
N; ++PR) {
362 if (BM[PR/32] & (1u << (PR%32)))
391 LastDef[S] = LastUse[S] =
Index;
398 for (
auto *SB : B.successors())
399 for (
auto R : getLiveIns(*SB, MRI, TRI))
400 LiveOnExit.insert(R);
402 for (
auto R : LiveOnExit)
407 for (
auto &
I : LastUse)
409 Left.insert(
I.first);
410 for (
auto &
I : LastDef)
412 Left.insert(
I.first);
417 for (
auto &
P : LiveMap)
424 LLVM_DEBUG(
dbgs() << __func__ <<
": index map\n" << IndexMap <<
'\n');
425 computeInitialLiveRanges(IndexMap, LiveMap);
435 auto addDeadRanges = [&IndexMap,&LiveMap,&DeadMap] (
RegisterRef R) ->
void {
436 auto F = LiveMap.find(R);
437 if (
F == LiveMap.end() ||
F->second.empty()) {
443 RangeList::iterator A = RL.begin(),
Z = RL.end()-1;
460 DeadMap[R].add(DS, DE,
false,
false);
476 for (
unsigned R = 1; R < NumRegs; ++R) {
478 if (Reserved[S.Reg] || Visited[S.Reg])
481 Visited[S.Reg] =
true;
484 for (
auto &
P : LiveMap)
486 addDeadRanges(
P.first);
507 OS <<
'[' << IR.
start() <<
':' << IR.
end() << (IR.
TiedEnd ?
'}' :
']');
522 for (
auto &
In : M.Block) {
524 OS << Idx << (Idx == M.
Last ?
". " :
" ") <<
In;
531 for (
auto &
I : P.Map) {
533 OS <<
printReg(
I.first.Reg, &P.TRI,
I.first.Sub) <<
" -> " << RL <<
"\n";
MachineBasicBlock & getBlock() const
MachineInstr * getInstr(IndexType Idx) const
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
iterator begin() const
begin/end - Return all of the registers in this class.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
static RegisterSet expandToSubRegs(RegisterRef R, const MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI)
unsigned const TargetRegisterInfo * TRI
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.
std::set< RegisterRef > RegisterSet
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
std::map< RegisterRef, RangeList > RegToRangeMap
const HexagonInstrInfo * TII
bool overlaps(const IndexRange &A) const
iterator_range< regclass_iterator > regclasses() const
unsigned getSubRegIndex() const
Returns sub-register index of the current sub-register.
IndexType getNextIndex(IndexType Idx) const
unsigned getNumRegs() const
Return the number of registers this target has (useful for sizing arrays holding per register informa...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
Iterator that enumerates the sub-registers of a Reg and the associated sub-register indices...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
MCSubRegIterator enumerates all sub-registers of Reg.
IndexType getIndex(MachineInstr *MI) const
void subtract(const IndexRange &Range)
void sort(IteratorTy Start, IteratorTy End)
constexpr bool empty(const T &RangeOrContainer)
Test whether RangeOrContainer is empty. Similar to C++17 std::empty.
void include(const RangeList &RL)
bool isValid() const
Returns true if this iterator is not yet at the end.
static uint64_t add(uint64_t LeftOp, uint64_t RightOp)
LaneBitmask getSubRegIndexLaneMask(unsigned SubIdx) const
Return a bitmask representing the parts of a register that are covered by SubIdx. ...
IndexType getPrevIndex(IndexType Idx) const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
HexagonBlockRanges(MachineFunction &MF)
bool isValid() const
isValid - returns true if this iterator is not yet at the end.
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 MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
RegToRangeMap computeLiveMap(InstrIndexMap &IndexMap)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
void merge(const IndexRange &A)
RegToRangeMap computeDeadMap(InstrIndexMap &IndexMap, RegToRangeMap &LiveMap)
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
iterator_range< livein_iterator > liveins() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void unionize(bool MergeAdjacent=false)
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...
void replaceInstr(MachineInstr *OldMI, MachineInstr *NewMI)
bool contains(const IndexRange &A) const
InstrIndexMap(MachineBasicBlock &B)
Statically lint checks LLVM IR
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.