|
From: Florian K. <br...@ac...> - 2012-10-12 02:40:54
|
On 10/11/2012 08:34 PM, Julian Seward wrote: > > We need to be able to represent conditional loads and stores in IR. > [...] > Also s390 might benefit from them, I think. Yes. It has both conditional load and store insns as well as some other more obscure insns that could potentially benfit from this by having a simplified IR generation. > For conditional stores, we could either add a guard expression field > to IRStmt_Store. Or, add a new variant, IRStmt_StoreC, identical to > IRStmt_Store but with an added guard field. This would have the > advantage of not having to have the vast majority of (normal) stores > carry an "always-true" guard field. +1 for IRStmt_StoreC. Having a separate statement kind makes sure it gets implemented by the tools, whereas an additional guard expression is too easily overlooked and then isn't handled properly. Remember the guard expression on the dirty helper? > At first I thought of having conditional loads as just another IRExpr > member. But that gives potential complexity with register allocation > if we allow arbitrary expressions for the "backup" value, since if the > guard is false then we won't want any of the expression to be > evaluated. Huh? I think you want to evaluate the backup expression if the guard is false. No? > But that requires doing proper control flow within > superblocks in the back ends, which they, and particularly the > register allocator, are not set up to do. > > So an alternative, more conservative proposal, is to have conditional > loads be a statement kind: > > result_temp = Conditional_Load( guard_expr, address_expr, backup_temp ) > > and the trick is that the backup value is an IRTemp, not an IRExpr, > which unambiguously forces us to evaluate it regardless of what > 'guard_expr' evaluates to. Just to be clear: in a Conditional_Load stmt both the address_expr and the backup_temp get evaluated independent of the value of the guard expression. Right? You probably need to stick in the endianess into the Conditional_Load. While we're at it... Can I have a Ist_PutC -- a conditional Put ? PutC ( guard_expr, offset, data_temp) If guard_expr is true, then data_temp will be stored at offset in guest state. That would help s390. Florian |