PreviousUpNext

15.4.339  src/lib/compiler/back/low/pwrpc32/code/registerkinds-pwrpc32.codemade.pkg

## registerkinds-pwrpc32.codemade.pkg
#
# This file generated at   2013-04-15:13:05:35   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/pwrpc32/pwrpc32.architecture-description
#
# Edits to this file will be LOST on next system rebuild.

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


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

    api Registerkinds_Pwrpc32 {
        #
        include Registerkinds;                                          # Registerkinds is from   src/lib/compiler/back/low/code/registerkinds.api
        
        # Architecture-specific register kinds:
        #
        spr_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;

        spr_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_spr_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:
        #
        r0: rkj::Codetemp_Info;

        xer: rkj::Codetemp_Info;

        lr: rkj::Codetemp_Info;

        ctr: 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_pwrpc32: Registerkinds_Pwrpc32 {
        #
                                                                        # Registerkinds_Pwrpc32 is from   src/lib/compiler/back/low/pwrpc32/code/registerkinds-pwrpc32.codemade.pkg
        #
        exception NO_SUCH_PHYSICAL_REGISTER_PWRPC32;
        
        fun error msg =  err::error("NO_SUCH_PHYSICAL_REGISTER_PWRPC32", msg);
        
        include 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) 
            =
            (fn (r, _) = if (deref asm_syntax_pwrpc32::ibm_syntax)   (int::to_string r);
                         else   ("r" + (int::to_string r));
                         fi) (register_number, register_size_in_bits)

        also
        fun sized_float_register_to_string (register_number, register_size_in_bits) 
            =
            (fn (f, _) = if (deref asm_syntax_pwrpc32::ibm_syntax)   (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) 
            =
            (fn (cr, _) = "cr" + (int::to_string cr)) (register_number, register_size_in_bits)

        also
        fun sized_ram_byte_to_string (register_number, register_size_in_bits) 
            =
            (fn (r, _) = "m" + (int::to_string r)) (register_number, register_size_in_bits)

        also
        fun sized_control_dependency_to_string (register_number, register_size_in_bits) 
            =
            (fn (r, _) = "ctrl" + (int::to_string r)) (register_number, register_size_in_bits)

        also
        fun sized_spr_to_string (register_number, register_size_in_bits) 
            =
            fn (1, _) => "xer";
               (8, _) => "lr";
               (9, _) => "ctr";
               (r, _) => int::to_string r;
            end (register_number, register_size_in_bits)

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

        fun int_register_to_string register_number 
            =
            sized_int_register_to_string (register_number, 64);

        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, 4);

        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, 8);

        fun spr_to_string register_number 
            =
            sized_spr_to_string (register_number, 64);

        fun registerset_to_string register_number 
            =
            sized_registerset_to_string (register_number, 0);
        
        spr_kind = rkj::make_registerkind { name => "SPR", 
                                            nickname => "spr"
                                          }
;
        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_PWRPC32;
             
             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_flags_register = rkj::REGISTERKIND_INFO { min_register_id => 64, 
                                                                     max_register_id => 71, 
                                                                     kind => rkj::FLAGS_REGISTER, 
                                                                     always_zero_register => NULL, 
                                                                     to_string => flags_register_to_string, 
                                                                     sized_to_string => sized_flags_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 => 72, 
                                                               max_register_id => 71, 
                                                               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 => 72, 
                                                                         max_register_id => 71, 
                                                                         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_spr = rkj::REGISTERKIND_INFO { min_register_id => 72, 
                                                          max_register_id => 103, 
                                                          kind => spr_kind, 
                                                          always_zero_register => NULL, 
                                                          to_string => spr_to_string, 
                                                          sized_to_string => sized_spr_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 => 104, 
                                                                  max_register_id => 103, 
                                                                  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_flags_register), 
                                      (rkj::RAM_BYTE, info_for_kind_ram_byte), 
                                      (rkj::CONTROL_DEPENDENCY, info_for_kind_control_dependency), 
                                      (spr_kind, info_for_kind_spr), (registerset_kind, 
                                      info_for_kind_registerset)];
            );
        
        include 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_spr = get_ith_hardware_register_of_kind spr_kind;
        get_ith_registerset = get_ith_hardware_register_of_kind registerset_kind;
        
        # Special registers:
        #
        stackptr_r = get_ith_int_register 1;
        asm_tmp_r = get_ith_int_register 28;
        fasm_tmp = get_ith_float_register 0;
        r0 = get_ith_int_register 0;
        xer = get_ith_spr 1;
        lr = get_ith_spr 8;
        ctr = get_ith_spr 9;
        
        # If you define a package registerkinds in your
        #
        #     pwrpc32.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