diff mbox

[v3,06/14] tcg: Allow non-constant control macros

Message ID 1372886968-17497-7-git-send-email-rth@twiddle.net
State New
Headers show

Commit Message

Richard Henderson July 3, 2013, 9:29 p.m. UTC
This allows TCG_TARGET_HAS_* to be a variable rather than a constant,
which allows easier support for differing ISA levels for the host.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/tcg-opc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Peter Maydell July 4, 2013, 10:53 a.m. UTC | #1
On 3 July 2013 22:29, Richard Henderson <rth@twiddle.net> wrote:
> This allows TCG_TARGET_HAS_* to be a variable rather than a constant,
> which allows easier support for differing ISA levels for the host.

The effect of this is that TCG_OPF_NOT_PRESENT means "if set,
op is definitely not present; if not set, op might or might
not be present", right? Which is OK because it's just a debug
guard/sanity check. (That might be worth noting in a comment
I guess.)

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM
Richard Henderson July 4, 2013, 5:28 p.m. UTC | #2
On 07/04/2013 03:53 AM, Peter Maydell wrote:
> On 3 July 2013 22:29, Richard Henderson <rth@twiddle.net> wrote:
>> This allows TCG_TARGET_HAS_* to be a variable rather than a constant,
>> which allows easier support for differing ISA levels for the host.
> 
> The effect of this is that TCG_OPF_NOT_PRESENT means "if set,
> op is definitely not present; if not set, op might or might
> not be present", right? Which is OK because it's just a debug
> guard/sanity check. (That might be worth noting in a comment
> I guess.)

Well, if not set, an entry must be present in the operands table.

E.g. for arm division, the { INDEX_op_div_i32, "r", "r", "r" } entry
is always there, even if TCG_TARGET_HAS_div_i32 evaluates to false
at runtime.  The entry must be there Just In Case the expression might
be true.


r~
diff mbox

Patch

diff --git a/tcg/tcg-opc.h b/tcg/tcg-opc.h
index 12967fb..c94e255 100644
--- a/tcg/tcg-opc.h
+++ b/tcg/tcg-opc.h
@@ -40,7 +40,7 @@  DEF(set_label, 0, 0, 1, TCG_OPF_BB_END)
 DEF(call, 0, 1, 2, TCG_OPF_CALL_CLOBBER) /* variable number of parameters */
 DEF(br, 0, 0, 1, TCG_OPF_BB_END)
 
-#define IMPL(X) (X ? 0 : TCG_OPF_NOT_PRESENT)
+#define IMPL(X) (__builtin_constant_p(X) && !(X) ? TCG_OPF_NOT_PRESENT : 0)
 #if TCG_TARGET_REG_BITS == 32
 # define IMPL64  TCG_OPF_64BIT | TCG_OPF_NOT_PRESENT
 #else