From: Mohamed Shafi <shafitvm@gmail.com>
To: GCC <gcc@gcc.gnu.org>
Subject: Help for target with BITS_PER_UNIT = 16
Date: Mon, 16 Aug 2010 13:18:00 -0000 [thread overview]
Message-ID: <AANLkTimq1NABM_O4JmS6OiiWg7fBtG0Jfg1g3drSt1SD@mail.gmail.com> (raw)
Hello all,
I am trying to port GCC 4.5.1 for a processor that has the following
addressing capability:
The data memory address space of 64K bytes is represented by a total
of 15 bits, with each address selecting a 16-bit element. When using
the address register, the LSB of address reg (AD) points to a 16-bit
field in data memory. If a data memory line is 128 bits there are 8,
16-bit elements per data memory line. We use little endian addressing,
so
if AD=0, bits [15:0] of data memory line address 0 would be selected.
If AD=1, bits [31:16] of data memory line address 0 would be selected.
If AD=9, bits [31:16] of data memory line address 1 would be selected.
So if i have the following program
short arr[5] = {11,12,13,14,15};
int foo ()
{
short a = arr[0] + arr[3];
return a;
}
Assume that short is 16bits and short address is 2byte aligned.Then I
expect the following code to get generated:
mov a0,#arr // Load the address
mov a1, a0 // Copy the address
add a1, 1 // Increment the location by 1 so that the address
points to arr[1]
ld.16 g0, (a1) // Load the value 12 into g0
mov a1, a0 // Copy the address
add a1, 3 // Increment the location by 3 so that the address
points to arr[3]
ld.16 g1, (a1) // Load the value 14 into g0
add g1, g1, g0 // Add 12 and 14
For the following code:
short arr[5] = {11,12,13,14,15};
int foo ()
{
short a,b;
a = (short) (&arr[3] - &arr[1]); // a is 2 after this operation
b = (short) ((char*)&arr[3] - (char*)&arr[1]); // b is 4 after this operation
return a;
}
My question is should i set the macro BITS_PER_UNIT = 16 to get a code
generated like this? From IRC chat i realize that BITS_PER_UNIT != 8
is seriously rotten. If that is the case how can i proceed to port
this target?
Regards,
Shafi
next reply other threads:[~2010-08-16 12:10 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-16 13:18 Mohamed Shafi [this message]
2010-08-16 14:27 ` Michael Matz
2010-08-16 19:40 ` Dave Korn
2010-08-16 15:25 ` Richard Guenther
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AANLkTimq1NABM_O4JmS6OiiWg7fBtG0Jfg1g3drSt1SD@mail.gmail.com \
--to=shafitvm@gmail.com \
--cc=gcc@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).