Related articles |
---|
Guidelines for instruction set design? cyril.cressent@gmail.com (2009-04-30) |
Re: Guidelines for instruction set design? rose@acm.org (Ken Rose) (2009-05-01) |
Re: Guidelines for instruction set design? kamalpr@gmail.com (2009-05-03) |
Re: Guidelines for instruction set design? gneuner2@comcast.net (George Neuner) (2009-05-03) |
Re: Guidelines for instruction set design? hsheboul@gmail.com (Hasan Alsheboul) (2009-05-04) |
Re: Guidelines for instruction set design? cyril.cressent@gmail.com (2009-05-04) |
Re: Guidelines for instruction set design? torbenm@pc-003.diku.dk (2009-05-04) |
Re: Guidelines for instruction set design? gah@ugcs.caltech.edu (glen herrmannsfeldt) (2009-05-05) |
Re: Guidelines for instruction set design? bartc@freeuk.com (BartC) (2009-05-05) |
Re: Guidelines for instruction set design? gneuner2@comcast.net (George Neuner) (2009-05-05) |
Re: Guidelines for instruction set design? walter@bytecraft.com (Walter Banks) (2009-05-06) |
Re: Guidelines for instruction set design? gmt@cs.arizona.edu (2009-05-06) |
Re: Guidelines for instruction set design? dot@dotat.at (Tony Finch) (2009-05-07) |
[9 later articles] |
From: | torbenm@pc-003.diku.dk (Torben =?iso-8859-1?Q?=C6gidius?= Mogensen) |
Newsgroups: | comp.compilers |
Date: | Mon, 04 May 2009 12:48:54 +0200 |
Organization: | Department of Computer Science, University of Copenhagen |
References: | 09-05-008 |
Keywords: | architecture |
Posted-Date: | 05 May 2009 10:46:53 EDT |
cyril.cressent@gmail.com writes:
> I was wondering if there are some general guidelines one should
> observe when designing an instruction set so that a C compiler can
> easily be ported to that CPU.
If your CPU supports the standard C datatypes (signed and unsigned
chars, shorts, integers and longs, single- and double precision reals
and pointers to byte addresses), you should not have that great
difficulties. You can make it simplest for yourself by choosing char
= 8 bits, short = int = long = pointer = float = 32 bits and double =
64 bits.
Having load/store instructions for all the sizes of char, integer,
long, pointer, float and double is also nice, as having to do a byte
store as a full-word load, a masking operation and a full-word store
is a pain. Doing a double-word load/store as two separate word
load/stores or a half-word load/store as two byte load/stores is less
of a problem, so you can make do with just byte and (32-bit) word
load/stores.
Shift left and right by arbitrary values is also useful, but if you
have single-bit shifts, you can do the rest in a loop. Rotates are
less useful, as C doesn't have rotates (though some compilers will
recognize certain combinations of shifts and and/ors as a rotate and
compile to this).
You should also be able to compare signed and unsigned numbers for <.
And there should be some support for procedure calls, i.e., a jump
that stores a return address in a register or memory and a jump to an
address stored in a register or in memory (so you can return).
Apart form the above, I can't think of anything essential.
You can implement floats and doubles in libraries using integer
instructions, as long as you have shifts and masks (and/or), but this
will be slower than having hardware for it.
Torben
Return to the
comp.compilers page.
Search the
comp.compilers archives again.