diff options
Diffstat (limited to 'gcc/gimple-fold.c')
-rw-r--r-- | gcc/gimple-fold.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index bde20a3..b9e0889 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -7058,6 +7058,58 @@ gimple_convert_to_ptrofftype (gimple_seq *seq, location_t loc, tree op) return gimple_convert (seq, loc, sizetype, op); } +/* Build a vector of type TYPE in which each element has the value OP. + Return a gimple value for the result, appending any new statements + to SEQ. */ + +tree +gimple_build_vector_from_val (gimple_seq *seq, location_t loc, tree type, + tree op) +{ + tree res, vec = build_vector_from_val (type, op); + if (is_gimple_val (vec)) + return vec; + if (gimple_in_ssa_p (cfun)) + res = make_ssa_name (type); + else + res = create_tmp_reg (type); + gimple *stmt = gimple_build_assign (res, vec); + gimple_set_location (stmt, loc); + gimple_seq_add_stmt_without_update (seq, stmt); + return res; +} + +/* Build a vector of type TYPE in which the elements have the values + given by ELTS. Return a gimple value for the result, appending any + new instructions to SEQ. */ + +tree +gimple_build_vector (gimple_seq *seq, location_t loc, tree type, + vec<tree> elts) +{ + unsigned int nelts = elts.length (); + gcc_assert (nelts == TYPE_VECTOR_SUBPARTS (type)); + for (unsigned int i = 0; i < nelts; ++i) + if (!TREE_CONSTANT (elts[i])) + { + vec<constructor_elt, va_gc> *v; + vec_alloc (v, nelts); + for (i = 0; i < nelts; ++i) + CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, elts[i]); + + tree res; + if (gimple_in_ssa_p (cfun)) + res = make_ssa_name (type); + else + res = create_tmp_reg (type); + gimple *stmt = gimple_build_assign (res, build_constructor (type, v)); + gimple_set_location (stmt, loc); + gimple_seq_add_stmt_without_update (seq, stmt); + return res; + } + return build_vector (type, elts); +} + /* Return true if the result of assignment STMT is known to be non-negative. If the return value is based on the assumption that signed overflow is undefined, set *STRICT_OVERFLOW_P to true; otherwise, don't change |