This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Inquiry about RTL
- From: "SRUTHY C.N." <csy2p100 at nitc dot ac dot in>
- To: <gcc at gnu dot org>, <gcc at gcc dot gnu dot org>
- Date: Sat, 16 Aug 2003 17:02:08 +0530 (IST)
- Subject: Inquiry about RTL
Sir,
consider the 2 programs below..
pgm 1:
main ()
{
char x='a',y='b'; int j,i;int a[4];
i=9;
for (j=0;j<4;j++)
a[j]=j+3;
}
pgm 2:
main ()
{
char x='a'; int j;char y='b';int i;int a[4];
i=9;
for (j=0;j<4;j++)
a[j]=j+3;
}
in pgm 1 the two char constants are declared together and in the rtl code
they are shown as stored at offsets -1 and -2 because char takes one byte
space..
----------------------------------------------------------------------
(insn 9 6 11 (set (mem/f:QI (plus:SI (reg:SI 38 virtual-stack-vars)
(const_int -1 [0xffffffff])) 0)
(const_int 97 [0x61])) -1 (nil)
(nil))
(insn 11 9 14 (set (mem/f:QI (plus:SI (reg:SI 38 virtual-stack-vars)
(const_int -2 [0xfffffffe])) 0)
(const_int 98 [0x62])) -1 (nil)
(nil))
---------------------------------------------------------------------
then why can't the next int var (int takes 4 byte) take offset -6? why it
is taking offset -8?
------------------------------------------------------------------------
(insn 17 14 18 (set (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
(const_int -8 [0xfffffff8])) 0)
(const_int 0 [0x0])) -1 (nil)
(nil))
--------------------------------------------------------------------
and array is starting from 32 onwards downwards actually it can start from
28 also...why is this?
--------------------------------------------------------------------
in pgm2
first char var takes offset -1 next int takes offset -8 then char y takes
-9 and next array is starting from 32 onwards downwards..
(insn 9 6 11 (set (mem/f:QI (plus:SI (reg:SI 38 virtual-stack-vars)
(const_int -1 [0xffffffff])) 0)
(const_int 97 [0x61])) -1 (nil)
(nil))
(insn 11 9 14 (set (mem/f:QI (plus:SI (reg:SI 38 virtual-stack-vars)
(const_int -9 [0xfffffff7])) 0)
(const_int 98 [0x62])) -1 (nil)
(nil))
(insn 14 11 17 (set (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
(const_int -16 [0xfffffff0])) 0)
(const_int 9 [0x9])) -1 (nil)
(nil))
(insn 17 14 18 (set (mem/f:SI (plus:SI (reg:SI 38 virtual-stack-vars)
(const_int -8 [0xfffffff8])) 0)
(const_int 0 [0x0])) -1 (nil)
(nil))
****************************************************
how to understand the stack layout of this rtl code generated... is there
any constraints like above ? why can't it take contiguous locations? will
it depend on the target machine?
****************************************************
while calling printf we have to pass the arguments to the stack..ther also
some alignments to multiple of 16 is done..
please tell me where can I get such details?
Thanking you,
SRUTHY C.N.