#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2006
    Posts
    271
    Rep Power
    15

    Internal design of a FORTRAN compiler


    I stumbled across this doing some random Googling. Interesting stuff if you're into compiler design. Design constraints for the old 8088 are much different than for newer chips

    IBM doc on the internal design of early RM Fortran compiler
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2006
    Posts
    271
    Rep Power
    15
    More on this particular FORTRAN compiler...

    I've been looking at the OBJ's it emits and another trick they used has become apparent.

    It emits small blobs of code (LEDATA records) and it defers resolution of certain things (ex. forward jump offsets and stack depth allocation for autovars) until after an LEDATA record has been written out.

    Once it knows the final values of those things, it emits other small 1 and 2 byte long LEDATA's that essentially "backpatch" and override some of the prior contents of the earlier LEDATA records.

    Fortran allows for implied declaration of variables, so a Fortran compiler won't know up front the size of local vars until its hit the last line in a function. So they emit the code for the body of the function before knowing what the final amount they needed to sub from SP was and backpatch it later on.

    This backpatching scheme clearly helped the compiler work better on low memory machines since it didn't need to keep all the code it was emitting around, just info about back patches.

    Essentially, it pushes some of what would normally be considered code generation off onto the linker for resolution.

    In the versions of this compiler that came out a few of years later, most (not all though) of this backpatch dance seems to have been eliminated...and its memory requirements on the packaging went up dramatically as well
    Last edited by Purple Avenger; February 23rd, 2007 at 07:23 PM.

IMN logo majestic logo threadwatch logo seochat tools logo