[fpc-devel] Re. z370 Cross Compilation, Pass 2 of ....

Bernd Oppolzer bernd.oppolzer at t-online.de
Sun Sep 1 19:53:37 CEST 2013


Am 01.09.2013 18:01, schrieb Florian Klämpfl:
> Am 01.09.2013 16:55, schrieb Bernd Oppolzer:
>> No need to answer to that ... I understood in the meantime that FPC does
>> NOT rely on
>> PUSH and POP instructions. Instead the linear assembler representation
>> is already fully
>> CPU specific.
>>
>> (which makes porting a bigger effort)
> Proof?
>
It's my opinion. If the compiler translates the source language
to machine code for an abstract target machine that is not too complicated
(but well suited to the needs of the source language), you only have to 
translate
the operations of this abstract machine one by one to your real target 
machine,
which seems to me to be an easier task.

Optimization can occur already in the stages, which are target-independent,
but later, too.

That's in my understanding Niklaus Wirth's P-Code approach. Furthermore,
there is a file interface between the two stages, so that the first part 
of the
compiler is very easy to port to new platforms. Only the second part has to
be modified (in theory). My port of the McGill compiler (which is a 
descendent
of Stanford, which is a descendent of the P4 compiler) works this way. 
In fact,
I only ported it from one IBM opsys to another, so there was no problem 
at all.
More interesting is, if I will succeed in porting it to an ASCII and 
Intel based
platform (Windows, Linux, OS/2) and what sort of problems I will see when
doing that.

When I did some extensions to the compiler (new statement types like
continue, break, return, which didn't exist before), I only had to 
change the
first part of the compiler; the second one was not affected, because I 
didn't
need new P-Code instructions.

But maybe the same idea is present in FPC, too. I have to take a closer 
look
at the tree representation of the FPC units after the first compile stage -
when my time allows me to do so. I don't have a real feeling at the moment,
if there is more work in the stage before that tree representation or 
after that -
that is, if the tree representation looks more like the source code or 
already
more like the linear assembly representation.

Kind regards

Bernd





More information about the fpc-devel mailing list