[fpc-devel] Re: Porting FPC to IBM zArch

Sven Barth pascaldragon at googlemail.com
Mon Aug 19 10:37:43 CEST 2013


Am 19.08.2013 06:00, schrieb Paul Robinson:
> I've been busy, I have other things I had to attend to, then I 
> realized I couldn't figure out what was going on without a decent 
> cross reference program, but nothing that's out there supports the 
> UNIT construct, nor do they know how to skip over {$DEFINE} {$IF} 
> {$ELSE}, and so I stopped to write one and I was busy with the work on 
> that. I'm having trouble there, so I set it aside.
I don't get what you're trying to say here.
> Anyway, I came back and realized if I can get one of the Big Endian 
> ports working I can just figure out what files it uses and then edit 
> those to change the generated assembly language and/or the object 
> files if it makes object files the way the Pascal 8000 compiler for 
> the 370 from the Australian Atomic Energy Commission did back in the 
> late 1970s and early 1980s did.
Analyzing what a big-endian compiler generates won't help you there. You 
need to look into the compiler's code and learn how it does generate 
code for a specific platform. That has nothing to do with big endian or 
little endian.

In FPC there is the frontend which generates a sort of abstract syntax 
tree on which then the platform specific backend generates code. Thereby 
the backend provides platform specific nodes for that abstract syntax 
tree of which then the "generate_code" method is invoked. Platform 
independant stuff is normally located in the ncg*.pas units and the 
platform specific stuff is in the nXY*.pas unit of the corresponding CPU 
directory where XY is a short form of the CPU, e.g. n68kadd.pas for the 
m68k add/compare node. Best is you look how other CPUs are implemented 
(prefereably the simpler ones like MIPS or m68k) and copy that more or 
less for the new platform.

Adding a new platform to FPC is not cheesecake and you should know how 
the compiler's backend work. Just looking at the output of a target 
won't help you!
>
> There are two things I'd like to find out to determine how it might be 
> possible to get Free Pascal ported to the s370 series.
>
> First, I want to add some of the compiler flags I mention in the 
> description of my attempts on the WIKI to add the s370 and/or zSystem 
> architecture, how do I get those flags - they do not break the build - 
> added as hooks to the compiler sources so that eventually a {$DEFINE 
> S370} statement can be added to get the compiler to build itself for 
> the 370 (and possibly other defines depending on the machine and OS 
> target}? There will eventually need a new directory for the files that 
> the 370 and whatever OSs it uses supports, but, again, that's months 
> away. I have to start over, and I have to start somewhere.
First step is to get a cross compiler to s370/zSystem working so that 
simple programs can be compiled which you can use to implement the RTL. 
Only when enough of the RTL is implemented and the code generator works 
good enough then you can try to cross compile the compiler, but not earlier.
>
> So how would I get the constants and values added to include the s370 
> as a target for FPC? Would I submit them as a bug fix request as a 
> patch through bugs.freepascal.org on Mantis or something else? I want 
> to reserve a definition number for that processor, at least for now so 
> it has a fixed identifier so eventually it can have its own PPU files 
> and everything else in the toolchain.
Search the compiler's source for e.g. m68k to see how other platforms 
are implemented.
>
> Second, how do I create a cross-compiler that runs on Windows, for any 
> of the big-endian processors, so that I can see what it has to 
> generate code for the target machine? Given that, I can change the 
> code to either change the generated object file - if it does direct 
> object files - or the assembly language so it generates S370 assembly.
No. You should learn how the compiler generates code and then implement 
a new code generator backend for s370, maybe based on a copy of another 
platform. Playing around with the output won't help you.
>
> I can then run the compiler through itself to create a cross-compiler 
> assembly for the 370. Then I can recompile the required modules, then 
> take the assemblies, assemble them with a 370 assembler, producing an 
> actual object module, then run the program against itself and the 
> compiler will at least compile itself. Having done that, I can then 
> create any necessary changes to implement anything needed to provide 
> the equivalent functionality and rebuild the toolchain so it is native 
> to the s370 and units to provide localized services can be created as 
> needed.
First step consists of cross compiled hello world programs to implement 
and test the RTL. The compiler is much too complicated to get it running 
at first.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20130819/e74953c6/attachment.html>


More information about the fpc-devel mailing list