This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.

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

# Re: Calculation of displacement of a variable.

• From: "C Jaiprakash, Noida" <cjaiprakash at noida dot hcltech dot com>
• To: Rama Singh <rama10nov at yahoo dot co dot in>
• Cc: gcc at gcc dot gnu dot org
• Date: Thu, 30 Oct 2003 18:55:42 +0530
• Subject: Re: Calculation of displacement of a variable.
• References: <20031030095631.9202.qmail@web8007.mail.in.yahoo.com>

Rama Singh wrote:

--- C Jaiprakash, Noida
<cjaiprakash@noida.hcltech.com> wrote: >

```Hi,
I am working on a gcc port, i have a question
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.```

clear from your mail is that you can have two memory
addresses both deferring on the basis of _Modes_. Now
if you are switching Memory_Access_mode through some
instruction then you must be emitting that
memory_switch_insn. Following that just have the
BAse_Reg + Displacement/2 otherwise keep the default
setting of Base_Reg + Displacement.

Yes abosulte address can be divided by 2 for higher modes but this will be a costly thing to do.

This is a little
tricky part but the displacement can be modified in
{"ft_lang_label":"__label__en","ft_lang_prob":0.74314225,"math_prob":0.9631908,"size":1409,"snap":"2021-43-2021-49","text_gpt3_token_len":464,"char_repetition_ratio":0.21565837,"word_repetition_ratio":0.23870967,"special_character_ratio":0.33286017,"punctuation_ratio":0.094915256,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99361485,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-12-01T00:33:46Z\",\"WARC-Record-ID\":\"<urn:uuid:6f9a4f24-4d1a-4aa0-b73b-782778925cd1>\",\"Content-Length\":\"7304\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:59355c45-8e01-4bc8-bd23-1572fc421574>\",\"WARC-Concurrent-To\":\"<urn:uuid:2bf0a4a7-7025-4f84-bf67-c0be85fe8ddb>\",\"WARC-IP-Address\":\"8.43.85.97\",\"WARC-Target-URI\":\"https://gcc.gnu.org/legacy-ml/gcc/2003-10/msg01438.html\",\"WARC-Payload-Digest\":\"sha1:BKMBS66D2ISVULCR2TGSKBJPAICJQ5UE\",\"WARC-Block-Digest\":\"sha1:75V2ZQY2QBHJID4L4CA3E7GC6QH4USRU\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-49/CC-MAIN-2021-49_segments_1637964359082.76_warc_CC-MAIN-20211130232232-20211201022232-00616.warc.gz\"}"}