This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: What to remove after tree-ssa is merged?


    It is not required for Ada right now because Ada doesn't work
    with tree-ssa anyway.

Sure, but there's no point in taking something out that we know will have
to be put back!

    And if it will, then we'll have to see how to fit in the thing that
    PLACEHOLDER_EXPR is for now.  I don't know what it is used for at
    present, but there has to be a way (or there will have to be) to
    express the same thing in GIMPLE.

Did you read the documentation on it in tree.def?  Whats's unclear about it?
Here it is for reference:

/* The following two codes are used in languages that have types where
   some field in an object of the type contains a value that is used in
   the computation of another field's offset or size and/or the size of
   the type.  The positions and/or sizes of fields can vary from object
   to object of the same type or even for one and the same object within
   its scope.

   Record types with discriminants in Ada or schema types in Pascal are
   examples of such types.  This mechanism is also used to create "fat
   pointers" for unconstrained array types in Ada; the fat pointer is a
   structure one of whose fields is a pointer to the actual array type
   and the other field is a pointer to a template, which is a structure
   containing the bounds of the array.  The bounds in the type pointed
   to by the first field in the fat pointer refer to the values in the
   template.

   When you wish to construct such a type you need "self-references"
   that allow you to reference the object having this type from the
   TYPE node, i.e. without having a variable instantiating this type.

   Such a "self-references" is done using a PLACEHOLDER_EXPR.  This is
   a node that will later be replaced with the object being referenced.
   Its type is that of the object and selects which object to use from
   a chain of references (see below).  No other slots are used in the
   PLACEHOLDER_EXPR.

   For example, if your type FOO is a RECORD_TYPE with a field BAR,
   and you need the value of <variable>.BAR to calculate TYPE_SIZE
   (FOO), just substitute <variable> above with a PLACEHOLDER_EXPR
   whose TREE_TYPE is FOO.  Then construct your COMPONENT_REF with
   the PLACEHOLDER_EXPR as the first operand (which has the correct
   type).  Later, when the size is needed in the program, the back-end
   will find this PLACEHOLDER_EXPR and generate code to calculate the
   actual size at run-time.  In the following, we describe how this
   calculation is done.

   When we wish to evaluate a size or offset, we check whether it
   contains a PLACEHOLDER_EXPR.  If it does, we construct a
   WITH_RECORD_EXPR that contains both the expression we wish to
   evaluate and an expression within which the object may be found.
   The latter expression is the object itself in the simple case of an
   Ada record with discriminant, but it can be the array in the case of
   an unconstrained array.

   In the latter case, we need the fat pointer, because the bounds of
   the array can only be accessed from it.  However, we rely here on the
   fact that the expression for the array contains the dereference of
   the fat pointer that obtained the array pointer.

   Accordingly, when looking for the object to substitute in place of
   a PLACEHOLDER_EXPR, we look down the first operand of the expression
   passed as the second operand to WITH_RECORD_EXPR until we find
   something of the desired type or reach a constant.  */

/* Denotes a record to later be supplied with a WITH_RECORD_EXPR when
   evaluating this expression.  The type of this expression is used to
   find the record to replace it.  */
DEFTREECODE (PLACEHOLDER_EXPR, "placeholder_expr", 'x', 0)

/* Provide an expression that references a record to be used in place
   of a PLACEHOLDER_EXPR.  The record to be used is the record within
   operand 1 that has the same type as the PLACEHOLDER_EXPR in
   operand 0.  */
DEFTREECODE (WITH_RECORD_EXPR, "with_record_expr", 'e', 2)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]