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]

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



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