PreviousUpNext

15.3.114  src/lib/compiler/back/low/jmp/jump-size-ranges.api

## jump-size-ranges.api --- specification of target information to resolve jumps. 
#
# Relative-branch instructions are often available in varieties
# with (say) one-byte, two-byte and four-byte offsets from the
# program counter.  
#
# This means that the size of the instruction depends on the target address,
# which in turn can depend on the lengths of intervening instructions.
#
# Such instructions are called "span-dependent".  
#
# Picking the right length for all span-dependent instructions in a module
# is typically an interative process of initially assuming they must all
# be maximum length, then shortening all possible instructions, which
# moves addresses around, possibly creating new opportunities to shorten
# more instructions.
#
# In the worst case this process may iterate as many times as there are
# span-dependent instructions; in practice it typically converges after
# one or two cycles.

# Compiled by:
#     src/lib/compiler/back/low/lib/lowhalf.lib

# This api is implemented in:
#
#     src/lib/compiler/back/low/intel32/jmp/jump-size-ranges-intel32-g.pkg
#     src/lib/compiler/back/low/pwrpc32/jmp/jump-size-ranges-pwrpc32-g.pkg
#     src/lib/compiler/back/low/sparc32/jmp/jump-size-ranges-sparc32-g.pkg
#
# Our core entrypoint
#
#     instantiate_span_dependent_op
#
# is invoked in:
#
#     src/lib/compiler/back/low/jmp/squash-jumps-and-write-code-to-code-segment-buffer-intel32-g.pkg
#     src/lib/compiler/back/low/jmp/squash-jumps-and-write-code-to-code-segment-buffer-sparc32-g.pkg
#     src/lib/compiler/back/low/jmp/squash-jumps-and-write-code-to-code-segment-buffer-pwrpc32-g.pkg


stipulate
    package lbl =  codelabel;                                                   # codelabel             is from   src/lib/compiler/back/low/code/codelabel.pkg
herein

    api Jump_Size_Ranges {
        #
        package mcf:  Machcode_Form;                                            # Machcode_Form         is from   src/lib/compiler/back/low/code/machcode-form.api
        package rgk:  Registerkinds;                                            # Registerkinds         is from   src/lib/compiler/back/low/code/registerkinds.api

        sharing mcf::rgk == rgk;                                                        # "rgk" == "registerkinds".

        branch_delayed_arch:  Bool;

        is_sdi:       mcf::Machine_Op -> Bool;
        min_size_of:  mcf::Machine_Op -> Int;
        max_size_of:  mcf::Machine_Op -> Int;
            #
            # min_size and max_size are not restricted to SDIs but 
            # instructions that may require NOPs after them, etc. 


        sdi_size:  (mcf::Machine_Op, (lbl::Codelabel -> Int), Int) -> Int;
            #
            # sdi_size (instruction, regmaps, labMap, loc) -- return the size of
            # instruction at location loc, assuming an assignment of labels
            # given by labMap.


        instantiate_span_dependent_op
            :
            {  sdi:             mcf::Machine_Op,
               size_in_bytes:   Int,
               at:              Int
            }
            ->
            List( mcf::Machine_Op );
                #
                # expand (instruction, size, loc) - expands sdi instruction instruction,
                # into size bytes at postion loc.
    };
end;



## COPYRIGHT (c) 1996 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