PreviousUpNext

15.4.255  src/lib/compiler/back/low/intel32/code/registerkinds-intel32.codemade.pkg

## registerkinds-intel32.codemade.pkg
#
# This file generated at   2015-12-06:08:43:06   by
#
#     src/lib/compiler/back/low/tools/arch/make-sourcecode-for-registerkinds-xxx-package.pkg
#
# from the architecture description file
#
#     src/lib/compiler/back/low/intel32/intel32.architecture-description
#
# Edits to this file will be LOST on next system rebuild.

# Compiled by:
#     src/lib/compiler/back/low/intel32/backend-intel32.lib


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

    api Registerkinds_Intel32 {
        #
        include api Registerkinds;                                              # Registerkinds is from   src/lib/compiler/back/low/code/registerkinds.api
        
        # Architecture-specific register kinds:
        #
        eflags_kind: rkj::Registerkind;

        fflags_kind: rkj::Registerkind;

        registerset_kind: rkj::Registerkind;

        
        # Functions to generate asmcode string names for registers.
        # The first five are for the standard cross-platform registersets,
        # the remainder are architecture-specific:
        #
        int_register_to_string: rkj::Interkind_Register_Id -> String;

        float_register_to_string: rkj::Interkind_Register_Id -> String;

        flags_register_to_string: rkj::Interkind_Register_Id -> String;

        ram_byte_to_string: rkj::Interkind_Register_Id -> String;

        control_dependency_to_string: rkj::Interkind_Register_Id -> String;

        eflags_to_string: rkj::Interkind_Register_Id -> String;

        fflags_to_string: rkj::Interkind_Register_Id -> String;

        registerset_to_string: rkj::Interkind_Register_Id -> String;

        #
        sized_int_register_to_string: (rkj::Interkind_Register_Id, rkj::Register_Size_In_Bits) -> String;

        sized_float_register_to_string: (rkj::Interkind_Register_Id, rkj::Register_Size_In_Bits) -> String;

        sized_flags_register_to_string: (rkj::Interkind_Register_Id, rkj::Register_Size_In_Bits) -> String;

        sized_ram_byte_to_string: (rkj::Interkind_Register_Id, rkj::Register_Size_In_Bits) -> String;

        sized_control_dependency_to_string: (rkj::Interkind_Register_Id, rkj::Register_Size_In_Bits) -> String;

        sized_eflags_to_string: (rkj::Interkind_Register_Id, rkj::Register_Size_In_Bits) -> String;

        sized_fflags_to_string: (rkj::Interkind_Register_Id, rkj::Register_Size_In_Bits) -> String;

        sized_registerset_to_string: (rkj::Interkind_Register_Id, rkj::Register_Size_In_Bits) -> String;

        
        # Architecture-specific special registers:
        #
        eax: rkj::Codetemp_Info;

        ecx: rkj::Codetemp_Info;

        edx: rkj::Codetemp_Info;

        ebx: rkj::Codetemp_Info;

        esp: rkj::Codetemp_Info;

        ebp: rkj::Codetemp_Info;

        esi: rkj::Codetemp_Info;

        edi: rkj::Codetemp_Info;

        st: Int -> rkj::Codetemp_Info;

        st0: rkj::Codetemp_Info;

        eflags: rkj::Codetemp_Info;

    };
end;

stipulate
    package rkj =  registerkinds_junk;                                  # registerkinds_junk    is from   src/lib/compiler/back/low/code/registerkinds-junk.pkg
    package err =  lowhalf_error_message;                               # lowhalf_error_message is from   src/lib/compiler/back/low/control/lowhalf-error-message.pkg
herein

    package registerkinds_intel32: Registerkinds_Intel32 {
        #
                                                                        # Registerkinds_Intel32 is from   src/lib/compiler/back/low/intel32/code/registerkinds-intel32.codemade.pkg
        #
        exception NO_SUCH_PHYSICAL_REGISTER_INTEL32;
        
        fun error msg =  err::error("NO_SUCH_PHYSICAL_REGISTER_INTEL32", msg);
        
        include package   registerkinds_junk;                                   # registerkinds_junk            is from   src/lib/compiler/back/low/code/registerkinds-junk.pkg
        

        fun sized_int_register_to_string (register_number, register_size_in_bits) 
            =
            \\ (0, 8) => "%al";
               (0, 16) => "%ax";
               (0, 32) => "%eax";
               (1, 8) => "%cl";
               (1, 16) => "%cx";
               (1, 32) => "%ecx";
               (2, 8) => "%dl";
               (2, 16) => "%dx";
               (2, 32) => "%edx";
               (3, 8) => "%bl";
               (3, 16) => "%bx";
               (3, 32) => "%ebx";
               (4, 16) => "%sp";
               (4, 32) => "%esp";
               (5, 16) => "%bp";
               (5, 32) => "%ebp";
               (6, 16) => "%si";
               (6, 32) => "%esi";
               (7, 16) => "%di";
               (7, 32) => "%edi";
               (r, _) => "%" + (int::to_string r);
            end (register_number, register_size_in_bits)

        also
        fun sized_float_register_to_string (register_number, register_size_in_bits) 
            =
            (\\ (f, _) = if (f < 8)   (("%st(" + (int::to_string f)) + ")");
                         else   ("%f" + (int::to_string f));
                         fi) (register_number, register_size_in_bits)

        also
        fun sized_flags_register_to_string (register_number, register_size_in_bits) 
            =
            (\\ _ = "cc") (register_number, register_size_in_bits)

        also
        fun sized_ram_byte_to_string (register_number, register_size_in_bits) 
            =
            (\\ _ = "mem") (register_number, register_size_in_bits)

        also
        fun sized_control_dependency_to_string (register_number, register_size_in_bits) 
            =
            (\\ _ = "ctrl") (register_number, register_size_in_bits)

        also
        fun sized_eflags_to_string (register_number, register_size_in_bits) 
            =
            (\\ _ = "$eflags") (register_number, register_size_in_bits)

        also
        fun sized_fflags_to_string (register_number, register_size_in_bits) 
            =
            (\\ _ = "$fflags") (register_number, register_size_in_bits)

        also
        fun sized_registerset_to_string (register_number, register_size_in_bits) 
            =
            (\\ _ = "REGISTERSET") (register_number, register_size_in_bits);

        fun int_register_to_string register_number 
            =
            sized_int_register_to_string (register_number, 32);

        fun float_register_to_string register_number 
            =
            sized_float_register_to_string (register_number, 64);

        fun flags_register_to_string register_number 
            =
            sized_flags_register_to_string (register_number, 32);

        fun ram_byte_to_string register_number 
            =
            sized_ram_byte_to_string (register_number, 8);

        fun control_dependency_to_string register_number 
            =
            sized_control_dependency_to_string (register_number, 0);

        fun eflags_to_string register_number 
            =
            sized_eflags_to_string (register_number, 32);

        fun fflags_to_string register_number 
            =
            sized_fflags_to_string (register_number, 32);

        fun registerset_to_string register_number 
            =
            sized_registerset_to_string (register_number, 0);
        
        eflags_kind = rkj::make_registerkind { name => "EFLAGS", 
                                               nickname => "eflags"
                                             }
;
        fflags_kind = rkj::make_registerkind { name => "FFLAGS", 
                                               nickname => "fflags"
                                             }
;
        registerset_kind = rkj::make_registerkind { name => "REGISTERSET", 
                                                    nickname => "registerset"
                                                  }
;
        
        package my_registerkinds = registerkinds_g
            (                                                   # registerkinds_g       is from   src/lib/compiler/back/low/code/registerkinds-g.pkg
             #
             exception NO_SUCH_PHYSICAL_REGISTER = NO_SUCH_PHYSICAL_REGISTER_INTEL32;
             
             codetemp_id_if_above = 256;
             
             # The 'hardware_registers' values below are dummies -- the actual
             # vectors get built and installed by the below call to
             #
             #     registerkinds_g ()
             #
             
             info_for_kind_int_register = rkj::REGISTERKIND_INFO { min_register_id => 0, 
                                                                   max_register_id => 31, 
                                                                   kind => rkj::INT_REGISTER, 
                                                                   always_zero_register => NULL, 
                                                                   to_string => int_register_to_string, 
                                                                   sized_to_string => sized_int_register_to_string, 
                                                                   codetemps_made_count => REF (0), 
                                                                   global_codetemps_created_so_far => REF (0), 
                                                                   hardware_registers => REF rkj::zero_length_rw_vector
                                                                 }
;
             info_for_kind_float_register = rkj::REGISTERKIND_INFO { min_register_id => 32, 
                                                                     max_register_id => 63, 
                                                                     kind => rkj::FLOAT_REGISTER, 
                                                                     always_zero_register => NULL, 
                                                                     to_string => float_register_to_string, 
                                                                     sized_to_string => sized_float_register_to_string, 
                                                                     codetemps_made_count => REF (0), 
                                                                     global_codetemps_created_so_far => REF (0), 
                                                                     hardware_registers => REF rkj::zero_length_rw_vector
                                                                   }
;
             info_for_kind_ram_byte = rkj::REGISTERKIND_INFO { min_register_id => 64, 
                                                               max_register_id => 63, 
                                                               kind => rkj::RAM_BYTE, 
                                                               always_zero_register => NULL, 
                                                               to_string => ram_byte_to_string, 
                                                               sized_to_string => sized_ram_byte_to_string, 
                                                               codetemps_made_count => REF (0), 
                                                               global_codetemps_created_so_far => REF (0), 
                                                               hardware_registers => REF rkj::zero_length_rw_vector
                                                             }
;
             info_for_kind_control_dependency = rkj::REGISTERKIND_INFO { min_register_id => 64, 
                                                                         max_register_id => 63, 
                                                                         kind => rkj::CONTROL_DEPENDENCY, 
                                                                         always_zero_register => NULL, 
                                                                         to_string => control_dependency_to_string, 
                                                                         sized_to_string => sized_control_dependency_to_string, 
                                                                         codetemps_made_count => REF (0), 
                                                                         global_codetemps_created_so_far => REF (0), 
                                                                         hardware_registers => REF rkj::zero_length_rw_vector
                                                                       }
;
             info_for_kind_eflags = rkj::REGISTERKIND_INFO { min_register_id => 64, 
                                                             max_register_id => 64, 
                                                             kind => eflags_kind, 
                                                             always_zero_register => NULL, 
                                                             to_string => eflags_to_string, 
                                                             sized_to_string => sized_eflags_to_string, 
                                                             codetemps_made_count => REF (0), 
                                                             global_codetemps_created_so_far => REF (0), 
                                                             hardware_registers => REF rkj::zero_length_rw_vector
                                                           }
;
             info_for_kind_fflags = rkj::REGISTERKIND_INFO { min_register_id => 65, 
                                                             max_register_id => 65, 
                                                             kind => fflags_kind, 
                                                             always_zero_register => NULL, 
                                                             to_string => fflags_to_string, 
                                                             sized_to_string => sized_fflags_to_string, 
                                                             codetemps_made_count => REF (0), 
                                                             global_codetemps_created_so_far => REF (0), 
                                                             hardware_registers => REF rkj::zero_length_rw_vector
                                                           }
;
             info_for_kind_registerset = rkj::REGISTERKIND_INFO { min_register_id => 66, 
                                                                  max_register_id => 65, 
                                                                  kind => registerset_kind, 
                                                                  always_zero_register => NULL, 
                                                                  to_string => registerset_to_string, 
                                                                  sized_to_string => sized_registerset_to_string, 
                                                                  codetemps_made_count => REF (0), 
                                                                  global_codetemps_created_so_far => REF (0), 
                                                                  hardware_registers => REF rkj::zero_length_rw_vector
                                                                }
;
             
             # The order here is not irrelevant.
             # We do a lot of linear searches over this list
             # -- see info_for() in src/lib/compiler/back/low/code/registerkinds-g.pkg
             # Probably   90% of the searchs are for INT_REGISTER info,
             # and likely 90% of the remaining searches are for FLOAT_REGISTER info,
             # so we put those first:
             #
             registerkind_infos = [(rkj::INT_REGISTER, info_for_kind_int_register), 
                                      (rkj::FLOAT_REGISTER, info_for_kind_float_register), 
                                      (rkj::FLAGS_REGISTER, info_for_kind_int_register), 
                                      (rkj::RAM_BYTE, info_for_kind_ram_byte), 
                                      (rkj::CONTROL_DEPENDENCY, info_for_kind_control_dependency), 
                                      (eflags_kind, info_for_kind_eflags), 
                                      (fflags_kind, info_for_kind_fflags), 
                                      (registerset_kind, info_for_kind_registerset)];
            );
        
        include package   my_registerkinds;
        
        # NB: package cls (== registerset) is a subpackage of registerkinds_junk, which was 'included' above.
        
        
        # Here get_ith_int_register(i) (e.g.) will return essentially
        #
        #     INT_REGISTER.REGISTERKIND_INFO.hardware_registers[i]
        #
        # -- see 'get_ith_hardware_register_of_kind' definition in   src/lib/compiler/back/low/code/registerkinds-g.pkg
        #
        get_ith_int_register = get_ith_hardware_register_of_kind INT_REGISTER;
        get_ith_float_register = get_ith_hardware_register_of_kind FLOAT_REGISTER;
        get_ith_flags_register = get_ith_hardware_register_of_kind FLAGS_REGISTER;
        get_ith_ram_byte = get_ith_hardware_register_of_kind RAM_BYTE;
        get_ith_control_dependency = get_ith_hardware_register_of_kind CONTROL_DEPENDENCY;
        get_ith_eflags = get_ith_hardware_register_of_kind eflags_kind;
        get_ith_fflags = get_ith_hardware_register_of_kind fflags_kind;
        get_ith_registerset = get_ith_hardware_register_of_kind registerset_kind;
        
        # Special registers:
        #
        eax = get_ith_int_register 0;
        ecx = get_ith_int_register 1;
        edx = get_ith_int_register 2;
        ebx = get_ith_int_register 3;
        esp = get_ith_int_register 4;
        ebp = get_ith_int_register 5;
        esi = get_ith_int_register 6;
        edi = get_ith_int_register 7;
        stackptr_r = get_ith_int_register 4;
        st = (\\ x = get_ith_float_register x);
        st0 = get_ith_float_register 0;
        asm_tmp_r = get_ith_int_register 0;
        fasm_tmp = get_ith_float_register 0;
        eflags = get_ith_eflags 0;
        
        # If you define a package registerkinds in your
        #
        #     intel32.architecture-description
        #
        # file its contents should appear at this point. This is an escape
        # to let you include any extra code required by your architecture.
        # Currently this space is empty on all supported architectures.
        #
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext