diff options
Diffstat (limited to 'gcc/internal-fn.c')
-rw-r--r-- | gcc/internal-fn.c | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/gcc/internal-fn.c b/gcc/internal-fn.c index a7bb748..eb5493f 100644 --- a/gcc/internal-fn.c +++ b/gcc/internal-fn.c @@ -3219,6 +3219,21 @@ static void (*const internal_fn_expanders[]) (internal_fn, gcall *) = { 0 }; +/* Invoke T(CODE, IFN) for each conditional function IFN that maps to a + tree code CODE. */ +#define FOR_EACH_CODE_MAPPING(T) \ + T (PLUS_EXPR, IFN_COND_ADD) \ + T (MINUS_EXPR, IFN_COND_SUB) \ + T (MULT_EXPR, IFN_COND_MUL) \ + T (TRUNC_DIV_EXPR, IFN_COND_DIV) \ + T (TRUNC_MOD_EXPR, IFN_COND_MOD) \ + T (RDIV_EXPR, IFN_COND_RDIV) \ + T (MIN_EXPR, IFN_COND_MIN) \ + T (MAX_EXPR, IFN_COND_MAX) \ + T (BIT_AND_EXPR, IFN_COND_AND) \ + T (BIT_IOR_EXPR, IFN_COND_IOR) \ + T (BIT_XOR_EXPR, IFN_COND_XOR) + /* Return a function that only performs CODE when a certain condition is met and that uses a given fallback value otherwise. For example, if CODE is a binary operation associated with conditional function FN: @@ -3238,31 +3253,30 @@ get_conditional_internal_fn (tree_code code) { switch (code) { - case PLUS_EXPR: - return IFN_COND_ADD; - case MINUS_EXPR: - return IFN_COND_SUB; - case MIN_EXPR: - return IFN_COND_MIN; - case MAX_EXPR: - return IFN_COND_MAX; - case TRUNC_DIV_EXPR: - return IFN_COND_DIV; - case TRUNC_MOD_EXPR: - return IFN_COND_MOD; - case RDIV_EXPR: - return IFN_COND_RDIV; - case BIT_AND_EXPR: - return IFN_COND_AND; - case BIT_IOR_EXPR: - return IFN_COND_IOR; - case BIT_XOR_EXPR: - return IFN_COND_XOR; +#define CASE(CODE, IFN) case CODE: return IFN; + FOR_EACH_CODE_MAPPING(CASE) +#undef CASE default: return IFN_LAST; } } +/* If IFN implements the conditional form of a tree code, return that + tree code, otherwise return ERROR_MARK. */ + +tree_code +conditional_internal_fn_code (internal_fn ifn) +{ + switch (ifn) + { +#define CASE(CODE, IFN) case IFN: return CODE; + FOR_EACH_CODE_MAPPING(CASE) +#undef CASE + default: + return ERROR_MARK; + } +} + /* Return true if IFN is some form of load from memory. */ bool |