PreviousUpNext

15.3.113  src/lib/compiler/back/low/jmp/squash-jumps-and-write-code-to-code-segment-buffer.api

# squash-jumps-and-write-code-to-code-segment-buffer.api
#
# API for the packages which select shortest possible representation
# for each branch and jump instruction and then generate the final
# absolute machine-code bytevector for the file being compiled.
#
# (Don't ask *me* why those are both done by the same package!)

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

###               "A computer lets you make more mistakes
###                faster than any other invention, with the
###                possible exceptions of handguns and Tequila."
###
###                                     -- Mitch Ratcliffe



# This api is implemented in:
#
# for intel32:    src/lib/compiler/back/low/jmp/squash-jumps-and-write-code-to-code-segment-buffer-intel32-g.pkg
# for pwrpc32:    src/lib/compiler/back/low/jmp/squash-jumps-and-write-code-to-code-segment-buffer-pwrpc32-g.pkg
# for sparc32:    src/lib/compiler/back/low/jmp/squash-jumps-and-write-code-to-code-segment-buffer-sparc32-g.pkg
#
api Squash_Jumps_And_Write_Code_To_Code_Segment_Buffer {
    #
    package mcg:  Machcode_Controlflow_Graph;                   # Machcode_Controlflow_Graph    is from   src/lib/compiler/back/low/mcg/machcode-controlflow-graph.api


    clear__textseg_list__and__dataseg_list:  Void -> Void;                              # Sheeeit, man.
        #
        # This call clears the internal global variables
        #     dataseg_list
        #     codeseg_list



    extract_all_code_and_data_from_machcode_controlflow_graph
        :
        (mcg::Machcode_Controlflow_Graph,  List(mcg::Node))     # This basic-block list gives the final order in which all basic blocks should be concatenated to produce final machine-code bytevector.
        ->
        Void;
        #
        # This call saves everything into the internal global variables
        #     dataseg_list
        #     codeseg_list


    squash_jumps_and_write_all_machine_code_and_data_bytes_into_code_segment_buffer:    Void -> Void;
        #
        # This takes the saved state in
        #     dataseg_list
        #     codeseg_list
        # and writes it all into the code_segment_buffer.
        #
        # Jump-squashing ("span-dependent-instruction size minimization")
        # is done along the way.
        # 
        # This call is is exported per
        # the Backend_Lowhalf_Core api in                                               # Backend_Lowhalf_Core                  is from   src/lib/compiler/back/low/main/main/backend-lowhalf-core.api
        # the Backend_Lowhalf api                                                       # Backend_Lowhalf                       is from   src/lib/compiler/back/low/main/main/backend-lowhalf.api
        # whence it gets invoked by the appropriate one of
        #
        #     backend_intel32_g::harvest_code_segment                                   # backend_intel32_g                     is from   src/lib/compiler/back/low/main/intel32/backend-intel32-g.pkg
        #     backend_pwrpc32::harvest_code_segment                                     # backend_pwrpc32                       is from   src/lib/compiler/back/low/main/pwrpc32/backend-pwrpc32.pkg
        #     backend_sparc32::harvest_code_segment                                     # backend_sparc32                       is from   src/lib/compiler/back/low/main/sparc32/backend-sparc32.pkg             
        #
        # which use
        #
        #     code_segment_buffer::harvest_code_segment                                 # code_segment_buffer                   is from   src/lib/compiler/execution/code-segments/code-segment-buffer.pkg
        #
        # to actually obtain the executable bytestring.
        #
        # Just to round things off, the above three functions
        # are basically the last thing called by
        #
        #     backend_tophalf_g::translate_anormcode_to_execode                         # backend_tophalf_g                     is from   src/lib/compiler/back/top/main/backend-tophalf-g.pkg
        #
        # which is basically the last thing called by
        #
        #     translate_raw_syntax_to_execode_g::translate_raw_syntax_to_execode        # translate_raw_syntax_to_execode_g     is from   src/lib/compiler/toplevel/main/translate-raw-syntax-to-execode-g.pkg
        #
        # which is the central call in both of
        #
        #     fun compile_one_sourcefile ()                                             # compile_in_dependency_order_g         is from   src/app/makelib/compile/compile-in-dependency-order-g.pkg
        #     fun prompt_read_evaluate_and_print_one_toplevel_mythryl_expression ()     # read_eval_print_loop_g                is from   src/lib/compiler/toplevel/interact/read-eval-print-loop-g.pkg
        #
        # which make the world go 'round. :-)
};


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext