|
GCC Middle and Back End API Reference
|
#include "tree-pass.h"
Data Structures | |
| struct | gimplify_omp_ctx |
| struct | gimplify_init_ctor_preeval_data |
Typedefs | |
| typedef char * | char_p |
Enumerations | |
| enum | gimplify_omp_var_data { GOVD_SEEN = 1, GOVD_EXPLICIT = 2, GOVD_SHARED = 4, GOVD_PRIVATE = 8, GOVD_FIRSTPRIVATE = 16, GOVD_LASTPRIVATE = 32, GOVD_REDUCTION = 64, GOVD_LOCAL = 128, GOVD_MAP = 256, GOVD_DEBUG_PRIVATE = 512, GOVD_PRIVATE_OUTER_REF = 1024, GOVD_LINEAR = 2048, GOVD_ALIGNED = 4096, GOVD_MAP_TO_ONLY = 8192, GOVD_DATA_SHARE_CLASS } |
| enum | omp_region_type { ORT_WORKSHARE = 0, ORT_SIMD = 1, ORT_PARALLEL = 2, ORT_COMBINED_PARALLEL = 3, ORT_TASK = 4, ORT_UNTIED_TASK = 5, ORT_TEAMS = 8, ORT_TARGET_DATA = 16, ORT_TARGET = 32 } |
Variables | |
| static struct gimplify_ctx * | gimplify_ctxp |
| static struct gimplify_omp_ctx * | gimplify_omp_ctxp |
| static unsigned int | tmp_var_id_num |
| static struct pointer_set_t * | nonlocal_vlas |
| typedef char* char_p |
@verbatim
Tree lowering pass. This pass converts the GENERIC functions-as-trees tree representation into the GIMPLE form. Copyright (C) 2002-2013 Free Software Foundation, Inc. Major work done by Sebastian Pop s.pop@laposte.net, Diego Novillo dnovillo@redhat.com and Jason Merrill jason@redhat.com.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.
| enum omp_region_type |
| void annotate_all_with_location | ( | ) |
Set the location for all the statements in a sequence STMT_P to LOCATION.
References pointer_set_insert().
|
static |
Set LOCATION for all the statements after iterator GSI in sequence SEQ. If GSI is pointing to the end of the sequence, start with the first statement in SEQ.
|
static |
Set the location for gimple statement GS to LOCATION.
| tree build_and_jump | ( | ) |
Build a GOTO to the LABEL_DECL pointed to by LABEL_P, building it first if necessary.
If there's nowhere to jump, just fall through.
|
static |
Prepare calls to builtins to SAVE and RESTORE the stack as well as a temporary through which they communicate.
References build_constructor(), and gimplify_seq_add_stmt().
|
static |
If a NOP conversion is changing a pointer to array of foo to a pointer
to foo, embed that change in the ADDR_EXPR by converting
T array[U];
(T *)&array
==>
&array[L]
where L is the lower bound. For simplicity, only do this for constant
lower bound.
The constraint is that the type of &array[L] is trivially convertible
to T *. We simplify only conversions from an ADDR_EXPR to a pointer type.
The addr_expr type should be a pointer to an array.
The pointer to element type shall be trivially convertible to
the expression pointer type. The lower bound and element sizes must be constant.
All checks succeeded. Build a new node to merge the cast.
We can have stripped a required restrict qualifier above.
|
static |
*EXPR_P is a COMPONENT_REF being used as an rvalue. If its type is different from its canonical type, wrap the whole thing inside a NOP_EXPR and force the type of the COMPONENT_REF to be the canonical type. The canonical type of a COMPONENT_REF is the type of the field being referenced--unless the field is a bit-field which can be read directly in a smaller mode, in which case the canonical type is the sign-appropriate type corresponding to that mode.
One could argue that all the stuff below is not necessary for
the non-bitfield case and declare it a FE error if type
adjustment would be needed. We need to preserve qualifiers and propagate them from
operand 0. Set the type of the COMPONENT_REF to the underlying type.
It is now a FE error, if the conversion from the canonical
type to the original expression type is not useless.
References copy(), copy_node(), current_function_decl, decl_function_context(), lang_hooks::dup_lang_specific_decl, gimplify_omp_ctxp, GS_ALL_DONE, GS_ERROR, omp_notice_variable(), ORT_SIMD, ORT_WORKSHARE, gimplify_omp_ctx::outer_context, pointer_set_insert(), gimplify_omp_ctx::region_type, seen_error(), and unshare_expr().
|
static |
Compare two case labels. Because the front end should already have made sure that case ranges do not overlap, it is enough to only compare the CASE_LOW values of each case label.
The 'default' case label always goes first.
|
inlinestatic |
Unshare most of the shared trees rooted at *TP. DATA is passed to the copy_if_shared_r callback unmodified.
References mostly_copy_tree_r().
|
static |
Callback for walk_tree to unshare most of the shared trees rooted at *TP. If *TP has been visited already, then *TP is deeply copied by calling mostly_copy_tree_r. DATA is passed to mostly_copy_tree_r unmodified.
Skip types, decls, and constants. But we do want to look at their
types and the bounds of types. Mark them as visited so we properly
unmark their subtrees on the unmark pass. If we've already seen them,
don't look down further. If this node has been visited already, unshare it and don't look
any deeper. Otherwise, mark the node as visited and keep looking.
|
inlinestatic |
Create a temporary with a name derived from VAL. Subroutine of lookup_tmp_var; nobody else should call this function.
Drop all qualifiers and address-space information from the value type.
References gimple_temp_hash_elt::temp, and gimple_temp_hash_elt::val.
| tree create_tmp_reg | ( | ) |
Create a new temporary variable declaration of type TYPE by calling create_tmp_var and if TYPE is a vector or a complex number, mark the new temporary as gimple register.
| tree create_tmp_var | ( | ) |
Create a new temporary variable declaration of type TYPE. DO push the variable into the current binding. Further, assume that this is called only from gimplification or optimization, at which point the creation of certain types are bugs.
We don't allow types that are addressable (meaning we can't make copies),
or incomplete. We also used to reject every variable size objects here,
but now support those for which a constant upper bound can be obtained.
The processing for variable sizes is performed in gimple_add_tmp_var,
point at which it really matters and possibly reached via paths not going
through this function, e.g. after direct calls to create_tmp_var_raw.
| tree create_tmp_var_name | ( | ) |
References create_tmp_var_name(), and input_location.
| tree create_tmp_var_raw | ( | ) |
Create a new temporary variable declaration of type TYPE. Do NOT push it into the current binding.
The variable was declared by the compiler.
And we don't want debug info for it.
Make the variable writable.
References create_tmp_var_raw(), and gimple_add_tmp_var().
| void declare_vars | ( | ) |
Declare all the variables in VARS in SCOPE. If DEBUG_INFO is true, generate debug info for them; otherwise don't.
We need to attach the nodes both to the BIND_EXPR and to its
associated BLOCK for debugging purposes. The key point here
is that the BLOCK_VARS of the BIND_EXPR_BLOCK of a BIND_EXPR
is a subchain of the BIND_EXPR_VARS of the BIND_EXPR.
|
static |
Destroy an omp construct that deals with variable remapping.
References gimplify_and_add(), gsi_end_p(), gsi_next(), gsi_stmt(), and last.
|
static |
Return a dummy expression of type TYPE in order to keep going after an error.
|
static |
Helper function of gimplify_omp_for, find OMP_FOR resp. OMP_SIMD with non-NULL OMP_FOR_INIT.
FALLTHRU
|
static |
Return whether we should exclude FNDECL from instrumentation.
|
static |
For VAR a VAR_DECL of variable size, try to find a constant upper bound for the size and adjust DECL_SIZE/DECL_SIZE_UNIT accordingly. Abort if no such upper bound can be obtained.
The only attempt we make is by querying the maximum size of objects
of the variable's type.
| tree force_gimple_operand | ( | ) |
Expand EXPR to list of gimple statements STMTS. If SIMPLE is true, force the result to be either ssa_name or an invariant, otherwise just force it to be a rhs expression. If VAR is not NULL, make the base variable of the final destination be VAR if suitable.
| tree force_gimple_operand_1 | ( | tree | expr, |
| gimple_seq * | stmts, | ||
| gimple_predicate | gimple_test_f, | ||
| tree | var | ||
| ) |
Expand EXPR to list of gimple statements STMTS. GIMPLE_TEST_F specifies the predicate that will hold for the result. If VAR is not NULL, make the base variable of the final destination be VAR if suitable.
gimple_test_f might be more strict than is_gimple_val, make
sure we pass both. Just checking gimple_test_f doesn't work
because most gimple predicates do not work recursively.
Referenced by add_to_predicate_list(), and vect_create_cond_for_alias_checks().
| tree force_gimple_operand_gsi | ( | gimple_stmt_iterator * | gsi, |
| tree | expr, | ||
| bool | simple_p, | ||
| tree | var, | ||
| bool | before, | ||
| enum gsi_iterator_update | m | ||
| ) |
Invoke force_gimple_operand_1 for EXPR with parameter VAR. If SIMPLE is true, force the result to be either ssa_name or an invariant, otherwise just force it to be a rhs expression. If some statements are produced, emits them at GSI. If BEFORE is true, the statements are appended before GSI, otherwise they are appended after it. M specifies the way GSI moves after insertion (GSI_SAME_STMT or GSI_CONTINUE_LINKING are the usual values).
Referenced by build_one_array(), contains_vce_or_bfcref_p(), expand_omp_atomic_load(), expand_omp_sections(), generate_subtree_copies(), gimple_gen_one_value_profiler(), gimple_gen_pow2_profiler(), gimplify_mem_ref_parts(), ifcombine_ifandif(), nothing_to_prefetch_p(), sra_modify_expr(), update_dominators_in_loop(), and vect_can_advance_ivs_p().
| tree force_gimple_operand_gsi_1 | ( | gimple_stmt_iterator * | gsi, |
| tree | expr, | ||
| gimple_predicate | gimple_test_f, | ||
| tree | var, | ||
| bool | before, | ||
| enum gsi_iterator_update | m | ||
| ) |
Invoke force_gimple_operand_1 for EXPR with parameters GIMPLE_TEST_F and VAR. If some statements are produced, emits them at GSI. If BEFORE is true. the statements are appended before GSI, otherwise they are appended after it. M specifies the way GSI moves after insertion (GSI_SAME_STMT or GSI_CONTINUE_LINKING are the usual values).
Referenced by create_mem_ref(), if_convertible_loop_p(), and insert_gimplified_predicates().
| tree force_labels_r | ( | ) |
A helper function to be called via walk_tree. Mark all labels under *TP as being forced. To be called for DECL_INITIAL of static variables.
|
static |
Return true if evaluating EXPR could trap. EXPR is GENERIC, while tree_could_trap_p can be called only on GIMPLE.
References get_initialized_tmp_var(), handled_component_p(), and is_gimple_reg().
| tree get_formal_tmp_var | ( | ) |
Return a formal temporary variable initialized with VAL. PRE_P is as
in gimplify_expr. Only use this function if:
1) The value of the unfactored expression represented by VAL will not
change between the initialization and use of the temporary, and
2) The temporary will not be otherwise modified.
For instance, #1 means that this is inappropriate for SAVE_EXPR temps,
and #2 means it is inappropriate for && temps.
For other cases, use get_initialized_tmp_var instead.
References chainon(), gimple_bind_set_vars(), and gimple_bind_vars().
| tree get_initialized_tmp_var | ( | ) |
Return a temporary variable initialized with VAL. PRE_P and POST_P are as in gimplify_expr.
| void gimple_add_tmp_var | ( | ) |
Push the temporary variable TMP into the current binding.
Later processing assumes that the object size is constant, which might
not be true at this point. Force the use of a constant upper bound in
this case. Mark temporaries local within the nearest enclosing parallel.
This case is for nested functions. We need to expose the locals
they create.
Return the stack of bindings created during gimplification.
References gimplify_ctx::conditional_cleanups, gimplify_ctx::conditions, and gimple_seq_empty_p().
| tree gimple_boolify | ( | ) |
EXPR is used in a boolean context; make sure it has BOOLEAN_TYPE.
For __builtin_expect ((long) (x), y) recurse into x as well
if x is truth_value_p. Also boolify the arguments of truth exprs.
FALLTHRU
These expressions always produce boolean results.
FALLTHRU
There expressions always prduce boolean results.
Other expressions that get here must have boolean values, but
might need to be converted to the appropriate mode.
|
static |
Return true iff there is a COND_EXPR between us and the innermost CLEANUP_POINT_EXPR. This info is used by gimple_push_cleanup.
| gimple gimple_current_bind_expr | ( | void | ) |
Return the first element of the stack of bindings.
References gimplify_ctx::conditions.
|
inlinestatic |
Return true if a location should not be emitted for this statement by annotate_one_with_location.
|
static |
Given a pointer value OP0, return a simplified version of an indirection through OP0, or NULL_TREE if no simplification is possible. This may only be applied to a rhs of an expression. Note that the resulting type may be different from the type pointed to in the sense that it is still compatible from the langhooks point of view.
|
static |
Pop the first element off the stack of bindings.
|
static |
Note that we've left a COND_EXPR. If we're back at unconditional scope now, add any conditional cleanups we've seen to the prequeue.
|
static |
Push a GIMPLE_BIND tuple onto the stack of bindings.
References gimplify_ctx::bind_expr_stack.
|
static |
Insert a cleanup marker for gimplify_cleanup_point_expr. CLEANUP is the cleanup action required. EH_ONLY is true if the cleanup should only be executed if an exception is thrown, not on normal exit.
Errors can result in improperly nested cleanups. Which results in
confusion when trying to resolve the GIMPLE_WITH_CLEANUP_EXPR. If we're in a conditional context, this is more complex. We only
want to run the cleanup if we actually ran the initialization that
necessitates it, but we want to run it after the end of the
conditional context. So we wrap the try/finally around the
condition and use a flag to determine whether or not to actually
run the destructor. Thus
test ? f(A()) : 0
becomes (approximately)
flag = 0;
try {
if (test) { A::A(temp); flag = 1; val = f(temp); }
else { val = 0; }
} finally {
if (flag) A::~A(temp);
}
val Because of this manipulation, and the EH edges that jump
threading cannot redirect, the temporary (VAR) will appear
to be used uninitialized. Don't warn.
References error(), GOVD_EXPLICIT, GOVD_MAP, and omp_add_variable().
|
static |
Note that we've entered a COND_EXPR.
| void gimple_regimplify_operands | ( | ) |
Some transformations like inlining may invalidate the GIMPLE form for operands. This function traverses all the operands in STMT and gimplifies anything that is not a valid gimple operand. Any new GIMPLE statements are inserted before *GSI_P.
NOTE: We start gimplifying operands from last to first to
make sure that side-effects on the RHS of calls, assignments
and ASMs are executed before the LHS. The ordering is not
important for other statements. If the LHS changed it in a way that requires a simple RHS,
create temporary.
| void gimple_seq_add_stmt_without_update | ( | ) |
Link gimple statement GS to the end of the sequence *SEQ_P. If *SEQ_P is NULL, a new sequence is allocated. This function is similar to gimple_seq_add_stmt, but does not scan the operands. During gimplification, we need to manipulate statement sequences before the def/use vectors have been constructed.
|
inlinestatic |
Mark statement G so a location will not be emitted by annotate_one_with_location.
The PLF flags are initialized to 0 when a new tuple is created,
so no need to initialize it anywhere.
|
static |
Rewrite the ADDR_EXPR node pointed to by EXPR_P
unary_expr
: ...
| '&' varname
...
PRE_P points to the list where side effects that must happen before
*EXPR_P should be stored.
POST_P points to the list where side effects that must happen after
*EXPR_P should be stored. Check if we are dealing with an expression of the form '&*ptr'.
While the front end folds away '&*ptr' into 'ptr', these
expressions may be generated internally by the compiler (e.g.,
builtins like __builtin_va_end). Caution: the silent array decomposition semantics we allow for
ADDR_EXPR means we can't always discard the pair. Gimplification of the ADDR_EXPR operand may drop
cv-qualification conversions, so make sure we add them if
needed. Take the address of our operand and then convert it to the type of
this ADDR_EXPR.
??? The interactions of VIEW_CONVERT_EXPR and aliasing is not at
all clear. The impact of this transformation is even less clear. If the operand is a useless conversion, look through it. Doing so
guarantees that the ADDR_EXPR and its operand will remain of the
same type. We use fb_either here because the C frontend sometimes takes
the address of a call that returns a struct; see
gcc.dg/c99-array-lval-1.c. The gimplifier will correctly make
the implied temporary explicit. Make the operand addressable.
Then mark it. Beware that it may not be possible to do so directly
if a temporary has been created by the gimplification. For various reasons, the gimplification of the expression
may have made a new INDIRECT_REF. The FEs may end up building ADDR_EXPRs early on a decl with
an incomplete type. Re-build ADDR_EXPRs in canonical form
here. Make sure TREE_CONSTANT and TREE_SIDE_EFFECTS are set properly.
If we re-built the ADDR_EXPR add a conversion to the original type
if required.
|
static |
Make sure OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE is set to
accurately reflect the presence of a FIRSTPRIVATE clause. We have to avoid assigning a shared variable
to itself when trying to add
__builtin_assume_aligned. Add in any implicit data sharing.
|
static |
For all variables that were not actually used within the context, remove PRIVATE, SHARED, and FIRSTPRIVATE clauses.
| void gimplify_and_add | ( | ) |
Both gimplify the statement T and append it to *SEQ_P. This function behaves exactly as gimplify_stmt, but you don't have to pass T as a reference.
|
static |
Gimplify statement T into sequence *SEQ_P, and return the first tuple in the sequence of generated tuples for this statement. Return NULL if gimplifying T produced no tuples.
|
static |
Helper for gimplify_call_expr. Gimplify a single argument *ARG_P Store any side-effects in PRE_P. CALL_LOCATION is the location of the CALL_EXPR.
In general, we allow lvalues for function arguments to avoid
extra overhead of copying large aggregates out of even larger
aggregates into temporaries only to copy the temporaries to
the argument list. Make optimizers happy by pulling out to
temporaries those types that fit in registers. Also strip a TARGET_EXPR that would force an extra copy.
If this is a variable sized type, we must remember the size.
FIXME diagnostics: This will mess up gcc.dg/Warray-bounds.c.
Make sure arguments have the same location as the function call
itself. There is a sequence point before a function call. Side effects in
the argument list must occur before the actual call. So, when
gimplifying arguments, force gimplify_expr to use an internal
post queue which is then appended to the end of PRE_P.
|
static |
Gimplify the operands of an ASM_EXPR. Input operands should be a gimple value; output operands should be a gimple lvalue.
An input/output operand. To give the optimizers more
flexibility, split it into separate input and output
operands. Turn the in/out constraint into an output constraint.
And add a matching input constraint.
If there are multiple alternatives in the constraint,
handle each of them individually. Those that allow register
will be replaced with operand number, the others will stay
unchanged. If we can't make copies, we can only accept memory.
If the operand is a memory input, it should be an lvalue.
Do not add ASMs with errors to the gimple IL stream.
|
static |
Gimplify a BIND_EXPR. Just voidify and recurse.
Mark variables seen in this bind expr.
Mark variable as local.
Preliminarily mark non-addressed complex variables as eligible
for promotion to gimple registers. We'll transform their uses
as we find them. Gimplify the body into the GIMPLE_BIND tuple's body.
Save stack on entry and restore it on exit. Add a try_finally
block to achieve this. Add clobbers for all variables that go out of scope.
Only care for variables that have to be in memory. Others
will be rewritten into SSA names, hence moved to the top-level.
| gimple gimplify_body | ( | ) |
Gimplify the body of statements of FNDECL and return a GIMPLE_BIND node containing the sequence of corresponding GIMPLE statements. If DO_PARMS is true, also gimplify the parameters.
Initialize for optimize_insn_for_s{ize,peed}_p possibly called during
gimplification. Unshare most shared trees in the body and in that of any nested functions.
It would seem we don't have to do this for nested functions because
they are supposed to be output and then the outer function gimplified
first, but the g++ front end doesn't always do it that way. Make sure input_location isn't set to something weird.
Resolve callee-copies. This has to be done before processing
the body so that DECL_VALUE_EXPR gets processed correctly. Gimplify the function's body.
The body must contain exactly one statement, a GIMPLE_BIND. If this is
not the case, wrap everything in a GIMPLE_BIND to make it so. If we had callee-copies statements, insert them at the beginning
of the function and clear DECL_VALUE_EXPR_P on the parameters.
|
static |
Gimplify the CALL_EXPR node *EXPR_P into the GIMPLE sequence PRE_P. WANT_VALUE is true if the result of the call is desired.
For reliable diagnostics during inlining, it is necessary that
every call_expr be annotated with file and line. This may be a call to a builtin function.
Builtin function calls may be transformed into different
(and more efficient) builtin function calls under certain
circumstances. Unfortunately, gimplification can muck things
up enough that the builtin expanders are not aware that certain
transformations are still valid.
So we attempt transformation/gimplification of the call before
we gimplify the CALL_EXPR. At this time we do not manage to
transform all calls in the same manner as the expanders do, but
we do transform most of them. There was a transformation of this call which computes the
same value, but in a more efficient way. Return and try
again. Remember the original function pointer type.
There is a sequence point before the call, so any side effects in
the calling expression must occur before the actual call. Force
gimplify_expr to use an internal post queue. Get argument types for verification.
If the last argument is __builtin_va_arg_pack () and it is not
passed as a named argument, decrease the number of CALL_EXPR
arguments and set instead the CALL_EXPR_VA_ARG_PACK flag. Copy all CALL_EXPR flags, location and block, except
CALL_EXPR_VA_ARG_PACK flag. Set CALL_EXPR_VA_ARG_PACK.
Finally, gimplify the function arguments.
Avoid gimplifying the second argument to va_start, which needs to
be the plain PARM_DECL. Verify the function result.
Try this again in case gimplification exposed something.
There was a transformation of this call which computes the
same value, but in a more efficient way. Return and try
again. If the function is "const" or "pure", then clear TREE_SIDE_EFFECTS on its
decl. This allows us to eliminate redundant or useless
calls to "const" functions. An infinite loop is considered a side effect.
If the value is not needed by the caller, emit a new GIMPLE_CALL
and clear *EXPR_P. Otherwise, leave *EXPR_P in its gimplified
form and delegate the creation of a GIMPLE_CALL to
gimplify_modify_expr. This is always possible because when
WANT_VALUE is true, the caller wants the result of this call into
a temporary, which means that we will emit an INIT_EXPR in
internal_get_tmp_var which will then be handled by
gimplify_modify_expr. The CALL_EXPR in *EXPR_P is already in GIMPLE form, so all we
have to do is replicate it as a GIMPLE_CALL tuple. Don't fold stmts inside of target construct. We'll do it
during omplower pass instead. Remember the original function type.
References GS_ERROR.
Referenced by gimplify_omp_workshare().
|
static |
Gimplify the CASE_LABEL_EXPR pointed to by EXPR_P.
Invalid OpenMP programs can play Duff's Device type games with
#pragma omp parallel. At least in the C front end, we don't
detect such invalid branches until after gimplification.
|
static |
Gimplify a CLEANUP_POINT_EXPR. Currently this works by adding GIMPLE_WITH_CLEANUP_EXPRs to the prequeue as we encounter cleanups while gimplifying the body, and converting them to TRY_FINALLY_EXPRs when we return to this function. FIXME should we complexify the prequeue handling instead? Or use flags for all the cleanups and let the optimizer tighten them up? The current code seems pretty fragile; it will break on a cleanup within any non-conditional nesting. But any such nesting would be broken, anyway; we can't write a TRY_FINALLY_EXPR that starts inside a nesting construct and continues out of it. We can do that at the RTL level, though, so having an optimizer to tighten up try/finally regions would be a Good Thing.
We only care about the number of conditions between the innermost
CLEANUP_POINT_EXPR and the cleanup. So save and reset the count and
any cleanups collected outside the CLEANUP_POINT_EXPR. Note that gsi_insert_seq_before and gsi_remove do not
scan operands, unlike some other sequence mutators. Do not use gsi_replace here, as it may scan operands.
We want to do a simple structural modification only.
|
static |
Forward declaration.
Referenced by gimplify_omp_workshare().
|
static |
Gimplify an expression sequence. This function gimplifies each
expression and rewrites the original expression with the last
expression of the sequence in GIMPLE form.
PRE_P points to the list where the side effects for all the
expressions in the sequence will be emitted.
WANT_VALUE is true when the result of the last COMPOUND_EXPR is used.
|
static |
Gimplify a C99 compound literal expression. This just means adding the DECL_EXPR before the current statement and using its anonymous decl instead.
Mark the decl as addressable if the compound literal
expression is addressable now, otherwise it is marked too late
after we gimplify the initialization expression. Otherwise, if we don't need an lvalue and have a literal directly
substitute it. Check if it matches the gimple predicate, as
otherwise we'd generate a new temporary, and we can as well just
use the decl we already have. Preliminarily mark non-addressed complex variables as eligible
for promotion to gimple registers. We'll transform their uses
as we find them. If the decl is not addressable, then it is being used in some
expression or on the right hand side of a statement, and it can
be put into a readonly data section. This decl isn't mentioned in the enclosing block, so add it to the
list of temps. FIXME it seems a bit of a kludge to say that
anonymous artificial vars aren't pushed, but everything else is.
Referenced by gimplify_omp_workshare().
|
static |
Gimplify the COMPONENT_REF, ARRAY_REF, REALPART_EXPR or IMAGPART_EXPR
node *EXPR_P.
compound_lval
: min_lval '[' val ']'
| min_lval '.' ID
| compound_lval '[' val ']'
| compound_lval '.' ID
This is not part of the original SIMPLE definition, which separates
array and member references, but it seems reasonable to handle them
together. Also, this way we don't run into problems with union
aliasing; gcc requires that for accesses through a union to alias, the
union reference must be explicit, which was not always the case when we
were splitting up array and member refs.
PRE_P points to the sequence where side effects that must happen before
*EXPR_P should be stored.
POST_P points to the sequence where side effects that must happen after
*EXPR_P should be stored. Create a stack of the subexpressions so later we can walk them in
order from inner to outer. We can handle anything that get_inner_reference can deal with.
Fold INDIRECT_REFs now to turn them into ARRAY_REFs.
Expand DECL_VALUE_EXPR now. In some cases that may expose
additional COMPONENT_REFs. Now EXPR_STACK is a stack of pointers to all the refs we've
walked through and P points to the innermost expression.
Java requires that we elaborated nodes in source order. That
means we must gimplify the inner expression followed by each of
the indices, in order. But we can't gimplify the inner
expression until we deal with any variable bounds, sizes, or
positions in order to deal with PLACEHOLDER_EXPRs.
So we do this in three steps. First we deal with the annotations
for any variables in the components, then we gimplify the base,
then we gimplify any indices, from left to right. Gimplify the low bound and element type size and put them into
the ARRAY_REF. If these values are set, they have already been
gimplified. Divide the element size by the alignment of the element
type (above). Set the field offset into T and gimplify it.
Divide the offset by its alignment.
Step 2 is to gimplify the base expression. Make sure lvalue is set
so as to match the min_lval predicate. Failure to do so may result
in the creation of large aggregate temporaries. And finally, the indices and operands of ARRAY_REF. During this
loop we also remove any useless conversions. Gimplify the dimension.
The innermost expression P may have originally had
TREE_SIDE_EFFECTS set which would have caused all the outer
expressions in *EXPR_P leading to P to also have had
TREE_SIDE_EFFECTS set. If the outermost expression is a COMPONENT_REF, canonicalize its type.
Referenced by gimplify_omp_workshare().
|
static |
Convert the conditional expression pointed to by EXPR_P '(p) ? a : b;'
into
if (p) if (p)
t1 = a; a;
else or else
t1 = b; b;
t1;
The second form is used when *EXPR_P is of type void.
PRE_P points to the list where side effects that must happen before
*EXPR_P should be stored. If this COND_EXPR has a value, copy the values into a temporary within
the arms. If either an rvalue is ok or we do not require an lvalue, create the
temporary. But we cannot do that if the type is addressable. If either branch has side effects or could trap, it can't be
evaluated unconditionally. Otherwise, only create and copy references to the values.
Build the new then clause, `tmp = then_;'. But don't build the
assignment if the value is void; in C++ it can be if it's a throw. Similarly, build the new else clause, `tmp = else_;'.
Move the COND_EXPR to the prequeue.
Remove any COMPOUND_EXPR so the following cases will be caught.
Make sure the condition has BOOLEAN_TYPE.
Break apart && and || conditions.
We can't rely on gimplify_expr to re-gimplify the expanded
form properly, as cleanups might cause the target labels to be
wrapped in a TRY_FINALLY_EXPR. To prevent that, we need to
set up a conditional context. Now do the normal gimplification.
Gimplify condition.
For -O0 avoid this optimization if the COND_EXPR and GOTO_EXPR
have different locations, otherwise we end up with incorrect
location information on the branches. For -O0 avoid this optimization if the COND_EXPR and GOTO_EXPR
have different locations, otherwise we end up with incorrect
location information on the branches. For if (...) {} else { code; } put label_true after
the else block. For if (...) { code; } else {} or
if (...) { code; } else goto label; or
if (...) { code; return; } else { ... }
label_cont isn't needed. GIMPLE_COND's are very low level; they have embedded
gotos. This particular embedded goto should not be marked
with the location of the original COND_EXPR, as it would
correspond to the COND_EXPR's condition, not the ELSE or the
THEN arms. To avoid marking it with the wrong location, flag
it as "no location". Both arms are empty; replace the COND_EXPR with its predicate.
Referenced by gimplify_omp_workshare().
|
static |
*EXPR_P is a NOP_EXPR or CONVERT_EXPR. Remove it and/or other conversions underneath as appropriate.
Then strip away all but the outermost conversion.
And remove the outermost conversion if it's useless.
If we still have a conversion at the toplevel,
then canonicalize some constructs. If a NOP conversion is changing the type of a COMPONENT_REF
expression, then canonicalize its type now in order to expose more
redundant conversions. If a NOP conversion is changing a pointer to array of foo
to a pointer to foo, embed that change in the ADDR_EXPR. If we have a conversion to a non-register type force the
use of a VIEW_CONVERT_EXPR instead.
|
static |
Gimplify a DECL_EXPR node *STMT_P by making any necessary allocation and initialization explicit.
??? DECL_ORIGINAL_TYPE is streamed for LTO so it needs to be gimplified
in case its size expressions contain problematic nodes like CALL_EXPR. Some front ends do not explicitly declare all anonymous
artificial variables. We compensate here by declaring the
variables, though it would be better if the front ends would
explicitly declare them. We must still examine initializers for static variables
as they may contain a label address.
References tree_int_cst_compare().
|
static |
Gimplify an EXIT_EXPR by converting to a GOTO_EXPR inside a COND_EXPR. This also involves building a label to jump to and communicating it to gimplify_loop_expr through gimplify_ctxp->exit_label.
| enum gimplify_status gimplify_expr | ( | tree * | expr_p, |
| gimple_seq * | pre_p, | ||
| gimple_seq * | post_p, | ||
| bool(*)(tree) | gimple_test_f, | ||
| fallback_t | fallback | ||
| ) |
Convert the GENERIC expression tree *EXPR_P to GIMPLE. If the
expression produces a value to be used as an operand inside a GIMPLE
statement, the value will be stored back in *EXPR_P. This value will
be a tree of class tcc_declaration, tcc_constant, tcc_reference or
an SSA_NAME. The corresponding sequence of GIMPLE statements is
emitted in PRE_P and POST_P.
Additionally, this process may overwrite parts of the input
expression during gimplification. Ideally, it should be
possible to do non-destructive gimplification.
EXPR_P points to the GENERIC expression to convert to GIMPLE. If
the expression needs to evaluate to a value to be used as
an operand in a GIMPLE statement, this value will be stored in
*EXPR_P on exit. This happens when the caller specifies one
of fb_lvalue or fb_rvalue fallback flags.
PRE_P will contain the sequence of GIMPLE statements corresponding
to the evaluation of EXPR and all the side-effects that must
be executed before the main expression. On exit, the last
statement of PRE_P is the core statement being gimplified. For
instance, when gimplifying 'if (++a)' the last statement in
PRE_P will be 'if (t.1)' where t.1 is the result of
pre-incrementing 'a'.
POST_P will contain the sequence of GIMPLE statements corresponding
to the evaluation of all the side-effects that must be executed
after the main expression. If this is NULL, the post
side-effects are stored at the end of PRE_P.
The reason why the output is split in two is to handle post
side-effects explicitly. In some cases, an expression may have
inner and outer post side-effects which need to be emitted in
an order different from the one given by the recursive
traversal. For instance, for the expression (*p--)++ the post
side-effects of '--' must actually occur *after* the post
side-effects of '++'. However, gimplification will first visit
the inner expression, so if a separate POST sequence was not
used, the resulting sequence would be:
1 t.1 = *p
2 p = p - 1
3 t.2 = t.1 + 1
4 *p = t.2
However, the post-decrement operation in line #2 must not be
evaluated until after the store to *p at line #4, so the
correct sequence should be:
1 t.1 = *p
2 t.2 = t.1 + 1
3 *p = t.2
4 p = p - 1
So, by specifying a separate post queue, it is possible
to emit the post side-effects in the correct order.
If POST_P is NULL, an internal queue will be used. Before
returning to the caller, the sequence POST_P is appended to
the main output sequence PRE_P.
GIMPLE_TEST_F points to a function that takes a tree T and
returns nonzero if T is in the GIMPLE form requested by the
caller. The GIMPLE predicates are in gimple.c.
FALLBACK tells the function what sort of a temporary we want if
gimplification cannot produce an expression that complies with
GIMPLE_TEST_F.
fb_none means that no temporary should be generated
fb_rvalue means that an rvalue is OK to generate
fb_lvalue means that an lvalue is OK to generate
fb_either means that either is OK, but an lvalue is preferable.
fb_mayfail means that gimplification may fail (in which case
GS_ERROR will be returned)
The return value is either GS_ERROR or GS_ALL_DONE, since this
function iterates until EXPR is completely gimplified or an error
occurs. If we are gimplifying a top-level statement, PRE_P must be valid.
Consistency checks.
We should have recognized the GIMPLE_TEST_F predicate to
know what kind of fallback to use in case a temporary is
needed to hold the value or address of *EXPR_P. We used to check the predicate here and return immediately if it
succeeds. This is wrong; the design is for gimplification to be
idempotent, and for the predicates to only test for valid forms, not
whether they are fully simplified. Remember the last statements added to PRE_P and POST_P. Every
new statement added by the gimplification helpers needs to be
annotated with location information. To centralize the
responsibility, we remember the last statement that had been
added to both queues before gimplifying *EXPR_P. If
gimplification produces new statements in PRE_P and POST_P, those
statements will be annotated with the same location information
as *EXPR_P. Loop over the specific gimplifiers until the toplevel node
remains the same. Strip away as many useless type conversions as possible
at the toplevel. Remember the expr.
Die, die, die, my darling.
Do any language-specific gimplification.
Make sure that all the cases set 'ret' appropriately.
First deal with the special cases.
C99 code may assign to an array in a structure value of a
conditional expression, and this has undefined behavior
only on execution, so create a temporary if an lvalue is
required. If errors are seen, then just process it as a CALL_EXPR.
C99 code may assign to an array in a structure returned
from a function, and this has undefined behavior only on
execution, so create a temporary if an lvalue is
required. Preserve the original type of the expression and the
source location of the outer expression. The parsers are careful to generate TRUTH_NOT_EXPR
only with operands that are always zero or one.
We do not fold here but handle the only interesting case
manually, as fold may re-introduce the TRUTH_NOT_EXPR. Just strip a conversion to void (or in void context) and
try again. FALLTHRU
unary_expr: ... | '(' cast ')' val | ... We arrive here through the various re-gimplifcation paths.
First try re-folding the whole thing.
Avoid re-gimplifying the address operand if it is already
in suitable form. Re-gimplifying would mark the address
operand addressable. Always gimplify when not in SSA form
as we still may have to gimplify decls with value-exprs. Constants need not be gimplified.
If we require an lvalue, such as for ADDR_EXPR, retain the
CONST_DECL node. Otherwise the decl is replaceable by its
value. ??? Should be == fb_lvalue, but ADDR_EXPR passes fb_either.
If the target is not LABEL, then it is a computed jump
and the target needs to be gimplified. Don't reduce this in place; let gimplify_init_constructor work its
magic. Buf if we're just elaborating this for side effects, just
gimplify any element that has side-effects. C99 code may assign to an array in a constructed
structure or union, and this has undefined behavior only
on execution, so create a temporary if an lvalue is
required. The following are special cases that are not handled by the
original GIMPLE grammar. SAVE_EXPR nodes are converted into a GIMPLE identifier and
eliminated. TMR_STEP and TMR_OFFSET are always integer constants.
This should have been stripped above.
Calls to destructors are generated automatically in FINALLY/CATCH
block. They should have location as UNKNOWN_LOCATION. However,
gimplify_call_expr will reset these call stmts to input_location
if it finds stmt's location is unknown. To prevent resetting for
destructors, we set the input_location to unknown.
Note that this only affects the destructor calls in FINALLY/CATCH
block, and will automatically reset to its original value by the
end of gimplify_expr. Don't create bogus GIMPLE_TRY with empty cleanup.
We get here when taking the address of a label. We mark
the label as "forced"; meaning it can never be removed and
it is a potential target for any computed goto. When within an OpenMP context, notice uses of variables.
Allow callbacks into the gimplifier during optimization.
Boolified binary truth expressions are semantically equivalent
to bitwise binary expressions. Canonicalize them to the
bitwise variant. Now make sure that operands have compatible type to
expression's new_type. Continue classified as tcc_binary.
Classified as tcc_expression.
Convert &X + CST to invariant &MEM[&X, CST]. Do this
after gimplifying operands - this is similar to how
it would be folding all gimplified stmts on creation
to have them canonicalized, which is what we eventually
should do anyway. Handle comparison of objects of non scalar mode aggregates
with a call to memcmp. It would be nice to only have to do
this for variable-sized objects, but then we'd have to allow
the same nest of reference nodes we allow for MODIFY_EXPR and
that's too complex.
Compare scalar mode aggregates as scalar mode values. Using
memcmp for them would be very inefficient at best, and is
plain wrong if bitfields are involved. Vector comparisons need no boolification.
If *EXPR_P does not need to be special-cased, handle it
according to its class. If we encountered an error_mark somewhere nested inside, either
stub out the statement or propagate the error back out. This was only valid as a return value from the langhook, which
we handled. Make sure it doesn't escape from any other context. We aren't looking for a value, and we don't have a valid
statement. If it doesn't have side-effects, throw it away. This is probably a _REF that contains something nested that
has side effects. Recurse through the operands to find it. Anything else with side-effects must be converted to
a valid statement before we get here. Historically, the compiler has treated a bare reference
to a non-BLKmode volatile lvalue as forcing a load. Normally, we do not want to create a temporary for a
TREE_ADDRESSABLE type because such a type should not be
copied by bitwise-assignment. However, we make an
exception here, as all we are doing here is ensuring that
we read the bytes that make up the type. We use
create_tmp_var_raw because create_tmp_var will abort when
given a TREE_ADDRESSABLE type. We can't do anything useful with a volatile reference to
an incomplete type, so just throw it away. Likewise for
a BLKmode type, since any implicit inner load should
already have been turned into an explicit one by the
gimplification process. If we are gimplifying at the statement level, we're done. Tack
everything together and return. Since *EXPR_P has been converted into a GIMPLE tuple, clear
it out for GC to reclaim it. The result of gimplifying *EXPR_P is going to be the last few
statements in *PRE_P and *POST_P. Add location information
to all the statements that were added by the gimplification
helpers. These expressions should already be in gimple IR form.
Otherwise we're gimplifying a subexpression, so the resulting
value is interesting. If it's a valid operand that matches
GIMPLE_TEST_F, we're done. Unless we are handling some
post-effects internally; if that's the case, we need to copy into
a temporary before adding the post-effects to POST_P. Otherwise, we need to create a new temporary for the gimplified
expression. We can't return an lvalue if we have an internal postqueue. The
object the lvalue refers to would (probably) be modified by the
postqueue; we need to copy the value out first, which means an
rvalue. An lvalue will do. Take the address of the expression, store it
in a temporary, and replace the expression with an INDIRECT_REF of
that temporary. An rvalue will do. Assign the gimplified expression into a
new temporary TMP and replace the original expression with
TMP. First, make sure that the expression has a type so that
it can be assigned into a temporary. If this is an asm statement, and the user asked for the
impossible, don't die. Fail and let gimplify_asm_expr
issue an error. Make sure the temporary matches our predicate.
References eval(), gimple_build_try(), gimple_seq_add_seq(), gimple_seq_empty_p(), gimple_set_location(), GIMPLE_TRY_CATCH, GIMPLE_TRY_FINALLY, gimple_try_set_catch_is_cleanup(), gimplify_and_add(), gimplify_seq_add_stmt(), GS_ALL_DONE, and input_location.
Referenced by lookup_tmp_var().
| void gimplify_function_tree | ( | ) |
Entry point to the gimplification pass. FNDECL is the FUNCTION_DECL node for the function we want to gimplify. Return the sequence of GIMPLE statements corresponding to the body of FNDECL.
Preliminarily mark non-addressed complex variables as eligible
for promotion to gimple registers. We'll transform their uses
as we find them. The tree body of the function is no longer needed, replace it
with the new GIMPLE body. If we're instrumenting function entry/exit, then prepend the call to
the entry hook and wrap the whole function in a TRY_FINALLY_EXPR to
catch the exit hook. ??? Add some way to ignore exceptions for this TFE.
Clear the block for BIND, since it is no longer directly inside
the function, but within a try block. Replace the current function body with the body
wrapped in the try/finally TF.
|
static |
A subroutine of gimplify_modify_expr. Break out elements of a CONSTRUCTOR used as an initializer into separate MODIFY_EXPRs. Note that we still need to clear any elements that don't have explicit initializers, so if not all elements are initialized we keep the original MODIFY_EXPR, we just remove all of the constructor elements. If NOTIFY_TEMP_CREATION is true, do not gimplify, just return GS_ERROR if we would have to create a temporary when gimplifying this constructor. Otherwise, return GS_OK. If NOTIFY_TEMP_CREATION is false, just do the gimplification.
Aggregate types must lower constructors to initialization of
individual elements. The exception is that a CONSTRUCTOR node
with no elements indicates zero-initialization of the whole. Fetch information about the constructor to direct later processing.
We might want to make static versions of it in various cases, and
can only do so if it known to be a valid constant initializer. If a const aggregate variable is being initialized, then it
should never be a lose to promote the variable to be static. ??? C++ doesn't automatically append a .<number> to the
assembler name, and even when it does, it looks at FE private
data structures to figure out what that number should be,
which are not set for this variable. I suppose this is
important for local statics for inline functions, which aren't
"local" in the object file sense. So in order to get a unique
TU-local symbol, we must invoke the lhd version now. If there are "lots" of initialized elements, even discounting
those that are not address constants (and thus *must* be
computed at runtime), then partition the constructor into
constant and non-constant parts. Block copy the constant
parts in, then generate code for the non-constant parts. TODO. There's code in cp/typeck.c to do this.
store_constructor will ignore the clearing of variable-sized
objects. Initializers for such objects must explicitly set
every field that needs to be set. If the constructor isn't complete, clear the whole object
beforehand.
??? This ought not to be needed. For any element not present
in the initializer, we should simply set them to zero. Except
we'd need to *find* the elements that are not present, and that
requires trickery to avoid quadratic compile-time behavior in
large cases or excessive memory use in small cases. If there are "lots" of zeros, it's more efficient to clear
the memory and then set the nonzero elements. If there are "lots" of initialized elements, and all of them
are valid address constants, then the entire initializer can
be dropped to memory, and then memcpy'd out. Don't do this
for sparse arrays, though, as it's more efficient to follow
the standard CONSTRUCTOR behavior of memset followed by
individual element initialization. Also don't do this for small
all-zero initializers (which aren't big enough to merit
clearing), and don't try to make bitwise copies of
TREE_ADDRESSABLE types.
We cannot apply such transformation when compiling chkp static
initializer because creation of initializer image in the memory
will require static initialization of bounds for it. It should
result in another gimplification of similar initializer and we
may fall into infinite loop. ??? We can still get unbounded array types, at least
from the C++ front end. This seems wrong, but attempt
to work around it for now. Find the maximum alignment we can assume for the object.
??? Make use of DECL_OFFSET_ALIGN.
Do a block move either if the size is so small as to make
each individual move a sub-unit move on average, or if it
is so large as to make individual moves inefficient. This is no longer an assignment of a CONSTRUCTOR, but
we still may have processing to do on the LHS. So
pretend we didn't do anything here to let that happen. If the target is volatile, we have non-zero elements and more than
one field to assign, initialize the target from a temporary. If there are nonzero elements and if needed, pre-evaluate to capture
elements overlapping with the lhs into temporaries. We must do this
before clearing to fetch the values before they are zeroed-out. Zap the CONSTRUCTOR element list, which simplifies this case.
Note that we still have to gimplify, in order to handle the
case of variable sized types. Avoid shared tree structures. If we have not block cleared the object, or if there are nonzero
elements in the constructor, add assignments to the individual
scalar fields of the object. Extract the real and imaginary parts out of the ctor.
Complex types have either COMPLEX_CST or COMPLEX_EXPR to
represent creation of a complex value. Go ahead and simplify constant constructors to VECTOR_CST.
Even when ctor is constant, it might contain non-*_CST
elements, such as addresses or trapping values like
1.0/0.0 - 1.0/0.0. Such expressions don't belong
in VECTOR_CST nodes. Don't reduce an initializer constant even if we can't
make a VECTOR_CST. It won't do anything for us, and it'll
prevent us from representing it as a single constant. Vector types use CONSTRUCTOR all the way through gimple
compilation as a general initializer. So how did we get a CONSTRUCTOR for a scalar type?
If we have gimplified both sides of the initializer but have
not emitted an assignment, do so now.
References GS_OK.
|
static |
A subroutine of gimplify_init_ctor_eval. Create a loop for
a RANGE_EXPR in a CONSTRUCTOR for an array.
var = lower;
loop_entry:
object[var] = value;
if (var == upper)
goto loop_exit;
var = var + 1;
goto loop_entry;
loop_exit:
We increment var _after_ the loop exit check because we might otherwise
fail if upper == TYPE_MAX_VALUE (type for upper).
Note that we never have to deal with SAVE_EXPRs here, because this has
already been taken care of for us, in gimplify_init_ctor_preeval(). A subroutine of gimplify_init_constructor. Generate individual MODIFY_EXPRs for a CONSTRUCTOR. OBJECT is the LHS against which the assignments should happen. ELTS is the CONSTRUCTOR_ELTS of the CONSTRUCTOR. CLEARED is true if the entire LHS object has been zeroed first.
NULL values are created above for gimplification errors.
??? Here's to hoping the front end fills in all of the indices,
so we don't have to figure out what's missing ourselves. Skip zero-sized fields, unless value has side-effects. This can
happen with calls to functions returning a zero-sized type, which
we shouldn't discard. As a number of downstream passes don't
expect sets of zero-sized fields, we rely on the gimplification of
the MODIFY_EXPR we make below to drop the assignment statement. If we have a RANGE_EXPR, we have to build a loop to assign the
whole range. If the lower bound is equal to upper, just treat it as if
upper was the index. Do not use bitsizetype for ARRAY_REF indices.
References can_move_by_pieces(), force_labels_r(), GS_ERROR, GS_UNHANDLED, HOST_WIDE_INT, int_size_in_bytes(), tree_output_constant_def(), and useless_type_conversion_p().
|
static |
Create and initialize the index variable.
Add the loop entry label.
Build the reference.
If we are a constructor, just call gimplify_init_ctor_eval to do
the store. Otherwise just assign value to the reference. NB we might have to call ourself recursively through
gimplify_init_ctor_eval if the value is a constructor. We exit the loop when the index var is equal to the upper bound.
Otherwise, increment the index var...
...and jump back to the loop entry.
Add the loop exit label.
Referenced by gimplify_modify_expr_to_memset().
|
static |
A subroutine of gimplify_init_constructor. Pre-evaluate EXPR, force values that overlap with the lhs (as described by *DATA) into temporaries.
If the value is constant, then there's nothing to pre-evaluate.
Ensure it does not have side effects, it might contain a reference to
the object we're initializing. If the type has non-trivial constructors, we can't pre-evaluate.
Recurse for nested constructors.
If this is a variable sized type, we must remember the size.
Gimplify the constructor element to something appropriate for the rhs
of a MODIFY_EXPR. Given that we know the LHS is an aggregate, we know
the gimplifier will consider this a store to memory. Doing this
gimplification now means that we won't have to deal with complicated
language-specific trees, nor trees like SAVE_EXPR that can induce
exponential search behavior. If we gimplified to a bare decl, we can be sure that it doesn't overlap
with the lhs, since "a = { .x=a }" doesn't make sense. This will
always be true for all scalars, since is_gimple_mem_rhs insists on a
temporary variable for them. If this is of variable size, we have no choice but to assume it doesn't
overlap since we can't make a temporary for it. Otherwise, we must search for overlap ...
... and if found, force the value into a temporary.
|
static |
If we find the base object, obviously we have overlap.
If the constructor component is indirect, determine if we have a
potential overlap with the lhs. The only bits of information we
have to go on at this point are addressability and alias sets. If the constructor component is a call, determine if it can hide a
potential overlap with the lhs through an INDIRECT_REF like above.
??? Ugh - this is completely broken. In fact this whole analysis
doesn't look conservative.
References ggc_free(), and gimplify_and_add().
|
static |
Gimplify a LOOP_EXPR. Normally this just involves gimplifying the body and replacing the LOOP_EXPR with goto, but if the loop contains an EXIT_EXPR, we need to append a label for it to jump to.
|
static |
Gimplify the MODIFY_EXPR node pointed to by EXPR_P.
modify_expr
: varname '=' rhs
| '*' ID '=' rhs
PRE_P points to the list where side effects that must happen before
*EXPR_P should be stored.
POST_P points to the list where side effects that must happen after
*EXPR_P should be stored.
WANT_VALUE is nonzero iff we want to use the value of this expression
in another expression. Trying to simplify a clobber using normal logic doesn't work,
so handle it here. Insert pointer conversions required by the middle-end that are not
required by the frontend. This fixes middle-end type checking for
for example gcc.dg/redecl-6.c. See if any simplifications can be done based on what the RHS is.
For zero sized types only gimplify the left hand side and right hand
side as statements and throw away the assignment. Do this after
gimplify_modify_expr_rhs so we handle TARGET_EXPRs of addressable
types properly. If the value being copied is of variable width, compute the length
of the copy into a WITH_SIZE_EXPR. Note that we need to do this
before gimplifying any of the operands so that we can resolve any
PLACEHOLDER_EXPRs in the size. Also note that the RTL expander uses
the size of the expression to be copied, not of the destination, so
that is what we must do here. As a special case, we have to temporarily allow for assignments
with a CALL_EXPR on the RHS. Since in GIMPLE a function call is
a toplevel statement, when gimplifying the GENERIC expression
MODIFY_EXPR <a, CALL_EXPR <foo>>, we cannot create the tuple
GIMPLE_ASSIGN <a, GIMPLE_CALL <foo>>.
Instead, we need to create the tuple GIMPLE_CALL <a, foo>. To
prevent gimplify_expr from trying to create a new temporary for
foo's LHS, we tell it that it should only gimplify until it
reaches the CALL_EXPR. On return from gimplify_expr, the newly
created GIMPLE_CALL <foo> will be the last statement in *PRE_P
and all we need to do here is set 'a' to be its LHS. Now see if the above changed *from_p to something we handle specially.
If we've got a variable sized assignment between two lvalues (i.e. does
not involve a call), then we can make things a bit more straightforward
by converting the assignment to memcpy or memset. Transform partial stores to non-addressable complex variables into
total stores. This allows us to use real instead of virtual operands
for these variables, which improves optimization. Try to alleviate the effects of the gimplification creating artificial
temporaries (see for example is_gimple_reg_rhs) on the debug info. Since the RHS is a CALL_EXPR, we need to create a GIMPLE_CALL
instead of a GIMPLE_ASSIGN. We should have got an SSA name from the start.
Don't fold stmts inside of target construct. We'll do it
during omplower pass instead.
|
static |
Promote partial stores to COMPLEX variables to total stores. *EXPR_P is a MODIFY_EXPR with a lhs of a REAL/IMAGPART_EXPR of a variable with DECL_GIMPLE_REG_P set. IMPORTANT NOTE: This promotion is performed by introducing a load of the other, unmodified part of the complex object just before the total store. As a consequence, if the object is still uninitialized, an undefined value will be loaded into a register, which may result in a spurious exception if the register is floating-point and the value happens to be a signaling NaN for example. Then the fully-fledged complex operations lowering pass followed by a DCE pass are necessary in order to fix things up.
References fold_convert_loc(), GS_OK, and useless_type_conversion_p().
|
static |
Subroutine of gimplify_modify_expr to do simplifications of MODIFY_EXPRs based on the code of the RHS. We loop for as long as something changes.
If we're assigning from a read-only variable initialized with
a constructor, do the direct assignment from the constructor,
but only if neither source nor target are volatile since this
latter assignment might end up being done on a per-field basis. Move the constructor into the RHS.
Let's see if gimplify_init_constructor will need to put
it in memory. If so, revert the change.
If we have code like
*(const A*)(A*)&x
where the type of "x" is a (possibly cv-qualified variant
of "A"), treat the entire expression as identical to "x".
This kind of code arises in C++ when an object is bound
to a const reference, and if "x" is a TARGET_EXPR we want
to take advantage of the optimization below. If we are initializing something from a TARGET_EXPR, strip the
TARGET_EXPR and initialize it directly, if possible. This can't
be done if the initializer is void, since that implies that the
temporary is set in some non-trivial way.
??? What about code that pulls out the temp and uses it
elsewhere? I think that such code never uses the TARGET_EXPR as
an initializer. If I'm wrong, we'll die because the temp won't
have any RTL. In that case, I guess we'll need to replace
references somehow. Remove any COMPOUND_EXPR in the RHS so the following cases will be
caught. If we already made some changes, let the front end have a
crack at this before we break it down. If we're initializing from a CONSTRUCTOR, break this into
individual MODIFY_EXPRs. If we're assigning to a non-register type, push the assignment
down into the branches. This is mandatory for ADDRESSABLE types,
since we cannot generate temporaries for such, but it saves a
copy in other cases as well. This code should mirror the code in gimplify_cond_expr.
For calls that return in memory, give *to_p as the CALL_EXPR's
return slot so that we don't generate a temporary. If we need a temporary, *to_p isn't accurate.
It's OK to use the return slot directly unless it's an NRV.
Don't force regs into memory.
It's OK to use the target directly if it's being
initialized. Always use the target and thus RSO for variable-sized types.
GIMPLE cannot deal with a variable-sized assignment
embedded in a call statement. Don't use the original target if it's already addressable;
if its address escapes, and the called function uses the
NRV optimization, a conforming program could see *to_p
change before the called function returns; see c++/19317.
When optimizing, the return_slot pass marks more functions
as safe after we have escape info. Likewise for calls that return an aggregate of non-constant size,
since we would not be able to generate a temporary at all. We don't change ret in this case because the
WITH_SIZE_EXPR might have been added in
gimplify_modify_expr, so returning GS_OK would lead to an
infinite loop. If we're initializing from a container, push the initialization
inside it. struct T x = (struct T) { 0, 1, 2 } can be optimized
into struct T x = { 0, 1, 2 } if the address of the
compound literal has never been taken.
|
static |
A subroutine of gimplify_modify_expr. Replace a MODIFY_EXPR with a call to __builtin_memcpy.
Mark the RHS addressable. Beware that it may not be possible to do so
directly if a temporary has been created by the gimplification. tmp = memcpy()
|
static |
A subroutine of gimplify_modify_expr. Replace a MODIFY_EXPR with a call to __builtin_memset. In this case we know that the RHS is a CONSTRUCTOR with an empty element list.
Assert our assumptions, to abort instead of producing wrong code
silently if they are not met. Beware that the RHS CONSTRUCTOR might
not be immediately exposed. Now proceed.
tmp = memset()
References gimplify_init_ctor_eval_range(), initializer_zerop(), simple_cst_equal(), unshare_expr(), and zero_sized_field_decl().
|
static |
Gimplify an OMP_ATOMIC statement.
|
static |
Gimplify the gross structure of an OMP_FOR statement.
Handle OMP_FOR_INIT.
Make sure the iteration variable is private.
Do this only on innermost construct for combined ones.
If DECL is not a gimple register, create a temporary variable to act
as an iteration counter. This is valid, since DECL cannot be
modified in the body of the loop. Handle OMP_FOR_COND.
Handle OMP_FOR_INCR.
Fallthru.
|
static |
Gimplify the contents of an OMP_PARALLEL statement. This involves gimplification of the body, as well as scanning the body for used variables. We need to do this scan now, because variable-sized decls will be decomposed during gimplification.
|
static |
Gimplify the gross structure of OpenMP target update construct.
|
static |
Gimplify the contents of an OMP_TASK statement. This involves gimplification of the body, as well as scanning the body for used variables. We need to do this scan now, because variable-sized decls will be decomposed during gimplification.
References types_compatible_p().
|
static |
Gimplify the gross structure of other OpenMP constructs. In particular, OMP_SECTIONS, OMP_SINGLE, OMP_TARGET, OMP_TARGET_DATA and OMP_TEAMS.
References cfun, lang_hooks_for_cilkplus::cilk_detect_spawn_and_unwrap, lang_hooks::cilkplus, fb_none, fn_contains_cilk_spawn_p(), get_initialized_tmp_var(), gimplify_call_expr(), lang_hooks_for_cilkplus::gimplify_cilk_spawn, gimplify_compound_expr(), gimplify_compound_literal_expr(), gimplify_compound_lval(), gimplify_cond_expr(), gimplify_self_mod_expr(), GS_OK, mark_addressable(), and seen_error().
| void gimplify_one_sizepos | ( | ) |
A subroutine of gimplify_type_sizes to make sure that *EXPR_P, a size or position, has had all of its SAVE_EXPRs evaluated. We add any required statements to *STMT_P.
We don't do anything if the value isn't there, is constant, or contains
A PLACEHOLDER_EXPR. We also don't want to do anything if it's already
a VAR_DECL. If it's a VAR_DECL from another function, the gimplifier
will want to replace it with a new variable, but that will cause problems
if this type is from outside the function. It's OK to have that here.
References targetm.
|
static |
Given a conditional expression *EXPR_P without side effects, gimplify its operands. New statements are inserted to PRE_P.
We need to handle && and || specially, as their gimplification
creates pure cond_expr, thus leading to an infinite cycle otherwise.
|
static |
Gimplify a RETURN_EXPR. If the expression to be returned is not a GIMPLE value, it is assigned to a new temporary and the statement is re-written to return the temporary. PRE_P points to the sequence where side effects that must happen before STMT should be stored.
Implicit _Cilk_sync must be inserted right before any return statement
if there is a _Cilk_spawn in the function. If the user has provided a
_Cilk_sync, the optimizer should remove this duplicate one. See through a return by reference.
If aggregate_value_p is true, then we can return the bare RESULT_DECL.
Recall that aggregate_value_p is FALSE for any aggregate type that is
returned in registers. If we're returning values in registers, then
we don't want to extend the lifetime of the RESULT_DECL, particularly
across another call. In addition, for those aggregates for which
hard_function_value generates a PARALLEL, we'll die during normal
expansion of structure assignments; there's special code in expand_return
to handle this case that does not exist in expand_expr. Note that we don't use gimplify_vla_decl because the RESULT_DECL
should be effectively allocated by the caller, i.e. all calls to
this function must be subject to the Return Slot Optimization. ??? With complex control flow (usually involving abnormal edges),
we can wind up warning about an uninitialized value for this. Due
to how this variable is constructed and initialized, this is never
true. Give up and never warn. Smash the lhs of the MODIFY_EXPR to the temporary we plan to use.
Then gimplify the whole thing.
References build_call_expr(), build_pointer_type(), builtin_decl_explicit(), create_tmp_var(), get_name(), gimplify_and_add(), gimplify_one_sizepos(), and gimplify_ctx::save_stack.
|
static |
Gimplify a SAVE_EXPR node. EXPR_P points to the expression to gimplify. After gimplification, EXPR_P will point to a new temporary that holds the original value of the SAVE_EXPR node. PRE_P points to the list where side effects that must happen before *EXPR_P should be stored.
If the SAVE_EXPR has not been resolved, then evaluate it once.
The operand may be a void-valued expression such as SAVE_EXPRs
generated by the Java frontend for class initialization. It is
being executed only for its side-effects.
|
static |
Gimplify a comparison between two aggregate objects of integral scalar mode as a comparison between the bitwise equivalent scalar values.
|
static |
Scan the OpenMP clauses in *LIST_P, installing mappings into a new and previous omp contexts.
Fall through.
| enum gimplify_status gimplify_self_mod_expr | ( | tree * | expr_p, |
| gimple_seq * | pre_p, | ||
| gimple_seq * | post_p, | ||
| bool | want_value, | ||
| tree | arith_type | ||
| ) |
Gimplify the self modifying expression pointed to by EXPR_P
(++, --, +=, -=).
PRE_P points to the list where side effects that must happen before
*EXPR_P should be stored.
POST_P points to the list where side effects that must happen after
*EXPR_P should be stored.
WANT_VALUE is nonzero iff we want to use the value of this expression
in another expression.
ARITH_TYPE is the type the computation should be performed in. Prefix or postfix?
Faster to treat as prefix if result is not used.
For postfix, make sure the inner expression's post side effects
are executed after side effects from this expression. Add or subtract?
Gimplify the LHS into a GIMPLE lvalue.
Extract the operands to the arithmetic operation.
For postfix operator, we evaluate the LHS to an rvalue and then use
that as the result value and in the postqueue operation. For POINTERs increment, use POINTER_PLUS_EXPR.
Referenced by gimplify_omp_workshare().
|
static |
Append sequence SRC to the end of sequence *DST_P. If *DST_P is NULL, a new sequence is allocated. This function is similar to gimple_seq_add_seq, but does not scan the operands. During gimplification, we need to manipulate statement sequences before the def/use vectors have been constructed.
|
inlinestatic |
Shorter alias name for the above function for use in gimplify.c only.
References si.
Referenced by build_stack_save_restore(), gimplify_expr(), and gimplify_vla_decl().
|
static |
Gimplify a statement list onto a sequence. These may be created either by an enlightened front-end, or by shortcut_cond_expr.
| bool gimplify_stmt | ( | ) |
Gimplification of expression trees.
Gimplify an expression which appears at statement context. The corresponding GIMPLE statements are added to *SEQ_P. If *SEQ_P is NULL, a new sequence is allocated. Return true if we actually added a statement to the queue.
|
static |
Gimplify a SWITCH_EXPR, and collect the vector of labels it can branch to.
If someone can be bothered to fill in the labels, they can
be bothered to null out the body too. Save old labels, get new ones from body, then restore the old
labels. Save all the things from the switch body to append after.
References build_qualified_type(), get_unwidened(), type(), and useless_type_conversion_p().
|
static |
Gimplify a TARGET_EXPR which doesn't appear on the rhs of an INIT_EXPR.
TARGET_EXPR temps aren't part of the enclosing block, so add it
to the temps list. Handle also variable length TARGET_EXPRs. If TARGET_EXPR_INITIAL is void, then the mere evaluation of the
expression is supposed to initialize the slot. PR c++/28266 Make sure this is expanded only once.
If needed, push the cleanup for the temp.
Add a clobber for the temporary going out of scope, like
gimplify_bind_expr. Only expand this once.
We should have expanded this before.
|
static |
Gimplify a TRANSACTION_EXPR. This involves gimplification of the body, and adding some EH bits.
Wrap the transaction body in a BIND_EXPR so we have a context
where to put decls for OpenMP.
| void gimplify_type_sizes | ( | ) |
Look through TYPE for variable-sized objects and gimplify each such size that we find. Add to LIST_P any statements generated.
We first do the main variant, then copy into any other variants.
Avoid infinite recursion.
These types may not have declarations, so handle them here.
Ensure VLA bounds aren't removed, for -O0 they should be variables
with assigned stack slots, for -O1+ -g they should be tracked
by VTA. We used to recurse on the pointed-to type here, which turned out to
be incorrect because its definition might refer to variables not
yet initialized at this point if a forward declaration is involved.
It was actually useful for anonymous pointed-to types to ensure
that the sizes evaluation dominates every possible later use of the
values. Restricting to such types here would be safe since there
is no possible forward declaration around, but would introduce an
undesirable middle-end semantic to anonymity. We then defer to
front-ends the responsibility of ensuring that the sizes are
evaluated both early and late enough, e.g. by attaching artificial
type declarations to the tree.
| enum gimplify_status gimplify_va_arg_expr | ( | ) |
Gimplify __builtin_va_arg, aka VA_ARG_EXPR, which is not really a builtin function, but a very special sort of operator.
Verify that valist is of the proper type.
Generate a diagnostic for requesting data of a type that cannot
be passed through `...' due to type promotion at the call site. Unfortunately, this is merely undefined, rather than a constraint
violation, so we cannot make this an error. If this call is never
executed, the program is still strictly conforming. We can, however, treat "undefined" any way we please.
Call abort to encourage the user to fix the program. Before the abort, allow the evaluation of the va_list
expression to exit or longjmp. This is dead code, but go ahead and finish so that the
mode of the result comes out right. Make it easier for the backends by protecting the valist argument
from multiple evaluations. For this case, the backends will be expecting a pointer to
TREE_TYPE (abi), but it's possible we've
actually been given an array (an actual TARGET_FN_ABI_VA_LIST).
So fix it. FIXME: Once most targets are converted we should merely
assert this is non-null.
|
static |
Gimplify a VAR_DECL or PARM_DECL. Return GS_OK if we expanded a DECL_VALUE_EXPR, and it's worth re-examining things.
??? If this is a local variable, and it has not been seen in any
outer BIND_EXPR, then it's probably the result of a duplicate
declaration, for which we've already issued an error. It would
be really nice if the front end wouldn't leak these at all.
Currently the only known culprit is C++ destructors, as seen
in g++.old-deja/g++.jason/binding.C. When within an OpenMP context, notice uses of variables.
If the decl is an alias for another expression, substitute it now.
For referenced nonlocal VLAs add a decl for debugging purposes
to the current function.
|
static |
|
static |
Gimplify a variable-length array DECL.
This is a variable-sized decl. Simplify its size and mark it
for deferred expansion. Don't mess with a DECL_VALUE_EXPR set by the front-end.
All occurrences of this decl in final gimplified code will be
replaced by indirection. Setting DECL_VALUE_EXPR does two
things: First, it lets the rest of the gimplifier know what
replacement to use. Second, it lets the debug info know
where to find the value. The call has been built for a variable-sized object.
Indicate that we need to restore the stack level when the
enclosing BIND_EXPR is exited.
References create_artificial_label(), gimplify_ctx::exit_label, gimple_build_goto(), gimple_build_label(), gimplify_and_add(), gimplify_seq_add_stmt(), and GS_ALL_DONE.
|
static |
A subroutine of gimplify_omp_atomic. The front end is supposed to have stabilized the lhs of the atomic operation as *ADDR. Return true if EXPR is this stabilized form.
Also include casts to other type variants. The C front end is fond
of adding these for e.g. volatile variables. This is like
STRIP_TYPE_NOPS but includes the main variant lookup.
|
static |
Walk *EXPR_P and replace appearances of *LHS_ADDR with LHS_VAR. If an expression does not involve the lhs, evaluate it into a temporary. Return 1 if the lhs appeared as a subexpression, 0 if it did not, or -1 if an error was encountered.
Break out any preevaluations from cp_build_modify_expr.
|
static |
Helper for get_formal_tmp_var and get_initialized_tmp_var.
Notice that we explicitly allow VAL to be a CALL_EXPR so that we
can create an INIT_EXPR and convert it into a GIMPLE_CALL below. gimplify_modify_expr might want to reduce this further.
|
static |
Returns true iff T is a valid RHS for an assignment to an un-renamed LHS, or for a call argument.
If we're dealing with a renamable type, either source or dest must be
a renamed variable.
|
static |
Return true if T is a valid memory RHS or a CALL_EXPR. Note that this predicate should only be used during gimplification. See the rationale for this in gimplify_modify_expr.
If we're dealing with a renamable type, either source or dest must be
a renamed variable.
|
static |
Returns true iff T is a valid RHS for an assignment to a renamed user -- or front-end generated artificial -- variable.
References is_gimple_reg_type().
|
static |
Return true if T is a CALL_EXPR or an expression that can be assigned to a temporary. Note that this predicate should only be used during gimplification. See the rationale for this in gimplify_modify_expr.
Referenced by lookup_tmp_var().
|
static |
Return true if T looks like a valid GIMPLE statement.
The only valid NOP_EXPR is the empty statement.
These are only valid if they're void.
These are always void.
These are valid regardless of their type.
|
static |
Create a temporary to hold the value of VAL. If IS_FORMAL, try to reuse an existing expression temporary.
If not optimizing, never really reuse a temporary. local-alloc
won't allocate any variable that is used in more than one basic
block, which means it will go into memory, causing much extra
work in reload and final and poorer code generation, outweighing
the extra memory allocation here.
References fb_rvalue, ggc_free(), gimplify_and_add(), gimplify_expr(), gimplify_ctx::into_ssa, is_gimple_reg_rhs_or_call(), is_gimple_reg_type(), make_ssa_name(), and unshare_expr().
| void mark_addressable | ( | ) |
Mark X addressable. Unlike the langhook we expect X to be in gimple form and we don't do any syntax checking.
Also mark the artificial SSA_NAME that points to the partition of X.
Referenced by create_iv(), gimplify_omp_workshare(), initialize_argument_information(), instrument_builtin_call(), and move_by_pieces_1().
|
static |
If *EXPR_P has a variable sized type, wrap it in a WITH_SIZE_EXPR.
If we've already wrapped this or the type is error_mark_node, we can't do
anything. If the size isn't known or is a constant, we have nothing to do.
Otherwise, make a WITH_SIZE_EXPR.
References build_call_array_loc(), BUILT_IN_NORMAL, and get_callee_fndecl().
|
static |
This page contains routines to unshare tree nodes, i.e. to duplicate tree
nodes that are referenced more than once in GENERIC functions. This is
necessary because gimplification (translation into GIMPLE) is performed
by modifying tree nodes in-place, so gimplication of a shared node in a
first context could generate an invalid GIMPLE form in a second context.
This is achieved with a simple mark/copy/unmark algorithm that walks the
GENERIC representation top-down, marks nodes with TREE_VISITED the first
time it encounters them, duplicates them if they already have TREE_VISITED
set, and finally removes the TREE_VISITED marks it has set.
The algorithm works only at the function level, i.e. it generates a GENERIC
representation of a function with no nodes shared within the function when
passed a GENERIC function (except for nodes that are allowed to be shared).
At the global level, it is also necessary to unshare tree nodes that are
referenced in more than one function, for the same aforementioned reason.
This requires some cooperation from the front-end. There are 2 strategies:
1. Manual unsharing. The front-end needs to call unshare_expr on every
expression that might end up being shared across functions.
2. Deep unsharing. This is an extension of regular unsharing. Instead
of calling unshare_expr on expressions that might be shared across
functions, the front-end pre-marks them with TREE_VISITED. This will
ensure that they are unshared on the first reference within functions
when the regular unsharing algorithm runs. The counterpart is that
this algorithm must look deeper than for manual unsharing, which is
specified by LANG_HOOKS_DEEP_UNSHARING.
If there are only few specific cases of node sharing across functions, it is
probably easier for a front-end to unshare the expressions manually. On the
contrary, if the expressions generated at the global level are as widespread
as expressions generated within functions, deep unsharing is very likely the
way to go. Similar to copy_tree_r but do not copy SAVE_EXPR or TARGET_EXPR nodes. These nodes model computations that must be done once. If we were to unshare something like SAVE_EXPR(i++), the gimplification process would create wrong code. However, if DATA is non-null, it must hold a pointer set that is used to unshare the subtrees of these nodes.
Do not copy SAVE_EXPR, TARGET_EXPR or BIND_EXPR nodes themselves, but
copy their subtrees if we can make sure to do it only once. Stop at types, decls, constants like copy_tree_r.
We can't do anything sensible with a BLOCK used as an
expression, but we also can't just die when we see it
because of non-expression uses. So we avert our eyes
and cross our fingers. Silly Java. Cope with the statement expression extension.
Leave the bulk of the work to copy_tree_r itself.
Referenced by copy_if_shared().
|
staticread |
Create a new omp construct that deals with variable remapping.
References pointer_set_destroy(), gimplify_omp_ctx::privatized_types, and gimplify_omp_ctx::variables.
|
static |
Referenced by gimple_push_cleanup(), and omp_is_private().
|
static |
Add an entry for DECL in the OpenMP context CTX with FLAGS.
Never elide decls whose type has TREE_ADDRESSABLE set. This means
there are constructors involved somewhere. We shouldn't be re-adding the decl with the same data
sharing class. The only combination of data sharing classes we should see is
FIRSTPRIVATE and LASTPRIVATE. When adding a variable-sized variable, we have to handle all sorts
of additional bits of data: the pointer replacement variable, and
the parameters of the type. Add the pointer replacement variable as PRIVATE if the variable
replacement is private, else FIRSTPRIVATE since we'll need the
address of the original variable either for SHARED, or for the
copy into or out of the context. Add all of the variable and type parameters (which should have
been gimplified to a formal temporary) as FIRSTPRIVATE. The variable-sized variable itself is never SHARED, only some form
of PRIVATE. The sharing would take place via the pointer variable
which we remapped above. We're going to make use of the TYPE_SIZE_UNIT at least in the
alloca statement we generate for the variable, so make sure it
is available. This isn't automatically needed for the SHARED
case, since we won't be allocating local storage then.
For local variables TYPE_SIZE_UNIT might not be gimplified yet,
in this case omp_notice_variable will be called later
on when it is gimplified. Similar to the direct variable sized case above, we'll need the
size of references being privatized.
|
static |
Return true if DECL is private within a parallel region that binds to the current construct's context or in parallel region's REDUCTION clause.
References might be private, but might be shared too.
References gimplify_omp_ctx::outer_context, and gimplify_omp_ctx::variables.
|
static |
Similarly for each of the type sizes of TYPE.
| void omp_firstprivatize_variable | ( | ) |
Add FIRSTPRIVATE entries for DECL in the OpenMP the surrounding parallels to CTX. If entries already exist, force them to be some flavor of private. If there is no enclosing parallel, do nothing.
|
static |
Verify that DECL is private within CTX. If there's specific information to the contrary in the innermost scope, generate an error.
References lang_hooks::decls, GOVD_FIRSTPRIVATE, GOVD_SEEN, GOVD_SHARED, is_global_var(), omp_add_variable(), OMP_CLAUSE_ALIGNED, OMP_CLAUSE_FIRSTPRIVATE, OMP_CLAUSE_LASTPRIVATE, OMP_CLAUSE_LINEAR, OMP_CLAUSE_PRIVATE, OMP_CLAUSE_SHARED, omp_notice_variable(), lang_hooks_for_decls::omp_private_debug_clause, ORT_COMBINED_PARALLEL, gimplify_omp_ctx::outer_context, gimplify_omp_ctx::region_type, and gimplify_omp_ctx::variables.
|
static |
Notice a threadprivate variable DECL used in OpenMP context CTX. This just prints out diagnostics about threadprivate variable uses in untied tasks. If DECL2 is non-NULL, prevent this warning on that variable.
|
static |
Referenced by canonicalize_component_ref(), and omp_is_private().
|
static |
Record the fact that DECL was used within the OpenMP context CTX. IN_CODE is true when real code uses DECL, and false when we should merely emit default(none) errors. Return true if DECL is going to be remapped and thus DECL shouldn't be gimplified into its DECL_VALUE_EXPR (if any).
Threadprivate variables are predetermined.
??? Some compiler-generated variables (like SAVE_EXPRs) could be
remapped firstprivate instead of shared. To some extent this is
addressed in omp_firstprivatize_type_sizes, but not effectively. FALLTHRU
decl will be either GOVD_FIRSTPRIVATE or GOVD_SHARED.
If nothing changed, there's nothing left to do.
If the variable is private in the current context, then we don't
need to propagate anything to an outer context.
|
static |
Optimize embedded COMPOUND_LITERAL_EXPRs within a CONSTRUCTOR, return a new CONSTRUCTOR if something changed.
References build_vector_from_ctor(), and initializer_constant_valid_p().
| void pop_gimplify_context | ( | ) |
Tear down a context for the gimplifier. If BODY is non-null, then put the temporaries into the outer BIND_EXPR. Otherwise, put them in the local_decls. BODY is not a sequence, but the first tuple in a sequence.
|
static |
Prepare the node pointed to by EXPR_P, an is_gimple_addressable expression, to be marked addressable. We cannot rely on such an expression being directly markable if a temporary has been created by the gimplification. In this case, we create another temporary and initialize it with a copy, which will become a store after we mark it addressable. This can happen if the front-end passed us something that it could not mark addressable yet, like a Fortran pass-by-reference parameter (int) floatvar.
| void preprocess_case_label_vec_for_gimple | ( | vec< tree > | labels, |
| tree | index_type, | ||
| tree * | default_casep | ||
| ) |
Prepare a vector of case labels to be used in a GIMPLE_SWITCH statement. LABELS is a vector that contains all case labels to look at. INDEX_TYPE is the type of the switch index expression. Case labels in LABELS are discarded if their values are not in the value range covered by INDEX_TYPE. The remaining case label values are folded to INDEX_TYPE. If a default case exists in LABELS, it is removed from LABELS and returned in DEFAULT_CASEP. If no default case exists, but the case labels already cover the whole range of INDEX_TYPE, a default case is returned pointing to one of the existing case labels. Otherwise DEFAULT_CASEP is set to NULL_TREE. DEFAULT_CASEP may be NULL, in which case the above comment doesn't apply and no action is taken regardless of whether a default case is found or not.
This is a non-default case label, i.e. it has a value.
See if the case label is reachable within the range of
the index type. Remove out-of-range case values. Turn
case ranges into a canonical form (high > low strictly)
and convert the case label values to the index type.
NB: The type of gimple_switch_index() may be the promoted
type, but the case labels retain the original type. This is a case range. Discard empty ranges.
If the bounds or the range are equal, turn this
into a simple (one-value) case. If the simple case value is unreachable, ignore it.
If the entire case range is unreachable, ignore it.
If the lower bound is less than the index type's
minimum value, truncate the range bounds. If the upper bound is greater than the index type's
maximum value, truncate the range bounds. We may have folded a case range to a one-value case.
The default case must be passed separately to the
gimple_build_switch routine. But if DEFAULT_CASEP
is NULL, we do not remove the default case (it would
be completely lost). If the switch has no default label, add one, so that we jump
around the switch body. If the labels already cover the whole
range of the switch index_type, add the default label pointing
to one of the existing labels.
References build_case_label(), len, and tree_int_cst_equal().
|
static |
Worker for unshare_expr_without_location.
| void push_gimplify_context | ( | ) |
Set up a context for the gimplifier.
References gimplify_ctx::bind_expr_stack, gimplify_ctxp, and gimplify_ctx::prev_context.
|
inlinestatic |
Strip off a legitimate source ending from the input string NAME of length LEN. Rather than having to know the names used by all of our front ends, we strip off an ending of a period followed by up to five characters. (Java uses ".class".)
References clean_symbol_name(), and strlen().
| gimple_predicate rhs_predicate_for | ( | ) |
Return the appropriate RHS predicate for this LHS.
|
static |
Given a conditional expression EXPR with short-circuit boolean predicates using TRUTH_ANDIF_EXPR or TRUTH_ORIF_EXPR, break the predicate apart into the equivalent sequence of conditionals.
First do simple transformations.
If there is no 'else', turn
if (a && b) then c
into
if (a) if (b) then c. Keep the original source location on the first 'if'.
Set the source location of the && on the second 'if'.
If there is no 'then', turn
if (a || b); else d
into
if (a); else if (b); else d. Keep the original source location on the first 'if'.
Set the source location of the || on the second 'if'.
If we're done, great.
Otherwise we need to mess with gotos. Change
if (a) c; else d;
to
if (a); else goto no;
c; goto end;
no: d; end:
and recursively gimplify the condition. If our arms just jump somewhere, hijack those labels so we don't
generate jumps to jumps. If we aren't hijacking a label for the 'then' branch, it falls through.
The 'else' branch also needs a label if it contains interesting code.
If there was nothing else in our arms, just forward the label(s).
If our last subexpression already has a terminal label, reuse it.
If we don't care about jumping to the 'else' branch, jump to the end
if the condition is false. We only want to emit these labels if we aren't hijacking them.
We only emit the jump over the else clause if we have to--if the
then clause may fall through. Otherwise we can wind up with a
useless jump and a useless label at the end of gimplified code,
which will cause us to think that this conditional as a whole
falls through even if it doesn't. If we then inline a function
which ends with such a condition, that can cause us to issue an
inappropriate warning about control reaching the end of a
non-void function.
References gimple_boolify().
|
static |
Handle shortcut semantics in the predicate operand of a COND_EXPR by rewriting it into multiple COND_EXPRs, and possibly GOTO_EXPRs. TRUE_LABEL_P and FALSE_LABEL_P point to the labels to jump to if the condition is true or false, respectively. If null, we should generate our own to skip over the evaluation of this specific expression. LOCUS is the source location of the COND_EXPR. This function is the tree equivalent of do_jump. shortcut_cond_r should only be called by shortcut_cond_expr.
OK, it's not a simple case; we need to pull apart the COND_EXPR to
retain the shortcut semantics. Just insert the gotos here;
shortcut_cond_expr will append the real blocks later. Turn if (a && b) into
if (a); else goto no;
if (b) goto yes; else goto no;
(no:) Keep the original source location on the first 'if'.
Set the source location of the && on the second 'if'.
Turn if (a || b) into
if (a) goto yes;
if (b) goto yes; else goto no;
(yes:) Keep the original source location on the first 'if'.
Set the source location of the || on the second 'if'.
As long as we're messing with gotos, turn if (a ? b : c) into
if (a)
if (b) goto yes; else goto no;
else
if (c) goto yes; else goto no;
Don't do this if one of the arms has void type, which can happen
in C++ when the arm is throw. Keep the original source location on the first 'if'. Set the source
location of the ? on the second 'if'.
|
static |
Determine whether to assign a location to the statement GS.
Don't emit a line note for a label. We particularly don't want to
emit one for the break label, since it doesn't actually correspond
to the beginning of the loop/switch.
| void sort_case_labels | ( | ) |
Sort the case labels in LABEL_VEC in place in ascending order.
|
static |
A stable comparison routine for use with splay trees and DECLs.
|
inlinestatic |
Unmark the visited trees rooted at *TP.
|
static |
Callback for walk_tree to unmark the visited trees rooted at *TP. Subtrees are walked until the first unvisited node is encountered.
If this node has been visited, unmark it and keep looking.
Otherwise, don't look any deeper.
|
static |
Unshare all the trees in the body of FNDECL, as well as in the bodies of any nested functions.
If the language requires deep unsharing, we need a pointer set to make
sure we don't repeatedly unshare subtrees of unshareable nodes.
| tree unshare_expr | ( | ) |
Unconditionally make an unshared copy of EXPR. This is used when using stored expressions which span multiple functions, such as BINFO_VTABLE, as the normal unsharing process can't tell that they're shared.
Referenced by canonicalize_component_ref(), follow_inital_value_to_phi(), forward_propagate_addr_expr(), gimple_gen_one_value_profiler(), gimplify_modify_expr_to_memset(), if_convertible_loop_p(), insert_gimplified_predicates(), ipa_modify_call_arguments(), ipa_set_jf_known_type(), lookup_tmp_var(), loop_has_blocks_with_irreducible_flag(), make_fancy_name(), nothing_to_prefetch_p(), remove_dead_stmt(), set_strinfo(), simplify_binary_expression(), tm_log_emit(), and vect_can_advance_ivs_p().
| tree unshare_expr_without_location | ( | ) |
Similar to unshare_expr but also prune all expression locations from EXPR.
Referenced by free_temp_arrays(), and ipa_set_jf_known_type().
|
static |
Likewise, but mark all trees as not visited.
References tsi_end_p(), tsi_last(), and tsi_stmt_ptr().
| tree voidify_wrapper_expr | ( | ) |
WRAPPER is a code such as BIND_EXPR or CLEANUP_POINT_EXPR which can both contain statements and have a value. Assign its value to a temporary and give it void_type_node. Return the temporary, or NULL_TREE if WRAPPER was already void.
Set p to point to the body of the wrapper. Loop until we find
something that isn't a wrapper. For a BIND_EXPR, the body is operand 1.
Advance to the last statement. Set all container types to
void. Assume that any tree upon which voidify_wrapper_expr is
directly called is a wrapper, and that its body is op0. The wrapper is on the RHS of an assignment that we're pushing
down.
|
static |
Return true if FDECL is accessing a field that is zero sized.
Referenced by gimplify_modify_expr_to_memset().
|
static |
Return true if TYPE is zero sized.
|
static |
Referenced by push_gimplify_context().
|
static |
Referenced by canonicalize_component_ref().
|
static |
Nonlocal VLAs seen in the current function.
|
static |
Create a new temporary name with PREFIX. Return an identifier.