Home | History | Annotate | Download | only in priv

Lines Matching refs:bb

58    After execution of the new BB, all guest state and guest memory is
256 /*--- Flattening out a BB into atomic SSA form ---*/
276 the end of 'bb'. */
278 static IRExpr* flatten_Expr ( IRSB* bb, IRExpr* ex )
282 IRType ty = typeOfIRExpr(bb->tyenv, ex);
288 t1 = newIRTemp(bb->tyenv, ty);
289 addStmtToIRSB(bb, IRStmt_WrTmp(t1,
291 flatten_Expr(bb, ex->Iex.GetI.ix),
296 t1 = newIRTemp(bb->tyenv, ty);
297 addStmtToIRSB(bb,
303 t1 = newIRTemp(bb->tyenv, ty);
304 addStmtToIRSB(bb, IRStmt_WrTmp(t1,
306 flatten_Expr(bb, qop->arg1),
307 flatten_Expr(bb, qop->arg2),
308 flatten_Expr(bb, qop->arg3),
309 flatten_Expr(bb, qop->arg4))));
315 t1 = newIRTemp(bb->tyenv, ty);
316 addStmtToIRSB(bb, IRStmt_WrTmp(t1,
318 flatten_Expr(bb, triop->arg1),
319 flatten_Expr(bb, triop->arg2),
320 flatten_Expr(bb, triop->arg3))));
325 t1 = newIRTemp(bb->tyenv, ty);
326 addStmtToIRSB(bb, IRStmt_WrTmp(t1,
328 flatten_Expr(bb, ex->Iex.Binop.arg1),
329 flatten_Expr(bb, ex->Iex.Binop.arg2))));
333 t1 = newIRTemp(bb->tyenv, ty);
334 addStmtToIRSB(bb, IRStmt_WrTmp(t1,
336 flatten_Expr(bb, ex->Iex.Unop.arg))));
340 t1 = newIRTemp(bb->tyenv, ty);
341 addStmtToIRSB(bb, IRStmt_WrTmp(t1,
344 flatten_Expr(bb, ex->Iex.Load.addr))));
350 newargs[i] = flatten_Expr(bb, newargs[i]);
351 t1 = newIRTemp(bb->tyenv, ty);
352 addStmtToIRSB(bb, IRStmt_WrTmp(t1,
359 t1 = newIRTemp(bb->tyenv, ty);
360 addStmtToIRSB(bb, IRStmt_WrTmp(t1,
361 IRExpr_Mux0X(flatten_Expr(bb, ex->Iex.Mux0X.cond),
362 flatten_Expr(bb, ex->Iex.Mux0X.expr0),
363 flatten_Expr(bb, ex->Iex.Mux0X.exprX))));
370 t1 = newIRTemp(bb->tyenv, ty);
371 addStmtToIRSB(bb, IRStmt_WrTmp(t1,
391 /* Append a completely flattened form of 'st' to the end of 'bb'. */
393 static void flatten_Stmt ( IRSB* bb, IRStmt* st )
405 addStmtToIRSB(bb, st);
408 e1 = flatten_Expr(bb, st->Ist.Put.data);
409 addStmtToIRSB(bb, IRStmt_Put(st->Ist.Put.offset, e1));
414 e1 = flatten_Expr(bb, puti->ix);
415 e2 = flatten_Expr(bb, puti->data);
417 addStmtToIRSB(bb, IRStmt_PutI(puti2));
423 addStmtToIRSB(bb, st);
426 e1 = flatten_Expr(bb, st->Ist.WrTmp.data);
427 addStmtToIRSB(bb, IRStmt_WrTmp(st->Ist.WrTmp.tmp, e1));
431 e1 = flatten_Expr(bb, st->Ist.Store.addr);
432 e2 = flatten_Expr(bb, st->Ist.Store.data);
433 addStmtToIRSB(bb, IRStmt_Store(st->Ist.Store.end, e1,e2));
437 e1 = flatten_Expr(bb, cas->addr);
438 e2 = cas->expdHi ? flatten_Expr(bb, cas->expdHi) : NULL;
439 e3 = flatten_Expr(bb, cas->expdLo);
440 e4 = cas->dataHi ? flatten_Expr(bb, cas->dataHi) : NULL;
441 e5 = flatten_Expr(bb, cas->dataLo);
444 addStmtToIRSB(bb, IRStmt_CAS(cas2));
447 e1 = flatten_Expr(bb, st->Ist.LLSC.addr);
449 ? flatten_Expr(bb, st->Ist.LLSC.storedata)
451 addStmtToIRSB(bb, IRStmt_LLSC(st->Ist.LLSC.end,
460 d2->mAddr = flatten_Expr(bb, d2->mAddr);
464 d2->guard = flatten_Expr(bb, d2->guard);
466 d2->args[i] = flatten_Expr(bb, d2->args[i]);
467 addStmtToIRSB(bb, IRStmt_Dirty(d2));
472 addStmtToIRSB(bb, st);
475 e1 = flatten_Expr(bb, st->Ist.AbiHint.base);
476 e2 = flatten_Expr(bb, st->Ist.AbiHint.nia);
477 addStmtToIRSB(bb, IRStmt_AbiHint(e1, st->Ist.AbiHint.len, e2));
480 e1 = flatten_Expr(bb, st->Ist.Exit.guard);
481 addStmtToIRSB(bb, IRStmt_Exit(e1, st->Ist.Exit.jk,
587 static void redundant_get_removal_BB ( IRSB* bb )
594 for (i = 0; i < bb->stmts_used; i++) {
595 IRStmt* st = bb->stmts[i];
616 Bool typesOK = toBool( typeOfIRExpr(bb->tyenv,valE)
624 bb->stmts[i] = IRStmt_WrTmp(st->Ist.WrTmp.tmp, valE);
640 typeOfIRExpr(bb->tyenv,st->Ist.Put.data) );
676 } /* for (i = 0; i < bb->stmts_used; i++) */
831 IRSB* bb,
849 key = mk_key_GetPut(bb->offsIP, typeOfIRExpr(bb->tyenv, bb->next));
853 for (i = bb->stmts_used-1; i >= 0; i--) {
854 st = bb->stmts[i];
895 typeOfIRExpr(bb->tyenv,st->Ist.Put.data) );
920 bb->stmts[i] = IRStmt_NoOp();
2474 as it is for now, since we'd have to truncate the BB
2538 /* 't1 = t2' -- don't add to BB; will be optimized out */
2541 /* 't = const' && 'const != F64i' -- don't add to BB
2722 exit destination and jump kind to the bb-end. Then, the exit and
2726 /* notstatic */ void do_deadcode_BB ( IRSB* bb )
2729 Int n_tmps = bb->tyenv->types_used;
2737 addUses_Expr(set, bb->next);
2743 for (i = bb->stmts_used-1; i >= 0; i--) {
2744 st = bb->stmts[i];
2759 bb->stmts[i] = IRStmt_NoOp();
2767 bb->stmts[i] = IRStmt_NoOp();
2782 && i_unconditional_exit < bb->stmts_used);
2783 bb->next
2784 = IRExpr_Const( bb->stmts[i_unconditional_exit]->Ist.Exit.dst );
2785 bb->jumpkind
2786 = bb->stmts[i_unconditional_exit]->Ist.Exit.jk;
2787 bb->offsIP
2788 = bb->stmts[i_unconditional_exit]->Ist.Exit.offsIP;
2789 for (i = i_unconditional_exit; i < bb->stmts_used; i++)
2790 bb->stmts[i] = IRStmt_NoOp();
2802 bb,
2811 for (i = bb->stmts_used-1; i >= 0; i--) {
2812 st = bb->stmts[i];
2820 &bb->stmts[0], i );
2825 /* We got something better. Install it in the bb. */
2827 bb->stmts[i]
2840 bb = flatten_BB(bb);
2841 return bb;
3348 /* The BB is modified in-place. Returns True if any changes were
3351 static Bool do_cse_BB ( IRSB* bb )
3366 if (0) { ppIRSB(bb); vex_printf("\n\n"); }
3383 for (i = 0; i < bb->stmts_used; i++) {
3384 st = bb->stmts[i];
3426 typeOfIRExpr(bb->tyenv,st->Ist.Put.data)
3481 bb->stmts[i] = IRStmt_WrTmp( t, IRExpr_RdTmp(q) );
3488 bb->stmts[i] = IRStmt_WrTmp( t, availExpr_to_IRExpr(eprime) );
3494 ppIRSB(bb);
3495 sanityCheckIRSB(bb, Ity_I32);
3534 static Bool collapseChain ( IRSB* bb, Int startHere,
3551 st = bb->stmts[j];
3578 static void collapse_AddSub_chains_BB ( IRSB* bb )
3584 for (i = bb->stmts_used-1; i >= 0; i--) {
3585 st = bb->stmts[i];
3596 if (collapseChain(bb, i-1, var, &var2, &con2)) {
3603 bb->stmts[i]
3615 ppIRStmt(bb->stmts[i]);
3628 && collapseChain(bb, i-1, st->Ist.WrTmp.data->Iex.GetI.ix
3636 bb->stmts[i]
3643 ppIRStmt(bb->stmts[i]);
3653 && collapseChain(bb, i-1, puti->ix->Iex.RdTmp.tmp,
3661 bb->stmts[i]
3667 ppIRStmt(bb->stmts[i]);
3687 IRExpr* findPutI ( IRSB* bb, Int startHere,
3702 /* Scan backwards in bb from startHere to find a suitable PutI
3706 st = bb->stmts[j];
3719 typeOfIRExpr(bb->tyenv,st->Ist.Put.data) );
3912 bb is modified in-place. */
3915 void do_redundant_GetI_elimination ( IRSB* bb )
3920 for (i = bb->stmts_used-1; i >= 0; i--) {
3921 st = bb->stmts[i];
3931 IRExpr* replacement = findPutI(bb, i-1, descr, ix, bias);
3935 && typeOfIRExpr(bb->tyenv, replacement) == descr->elemTy) {
3943 bb->stmts[i] = IRStmt_WrTmp(st->Ist.WrTmp.tmp, replacement);
3952 bb is modified in-place. */
3955 void do_redundant_PutI_elimination ( IRSB* bb )
3965 for (i = 0; i < bb->stmts_used; i++) {
3966 st = bb->stmts[i];
3983 for (j = i+1; j < bb->stmts_used; j++) {
3984 stj = bb->stmts[j];
3998 if (guestAccessWhichMightOverlapPutI(bb->tyenv, st, stj))
4009 bb->stmts[i] = IRStmt_NoOp();
4160 static Int calc_unroll_factor( IRSB* bb )
4165 for (i = 0; i < bb->stmts_used; i++) {
4166 if (bb->stmts[i]->tag != Ist_NoOp)
4227 /* The BB ends in a jump to a literal location. */
4237 /* Now we know the BB ends to a jump to a literal location. If
4239 unrolling stage, first cloning the bb so the original isn't
4284 /* Ok, we found idiom #2. Copy the BB, switch around the xxx and
4287 the copied BB. */
4301 found and checked the last stmt in the original bb. */
4962 /* notstatic */ Addr64 ado_treebuild_BB ( IRSB* bb )
4973 Int n_tmps = bb->tyenv->types_used;
4976 /* Phase 1. Scan forwards in bb, counting use occurrences of each
4977 temp. Also count occurrences in the bb->next field. Take the
4985 for (i = 0; i < bb->stmts_used; i++) {
4986 st = bb->stmts[i];
5003 aoccCount_Expr(uses, bb->next );
5014 /* Phase 2. Scan forwards in bb. For each statement in turn:
5034 Finally, apply env to bb->next.
5042 /* The stmts in bb are being reordered, and we are guaranteed to
5048 for (i = 0; i < bb->stmts_used; i++) {
5050 st = bb->stmts[i];
5057 bb->stmts[j] = IRStmt_WrTmp( env[A_NENV-1].binder,
5072 continue; /* for (i = 0; i < bb->stmts_used; i++) loop */
5084 continue; /* for (i = 0; i < bb->stmts_used; i++) loop */
5140 bb->stmts[j] = IRStmt_WrTmp( env[k].binder, env[k].bindee );
5160 bb->stmts[j] = st2;
5161 /* vex_printf("**2 "); ppIRStmt(bb->stmts[j]); vex_printf("\n"); */
5165 } /* for each stmt in the original bb ... */
5171 bb->next = atbSubst_Expr(env, bb->next);
5172 bb->stmts_used = j;
5185 /* Do a simple cleanup pass on bb. This is: redundant Get removal,
5193 IRSB* bb,
5198 redundant_get_removal_BB ( bb );
5201 ppIRSB(bb);
5205 redundant_put_removal_BB ( bb, preciseMemExnsFn );
5209 ppIRSB(bb);
5212 bb = cprop_BB ( bb );
5215 ppIRSB(bb);
5218 do_deadcode_BB ( bb );
5221 ppIRSB(bb);
5224 bb = spec_helpers_BB ( bb, specHelper );
5225 do_deadcode_BB ( bb );
5228 ppIRSB(bb);
5231 return bb;
5235 /* Do some more expensive transformations on bb, which are aimed at
5239 IRSB* expensive_transformations( IRSB* bb )
5241 (void)do_cse_BB( bb );
5242 collapse_AddSub_chains_BB( bb );
5243 do_redundant_GetI_elimination( bb );
5245 do_redundant_PutI_elimination( bb );
5247 do_deadcode_BB( bb );
5248 return bb;
5252 /* Scan a flattened BB to look for signs that more expensive
5260 IRSB* bb )
5270 for (i = 0; i < bb->stmts_used; i++) {
5271 st = bb->stmts[i];
5283 switch (typeOfIRTemp(bb->tyenv, st->Ist.WrTmp.tmp)) {
5365 IRSB *bb, *bb2;
5372 bb = flatten_BB ( bb0 );
5376 ppIRSB(bb);
5380 if (vex_control.iropt_level <= 0) return bb;
5388 bb = cheap_transformations( bb, specHelper, preciseMemExnsFn );
5393 bb = cprop_BB(bb);
5394 bb = spec_helpers_BB ( bb, specHelper );
5396 redundant_put_removal_BB ( bb, preciseMemExnsFn );
5398 do_cse_BB( bb );
5399 do_deadcode_BB( bb );
5406 considerExpensives( &hasGetIorPutI, &hasVorFtemps, bb );
5414 (void)do_cse_BB( bb );
5415 bb );
5423 bb = expensive_transformations( bb );
5424 bb = cheap_transformations( bb, specHelper, preciseMemExnsFn );
5426 cses = do_cse_BB( bb );
5428 bb = cheap_transformations( bb, specHelper, preciseMemExnsFn );
5431 /* Now have a go at unrolling simple (single-BB) loops. If
5434 bb2 = maybe_loop_unroll_BB( bb, guest_addr );
5436 bb = cheap_transformations( bb2, specHelper, preciseMemExnsFn );
5438 bb = expensive_transformations( bb );
5439 bb = cheap_transformations( bb, specHelper, preciseMemExnsFn );
5442 do_cse_BB( bb );
5443 do_deadcode_BB( bb );
5450 return bb;