本文整理汇总了C++中Opnd::asSsaVarOpnd方法的典型用法代码示例。如果您正苦于以下问题:C++ Opnd::asSsaVarOpnd方法的具体用法?C++ Opnd::asSsaVarOpnd怎么用?C++ Opnd::asSsaVarOpnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opnd
的用法示例。
在下文中一共展示了Opnd::asSsaVarOpnd方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: clearPhiSrcs
void SSABuilder::clearPhiSrcs(Node *node, const StlVectorSet<VarOpnd *> *whatVars)
{
Inst* phi = (Inst*)node->getSecondInst();
if (whatVars) {
for (;phi!=NULL && phi->isPhi(); phi = phi->getNextInst()) {
Opnd *dstOp = phi->getDst();
VarOpnd *varOpnd = dstOp->asVarOpnd();
if (!varOpnd) {
SsaVarOpnd *ssaOpnd = dstOp->asSsaVarOpnd();
assert(ssaOpnd);
varOpnd = ssaOpnd->getVar();
}
if (whatVars->has(varOpnd)) {
PhiInst *phiInst = phi->asPhiInst();
assert(phiInst);
phiInst->setNumSrcs(0);
}
}
} else {
for (;phi!=NULL && phi->isPhi(); phi = phi->getNextInst()) {
PhiInst *phiInst = phi->asPhiInst();
assert(phiInst);
phiInst->setNumSrcs(0);
}
}
}
示例2: assert
void SSABuilder::checkForTrivialPhis2(Node *node,
const StlVectorSet<VarOpnd *> *lookatVars,
StlVector<VarOpnd *> *changedVars,
StlVector<Opnd *> *removedVars)
{
// Check that phi insts can start from the second or third position only
// and goes in a row
assert(phiInstsOnRightPositionsInBB(node));
Inst* phi = (Inst*)node->getSecondInst();
if(phi && !phi->isPhi()) {
// try the next one (third)
phi = phi->getNextInst();
}
Inst *nextphi = NULL;
#ifdef DEBUG_SSA
if (Log::isEnabled()) {
Log::out() << "Checking node " << (int)node->getId()
<< " for trivial phis2" << ::std::endl;
}
#endif
for (;phi->isPhi(); phi = nextphi) {
nextphi = phi->getNextInst();
#ifdef _DEBUG
PhiInst *phiInst = phi->asPhiInst();
assert(phiInst);
#endif
U_32 nSrcs = phi->getNumSrcOperands();
if (nSrcs <= 1) {
// phi must be trivial
#ifdef DEBUG_SSA
::std::ostream &cout = Log::out();
if (Log::isEnabled()) {
cout << "removing trivial2 instruction "; phi->print(cout); cout << ::std::endl;
}
#endif
Opnd *dstOp = phi->getDst();
VarOpnd *varOp = dstOp->asVarOpnd();
if (!varOp) {
SsaVarOpnd *ssaOp = dstOp->asSsaVarOpnd();
assert(ssaOp);
varOp = ssaOp->getVar();
}
assert(!lookatVars || (lookatVars->has(varOp)));
changedVars->push_back(varOp);
removedVars->push_back(dstOp);
phi->unlink();
}
}
}
示例3: applyToInst
void applyToInst(Inst *inst) {
if (inst->getOpcode() == Op_Phi) {
// we should just delete the whole thing.
Opnd *dstOpnd = inst->getDst();
if (dstOpnd->isSsaVarOpnd()) {
SsaVarOpnd *ssaOpnd = dstOpnd->asSsaVarOpnd();
VarOpnd *var = ssaOpnd->getVar();
if (usedOutOfSsa.has(var)) {
// remove instruction
inst->unlink();
return;
}
} else if (dstOpnd->isVarOpnd()) {
VarOpnd *var = dstOpnd->asVarOpnd();
if (usedOutOfSsa.has(var)) {
// remove instruction
inst->unlink();
return;
}
}
}
U_32 numSrcs = inst->getNumSrcOperands();
for (U_32 i=0; i<numSrcs; ++i) {
Opnd *thisOpnd = inst->getSrc(i);
VarOpnd *varOpnd = needToDeSsaOpnd(thisOpnd);
if (varOpnd) {
inst->setSrc(i, varOpnd);
}
}
Opnd *dstOpnd = inst->getDst();
VarOpnd *varDstOpnd = needToDeSsaOpnd(dstOpnd);
if (varDstOpnd) {
inst->setDst(varDstOpnd);
}
}
示例4: renameNode
//
// traverse dominator tree and rename variables
//
void SSABuilder::renameNode(RenameStack *renameStack, DominatorNode* dt,
const StlVectorSet<VarOpnd *> *whatVars)
{
if (dt == NULL) return;
Node* node = dt->getNode();
Inst* head = (Inst*)node->getFirstInst();
#ifdef DEBUG_SSA
std::ostream &cout = Log::out();
if (Log::isEnabled()) {
cout << "renameNode "; FlowGraph::printLabel(cout, node); cout << std::endl;
}
#endif
for (Inst* i = head->getNextInst(); i != NULL; i = i->getNextInst()) {
if (!i->isPhi()) {
// replace src with ssa opnd
U_32 nSrcs = i->getNumSrcOperands();
for (U_32 j = 0; j < nSrcs; j++) {
Opnd *srcj = i->getSrc(j);
VarOpnd *srcjVar = (srcj->isSsaVarOpnd()
? srcj->asSsaVarOpnd()->getVar()
: srcj->asVarOpnd());
if (!(srcjVar && !srcjVar->isAddrTaken()))
continue;
if (whatVars && !whatVars->has(srcjVar)) continue;
SsaVarOpnd* ssa = renameStack->lookup(srcjVar);
assert(ssa);
i->setSrc(j,ssa);
}
}
// for both Phi and non-Phi
// we replace any non-ssa dst with a new ssa opnd
// and record it in the RenameStack map
Opnd* dst = i->getDst();
VarOpnd *theVar = dst->asVarOpnd();
if (theVar && (!theVar->isAddrTaken())
&& !(whatVars && !whatVars->has(theVar))) {
SsaVarOpnd* ssaDst = opndManager.createSsaVarOpnd((VarOpnd*)dst);
#ifdef DEBUG_SSA
if (Log::isEnabled()) {
cout << "SSA "; ssaDst->print(cout); cout << ::std::endl;
}
#endif
renameStack->insert((VarOpnd*)dst, ssaDst);
i->setDst(ssaDst);
#ifdef DEBUG_SSA
if (Log::isEnabled()) {
i->print(cout); cout << ::std::endl;
}
#endif
// record stVar inst
} else if (dst->isSsaVarOpnd()) {
SsaVarOpnd* ssaDst = dst->asSsaVarOpnd();
theVar = ssaDst->getVar();
if (whatVars && !whatVars->has(theVar))
continue;
#ifdef DEBUG_SSA
if (Log::isEnabled()) {
cout << "SSA "; ssaDst->print(cout); cout << ::std::endl;
}
#endif
renameStack->insert(ssaDst->getVar(), ssaDst);
#ifdef DEBUG_SSA
if (Log::isEnabled()) {
i->print(cout); cout << ::std::endl;
}
#endif
}
}
// add var sources to following phi instructions
const Edges& edges = node->getOutEdges();
Edges::const_iterator
eiter = edges.begin(),
eend = edges.end();
for(eiter = edges.begin(); eiter != eend; ++eiter) {
Edge* e = *eiter;
Node* succ = e->getTargetNode();
// Phi insts are inserted to the beginning of the block
// if succ does not have phi insts, then we can skip it
Inst *phi = (Inst*)succ->getSecondInst();
if (phi==NULL || !phi->isPhi()) continue;
// node is jth predecessor for succ
// replace jth var of phi insts
Inst* nextphi = phi->getNextInst();
for (;phi!=NULL && phi->isPhi(); phi = nextphi) {
nextphi = phi->getNextInst();
// get var
Opnd *theopnd = phi->getDst();
VarOpnd *thevar = theopnd->asVarOpnd();
//.........这里部分代码省略.........