PreviousUpNext

15.3.129  src/lib/compiler/back/low/main/nextcode/platform-register-info.api

## platform-register-info.api
#
# Even sections of the compiler like the Nextcode ("continuation passing style")
# passes, which are nominally architecture-agnostic, still need to know some
# platform-specific things about the number of registers and any special
# register-use conventions.
#
# Here we define the API used to supply that information.
#
# There is a lot of redundancy between this API and Registerkinds,                      # Registerkinds         is from   src/lib/compiler/back/low/code/registerkinds.api
# presumably because Platform_Register_Info derives from the original
# SML/NJ codebase dating back to 1990, whereas Registerkinds derives
# from the separate and later MLRISC project (== compiler backend lowhalf),
# which has never been fully integrated.                XXX SUCKO FIXME

# Compiled by:
#     src/lib/compiler/core.sublib





stipulate
    package rkj =  registerkinds_junk;                                                  # registerkinds_junk    is from   src/lib/compiler/back/low/code/registerkinds-junk.pkg
    package rwv =  rw_vector;                                                           # rw_vector             is from   src/lib/std/src/rw-vector.pkg
herein

    # This api is implemented in:
    #
    #    src/lib/compiler/back/low/main/intel32/backend-lowhalf-intel32-g.pkg
    #    src/lib/compiler/back/low/main/pwrpc32/backend-lowhalf-pwrpc32.pkg
    #    src/lib/compiler/back/low/main/sparc32/backend-lowhalf-sparc32.pkg
    #
    # This api is used in:
    #
    #    src/lib/compiler/back/low/main/main/translate-nextcode-to-treecode-g.pkg
    #    src/lib/compiler/back/low/main/main/backend-lowhalf-g.pkg
    #    src/lib/compiler/back/low/main/nextcode/check-heapcleaner-calls-g.pkg
    #    src/lib/compiler/back/low/main/nextcode/nextcode-ccalls-g.pkg
    #    src/lib/compiler/back/low/main/nextcode/convert-nextcode-fun-args-to-treecode-g.pkg
    #    src/lib/compiler/back/low/main/nextcode/emit-treecode-heapcleaner-calls-g.pkg
    #
    api Platform_Register_Info {
        #
        package tcf: Treecode_Form;                                                     # Treecode_Form         is from   src/lib/compiler/back/low/treecode/treecode-form.api
        package rgk: Registerkinds;                                                     # Registerkinds         is from   src/lib/compiler/back/low/code/registerkinds.api

        virtual_framepointer:           rkj::Codetemp_Info;
        vfptr:                          tcf::Int_Expression;                            # "vfptr" == "virtual frame pointer".  See http://www.smlnj.org//compiler-notes/omit-vfp.ps

        heap_allocation_pointer:        tcf::Int_Expression;                            # (edi on Intel32)      We allot ram just by advancing this pointer.  Must be a register, - tcf::CODETEMP_INFO(r) 

        # The boolean argument in each case indicates the use of the virtual
        # frame pointer:  Use virtual fp if TRUE and physical fp if FALSE.
        #
        # In principle a lot more of these should be functions over the boolean,
        # however, the intel32 is the only one that implements registers in memory,
        # so we will limit this to the set that it needs. 
        #
        framepointer:                           Bool -> tcf::Int_Expression;                    # Holds current C stackframe, which holds pointers to runtime resources like the heapcleaner ("garbage collector"), which is written in C.
        heap_allocation_limit:          Bool -> tcf::Int_Expression;                    # heap_allocation_pointer may not advance beyond this point.
        #
        stdlink:                        Bool -> tcf::Int_Expression;                    # (vreg 0 on Intel32)   These four registers are used transitionally during invocation of the heapcleaner, but are
        stdclos:                        Bool -> tcf::Int_Expression;                    # (vreg 1 on Intel32)   otherwise free for general use.  I'm guessing that they are vestiges of the original compiler
        stdarg:                         Bool -> tcf::Int_Expression;                    # (ebp on Intel32)      fun-invocation protocol, since superceded by more sophisticated mechanisms.
        stdfate:                        Bool -> tcf::Int_Expression;                    # (esi on Intel32)
        #
        exception_handler_register:     Bool -> tcf::Int_Expression;                    # Presumably the current exception handler.
        current_thread_ptr:             Bool -> tcf::Int_Expression;                    # Special support for CML-style app-level multithreading.
        base_pointer:                   Bool -> tcf::Int_Expression;                    # "The base_pointer contains the start address of the entire compilation unit."

        heap_changelog_pointer:         Bool -> tcf::Int_Expression;                    # Every (pointer) update to the heap gets logged to this heap-allocated cons-cell list.
                                                                                        # (The heapcleaner scans this list to detect intergenerational pointers.)

        heapcleaner_link:               Bool -> tcf::Int_Expression; 

        heap_is_exhausted__test:        Null_Or( tcf::Flag_Expression );                # Optional platform-specific test for   (heap_allocation_pointer > heap_allocation_limit)
                                                                                        # Used in   src/lib/compiler/back/low/main/nextcode/emit-treecode-heapcleaner-calls-g.pkg
                                                                                        # and       src/lib/compiler/back/low/main/main/translate-nextcode-to-treecode-g.pkg
                                                                                        # We currently have platform-specific tests on Pwrpc32 and Sparc32 but not Intel32.
        calleesave:                     rwv::Rw_Vector( tcf::Int_Expression );
        use_signed_heaplimit_check:     Bool;
        address_width:                  tcf::Int_Bitsize;                               # The natural address arithmetic width of the architecture. "For most architectures this is 32."

        miscregs:                       List(  tcf::Int_Expression );
        floatregs:                      List(  tcf::Float_Expression );
        savedfpregs:                    List(  tcf::Float_Expression );

        available_int_registers:        List(  tcf::Register );                         # On x86 this is:    [ebp, esi, ebx, ecx, edx, eax] -- everything but esp and edi (==heap_allocation_pointer).
        global_int_registers:           List(  tcf::Register );                         # On x86 this is:    [edi, esp, vfptr]  vfptr -must- be on this list -- see http://www.smlnj.org//compiler-notes/omit-vfp.ps

        global_float_registers:         List(  tcf::Register );                         # On x86 this is float registers 0-7.
        available_float_registers:      List(  tcf::Register );                         # On x86 this is float registers 8-32.

        ccall_caller_save_r:            List(  tcf::Register );
        ccall_caller_save_f:            List(  tcf::Register );
    };
end;

## COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext