This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: PDP-10 backend for gcc
[gcc mailing list brought back in the discussion, because it's (hopefully)
of general interest]
Alan Lehotsky <lehotsky@tiac.net> writes:
> >Ok. How about this idea: Pointers are represented internally as
> >normal integers, using integer arithmetic etc, and only converted
> >to PDP-10 pointer format just before emitting assembly output?
>
> Won't work - you can't tag integers and the back-end won't
> be able to figure out when an integer is part of a pointer
> and when it's just adding 1 to a variable.
>
> The RTL phase discards almost ALL language type information and
> only operates on things in 'enum machine_mode', which is
> basically just an enumeration of basic data types of fundemental
> sizes (viz. QImode, HImode, SImode...)
Oh. But the back end MUST know whether it's operating on pointers or
integers. Byte pointer subtraction on a PDP-10 is much different from
integer subtraction. Basically, PDP-10 byte pointers are not are not
integers, at least not with respect to how arithmetic are performed on
them.
So, does adding some kind of proper Pmode (not just a #define as it is
now, according to gcc documentation) for byte pointers sound appropriate?
Word pointers are like integers, so PSImode could be used for them.
> >In the PDP-10 case, the 30-bit word address space would be represented
> >as a 32-bit char address space, because there are four 9-bit chars in
> >a word. Pointers could be converted by something like
>
> I guess I don't understand quite what you're proposing.
I was proposing that all pointer values are represented internally as
32-bit linear byte addresses, just as they are now. Only when a
pointer is written to output is it converted to a PDP-10 byte pointer
or word address.
E.i.
internal gcc pointer PDP-10 pointer
type value (octal representation, ",," separates half-words)
(char *) 0 700000,,000000
(char *) 1 710000,,000000
(char *) 2 720000,,000000
(char *) 3 730000,,000000 these are all global
(char *) 4 700000,,000001 byte pointers for 9-bit
(char *) 5 710000,,000001 bytes, i.e. chars
(char *) 6 720000,,000001
(char *) 7 730000,,000001
(char *) 8 700000,,000002
(short *) 0 750000,,000000
(short *) 2 760000,,000000 these are all global
(short *) 4 750000,,000001 byte pointers for 18-bit
(short *) 6 760000,,000001 bytes, i.e. shorts
(short *) 8 750000,,000002
(int *) 0 000000,,000000
(int *) 4 000000,,000001
(int *) 8 000000,,000002
(long long *)0 000000,,000000
(long long *)8 000000,,000002
(Modulo any compilcations for the NULL pointer.)