PreviousUpNext

15.4.375  src/lib/compiler/back/low/sparc32/code/registerkinds-sparc32.codemade.pkg

## registerkinds-sparc32.codemade.pkg
#
# This file generated at   2015-12-06:08:43:07   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/sparc32/sparc32.architecture-description
#
# Edits to this file will be LOST on next system rebuild.

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


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

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

        psr_kind: rkj::Registerkind;

        fsr_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;

        y_to_string: rkj::Interkind_Register_Id -> String;

        psr_to_string: rkj::Interkind_Register_Id -> String;

        fsr_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_y_to_string: (rkj::Interkind_Register_Id, rkj::Register_Size_In_Bits) -> String;

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

        sized_fsr_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:
        #
        framepointer_r: rkj::Codetemp_Info;

        link_reg: rkj::Codetemp_Info;

        y: rkj::Codetemp_Info;

        psr: rkj::Codetemp_Info;

        fsr: rkj::Codetemp_Info;

        r0: 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_sparc32: Registerkinds_Sparc32 {
        #
                                                                        # Registerkinds_Sparc32 is from   src/lib/compiler/back/low/sparc32/code/registerkinds-sparc32.codemade.pkg
        #
        exception NO_SUCH_PHYSICAL_REGISTER_SPARC32;
        
        fun error msg =  err::error("NO_SUCH_PHYSICAL_REGISTER_SPARC32", 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) 
            =
            (\\ (r, _) = if (r < 8)   ("%g" + (int::to_string r));
                         else   if (r == 14)   "%sp";
                                else   if (r < 16)   ("%o" + (int::to_string (r - 8)));
                                       else   if (r < 24)   ("%l" + (int::to_string (r - 16)));
                                              else   if (r == 30)   "%fp";
                                                     else   if (r < 32)   ("%i" + (int::to_string (r - 24)));
                                                            else   ("%r" + (int::to_string r));
                                                            fi;
                                                     fi;
                                              fi;
                                       fi;
                                fi;
                         fi) (register_number, register_size_in_bits)

        also
        fun sized_float_register_to_string (register_number, register_size_in_bits) 
            =
            (\\ (f, _) = "%f" + (int::to_string f)) (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) 
            =
            (\\ (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) 
            =
            (\\ (r, _) = "ctrl" + (int::to_string r)) (register_number, register_size_in_bits)

        also
        fun sized_y_to_string (register_number, register_size_in_bits) 
            =
            (\\ _ = "%y") (register_number, register_size_in_bits)

        also
        fun sized_psr_to_string (register_number, register_size_in_bits) 
            =
            \\ (0, _) => "%psr";
               (n, _) => "%psr" + (int::to_string n);
            end (register_number, register_size_in_bits)

        also
        fun sized_fsr_to_string (register_number, register_size_in_bits) 
            =
            \\ (0, _) => "%fsr";
               (n, _) => "%fsr" + (int::to_string n);
            end (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, 64);

        fun float_register_to_string register_number 
            =
            sized_float_register_to_string (register_number, 32);

        fun flags_register_to_string register_number 
            =
            sized_flags_register_to_string (register_number, 64);

        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 y_to_string register_number 
            =
            sized_y_to_string (register_number, 64);

        fun psr_to_string register_number 
            =
            sized_psr_to_string (register_number, 64);

        fun fsr_to_string register_number 
            =
            sized_fsr_to_string (register_number, 64);

        fun registerset_to_string register_number 
            =
            sized_registerset_to_string (register_number, 0);
        
        y_kind = rkj::make_registerkind { name => "Y", 
                                          nickname => "y"
                                        }
;
        psr_kind = rkj::make_registerkind { name => "PSR", 
                                            nickname => "psr"
                                          }
;
        fsr_kind = rkj::make_registerkind { name => "FSR", 
                                            nickname => "fsr"
                                          }
;
        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_SPARC32;
             
             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 => THE (0), 
                                                                   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_y = rkj::REGISTERKIND_INFO { min_register_id => 64, 
                                                        max_register_id => 64, 
                                                        kind => y_kind, 
                                                        always_zero_register => NULL, 
                                                        to_string => y_to_string, 
                                                        sized_to_string => sized_y_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_psr = rkj::REGISTERKIND_INFO { min_register_id => 65, 
                                                          max_register_id => 65, 
                                                          kind => psr_kind, 
                                                          always_zero_register => NULL, 
                                                          to_string => psr_to_string, 
                                                          sized_to_string => sized_psr_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_fsr = rkj::REGISTERKIND_INFO { min_register_id => 66, 
                                                          max_register_id => 66, 
                                                          kind => fsr_kind, 
                                                          always_zero_register => NULL, 
                                                          to_string => fsr_to_string, 
                                                          sized_to_string => sized_fsr_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 => 67, 
                                                                  max_register_id => 66, 
                                                                  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), 
                                      (y_kind, info_for_kind_y), (psr_kind, 
                                      info_for_kind_psr), (fsr_kind, info_for_kind_fsr), 
                                      (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_y = get_ith_hardware_register_of_kind y_kind;
        get_ith_psr = get_ith_hardware_register_of_kind psr_kind;
        get_ith_fsr = get_ith_hardware_register_of_kind fsr_kind;
        get_ith_registerset = get_ith_hardware_register_of_kind registerset_kind;
        
        # Special registers:
        #
        stackptr_r = get_ith_int_register 14;
        framepointer_r = get_ith_int_register 30;
        asm_tmp_r = get_ith_int_register 10;
        link_reg = get_ith_int_register 15;
        fasm_tmp = get_ith_float_register 30;
        y = get_ith_y 0;
        psr = get_ith_psr 0;
        fsr = get_ith_fsr 0;
        r0 = get_ith_int_register 0;
        
        # If you define a package registerkinds in your
        #
        #     sparc32.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