本文整理汇总了C++中IR类的典型用法代码示例。如果您正苦于以下问题:C++ IR类的具体用法?C++ IR怎么用?C++ IR使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BB_irlist
//Check that all basic blocks should only end with terminator IR.
void IRBB::verify()
{
UINT c = 0;
C<IR*> * ct;
for (IR * ir = BB_irlist(this).get_head(&ct);
ir != NULL; ir = BB_irlist(this).get_next(&ct)) {
ASSERT0(ir->is_single());
ASSERT0(ir->get_bb() == this);
switch (IR_code(ir)) {
case IR_ST:
case IR_STPR:
case IR_STARRAY:
case IR_IST:
case IR_PHI:
case IR_REGION:
case IR_CALL:
case IR_ICALL:
case IR_GOTO:
case IR_IGOTO:
case IR_TRUEBR:
case IR_FALSEBR:
case IR_RETURN:
case IR_SWITCH:
break;
default: ASSERT(0, ("BB does not supported this kind of IR."));
}
if (is_bb_down_boundary(ir)) {
ASSERT(ir == BB_last_ir(this), ("invalid BB down boundary."));
}
c++;
}
ASSERT0(c == getNumOfIR());
}
示例2: ASSERT
//Canonicalize det of IF.
//e.g: if (a=10,b+=3,c<a) {...}
//be replaced by
// a = 10;
// b += 3;
// if (c<a) {...}
bool IR_CFS_OPT::hoistIf(IR ** head, IR * ir)
{
ASSERT(ir->is_if(), ("need IF"));
ASSERT(IF_det(ir), ("DET is NULL"));
IR * det = IF_det(ir);
INT i = 0;
while (det != NULL) {
i++;
det = det->get_next();
}
IR * new_list = NULL;
if (i > 1) {
det = IF_det(ir);
while (i > 1) {
IR * c = det;
ASSERT(c->is_stmt(),
("Non-stmt ir should be remove during reshape_ir_tree()"));
det = det->get_next();
xcom::remove(&IF_det(ir), c);
xcom::add_next(&new_list, c);
i--;
}
xcom::insertbefore(head, ir, new_list);
return true;
}
return false;
}
示例3: ASSERT0
//Before removing bb, revising phi opnd if there are phis
//in one of bb's successors.
void IRBB::removeSuccessorPhiOpnd(CFG<IRBB, IR> * cfg)
{
IR_CFG * ircfg = (IR_CFG*)cfg;
Region * ru = ircfg->get_ru();
Vertex * vex = ircfg->get_vertex(BB_id(this));
ASSERT0(vex);
for (EdgeC * out = VERTEX_out_list(vex);
out != NULL; out = EC_next(out)) {
Vertex * succ_vex = EDGE_to(EC_edge(out));
IRBB * succ = ircfg->get_bb(VERTEX_id(succ_vex));
ASSERT0(succ);
UINT const pos = ircfg->WhichPred(this, succ);
for (IR * ir = BB_first_ir(succ);
ir != NULL; ir = BB_next_ir(succ)) {
if (!ir->is_phi()) { break; }
ASSERT0(cnt_list(PHI_opnd_list(ir)) ==
cnt_list(VERTEX_in_list(succ_vex)));
IR * opnd;
UINT lpos = pos;
for (opnd = PHI_opnd_list(ir);
lpos != 0; opnd = IR_next(opnd)) {
ASSERT0(opnd);
lpos--;
}
opnd->removeSSAUse();
((CPhi*)ir)->removeOpnd(opnd);
ru->freeIRTree(opnd);
}
}
}
示例4: IRremote
volatile char IRremote(char key, char first)
{
if(first)
{
lcd.cls();
menu.setTitle(TEXT("IR Remote"));
menu.setBar(TEXT("Delayed"), TEXT("Trigger"));
lcd.update();
}
switch(key)
{
case FL_KEY:
ir.shutterDelayed();
break;
case FR_KEY:
ir.shutterNow();
break;
case LEFT_KEY:
return FN_CANCEL;
}
return FN_CONTINUE;
}
示例5: if
/* Canonicalize det of IF.
e.g: if (a=10,b+=3,c<a) {...}
be replaced by
a = 10;
b += 3;
if (c<a) {...} */
bool IR_CFS_OPT::hoist_if(IR ** head, IR * ir)
{
IS_TRUE(IR_type(ir) == IR_IF, ("need IF"));
IS_TRUE(IF_det(ir), ("DET is NULL"));
IR * det = IF_det(ir);
INT i = 0;
while (det != NULL) {
i++;
det = IR_next(det);
}
IR * new_list = NULL;
if (i > 1) {
det = IF_det(ir);
while (i > 1) {
IR * c = det;
IS_TRUE(c->is_stmt(),
("Non-stmt ir should be remove during reshape_ir_tree()"));
det = IR_next(det);
remove(&IF_det(ir), c);
add_next(&new_list, c);
i--;
}
insertbefore(head, ir, new_list);
return true;
}
return false;
}
示例6: ASSERT0
//Allocate MDPhi and initialize with the number of operands.
//Each operands has zero version to mdid.
MDPhi * UseDefMgr::allocMDPhi(UINT mdid, UINT num_operands)
{
ASSERT0(mdid > 0 && num_operands > 0);
MDPhi * phi = (MDPhi*)smpoolMallocConstSize(sizeof(MDPhi), m_phi_pool);
phi->init();
MDDEF_id(phi) = m_def_count++;
m_def_vec.set(MDDEF_id(phi), phi);
VMD const* vmd = allocVMD(mdid, 0);
ASSERT0(vmd);
MD const* md = m_md_sys->getMD(mdid);
ASSERT0(md);
IR * last = NULL;
for (UINT i = 0; i < num_operands; i++) {
IR * opnd = m_ru->buildId(md->get_base());
opnd->setRefMD(md, m_ru);
MDSSAInfo * mdssainfo = genMDSSAInfo(opnd);
ASSERT0(m_sbs_mgr);
mdssainfo->getVOpndSet()->append(vmd, *m_sbs_mgr);
xcom::add_next(&MDPHI_opnd_list(phi), &last, opnd);
ID_phi(opnd) = phi;
}
return phi;
}
示例7: while
/* Hoist det of loop.
e.g: while (a=10,b+=3,c<a) {
IR-LIST;
}
be replaced by
a = 10;
b += 3;
while (c<a) {
IR-LIST;
a = 10;
b += 3;
} */
bool IR_CFS_OPT::hoist_loop(IR ** head, IR * ir)
{
IS_TRUE(IR_type(ir)==IR_DO_WHILE ||
IR_type(ir)==IR_WHILE_DO ||
IR_type(ir)==IR_DO_LOOP, ("need LOOP"));
IS_TRUE(LOOP_det(ir), ("DET is NULL"));
IR * det = LOOP_det(ir);
INT i = 0;
while (det != NULL) {
i++;
det = IR_next(det);
}
IR * new_list = NULL, * new_body_list = NULL;
if (i > 1) {
det = LOOP_det(ir);
while (i > 1) {
IR * c = det;
IS_TRUE(c->is_stmt(), ("Non-stmt ir should be remove "
"during reshape_ir_tree()"));
det = IR_next(det);
remove(&LOOP_det(ir), c);
add_next(&new_list, c);
i--;
}
new_body_list = m_ru->dup_irs_list(new_list);
insertbefore(head, ir, new_list);
add_next(&LOOP_body(ir), new_body_list);
return true;
}
return false;
}
示例8: ASSERT0
//Hoist det of loop.
//e.g: while (a=10,b+=3,c<a) {
// IR-List;
// }
//
//be replaced by
//
// a = 10;
// b += 3;
// while (c<a) {
// IR-List;
// a = 10;
// b += 3;
// }
bool IR_CFS_OPT::hoistLoop(IR ** head, IR * ir)
{
ASSERT0(ir->is_dowhile() || ir->is_whiledo() || ir->is_doloop());
ASSERT(LOOP_det(ir), ("DET is NULL"));
IR * det = LOOP_det(ir);
INT i = 0;
while (det != NULL) {
i++;
det = det->get_next();
}
IR * new_list = NULL, * new_body_list = NULL;
if (i > 1) {
det = LOOP_det(ir);
while (i > 1) {
IR * c = det;
ASSERT(c->is_stmt(), ("Non-stmt ir should be remove "
"during reshape_ir_tree()"));
det = det->get_next();
xcom::remove(&LOOP_det(ir), c);
xcom::add_next(&new_list, c);
i--;
}
new_body_list = m_ru->dupIRTreeList(new_list);
xcom::insertbefore(head, ir, new_list);
xcom::add_next(&LOOP_body(ir), new_body_list);
return true;
}
return false;
}
示例9: ASSERT0
//Before removing bb or change bb successor,
//you need remove the related PHI operand if BB successor has PHI stmt.
void IRBB::removeSuccessorDesignatePhiOpnd(CFG<IRBB, IR> * cfg, IRBB * succ)
{
ASSERT0(cfg && succ);
IR_CFG * ircfg = (IR_CFG*)cfg;
Region * ru = ircfg->get_ru();
UINT const pos = ircfg->WhichPred(this, succ);
for (IR * ir = BB_first_ir(succ); ir != NULL; ir = BB_next_ir(succ)) {
if (!ir->is_phi()) { break; }
ASSERT0(cnt_list(PHI_opnd_list(ir)) == succ->getNumOfPred(cfg));
IR * opnd;
UINT lpos = pos;
for (opnd = PHI_opnd_list(ir); lpos != 0; opnd = opnd->get_next()) {
ASSERT0(opnd);
lpos--;
}
if (opnd == NULL) {
//PHI does not contain any operand.
continue;
}
opnd->removeSSAUse();
((CPhi*)ir)->removeOpnd(opnd);
ru->freeIRTree(opnd);
}
}
示例10: CE_Eliminator
CE_Eliminator(IR* hir) : _cee_count(0), _ifop_count(0), _hir(hir) {
_has_substitution = false;
_hir->iterate_preorder(this);
if (_has_substitution) {
// substituted some ifops/phis, so resolve the substitution
SubstitutionResolver sr(_hir);
}
CompileLog* log = _hir->compilation()->log();
if (log != NULL)
log->set_context("optimize name='cee'");
}
示例11: CE_Eliminator
CE_Eliminator(IR* hir) : _cee_count(0), _ifop_count(0), _hir(hir) {
_has_substitution = false;
_hir->iterate_preorder(this);
if (_has_substitution) {
// substituted some ifops/phis, so resolve the substitution
SubstitutionResolver sr(_hir);
}
}
示例12: fprintf
void IRBB::dump(Region * ru)
{
if (g_tfile == NULL) { return; }
g_indent = 0;
fprintf(g_tfile, "\n----- BB%d ------", BB_id(this));
if (get_lab_list().get_elem_count() > 0) {
fprintf(g_tfile, "\nLABEL:");
dumpBBLabel(get_lab_list(), g_tfile);
}
//Attributes
fprintf(g_tfile, "\nATTR:");
if (BB_is_entry(this)) {
fprintf(g_tfile, "entry_bb ");
}
//if (BB_is_exit(this)) {
// fprintf(g_tfile, "exit_bb ");
//}
if (BB_is_fallthrough(this)) {
fprintf(g_tfile, "fall_through ");
}
if (BB_is_target(this)) {
fprintf(g_tfile, "branch_target ");
}
//IR list
fprintf(g_tfile, "\nSTMT NUM:%d", getNumOfIR());
g_indent += 3;
TypeMgr * dm = ru->get_type_mgr();
for (IR * ir = BB_first_ir(this);
ir != NULL; ir = BB_irlist(this).get_next()) {
ASSERT0(IR_next(ir) == NULL && IR_prev(ir) == NULL);
ASSERT0(ir->get_bb() == this);
dump_ir(ir, dm, NULL, true, true, false);
}
g_indent -= 3;
fprintf(g_tfile, "\n");
fflush(g_tfile);
}
示例13: ASSERT0
//Check and replace 'ir' with 'cand_expr' if they are
//equal, and update DU info. If 'cand_expr' is NOT leaf,
//that will create redundant computation, and
//depends on later Redundancy Elimination to reverse back.
//exp: expression which will be replaced.
//
//cand_expr: substitute cand_expr for exp.
// e.g: cand_expr is *p, cand_expr_md is MD3
// *p(MD3) = 10 //p point to MD3
// ...
// g = *q(MD3) //q point to MD3
//
//exp_use_ssadu: true if exp used SSA du info.
//
//NOTE: Do NOT handle stmt.
void IR_CP::replaceExp(IR * exp, IR const* cand_expr,
IN OUT CPCtx & ctx, bool exp_use_ssadu)
{
ASSERT0(exp && exp->is_exp() && cand_expr);
ASSERT0(exp->get_exact_ref());
if (!checkTypeConsistency(exp, cand_expr)) {
return;
}
IR * parent = IR_parent(exp);
if (parent->is_ild()) {
CPC_need_recomp_aa(ctx) = true;
} else if (parent->is_ist() && exp == IST_base(parent)) {
if (!cand_expr->is_ld() && !cand_expr->is_pr() && !cand_expr->is_lda()) {
return;
}
CPC_need_recomp_aa(ctx) = true;
}
IR * newir = m_ru->dupIRTree(cand_expr);
m_du->copyIRTreeDU(newir, cand_expr, true);
ASSERT0(cand_expr->get_stmt());
if (exp_use_ssadu) {
//Remove exp SSA use.
ASSERT0(exp->get_ssainfo());
ASSERT0(exp->get_ssainfo()->get_uses().find(exp));
exp->removeSSAUse();
} else {
m_du->removeUseOutFromDefset(exp);
}
CPC_change(ctx) = true;
ASSERT0(exp->get_stmt());
bool doit = parent->replaceKid(exp, newir, false);
ASSERT0(doit);
UNUSED(doit);
m_ru->freeIRTree(exp);
}
示例14: ASSERT0
//Duplicate and add an operand that indicated by opnd_pos at phi stmt
//in one of bb's successors.
void IRBB::dupSuccessorPhiOpnd(CFG<IRBB, IR> * cfg, Region * ru, UINT opnd_pos)
{
IR_CFG * ircfg = (IR_CFG*)cfg;
Vertex * vex = ircfg->get_vertex(BB_id(this));
ASSERT0(vex);
for (EdgeC * out = VERTEX_out_list(vex);
out != NULL; out = EC_next(out)) {
Vertex * succ_vex = EDGE_to(EC_edge(out));
IRBB * succ = ircfg->get_bb(VERTEX_id(succ_vex));
ASSERT0(succ);
for (IR * ir = BB_first_ir(succ);
ir != NULL; ir = BB_next_ir(succ)) {
if (!ir->is_phi()) {
break;
}
ASSERT0(cnt_list(PHI_opnd_list(ir)) >= opnd_pos);
IR * opnd;
UINT lpos = opnd_pos;
for (opnd = PHI_opnd_list(ir);
lpos != 0; opnd = opnd->get_next()) {
ASSERT0(opnd);
lpos--;
}
IR * newopnd = ru->dupIRTree(opnd);
if (opnd->is_read_pr()) {
newopnd->copyRef(opnd, ru);
ASSERT0(PR_ssainfo(opnd));
PR_ssainfo(newopnd) = PR_ssainfo(opnd);
SSA_uses(PR_ssainfo(newopnd)).append(newopnd);
}
((CPhi*)ir)->addOpnd(newopnd);
}
}
}
示例15: settings_load
void settings_load()
{
eeprom_read_block((void*)&conf, &conf_eep, sizeof(settings_t));
if(settings_camera_index > 0)
{
eeprom_read_block((void*)&conf.camera, &camera_settings_eep[settings_camera_index - 1], sizeof(camera_settings_t));
}
if(conf.lcdContrast > 0xf || conf.lcdContrast < 0x1) conf.lcdContrast = 0x8;
if(conf.lcdCoefficent > 0x7 || conf.lcdCoefficent < 0x3) conf.lcdCoefficent = 0x7;
if(conf.lcdBias > 0x4 || conf.lcdBias < 0x3) conf.lcdBias = 0x4;
if(conf.apertureMin > 100 || conf.apertureMin < 2) conf.apertureMin = 2;
if(conf.lightIntegrationMinutes == 255 || conf.lightIntegrationMinutes == 0) conf.lightIntegrationMinutes = 10;
if(conf.camera.brampGap > 20 || conf.camera.brampGap == 0) conf.camera.brampGap = 6;
if(conf.errorAlert > 5) conf.errorAlert = 0;
if(conf.linearInterpolation > 1) conf.linearInterpolation = 0;
lcd.color(conf.lcdColor);
ir.init();
ir.make = conf.camera.cameraMake;
if(conf.auxPort != AUX_MODE_DISABLED)
{
aux1_off();
aux2_off();
}
if(bt.present && !remote.connected)
{
if(conf.btMode == BT_MODE_SLEEP) bt.sleep(); else bt.advertise();
}
}