This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Calculation of displacement of a variable.
- From: "C Jaiprakash, Noida" <cjaiprakash at noida dot hcltech dot com>
- To: "'gcc at gcc dot gnu dot org'" <gcc at gcc dot gnu dot org>
- Date: Thu, 30 Oct 2003 13:37:44 +0530
- Subject: Calculation of displacement of a variable.
Hi,
I am working on a gcc port, i have a question about how displacements are
calculated for variables in gcc.
Consider for ex following code
void fun()
{
char a,b,c,d;
int x,y,z;
long i,j,k;
}
Assuming following sizes for
char = 8 bit
int = 16 bit
long = 32 bit
following will the dislacements for above variables
a = Base Reg + 1
b = Base Reg + 2
c = Base Reg + 3
d = Base Reg + 4
x = Base Reg + 6
y = Base Reg + 8
z = Base Reg + 10
i = Base Reg + 12
j = Base Reg + 16
k = Base Reg + 20
But the problem is h/w accesses memory as nth byte ot nth word so ( Base Reg
+ 1 ) if accessed in byte access mode will read 1st byte.
For ex byte at 0001h if BASE REG = 0000h
and it will access 1st word if memory is accessed in word mode. i.e a word
from memory location 0002h.
Due to this behaviour of h/w the actual displacements should have been
generated as below
a = Base Reg + 1
b = Base Reg + 2
c = Base Reg + 3
d = Base Reg + 4
x = Base Reg + 3
y = Base Reg + 4
z = Base Reg + 5
i = Base Reg + 6
j = Base Reg + 8
k = Base Reg + 10
Is it possible to generate such displacements in gcc? Basically definitions
of BITS_PER_UNIT and UNITS_PER_WORD here are dependent on mode,
i.e for
QImode : BITS_PER_UNIT = 8, UNITS_PER_WORD = 2
HImode : BITS_PER_UNIT = 16, UNITS_PER_WORD = 1
SImode : BITS_PER_UNIT = 16, UNITS_PER_WORD = 1
Can this behaviour be implemented in gcc? any pointers in this direction are
appreciated.
Thanks,
C Jaiprakash