public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Patch: stab info for const fields
@ 2002-10-31 14:05 Richard Kenner
  2002-10-31 14:29 ` Mark Mitchell
  0 siblings, 1 reply; 30+ messages in thread
From: Richard Kenner @ 2002-10-31 14:05 UTC (permalink / raw)
  To: mark; +Cc: gcc-patches, gcc

    GCC is pretty clear on the idea that the type system is, roughly
    speaking, the C type system.  The front end's job is to translate its
    own type system into that type system.

Right, but we haven't been as clear as we should be on what "the C type
system" is.  That's basically what started this: what about readonly?
Consider (going back to C):

	int a;
	const int b;

	... a + b ...

What does that PLUS_EXPR look like?  If A and B are different types (with
a different TREE_READONLY), then we have to have a conversion in that
PLUS_EXPR.  Sure the optimizer can "do the right thing" and ignore it,
but those conversions aren't making things any easier.

    If you have declarations whose size is not that of their type, you
    have to say more about what tree operations are legal in the middle
    end.  Can you use a MODIFY_EXPR to assign these out-sized objects to
    ordinary-sized objects?  Normally, the constraint on a MODIFY_EXPR is
    that the two operands have the same type.  This is but the tip of the
    iceberg.

Yes, but I think they can all be solved the way the PLUS_EXPR above is:
the *operation* is, semantically, that of its type.  However, the optimizers
are allowed to use the fact that B is constant.  Similarly with a MODIFY_EXPR
in the aggregate case: only the size corresponding to the type is modified,
but if one operand is actually more aligned that the type, the optimizer and
code generator is allowed to take advantage of that.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Patch: stab info for const fields
@ 2002-11-01 12:35 Richard Kenner
  0 siblings, 0 replies; 30+ messages in thread
From: Richard Kenner @ 2002-11-01 12:35 UTC (permalink / raw)
  To: aph; +Cc: gcc-patches, gcc, zack

    So the question becomes: "in what circumstances is there just one,
    well-defined, conversion that makes sense?"  If we properly define
    those circumstances the problem is solved.

Sure, but, as I said, that's precisely equivalent to the original question.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Patch: stab info for const fields
@ 2002-11-01  4:59 Richard Kenner
  0 siblings, 0 replies; 30+ messages in thread
From: Richard Kenner @ 2002-11-01  4:59 UTC (permalink / raw)
  To: aph; +Cc: gcc-patches, gcc, zack

    I believe that Zack implicitly meant (3), using a superset of (2).

OK, what *is* that superset?  How is it defined precisely? 

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Patch: stab info for const fields
@ 2002-11-01  4:45 Richard Kenner
  2002-11-01  4:56 ` Andrew Haley
  0 siblings, 1 reply; 30+ messages in thread
From: Richard Kenner @ 2002-11-01  4:45 UTC (permalink / raw)
  To: aph; +Cc: gcc-patches, gcc, zack

    You seem to have smipped

       Most of the time there is just one, well-defined, conversion
       operation that makes sense in any such context.  If there is none,
       or if there could be multiple intended semantics, the tree is
       ill-formed; the middle-end will abort if handed such a tree.

    So the question becomes: "in what circumstances is there just one,
    well-defined, conversion that makes sense?"  If we properly define
    those circumstances the problem is solved.

Well, that's exactly what we're trying to do: to "properly define" what
"implicit conversions" are valid.  What is your proposal?

To restate the four that we've talked about into that terminology, they are:

(1) None.
(2) Only between types whose TYPE_MAIN_VARIANT are the same.
(3) Some other, language-independent formulation.
(3a) A language-dependent formulation.

So we're back to the original question.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Patch: stab info for const fields
@ 2002-11-01  3:45 Richard Kenner
  2002-11-01  3:55 ` Andrew Haley
  0 siblings, 1 reply; 30+ messages in thread
From: Richard Kenner @ 2002-11-01  3:45 UTC (permalink / raw)
  To: zack; +Cc: gcc-patches, gcc

     - In the language-independent tree representation, whenever a tree
       with type A has an operand with type B, A not identical to B, the
       operand is implicitly converted to type A before the operation
       occurs.

But what does that mean?  That's the essence of the problem.

Please go back to the originally-stated question: if a see a PLUS_EXPR and
look at its type and the types of its operands, how do I know if that's
a valid tree node in our IL?  If the answer is "you look at the definition
of the language it's written in", that's a serious problem in my view.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Patch: stab info for const fields
@ 2002-10-31 16:04 Richard Kenner
  2002-10-31 16:26 ` Gabriel Dos Reis
  0 siblings, 1 reply; 30+ messages in thread
From: Richard Kenner @ 2002-10-31 16:04 UTC (permalink / raw)
  To: zack; +Cc: gcc-patches, gcc, mark

    If you look again at the bit you snipped, the implementation I
    suggested should be totally language-independent (in the
    language-independent parts of the compiler).

Yes, the *implementation* is, but the *definition* is not, so that when
people are looking at a tree, they can't know whether it's valid or not
without knowlege of the language in question and I think that's a bad idea.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Patch: stab info for const fields
@ 2002-10-31 15:24 Richard Kenner
  2002-10-31 15:50 ` Zack Weinberg
  0 siblings, 1 reply; 30+ messages in thread
From: Richard Kenner @ 2002-10-31 15:24 UTC (permalink / raw)
  To: zack; +Cc: gcc-patches, gcc, mark

     (3a) The types are "compatible", which is a term with a precise
          but language-specific definition; consult the relevant standard.

I don't like that idea at all.  It means that how you interpret a tree
in the middle-end is a function of the front-end that generated it.
But I'd strongly argue that the trees are meant to be a
language-independent IL.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Patch: stab info for const fields
@ 2002-10-31 14:33 Richard Kenner
  2002-10-31 15:14 ` Zack Weinberg
  0 siblings, 1 reply; 30+ messages in thread
From: Richard Kenner @ 2002-10-31 14:33 UTC (permalink / raw)
  To: mark; +Cc: gcc-patches, gcc

    Again, this goes to Zack's point; we can allow two types to be compatible,
    even if they are not the same.  (That idea already exists in C/C++)

So the idea is that we allow "compatible" types on the two operands and
the result of a PLUS_EXPR, but they are not required to all be the same?
We've never really been clear on that and there are three possibilities:

(1) The types are exactly the same.
(2) TYPE_MAIN_VARIANT of the types are the same.
(3) The types are "compatible" (to be defined later).

I've argued for (1) in the past and continue to do so.  Is the above
arguing for (2) or (3)?

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Re: Patch: stab info for const fields
@ 2002-10-31 13:37 Richard Kenner
  2002-10-31 13:52 ` Mark Mitchell
  0 siblings, 1 reply; 30+ messages in thread
From: Richard Kenner @ 2002-10-31 13:37 UTC (permalink / raw)
  To: mark; +Cc: gcc-patches, gcc

    It would be great to get all this junk out of DECLs, but it will
    take some doing...

I'm still not sure it's moving in the right direction.  Consider the
following in Ada:

	type Myint is range 0..1000;
	for Myint'size use 32;
	type T is record f1, f2: Myint; end record;
	X: T;
	for X'size use 128;

This has X of type T, which is 64 bits, but X is 128 bits.

Currently, GNAT makes a special type for X which is a record of one
field.  That field is of type T and the type for X has a size of 128 bits.
Then X is of that type.

But doing this means that all references to X need an implicit
COMPONENT_REF to extract the actual data.  This is a mess.

If we allow the size of a decl to be larger than that of its type, we
can avoid this mess.

^ permalink raw reply	[flat|nested] 30+ messages in thread
* Patch: stab info for const fields
@ 2002-10-30 15:16 Dale Johannesen
  2002-10-30 22:01 ` Mark Mitchell
  0 siblings, 1 reply; 30+ messages in thread
From: Dale Johannesen @ 2002-10-30 15:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: Dale Johannesen

For fields of the form
   struct s {
      char *const p;
   }
the C FE sets the READONLY bit on the FIELD_DECL node, not
on its type.  This results in the 'const' attribute not getting
passed to the debugger.  Likewise for volatile.  Note that C++
does this differently, and is already generating correct debug
info (READONLY bit is on both the FIELD_DECL and the type) so
this code avoids emitting the 'const' code twice in that case.

Testing:  built the following -g, in C and C++, and verified that
gdb displayed all the types correctly.  How do you put a test like
this in the suite?  Also bootstrap and test.

struct ssc  { char *const p1; const char* p2; };
struct ss { char *ptr; };
struct ssv { char* volatile p1; volatile char* p2; };
struct big { const volatile char* p1; const char* volatile p2;
              volatile char* const p3; char* const volatile p4; };
struct sbits { char const p1:3; const char p2: 3; };
int main() {}

2002-10-30  Dale Johannesen  <dalej@apple.com>

         * dbxout.c (dbxout_type_fields):  Emit correct debug info
         for const and volatile fields.

Index: dbxout.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/dbxout.c,v
retrieving revision 1.128
diff -u -d -b -w -c -3 -p -r1.128 dbxout.c
cvs server: conflicting specifications of output style
*** dbxout.c    27 Sep 2002 03:08:37 -0000      1.128
--- dbxout.c    30 Oct 2002 23:12:29 -0000
*************** dbxout_type_fields (type)
*** 782,787 ****
--- 782,812 ----
               CHARS (2);
             }

+         if (use_gnu_debug_info_extensions
+             && TREE_CODE (tem) == FIELD_DECL
+             && (TREE_READONLY (tem) || TREE_THIS_VOLATILE (tem)))
+           {
+             tree type =
+               DECL_BIT_FIELD_TYPE (tem)
+               ? DECL_BIT_FIELD_TYPE (tem)
+               : TREE_TYPE (tem);
+             if ((TYPE_VOLATILE (type) != TREE_THIS_VOLATILE (tem))
+                || (TYPE_READONLY (type) != TREE_READONLY (tem)))
+               {
+                 have_used_extensions = 1;
+                 if ( TREE_READONLY (tem))
+                   {
+                     putc ('k', asmfile);
+                     CHARS (1);
+                   }
+                 if ( TREE_THIS_VOLATILE (tem))
+                   {
+                     putc ('B', asmfile);
+                     CHARS (1);
+                   }
+               }
+           }
+
           dbxout_type ((TREE_CODE (tem) == FIELD_DECL
                         && DECL_BIT_FIELD_TYPE (tem))
                        ? DECL_BIT_FIELD_TYPE (tem) : TREE_TYPE (tem), 
0);

^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2002-11-01 20:35 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-31 14:05 Patch: stab info for const fields Richard Kenner
2002-10-31 14:29 ` Mark Mitchell
  -- strict thread matches above, loose matches on Subject: below --
2002-11-01 12:35 Richard Kenner
2002-11-01  4:59 Richard Kenner
2002-11-01  4:45 Richard Kenner
2002-11-01  4:56 ` Andrew Haley
2002-11-01  3:45 Richard Kenner
2002-11-01  3:55 ` Andrew Haley
2002-10-31 16:04 Richard Kenner
2002-10-31 16:26 ` Gabriel Dos Reis
2002-10-31 20:17   ` Zack Weinberg
2002-11-01  4:52     ` Gabriel Dos Reis
2002-10-31 15:24 Richard Kenner
2002-10-31 15:50 ` Zack Weinberg
2002-10-31 14:33 Richard Kenner
2002-10-31 15:14 ` Zack Weinberg
2002-10-31 13:37 Richard Kenner
2002-10-31 13:52 ` Mark Mitchell
2002-10-30 15:16 Dale Johannesen
2002-10-30 22:01 ` Mark Mitchell
2002-10-31  9:42   ` Dale Johannesen
2002-10-31  9:47     ` Mark Mitchell
2002-10-31 10:25       ` Dale Johannesen
2002-10-31 11:06         ` Mark Mitchell
2002-10-31 12:50           ` Zack Weinberg
2002-10-31 12:54             ` Mark Mitchell
2002-10-31 13:10               ` Zack Weinberg
2002-10-31 13:12                 ` Mark Mitchell
2002-10-31 14:26             ` Joseph S. Myers
2002-10-31 11:21   ` Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).