81 printv(
unsigned r) : R(r) {}
117 unsigned n = RC.Bits.
size();
125 bool ConstRef =
false;
127 for (
unsigned i = 1, n = RC.Bits.
size(); i < n; ++i) {
132 if (!IsRef && V == SV)
148 unsigned Count = i - Start;
152 OS <<
'-' << i-1 <<
"]:";
155 << SV.
RefI.
Pos+(Count-1) <<
']';
160 SeqRef = ConstRef =
false;
164 unsigned Count = n - Start;
166 OS <<
"]:" << RC[Start];
168 OS <<
'-' << n-1 <<
"]:";
172 << SV.
RefI.
Pos+(Count-1) <<
']';
184 for (CellMapType::iterator
I = Map.begin(),
E = Map.end();
I !=
E; ++
I)
205 bool Changed =
false;
206 for (uint16_t i = 0, n = Bits.
size(); i < n; ++i) {
208 Changed |= Bits[i].meet(RCV,
BitRef(SelfR, i));
224 for (uint16_t i = 0; i <=
E-
B; ++i)
227 for (uint16_t i = 0; i < W-
B; ++i)
229 for (uint16_t i = 0; i <=
E; ++i)
230 Bits[i] = RC[i+(W-B)];
240 for (uint16_t i = B; i <=
E; ++i)
241 RC.Bits[i-B] = Bits[i];
246 for (uint16_t i = 0; i < W-
B; ++i)
247 RC.Bits[i] = Bits[i+B];
248 for (uint16_t i = 0; i <=
E; ++i)
249 RC.Bits[i+(W-B)] = Bits[i];
256 uint16_t W =
width();
263 for (uint16_t i = 0; i < W-Sh; ++i)
266 for (uint16_t i = 0; i < Sh; ++i)
267 Bits[i] = Bits[W-Sh+i];
269 for (uint16_t i = 0; i < W-Sh; ++i)
270 Bits[i+Sh] = Tmp.Bits[i];
287 for (uint16_t i = 0; i < WRC; ++i)
288 Bits[i+W] = RC.Bits[i];
293 uint16_t W =
width();
296 while (C < W && Bits[C] == V)
302 uint16_t W =
width();
305 while (C < W && Bits[W-(C+1)] == V)
311 uint16_t W = Bits.
size();
312 if (RC.Bits.
size() != W)
314 for (uint16_t i = 0; i < W; ++i)
315 if (Bits[i] != RC[i])
321 for (
unsigned i = 0, n =
width(); i < n; ++i) {
324 Bits[i].RefI =
BitRef(R, i);
342 PhysR = *VC->
begin();
370 CellMapType::const_iterator
F = M.find(RR.
Reg);
375 return F->second.extract(M);
388 assert(RR.
Sub == 0 &&
"Unexpected sub-register in definition");
395 uint16_t W = A.
width();
396 for (uint16_t i = 0; i < W; ++i)
397 if (!A[i].is(0) && !A[i].is(1))
406 uint16_t W = A.
width();
407 for (uint16_t i = 0; i < W; ++i) {
421 for (uint16_t i = 0; i < W; ++i) {
433 for (uint16_t i = 0; i < BW; ++i)
440 uint16_t W = A1.
width();
445 for (I = 0; I < W; ++
I) {
448 if (!V1.
num() || !V2.
num())
450 unsigned S =
bool(V1) +
bool(V2) + Carry;
461 else if (V2.
is(Carry))
473 uint16_t W = A1.
width();
478 for (I = 0; I < W; ++
I) {
481 if (!V1.
num() || !V2.
num())
483 unsigned S =
bool(V1) -
bool(V2) - Borrow;
507 uint16_t
Z = A1.
ct(
false) + A2.
ct(
false);
517 uint16_t
Z = A1.
ct(
false) + A2.
ct(
false);
535 uint16_t W = A1.
width();
545 uint16_t W = A1.
width();
550 Res.
fill(W-Sh, W, Sign);
556 uint16_t W = A1.
width();
559 for (uint16_t i = 0; i < W; ++i) {
566 else if (V1.
is(0) || V2.
is(0))
578 uint16_t W = A1.
width();
581 for (uint16_t i = 0; i < W; ++i) {
584 if (V1.
is(1) || V2.
is(1))
600 uint16_t W = A1.
width();
603 for (uint16_t i = 0; i < W; ++i) {
619 uint16_t W = A1.
width();
621 for (uint16_t i = 0; i < W; ++i) {
634 uint16_t BitN)
const {
642 uint16_t BitN)
const {
651 uint16_t
C = A1.
cl(B), AW = A1.
width();
654 if ((C < AW && A1[AW-1-C].num()) || C == AW)
661 uint16_t
C = A1.
ct(B), AW = A1.
width();
664 if ((C < AW && A1[C].num()) || C == AW)
670 uint16_t FromN)
const {
671 uint16_t W = A1.
width();
676 Res.
fill(FromN, W, Sign);
681 uint16_t FromN)
const {
682 uint16_t W = A1.
width();
690 uint16_t
B, uint16_t
E)
const {
691 uint16_t W = A1.
width();
695 uint16_t Last = (E > 0) ? E-1 : W-1;
705 assert(AtN < W1 && AtN+W2 <= W1);
714 assert(Sub == 0 &&
"Generic BitTracker::mask called for Sub != 0");
716 assert(W > 0 &&
"Cannot generate mask for empty register");
725 case TargetOpcode::REG_SEQUENCE: {
742 case TargetOpcode::COPY: {
771 dbgs() <<
"Visit FI(BB#" << ThisN <<
"): " << PI;
774 assert(MD.
getSubReg() == 0 &&
"Unexpected sub-register in definition");
782 bool Changed =
false;
784 for (
unsigned i = 1, n = PI.getNumOperands(); i < n; i += 2) {
788 dbgs() <<
" edge BB#" << PredN <<
"->BB#" << ThisN;
789 if (!EdgeExec.count(CFGEdge(PredN, ThisN))) {
791 dbgs() <<
" not executable\n";
795 RegisterRef RU = PI.getOperand(i);
796 RegisterCell ResC = ME.
getCell(RU, Map);
799 <<
" cell: " << ResC <<
"\n";
800 Changed |= DefC.
meet(ResC, DefRR.Reg);
806 <<
" cell: " << DefC <<
"\n";
808 visitUsesOf(DefRR.Reg);
815 dbgs() <<
"Visit MI(BB#" << ThisN <<
"): " <<
MI;
822 bool Eval = ME.
evaluate(MI, Map, ResMap);
831 <<
" cell: " << ME.
getCell(RU, Map) <<
"\n";
833 dbgs() <<
"Outputs:\n";
834 for (CellMapType::iterator
I = ResMap.begin(),
E = ResMap.end();
836 RegisterRef RD(
I->first);
838 << ME.
getCell(RD, ResMap) <<
"\n";
850 assert(RD.Sub == 0 &&
"Unexpected sub-register in definition");
854 bool Changed =
false;
855 if (!Eval || ResMap.count(RD.Reg) == 0) {
859 if (RefC != ME.
getCell(RD, Map)) {
864 RegisterCell DefC = ME.
getCell(RD, Map);
865 RegisterCell ResC = ME.
getCell(RD, ResMap);
873 for (uint16_t i = 0, w = DefC.width(); i < w; ++i) {
874 BitValue &V = DefC[i];
896 bool FallsThrough =
true, DefaultToAll =
false;
903 dbgs() <<
"Visit BR(BB#" << ThisN <<
"): " <<
MI;
904 assert(MI.isBranch() &&
"Expecting branch instruction");
905 InstrExec.insert(&MI);
906 bool Eval = ME.
evaluate(MI, Map, BTs, FallsThrough);
913 dbgs() <<
" failed to evaluate: will add all CFG successors\n";
914 }
else if (!DefaultToAll) {
917 dbgs() <<
" adding targets:";
918 for (
unsigned i = 0, n = BTs.size(); i < n; ++i)
919 dbgs() <<
" BB#" << BTs[i]->getNumber();
921 dbgs() <<
"\n falls through\n";
923 dbgs() <<
"\n does not fall through\n";
925 Targets.insert(BTs.begin(), BTs.end());
928 }
while (FallsThrough && It != End);
943 if (Next != MF.
end())
944 Targets.insert(&*Next);
951 for (
unsigned i = 0, n = Targets.size(); i < n; ++i) {
952 int TargetN = Targets[i]->getNumber();
953 FlowQ.push(CFGEdge(ThisN, TargetN));
957 void BT::visitUsesOf(
unsigned Reg) {
965 if (!InstrExec.count(UseI))
970 visitNonBranch(*UseI);
972 visitBranchesFrom(*UseI);
987 assert(Map.count(OldRR.
Reg) > 0 &&
"OldRR not present in map");
990 uint16_t OMB = OM.
first(), OME = OM.last();
991 uint16_t NMB = NM.
first(), NME = NM.
last();
993 assert((OME-OMB == NME-NMB) &&
994 "Substituting registers of different lengths");
995 for (CellMapType::iterator
I = Map.begin(),
E = Map.end();
I !=
E; ++
I) {
997 for (uint16_t i = 0, w = RC.
width(); i < w; ++i) {
1014 return ReachedBB.
count(BN);
1021 InstrExec.insert(&MI);
1026 while (!FlowQ.empty())
1048 assert(
I->getNumber() >= 0 &&
"Disconnected block");
1049 unsigned BN =
I->getNumber();
1059 FlowQ.push(CFGEdge(-1, EntryN));
1061 while (!FlowQ.empty()) {
1062 CFGEdge Edge = FlowQ.front();
1065 if (EdgeExec.count(Edge))
1067 EdgeExec.insert(Edge);
1068 ReachedBB.
insert(Edge.second);
1073 while (It != End && It->isPHI()) {
1075 InstrExec.insert(&PI);
1082 if (BlockScanned[Edge.second])
1084 BlockScanned[Edge.second] =
true;
1087 while (It != End && !It->isBranch()) {
1089 InstrExec.insert(&MI);
1098 int NextN = Next->getNumber();
1099 FlowQ.push(CFGEdge(ThisN, NextN));
1104 visitBranchesFrom(*It);
bool isEHPad() const
Returns true if the block is a landing pad.
const TargetRegisterInfo & TRI
RegisterCell & fill(uint16_t B, uint16_t E, const BitValue &V)
bool isBranch(QueryType Type=AnyInBundle) const
Returns true if this is a conditional, unconditional, or indirect branch.
static unsigned virtReg2Index(unsigned Reg)
Convert a virtual register number to a 0-based index.
std::map< unsigned, RegisterCell > CellMapType
bool isInt(const RegisterCell &A) const
RegisterCell eCLR(const RegisterCell &A1, uint16_t BitN) const
void print_cells(raw_ostream &OS) const
int getNumber() const
MachineBasicBlocks are uniquely numbered at the function level, unless they're not in a MachineFuncti...
static RegisterCell top(uint16_t Width)
unsigned getRegSizeInBits(const TargetRegisterClass &RC) const
Return the size in bits of a register from class RC.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
void visit(const MachineInstr &MI)
RegisterCell eASR(const RegisterCell &A1, uint16_t Sh) const
static RegisterCell self(unsigned Reg, uint16_t Width)
RegisterCell & rol(uint16_t Sh)
uint16_t getRegBitWidth(const RegisterRef &RR) const
TerminatorInst::SuccIterator< TerminatorInst *, BasicBlock > succ_iterator
RegisterCell eXOR(const RegisterCell &A1, const RegisterCell &A2) const
uint16_t ct(bool B) const
RegisterCell eAND(const RegisterCell &A1, const RegisterCell &A2) const
static use_nodbg_iterator use_nodbg_end()
void putCell(const RegisterRef &RR, RegisterCell RC, CellMapType &M) const
RegisterCell eXTR(const RegisterCell &A1, uint16_t B, uint16_t E) const
virtual bool evaluate(const MachineInstr &MI, const CellMapType &Inputs, CellMapType &Outputs) const
const APInt & getValue() const
Return the constant as an APInt value reference.
uint64_t toInt(const RegisterCell &A) const
RegisterCell extract(const BitMask &M) const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
RegisterCell get(RegisterRef RR) const
iterator begin() const
begin/end - Return all of the registers in this class.
Reg
All possible values of the reg field in the ModR/M byte.
zlib-gnu style compression
This file implements a class to represent arbitrary precision integral constant values and operations...
unsigned getNumOperands() const
Access to explicit operands of the instruction.
RegisterCell eMLS(const RegisterCell &A1, const RegisterCell &A2) const
bool is(unsigned T) const
RegisterCell eSUB(const RegisterCell &A1, const RegisterCell &A2) const
Printable PrintReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubRegIdx=0)
Prints virtual and physical registers with or without a TRI instance.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
bool isDebugValue() const
INITIALIZE_PASS(HexagonEarlyIfConversion,"hexagon-eif","Hexagon early if conversion", false, false) bool HexagonEarlyIfConversion MachineBasicBlock * SB
Function Alias Analysis false
unsigned const MachineRegisterInfo * MRI
RegisterCell eSXT(const RegisterCell &A1, uint16_t FromN) const
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const MachineOperand & getOperand(unsigned i) const
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
std::pair< iterator, bool > insert(const ValueT &V)
RegisterCell eASL(const RegisterCell &A1, uint16_t Sh) const
unsigned getBitWidth() const
Return the number of bits in the APInt.
static const unsigned End
RegisterCell getCell(const RegisterRef &RR, const CellMapType &M) const
for(unsigned i=0, e=MI->getNumOperands();i!=e;++i)
void subst(RegisterRef OldRR, RegisterRef NewRR)
std::vector< MachineBasicBlock * >::const_iterator const_succ_iterator
RegisterCell eCTB(const RegisterCell &A1, bool B, uint16_t W) const
self_iterator getIterator()
RegisterCell eZXT(const RegisterCell &A1, uint16_t FromN) const
RegisterCell eCLB(const RegisterCell &A1, bool B, uint16_t W) const
succ_iterator succ_begin()
unsigned getSubReg() const
RegisterCell eADD(const RegisterCell &A1, const RegisterCell &A2) const
SetVector< const MachineBasicBlock * > BranchTargetList
RegisterCell eORL(const RegisterCell &A1, const RegisterCell &A2) const
Iterator for intrusive lists based on ilist_node.
This is the shared class of boolean and integer constants.
static BitValue self(const BitRef &Self=BitRef())
MachineOperand class - Representation of each machine instruction operand.
MachineBasicBlock * getBlockNumbered(unsigned N) const
getBlockNumbered - MachineBasicBlocks are automatically numbered when they are inserted into the mach...
bool isSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB is a successor of this block.
RegisterCell eLSR(const RegisterCell &A1, uint16_t Sh) const
MachineRegisterInfo & MRI
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Class for arbitrary precision integers.
const TargetRegisterClass * getMinimalPhysRegClass(unsigned Reg, MVT VT=MVT::Other) const
Returns the Register Class of a physical register of the given type, picking the most sub register cl...
RegisterCell & insert(const RegisterCell &RC, const BitMask &M)
Representation of each machine instruction.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
virtual BitMask mask(unsigned Reg, unsigned Sub) const
RegisterCell & cat(const RegisterCell &RC)
virtual bool track(const TargetRegisterClass *RC) const
BitTracker(const MachineEvaluator &E, MachineFunction &F)
uint16_t cl(bool B) const
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
RegisterCell eMLU(const RegisterCell &A1, const RegisterCell &A2) const
void reserve(size_t Size)
Grow the DenseSet so that it can contain at least NumEntries items before resizing again...
RegisterCell eIMM(int64_t V, uint16_t W) const
bool operator==(const RegisterCell &RC) const
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
size_type count(const_arg_type_t< ValueT > V) const
Return 1 if the specified key is in the set, 0 otherwise.
bool reached(const MachineBasicBlock *B) const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void put(RegisterRef RR, const RegisterCell &RC)
RegisterCell eSET(const RegisterCell &A1, uint16_t BitN) const
RegisterCell eNOT(const RegisterCell &A1) const
This class implements an extremely fast bulk output stream that can only output to a stream...
bool meet(const RegisterCell &RC, unsigned SelfR)
RegisterCell & regify(unsigned R)
static RegisterCell ref(const RegisterCell &C)
reg_begin/reg_end - Provide iteration support to walk over all definitions and uses of a register wit...
use_nodbg_iterator use_nodbg_begin(unsigned RegNo) const
static BitValue ref(const BitValue &V)
RegisterCell eINS(const RegisterCell &A1, const RegisterCell &A2, uint16_t AtN) const