15using namespace threadSafety;
50SExpr* Future::force() {
58 unsigned Idx = Predecessors.
size();
61 for (
auto *
E : Args) {
62 if (
auto *Ph = dyn_cast<Phi>(
E)) {
63 Ph->values().reserveCheck(1, Arena);
64 Ph->values().push_back(
nullptr);
71 Predecessors.
reserve(NumPreds, Arena);
72 for (
auto *
E : Args) {
73 if (
auto *Ph = dyn_cast<Phi>(
E)) {
74 Ph->values().reserve(NumPreds, Arena);
83 if (
const auto *
V = dyn_cast<Variable>(
E)) {
89 if (
const auto *Ph = dyn_cast<Phi>(
E)) {
105 if (
auto *
V = dyn_cast<Variable>(
E)) {
116 if (
auto *Ph = dyn_cast<Phi>(
E)) {
139 for (
unsigned i = 1, n = Ph->
values().
size(); i < n; ++i) {
151unsigned BasicBlock::renumberInstrs(
unsigned ID) {
152 for (
auto *Arg : Args)
153 Arg->setID(
this, ID++);
154 for (
auto *Instr : Instrs)
155 Instr->setID(
this, ID++);
156 TermInstr->
setID(
this, ID++);
166 if (Visited)
return ID;
169 ID =
Block->topologicalSort(Blocks, ID);
174 Blocks[BlockID] =
this;
192 if (!Visited)
return ID;
195 ID = DominatorNode.
Parent->topologicalFinalSort(Blocks, ID);
196 for (
auto *Pred : Predecessors)
197 ID = Pred->topologicalFinalSort(Blocks, ID);
198 assert(
static_cast<size_t>(ID) < Blocks.
size());
200 Blocks[BlockID] =
this;
207void BasicBlock::computeDominator() {
210 for (
auto *Pred : Predecessors) {
212 if (Pred->BlockID >= BlockID)
continue;
214 if (Candidate ==
nullptr) {
219 auto *Alternate = Pred;
220 while (Alternate != Candidate) {
221 if (Candidate->BlockID > Alternate->BlockID)
222 Candidate = Candidate->DominatorNode.
Parent;
224 Alternate = Alternate->DominatorNode.
Parent;
227 DominatorNode.
Parent = Candidate;
234void BasicBlock::computePostDominator() {
239 if (Succ->BlockID <= BlockID)
continue;
241 if (Candidate ==
nullptr) {
246 auto *Alternate = Succ;
247 while (Alternate != Candidate) {
248 if (Candidate->BlockID < Alternate->BlockID)
249 Candidate = Candidate->PostDominatorNode.
Parent;
251 Alternate = Alternate->PostDominatorNode.
Parent;
254 PostDominatorNode.
Parent = Candidate;
259void SCFG::renumberInstrs() {
260 unsigned InstrID = 0;
261 for (
auto *
Block : Blocks)
262 InstrID =
Block->renumberInstrs(InstrID);
291 unsigned NumUnreachableBlocks = Entry->topologicalSort(Blocks, Blocks.size());
292 if (NumUnreachableBlocks > 0) {
294 for (
unsigned I = NumUnreachableBlocks,
E = Blocks.size(); I <
E; ++I) {
295 unsigned NI = I - NumUnreachableBlocks;
296 Blocks[NI] = Blocks[I];
297 Blocks[NI]->BlockID = NI;
300 Blocks.drop(NumUnreachableBlocks);
304 for (
auto *
Block : Blocks)
305 Block->computeDominator();
308 unsigned NumBlocks = Exit->topologicalFinalSort(Blocks, 0);
309 assert(
static_cast<size_t>(NumBlocks) == Blocks.size());
317 for (
auto *
Block : Blocks.reverse()) {
318 Block->computePostDominator();
323 for (
auto *
Block : Blocks) {
328 for (
auto *
Block : Blocks.reverse()) {
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static void computeNodeSize(BasicBlock *B, BasicBlock::TopologyNode BasicBlock::*TN)
static void computeNodeID(BasicBlock *B, BasicBlock::TopologyNode BasicBlock::*TN)
A basic block is part of an SCFG.
unsigned addPredecessor(BasicBlock *Pred)
ArrayRef< BasicBlock * > successors()
void reservePredecessors(unsigned NumPreds)
virtual SExpr * compute()
Phi Node, for code in SSA form.
const ValArray & values() const
Base class for AST nodes in the typed intermediate language.
void setID(BasicBlock *B, unsigned id)
Set the basic block and instruction ID for this expression.
void reserve(size_t Ncp, MemRegionRef A)
void push_back(const T &Elem)
void reserveCheck(size_t N, MemRegionRef A)
bool isTrivial(const SExpr *E)
TIL_UnaryOpcode
Opcode for unary arithmetic operations.
void simplifyIncompleteArg(til::Phi *Ph)
StringRef getBinaryOpcodeString(TIL_BinaryOpcode Op)
Return the name of a binary opcode.
StringRef getUnaryOpcodeString(TIL_UnaryOpcode Op)
Return the name of a unary opcode.
TIL_BinaryOpcode
Opcode for binary arithmetic operations.
SExpr * simplifyToCanonicalVal(SExpr *E)
const SExpr * getCanonicalVal(const SExpr *E)
The JSON file list parser is used to communicate input to InstallAPI.