PreviousUpNext

15.4.378  src/lib/compiler/back/low/sparc32/emit/translate-machcode-to-asmcode-sparc32-g.codemade.pkg

## translate-machcode-to-asmcode-sparc32-g.codemade.pkg
#
# This file generated at   2015-12-06:08:43:07   by
#
#     src/lib/compiler/back/low/tools/arch/make-sourcecode-for-translate-machcode-to-asmcode-xxx-g-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


# We are invoked by:
#
#     src/lib/compiler/back/low/main/sparc32/backend-lowhalf-sparc32.pkg
#
stipulate
    package lem =  lowhalf_error_message;                                               # lowhalf_error_message         is from   src/lib/compiler/back/low/control/lowhalf-error-message.pkg
    package pp  =  standard_prettyprinter;                                              # standard_prettyprinter                is from   src/lib/prettyprint/big/src/standard-prettyprinter.pkg
    package rkj =  registerkinds_junk;                                          # registerkinds_junk            is from   src/lib/compiler/back/low/code/registerkinds-junk.pkg
herein

    generic package translate_machcode_to_asmcode_sparc32_g (
        #
        package cst: Codebuffer;                                                        # Codebuffer                    is from   src/lib/compiler/back/low/code/codebuffer.api
        
        package mcf: Machcode_Sparc32                                                   # Machcode_Sparc32              is from   src/lib/compiler/back/low/sparc32/code/machcode-sparc32.codemade.api
                     where
                         tcf == cst::pop::tcf;                          # "tcf" == "treecode_form".
        
        package crm: Compile_Register_Moves_Sparc32                                     # Compile_Register_Moves_Sparc32        is from   src/lib/compiler/back/low/sparc32/code/compile-register-moves-sparc32.api
                     where
                         mcf == mcf;
        
        package tce: Treecode_Eval                                                      # Treecode_Eval                 is from   src/lib/compiler/back/low/treecode/treecode-eval.api
                     where
                         tcf == mcf::tcf;                                       # "tcf" == "treecode_form".
        

###line 485.22 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"
        v9: Bool;

    )
    : (weak) Machcode_Codebuffer_Pp
    {
                                                                                # Machcode_Codebuffer_Pp                is from   src/lib/compiler/back/low/emit/machcode-codebuffer-pp.api
        
        # Export to client packages:
        #
        package cst =  cst;                                                     # "cst"  == "codestream".
        package mcf =  mcf;                                                     # "mcf" == "machcode_form" (abstract machine code).
        
        stipulate
            package rgk =  mcf::rgk;            # "rgk" == "registerkinds".
            package tcf =  mcf::tcf;            # "tcf" == "treecode_form".
            package pop =  cst::pop;                                            # "pop" == "pseudo_op".
            package lac =  mcf::lac;                                            # "lac" == "late_constant".
        herein
        
        include package   asm_flags;                                                    # asm_flags             is from   src/lib/compiler/back/low/emit/asm-flags.pkg
        
        fun error msg
            =
            lem::error ("translate_machcode_to_asmcode_sparc32_g", msg);
        
        fun make_codebuffer (pp: pp::Pp) format_annotations
            =
            {   # stream = *asm_stream::asm_out_stream;                         # asm_stream            is from   src/lib/compiler/back/low/emit/asm-stream.pkg
        
                fun emit' s
                    =
                    pp.lit s;
        
                newline = REF TRUE;
                tabs    = REF 0;
        
                fun tabbing 0 => ();
                    tabbing n => { emit' "\t"; tabbing (n - 1); } ;
                end;
        
                fun emit s
                    =
                    {   tabbing *tabs;
                        tabs := 0;
                        newline := FALSE;
                        emit' s;
                    };
        
                fun nl     ()
                    =
                    {   tabs := 0;
                        if (not *newline)
                            #
                            newline := TRUE;
                            emit' "\n";
                        fi;
                    };
        
                fun comma  () =  emit ", ";
                fun tab    () =  tabs := 1;
                fun indent () =  tabs := 2;
        
                fun ms n
                    =
                    {   s = int::to_string n;
        
                        if (n < 0)   "-" + string::substring (s, 1, size s - 1);
                        else         s;
                        fi;
                    };
        
                fun put_label lab           = emit (pop::cpo::bpo::label_expression_to_string (tcf::LABEL lab));
                fun put_label_expression le = emit (pop::cpo::bpo::label_expression_to_string (tcf::LABEL_EXPRESSION le));
        
                fun put_const lateconst
                    =
                    emit (lac::late_constant_to_string  lateconst);
        
                fun put_int i
                    =
                    emit (ms i);
        
                fun paren f
                    =
                    {   emit "(";
                        f ();
                        emit ")";
                    };
        
                fun put_private_label  label
                    =
                    emit (pop::cpo::bpo::define_private_label label  +  "\n");
        
                fun put_public_label  label
                    =
                    put_private_label  label;
        
                fun put_comment  msg
                    =
                    {   tab ();
                        emit ("/* " + msg + " */");
                        nl ();
                    };
        
                fun put_bblock_note a
                    =
                    put_comment (note::to_string a);
        
                fun get_notes () =  error "get_notes";
                fun do_nothing _ =  ();
                fun fail _       =  raise exception DIE "asmcode-emitter";
        
                fun put_ramregion  ramregion
                    =
                    put_comment (mcf::rgn::ramregion_to_string  ramregion);
        
                put_ramregion
                    =
                    if *show_region    put_ramregion;
                    else               do_nothing;
                    fi;
        
                fun put_pseudo_op  pseudo_op
                    =
                    {   emit (pop::pseudo_op_to_string  pseudo_op);
                        emit "\n";
                    };
        
                fun init  size
                    =
                    {   put_comment ("Code Size = " + ms size);
                        nl ();
                    };
        
                put_register_info = asm_formatting_utilities::reginfo
                                         (emit, format_annotations);
        
                fun put_register r
                    =
                    {   emit (rkj::register_to_string r);
                        put_register_info r;
                    };
        
                fun put_registerset (title, registerset)
                    =
                    {   nl ();
                        put_comment  (title  +  rkj::cls::codetemplists_to_string  registerset);
                    };
        
                put_registerset
                    =
                    if *show_registerset   put_registerset;
                    else                   do_nothing;
                    fi;
        
                fun put_defs  registerset =  put_registerset ("defs: ", registerset);
                fun put_uses  registerset =  put_registerset ("uses: ", registerset);
        
                put_cuts_to
                    =
                    *show_cuts_to   ??   asm_formatting_utilities::put_cuts_to  emit
                                    ::   do_nothing;
        
                fun emitter instruction
                    =
                    {
                        # NB: The following incorrect-indentation problem is nontrivial to fix
                        #     so I'm just living with it for the moment.  -- 2011-05-14 CrT

        fun asm_load (mcf::LDSB) => "ldsb";
            asm_load (mcf::LDSH) => "ldsh";
            asm_load (mcf::LDUB) => "ldub";
            asm_load (mcf::LDUH) => "lduh";
            asm_load (mcf::LD) => "ld";
            asm_load (mcf::LDX) => "ldx";
            asm_load (mcf::LDD) => "ldd";
        end

        also
        fun put_load x 
            =
            emit (asm_load x)

        also
        fun asm_store (mcf::STB) => "stb";
            asm_store (mcf::STH) => "sth";
            asm_store (mcf::ST) => "st";
            asm_store (mcf::STX) => "stx";
            asm_store (mcf::STD) => "std";
        end

        also
        fun put_store x 
            =
            emit (asm_store x)

        also
        fun asm_fload (mcf::LDF) => "ldf";
            asm_fload (mcf::LDDF) => "lddf";
            asm_fload (mcf::LDQF) => "ldqf";
            asm_fload (mcf::LDFSR) => "ldfsr";
            asm_fload (mcf::LDXFSR) => "ldxfsr";
        end

        also
        fun put_fload x 
            =
            emit (asm_fload x)

        also
        fun asm_fstore (mcf::STF) => "stf";
            asm_fstore (mcf::STDF) => "stdf";
            asm_fstore (mcf::STFSR) => "stfsr";
        end

        also
        fun put_fstore x 
            =
            emit (asm_fstore x)

        also
        fun asm_arith (mcf::AND) => "and";
            asm_arith (mcf::ANDCC) => "andcc";
            asm_arith (mcf::ANDN) => "andn";
            asm_arith (mcf::ANDNCC) => "andncc";
            asm_arith (mcf::OR) => "or";
            asm_arith (mcf::ORCC) => "orcc";
            asm_arith (mcf::ORN) => "orn";
            asm_arith (mcf::ORNCC) => "orncc";
            asm_arith (mcf::XOR) => "xor";
            asm_arith (mcf::XORCC) => "xorcc";
            asm_arith (mcf::XNOR) => "xnor";
            asm_arith (mcf::XNORCC) => "xnorcc";
            asm_arith (mcf::ADD) => "add";
            asm_arith (mcf::ADDCC) => "addcc";
            asm_arith (mcf::TADD) => "tadd";
            asm_arith (mcf::TADDCC) => "taddcc";
            asm_arith (mcf::TADDTV) => "taddtv";
            asm_arith (mcf::TADDTVCC) => "taddtvcc";
            asm_arith (mcf::SUB) => "sub";
            asm_arith (mcf::SUBCC) => "subcc";
            asm_arith (mcf::TSUB) => "tsub";
            asm_arith (mcf::TSUBCC) => "tsubcc";
            asm_arith (mcf::TSUBTV) => "tsubtv";
            asm_arith (mcf::TSUBTVCC) => "tsubtvcc";
            asm_arith (mcf::UMUL) => "umul";
            asm_arith (mcf::UMULCC) => "umulcc";
            asm_arith (mcf::SMUL) => "smul";
            asm_arith (mcf::SMULCC) => "smulcc";
            asm_arith (mcf::UDIV) => "udiv";
            asm_arith (mcf::UDIVCC) => "udivcc";
            asm_arith (mcf::SDIV) => "sdiv";
            asm_arith (mcf::SDIVCC) => "sdivcc";
            asm_arith (mcf::MULX) => "mulx";
            asm_arith (mcf::SDIVX) => "sdivx";
            asm_arith (mcf::UDIVX) => "udivx";
        end

        also
        fun put_arith x 
            =
            emit (asm_arith x)

        also
        fun asm_shift (mcf::SLL) => "sll";
            asm_shift (mcf::SRL) => "srl";
            asm_shift (mcf::SRA) => "sra";
            asm_shift (mcf::SLLX) => "sllx";
            asm_shift (mcf::SRLX) => "srlx";
            asm_shift (mcf::SRAX) => "srax";
        end

        also
        fun put_shift x 
            =
            emit (asm_shift x)

        also
        fun asm_farith1 (mcf::FITOS) => "fitos";
            asm_farith1 (mcf::FITOD) => "fitod";
            asm_farith1 (mcf::FITOQ) => "fitoq";
            asm_farith1 (mcf::FSTOI) => "fstoi";
            asm_farith1 (mcf::FDTOI) => "fdtoi";
            asm_farith1 (mcf::FQTOI) => "fqtoi";
            asm_farith1 (mcf::FSTOD) => "fstod";
            asm_farith1 (mcf::FSTOQ) => "fstoq";
            asm_farith1 (mcf::FDTOS) => "fdtos";
            asm_farith1 (mcf::FDTOQ) => "fdtoq";
            asm_farith1 (mcf::FQTOS) => "fqtos";
            asm_farith1 (mcf::FQTOD) => "fqtod";
            asm_farith1 (mcf::FMOVS) => "fmovs";
            asm_farith1 (mcf::FNEGS) => "fnegs";
            asm_farith1 (mcf::FABSS) => "fabss";
            asm_farith1 (mcf::FMOVD) => "fmovd";
            asm_farith1 (mcf::FNEGD) => "fnegd";
            asm_farith1 (mcf::FABSD) => "fabsd";
            asm_farith1 (mcf::FMOVQ) => "fmovq";
            asm_farith1 (mcf::FNEGQ) => "fnegq";
            asm_farith1 (mcf::FABSQ) => "fabsq";
            asm_farith1 (mcf::FSQRTS) => "fsqrts";
            asm_farith1 (mcf::FSQRTD) => "fsqrtd";
            asm_farith1 (mcf::FSQRTQ) => "fsqrtq";
        end

        also
        fun put_farith1 x 
            =
            emit (asm_farith1 x)

        also
        fun asm_farith2 (mcf::FADDS) => "fadds";
            asm_farith2 (mcf::FADDD) => "faddd";
            asm_farith2 (mcf::FADDQ) => "faddq";
            asm_farith2 (mcf::FSUBS) => "fsubs";
            asm_farith2 (mcf::FSUBD) => "fsubd";
            asm_farith2 (mcf::FSUBQ) => "fsubq";
            asm_farith2 (mcf::FMULS) => "fmuls";
            asm_farith2 (mcf::FMULD) => "fmuld";
            asm_farith2 (mcf::FMULQ) => "fmulq";
            asm_farith2 (mcf::FSMULD) => "fsmuld";
            asm_farith2 (mcf::FDMULQ) => "fdmulq";
            asm_farith2 (mcf::FDIVS) => "fdivs";
            asm_farith2 (mcf::FDIVD) => "fdivd";
            asm_farith2 (mcf::FDIVQ) => "fdivq";
        end

        also
        fun put_farith2 x 
            =
            emit (asm_farith2 x)

        also
        fun asm_fcmp (mcf::FCMPS) => "fcmps";
            asm_fcmp (mcf::FCMPD) => "fcmpd";
            asm_fcmp (mcf::FCMPQ) => "fcmpq";
            asm_fcmp (mcf::FCMPES) => "fcmpes";
            asm_fcmp (mcf::FCMPED) => "fcmped";
            asm_fcmp (mcf::FCMPEQ) => "fcmpeq";
        end

        also
        fun put_fcmp x 
            =
            emit (asm_fcmp x)

        also
        fun asm_branch (mcf::BN) => "n";
            asm_branch (mcf::BE) => "e";
            asm_branch (mcf::BLE) => "le";
            asm_branch (mcf::BL) => "l";
            asm_branch (mcf::BLEU) => "leu";
            asm_branch (mcf::BCS) => "cs";
            asm_branch (mcf::BNEG) => "neg";
            asm_branch (mcf::BVS) => "vs";
            asm_branch (mcf::BA) => "";
            asm_branch (mcf::BNE) => "ne";
            asm_branch (mcf::BG) => "g";
            asm_branch (mcf::BGE) => "ge";
            asm_branch (mcf::BGU) => "gu";
            asm_branch (mcf::BCC) => "cc";
            asm_branch (mcf::BPOS) => "pos";
            asm_branch (mcf::BVC) => "vs";
        end

        also
        fun put_branch x 
            =
            emit (asm_branch x)

        also
        fun asm_rcond (mcf::RZ) => "rz";
            asm_rcond (mcf::RLEZ) => "rlez";
            asm_rcond (mcf::RLZ) => "rlz";
            asm_rcond (mcf::RNZ) => "rnz";
            asm_rcond (mcf::RGZ) => "rgz";
            asm_rcond (mcf::RGEZ) => "rgez";
        end

        also
        fun put_rcond x 
            =
            emit (asm_rcond x)

        also
        fun asm_prediction (mcf::PT) => "pt";
            asm_prediction (mcf::PN) => "pn";
        end

        also
        fun put_prediction x 
            =
            emit (asm_prediction x)

        also
        fun asm_fbranch (mcf::FBN) => "fbn";
            asm_fbranch (mcf::FBNE) => "fbne";
            asm_fbranch (mcf::FBLG) => "fblg";
            asm_fbranch (mcf::FBUL) => "fbul";
            asm_fbranch (mcf::FBL) => "fbl";
            asm_fbranch (mcf::FBUG) => "fbug";
            asm_fbranch (mcf::FBG) => "fbg";
            asm_fbranch (mcf::FBU) => "fbu";
            asm_fbranch (mcf::FBA) => "fb";
            asm_fbranch (mcf::FBE) => "fbe";
            asm_fbranch (mcf::FBUE) => "fbue";
            asm_fbranch (mcf::FBGE) => "fbge";
            asm_fbranch (mcf::FBUGE) => "fbuge";
            asm_fbranch (mcf::FBLE) => "fble";
            asm_fbranch (mcf::FBULE) => "fbule";
            asm_fbranch (mcf::FBO) => "fbo";
        end

        also
        fun put_fbranch x 
            =
            emit (asm_fbranch x)

        also
        fun asm_fsize (mcf::SS) => "s";
            asm_fsize (mcf::DD) => "d";
            asm_fsize (mcf::QQ) => "q";
        end

        also
        fun put_fsize x 
            =
            emit (asm_fsize x)

        also
        fun put_operand (mcf::REG int_register) => put_register int_register;
            put_operand (mcf::IMMED int) => put_int int;
            put_operand (mcf::LAB label_expression) => put_label_expression label_expression;
            put_operand (mcf::LO label_expression) => {   emit "%lo("; 
                                                          put_label_expression label_expression; 
                                                          emit ")"; 
                                                      };
            put_operand (mcf::HI label_expression) => {   emit "%hi("; 
                                                          put_label_expression label_expression; 
                                                          emit ")"; 
                                                      };
        end;

###line 488.7 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"

        fun put_leaf FALSE => ();
            put_leaf TRUE => emit "l";
        end;

###line 489.7 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"

        fun put_nop FALSE => ();
            put_nop TRUE => emit "\n\tnop";
        end;

###line 490.7 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"

        fun put_a FALSE => ();
            put_a TRUE => emit ",a";
        end;

###line 491.7 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"

        fun put_cc FALSE => ();
            put_cc TRUE => emit "cc";
        end;

        fun put_op' instruction 
            =
            case instruction
                #
                mcf::LOAD { l, 
                            d, 
                            r, 
                            i, 
                            ramregion
                          }
                    => {   put_load l; 
                           emit "\t["; 
                           put_register r; 
                           emit "+"; 
                           put_operand i; 
                           emit "], "; 
                           put_register d; 
                           put_ramregion ramregion; 
                       };
                mcf::STORE { s, 
                             d, 
                             r, 
                             i, 
                             ramregion
                           }
                    => {   put_store s; 
                           emit "\t"; 
                           put_register d; 
                           emit ", ["; 
                           put_register r; 
                           emit "+"; 
                           put_operand i; 
                           emit "]"; 
                           put_ramregion ramregion; 
                       };
                mcf::FLOAD { l, 
                             r, 
                             i, 
                             d, 
                             ramregion
                           }
                    => {   put_fload l; 
                           emit "\t["; 
                           put_register r; 
                           emit "+"; 
                           put_operand i; 
                           emit "], "; 
                           put_register d; 
                           put_ramregion ramregion; 
                       };
                mcf::FSTORE { s, 
                              d, 
                              r, 
                              i, 
                              ramregion
                            }
                    => {   put_fstore s; 
                           emit "\t["; 
                           put_register r; 
                           emit "+"; 
                           put_operand i; 
                           emit "], "; 
                           put_register d; 
                           put_ramregion ramregion; 
                       };
                mcf::UNIMP { const22 } => {   emit "unimp "; 
                                              put_int const22; 
                                          };
                mcf::SETHI { i, 
                             d
                           }
                    => {   
###line 675.18 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"
                           i = one_word_unt::to_string (one_word_unt::(<<) (one_word_unt::from_int i, 
                                                           0uxA));

                               {   emit "sethi\t%hi(0x"; 
                                   emit i; 
                                   emit "), "; 
                                   put_register d; 
                               };
                       };
                mcf::ARITH { a, 
                             r, 
                             i, 
                             d
                           }
                    => case (a, rkj::interkind_register_id_of r, rkj::interkind_register_id_of d, 
                               i)
                           #
                           (mcf::OR, 0, _, mcf::REG _) => {   emit "mov\t"; 
                                                              put_operand i; 
                                                              emit ", "; 
                                                              put_register d; 
                                                          };
                           (mcf::OR, 0, _, _) => {   emit "set\t"; 
                                                     put_operand i; 
                                                     emit ", "; 
                                                     put_register d; 
                                                 };
                           (mcf::SUBCC, _, 0, _) => {   emit "cmp\t"; 
                                                        put_register r; 
                                                        emit ", "; 
                                                        put_operand i; 
                                                    };
                           _   => {   put_arith a; 
                                      emit "\t"; 
                                      put_register r; 
                                      emit ", "; 
                                      put_operand i; 
                                      emit ", "; 
                                      put_register d; 
                                  };
                       esac;
                mcf::SHIFT { s, 
                             r, 
                             i, 
                             d
                           }
                    => {   put_shift s; 
                           emit "\t"; 
                           put_register r; 
                           emit ", "; 
                           put_operand i; 
                           emit ", "; 
                           put_register d; 
                       };
                mcf::MOVICC { b, 
                              i, 
                              d
                            }
                    => {   emit "mov"; 
                           put_branch b; 
                           emit "\t"; 
                           put_operand i; 
                           emit ", "; 
                           put_register d; 
                       };
                mcf::MOVFCC { b, 
                              i, 
                              d
                            }
                    => {   emit "mov"; 
                           put_fbranch b; 
                           emit "\t"; 
                           put_operand i; 
                           emit ", "; 
                           put_register d; 
                       };
                mcf::MOVR { rcond, 
                            r, 
                            i, 
                            d
                          }
                    => {   emit "movr"; 
                           put_rcond rcond; 
                           emit "\t"; 
                           put_register r; 
                           emit ", "; 
                           put_operand i; 
                           emit ", "; 
                           put_register d; 
                       };
                mcf::FMOVICC { size, 
                               b, 
                               r, 
                               d
                             }
                    => {   emit "fmov"; 
                           put_fsize size; 
                           put_branch b; 
                           emit "\t"; 
                           put_register r; 
                           emit ", "; 
                           put_register d; 
                       };
                mcf::FMOVFCC { size, 
                               b, 
                               r, 
                               d
                             }
                    => {   emit "fmov"; 
                           put_fsize size; 
                           put_fbranch b; 
                           emit "\t"; 
                           put_register r; 
                           emit ", "; 
                           put_register d; 
                       };
                mcf::BICC { b, 
                            a, 
                            label, 
                            nop
                          }
                    => {   emit "b"; 
                           put_branch b; 
                           put_a a; 
                           emit "\t"; 
                           put_label label; 
                           put_nop nop; 
                       };
                mcf::FBFCC { b, 
                             a, 
                             label, 
                             nop
                           }
                    => {   put_fbranch b; 
                           put_a a; 
                           emit "\t"; 
                           put_label label; 
                           put_nop nop; 
                       };
                mcf::BR { rcond, 
                          p, 
                          r, 
                          a, 
                          label, 
                          nop
                        }
                    => {   emit "b"; 
                           put_rcond rcond; 
                           put_a a; 
                           put_prediction p; 
                           emit "\t"; 
                           put_register r; 
                           emit ", "; 
                           put_label label; 
                           put_nop nop; 
                       };
                mcf::BP { b, 
                          p, 
                          cc, 
                          a, 
                          label, 
                          nop
                        }
                    => {   emit "bp"; 
                           put_branch b; 
                           put_a a; 
                           put_prediction p; 
                           emit "\t%"; 
                           emit if (cc == mcf::ICC)   "i";
                                else   "x";
                                fi; 
                           emit "cc, "; 
                           put_label label; 
                           put_nop nop; 
                       };
                mcf::JMP { r, 
                           i, 
                           labs, 
                           nop
                         }
                    => {   emit "jmp\t["; 
                           put_register r; 
                           emit "+"; 
                           put_operand i; 
                           emit "]"; 
                           put_nop nop; 
                       };
                mcf::JMPL { r, 
                            i, 
                            d, 
                            defs, 
                            uses, 
                            cuts_to, 
                            nop, 
                            ramregion
                          }
                    => {   emit "jmpl\t["; 
                           put_register r; 
                           emit "+"; 
                           put_operand i; 
                           emit "], "; 
                           put_register d; 
                           put_ramregion ramregion; 
                           put_defs defs; 
                           put_uses uses; 
                           put_cuts_to cuts_to; 
                           put_nop nop; 
                       };
                mcf::CALL { defs, 
                            uses, 
                            label, 
                            cuts_to, 
                            nop, 
                            ramregion
                          }
                    => {   emit "call\t"; 
                           put_label label; 
                           put_ramregion ramregion; 
                           put_defs defs; 
                           put_uses uses; 
                           put_cuts_to cuts_to; 
                           put_nop nop; 
                       };
                mcf::TICC { t, 
                            cc, 
                            r, 
                            i
                          }
                    => {   emit "t"; 
                           put_branch t; 
                           emit "\t"; 
                           if (cc == mcf::ICC)   ();
                           else   (emit "%xcc, ");
                           fi; 
                           put_register r; 
                           emit "+"; 
                           put_operand i; 
                       };
                mcf::FPOP1 { a, 
                             r, 
                             d
                           }
                    => {   
###line 783.18 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"

                           fun f (a, r, d) 
                               =
                               {   emit a; 
                                   emit "\t"; 
                                   emit (rgk::float_register_to_string r); 
                                   emit ", "; 
                                   emit (rgk::float_register_to_string d); 
                               };

###line 788.18 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"

                           fun g (a, r, d) 
                               =
                               {   
###line 789.22 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"
                                   r = rkj::intrakind_register_id_of r;

###line 790.22 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"
                                   d = rkj::intrakind_register_id_of d;

                                   f (a, r, d); 
                                       emit "\n\t"; 
                                       f ("fmovs", r + 1, d + 1);
                               };

###line 794.18 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"

                           fun h (a, r, d) 
                               =
                               {   
###line 795.22 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"
                                   r = rkj::intrakind_register_id_of r;

###line 796.22 "src/lib/compiler/back/low/sparc32/sparc32.architecture-description"
                                   d = rkj::intrakind_register_id_of d;

                                   f (a, r, d); 
                                       emit "\n\t"; 
                                       f ("fmovs", r + 1, d + 1); 
                                       emit "\n\t"; 
                                       f ("fmovs", r + 2, d + 2); 
                                       emit "\n\t"; 
                                       f ("fmovs", r + 3, d + 3);
                               };

                           if  v9
                               #
                               put_farith1 a; 
                               emit "\t"; 
                               put_register r; 
                               emit ", "; 
                               put_register d; 
                           else
                           case a
                               #
                               mcf::FMOVD => g ("fmovs", r, d);
                               mcf::FNEGD => g ("fnegs", r, d);
                               mcf::FABSD => g ("fabss", r, d);
                               mcf::FMOVQ => h ("fmovs", r, d);
                               mcf::FNEGQ => h ("fnegs", r, d);
                               mcf::FABSQ => h ("fabss", r, d);
                               _   => {   put_farith1 a; 
                                          emit "\t"; 
                                          put_register r; 
                                          emit ", "; 
                                          put_register d; 
                                      };
                           esac;
                           fi;
                       };
                mcf::FPOP2 { a, 
                             r1, 
                             r2, 
                             d
                           }
                    => {   put_farith2 a; 
                           emit "\t"; 
                           put_register r1; 
                           emit ", "; 
                           put_register r2; 
                           emit ", "; 
                           put_register d; 
                       };
                mcf::FCMP { cmp, 
                            r1, 
                            r2, 
                            nop
                          }
                    => {   put_fcmp cmp; 
                           emit "\t"; 
                           put_register r1; 
                           emit ", "; 
                           put_register r2; 
                           put_nop nop; 
                       };
                mcf::SAVE { r, 
                            i, 
                            d
                          }
                    => {   emit "save\t"; 
                           put_register r; 
                           emit ", "; 
                           put_operand i; 
                           emit ", "; 
                           put_register d; 
                       };
                mcf::RESTORE { r, 
                               i, 
                               d
                             }
                    => {   emit "restore\t"; 
                           put_register r; 
                           emit ", "; 
                           put_operand i; 
                           emit ", "; 
                           put_register d; 
                       };
                mcf::RDY { d } => {   emit "rd\t%y, "; 
                                      put_register d; 
                                  };
                mcf::WRY { r, 
                           i
                         }
                    => {   emit "wr\t"; 
                           put_register r; 
                           emit ", "; 
                           put_operand i; 
                           emit ", %y"; 
                       };
                mcf::RET { leaf, 
                           nop
                         }
                    => {   emit "ret"; 
                           put_leaf leaf; 
                           put_nop nop; 
                       };
                mcf::SOURCE { } => emit "source";
                mcf::SINK { } => emit "sink";
                mcf::PHI { } => emit "phi";
            esac;
                        tab ();
                        put_op' instruction;
                        nl ();
                    }                                           # fun emitter
        
                also
                fun put_indented_instruction  instruction
                    =
                    {   indent ();
                        put_op instruction;
                        nl ();
                    }
        
                also
                fun put_instructions instructions
                    =
                    apply if *indent_copies   put_indented_instruction;
                          else put_op;
                          fi
                          instructions
        
                also
                fun put_op (mcf::NOTE { op, note } )
                        =>
                        {   put_comment (note::to_string note);
                            nl ();
                            put_op op;
                        };
        
                    put_op (mcf::LIVE { regs, spilled } )
                        =>
                        put_comment("live= " + rkj::cls::codetemplists_to_string regs +
                            "spilled= " + rkj::cls::codetemplists_to_string spilled);
        
                    put_op (mcf::DEAD { regs, spilled } )
                        =>
                        put_comment("dead= " + rkj::cls::codetemplists_to_string regs +                 # 'dead' here was 'killed' -- is there a critical difference?
                            "spilled= " + rkj::cls::codetemplists_to_string spilled);
        
                    put_op (mcf::BASE_OP i)
                        =>
                        emitter i;
        
                    put_op (mcf::COPY { kind=>rkj::INT_REGISTER, size_in_bits, src, dst, tmp } )
                        =>
                        put_instructions (crm::compile_int_register_moves { tmp, src, dst } );
        
                    put_op (mcf::COPY { kind=>rkj::FLOAT_REGISTER, size_in_bits, src, dst, tmp } )
                        =>
                        put_instructions (crm::compile_float_register_moves { tmp, src, dst } );
        
                    put_op _
                        =>
                        error "put_op";
                end;
        
                
                {
                  start_new_cccomponent => init,
                  put_pseudo_op,
                  put_op,
                  get_completed_cccomponent => fail,
                  put_private_label,
                  put_public_label,
                  put_comment,
                  put_fn_liveout_info => do_nothing,
                  put_bblock_note,
                  get_notes
                };
            };                                                                          # fun make_codebuffer
        end;                                                                            # stipulate
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext