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]

Re: genattrtab.c [Am I on drugs?!?]



  In message <9909301822.AA16833@vlsi1.ultra.nyu.edu>you write:
  >     From genattrtab.c::simplify_cond:
  > 
  >       int len = XVECLEN (exp, 0);
  >       rtunion *tests = (rtunion *) alloca (len * sizeof (rtunion));
  >       int allsame = 1;
  >       char *first_spacer;
  > 
  >       /* This lets us free all storage allocated below, if appropriate.  */
  >       first_spacer = (char *) obstack_finish (rtl_obstack);
  > 
  >       bcopy ((char *) XVEC (exp, 0)->elem, (char *) tests,
  > 	     len * sizeof (rtunion));
  > 
  > 
  >     rtunion is:
  > 
  >     typedef union rtunion_def
  >     {
  >       HOST_WIDE_INT rtwint;
  >       int rtint;
  >       char *rtstr;
  >       struct rtx_def *rtx;
  >       struct rtvec_def *rtvec;
  >       enum machine_mode rttype;
  >       addr_diff_vec_flags rt_addr_diff_vec_flags;
  >       struct bitmap_head_def *rtbit;
  >       union tree_node *rttree;
  >       struct basic_block_def *bb;
  >     } rtunion;
  > 
  >     Note that if sizeof (HOST_WIDE_INT) >= sizeof (pointer), then we lose
  >     so badly it's not funny in the bcopy shown above.
  > 
  > Why?  The sizes in alloca and in bcopy are the same and look right to me:
  > they are the size of the union, which will be the maximum of the sizes
  > of a pointer and HOST_WIDE_INT.
The rtx pointers from the elem array end up in the wrong places in the test
array when a HOST_WIDE_INT is larger than a pointer.

Consider if a pointer is 32bits and a HOST_WIDE_INT is 64 bits.

Each entry in the rtunion array is twice the size of each entry in the 
elem array.

So let's pretend elem has 4 elements.  A, B, C, D.

We place them into test and end up with tests[0] containing A & B
and tests[1] containing C & D because each element in the tests array
is large enough to hold two pointers.

Not particularly good when we wanted to access tests[0].rtx, tests[1].rtx,
tests[2].rtx, tests[3].rtx.




jeff



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