* Need help in deciding the instruction set for a new target.
@ 2010-08-23 18:25 Mohamed Shafi
2010-08-23 19:00 ` Ian Lance Taylor
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Mohamed Shafi @ 2010-08-23 18:25 UTC (permalink / raw)
To: GCC
Hello all,
I am trying to do a port on GCC 4.5. The target has a memory
resolution of 32bits i.e. char is 32bits in the target (addr 0 selects
1st 32bit and addr 1 selects 2nd 32bit). It has only word (32bit)
access.
In terms of address resolution this target is similar to c4x which
became obsolete in GCC 4.2. There are two ways to implement this port.
One is to have BITS_PER_UNIT ==32, like c4x and other is to have a
normal C like char == 8, short == 16, and int == 32. We are thinking
about having BITS_PER_UNIT == 32. Yes I know the support for such a
target is bit rotten in GCC. I am currently trying to removing it.
In the mean time, we are in the process of finalizing the
instructions. The current instruction set has support for 32bit
immediate data only in move operations. i.e.
move src1GP, #imm32
For all other operations like div, sub, add, compare, modulus, load,
store the support is only for 16bit immediate. For all these
instruction there is separate flavor for sign and zero extension. i.e.
mod.s32 srcdstGP, #imm16 // 32%imm16 signed modulus
mod.u32 srcdstGP, #imm16 // 32%imm16 unsigned modulus
cmp.s32 src1GP, #imm16 // signed register to 16-bit immediate compare
cmp.u32 src1GP, #imm16 // unsigned register to 16-bit immediate compare
sub.s32 srcdstGP, #imm16 // signed 16-bit register to immediate subtract
sub.u32 srcdstGP, #imm16 // unsigned 16-bit register to immediate subtract
I want to know if it is good to have both sign and zero extension for
16bit immediate.
Will it be of any use with a configuration where char == short == int == 32bit?
Will I be able to support these kinds of instructions in a GCC port?
Or will it good to have a separate sign and zero extension
instruction, which the current instruction set doesn’t have.
Do I need a separate sign and zero ext instructions along with the
above instructions?
It would be of great help if you could guide me in deciding these instructions.
Regards,
Shafi
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Need help in deciding the instruction set for a new target.
2010-08-23 18:25 Need help in deciding the instruction set for a new target Mohamed Shafi
@ 2010-08-23 19:00 ` Ian Lance Taylor
2010-08-23 20:24 ` Bernd Schmidt
2010-08-23 22:20 ` Richard Henderson
2 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2010-08-23 19:00 UTC (permalink / raw)
To: Mohamed Shafi; +Cc: GCC
Mohamed Shafi <shafitvm@gmail.com> writes:
> I want to know if it is good to have both sign and zero extension for
> 16bit immediate.
Hard to say. It really depends on the kind of constants you expect your
programs to use. It's generally a good idea to have an efficient way to
load small constants which many programs use, such as 0, 1, -1. The
latter implies that you will want sign extending immediate operations.
Whether your programs will benefit from an efficient way to load 0xffff,
I don't know.
> Will it be of any use with a configuration where char == short == int == 32bit?
Yes, the size of supported immediate constants is really orthogonal to
the size of the data types. Your programs are certainly going to refer
to numbers like 0, 1, and -1. Efficient ways of using those constants
will generally pay off, though of course it is a tradeoff like
everything else in architecture design.
> Will I be able to support these kinds of instructions in a GCC port?
Yes.
> Or will it good to have a separate sign and zero extension
> instruction, which the current instruction set doesn’t have.
> Do I need a separate sign and zero ext instructions along with the
> above instructions?
When char is 32 bits, you don't really need sign and zero extension of
unknown values. So the question is whether you need them for immediate
constants. As I mention above, it will probably pay off to have
instructions which support sign extending immediate constants. Whether
that is done via operands to add, etc., or via a load-immediate
instruction, really depends on other characteristics of your
architecture and of the programs you expect to write.
Hope this helps.
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Need help in deciding the instruction set for a new target.
2010-08-23 18:25 Need help in deciding the instruction set for a new target Mohamed Shafi
2010-08-23 19:00 ` Ian Lance Taylor
@ 2010-08-23 20:24 ` Bernd Schmidt
2010-08-23 22:20 ` Richard Henderson
2 siblings, 0 replies; 4+ messages in thread
From: Bernd Schmidt @ 2010-08-23 20:24 UTC (permalink / raw)
To: Mohamed Shafi; +Cc: GCC
On 08/23/2010 08:05 PM, Mohamed Shafi wrote:
> sub.s32 srcdstGP, #imm16 // signed 16-bit register to immediate subtract
> sub.u32 srcdstGP, #imm16 // unsigned 16-bit register to immediate subtract
If you're using a bit to decide between these two, a better encoding
would be to just support a single instruction with a signed 17bit immediate.
Bernd
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Need help in deciding the instruction set for a new target.
2010-08-23 18:25 Need help in deciding the instruction set for a new target Mohamed Shafi
2010-08-23 19:00 ` Ian Lance Taylor
2010-08-23 20:24 ` Bernd Schmidt
@ 2010-08-23 22:20 ` Richard Henderson
2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2010-08-23 22:20 UTC (permalink / raw)
To: Mohamed Shafi; +Cc: GCC
On 08/23/2010 11:05 AM, Mohamed Shafi wrote:
> sub.s32 srcdstGP, #imm16 // signed 16-bit register to immediate subtract
> sub.u32 srcdstGP, #imm16 // unsigned 16-bit register to immediate subtract
Having both of these is probably not useful. Bernd pointed
out that a 17-bit constant would be more useful. I'll point
out that if you have a signed constant then SUB and ADD tend
to be essentially identical as well.
Consider implementing "reverse subtract"
RSUB reg, #imm
as
reg = imm - reg
instead.
r~
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-23 20:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-23 18:25 Need help in deciding the instruction set for a new target Mohamed Shafi
2010-08-23 19:00 ` Ian Lance Taylor
2010-08-23 20:24 ` Bernd Schmidt
2010-08-23 22:20 ` Richard Henderson
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).