PreviousUpNext

15.4.338  src/lib/compiler/back/low/pwrpc32/code/treecode-extension-sext-compiler-pwrpc32-g.pkg

## treecode-extension-sext-compiler-pwrpc32-g.pkg
#
# Background comments may be found in:
#
#     src/lib/compiler/back/low/treecode/treecode-extension.api

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

# emit code for extensions to the pwrpc32 instruction set.



###             "An extraordinary amount of arrogance is present in any
###              claim of having been the first to invent something."
###
###                                       -- Benoit Mandelbrot



api Treecode_Extension_Sext_Compiler_Pwrpc32 {
    #
    package mcf: Machcode_Pwrpc32;                              # Machcode_Pwrpc32              is from   src/lib/compiler/back/low/pwrpc32/code/machcode-pwrpc32.codemade.api

    package tcs: Treecode_Codebuffer                            # Treecode_Codebuffer           is from   src/lib/compiler/back/low/treecode/treecode-codebuffer.api
                 where
                      tcf == mcf::tcf;                          # "tcf" == "treecode_form".

    package mcg:  Machcode_Controlflow_Graph                    # Machcode_Controlflow_Graph    is from   src/lib/compiler/back/low/mcg/machcode-controlflow-graph.api
                  where
                       mcf == mcf                               # "mcf" == "machcode_form" (abstract machine code).
                  also pop == tcs::cst::pop;                    # "pop" == "pseudo_op".

    Reducer
        = 
        tcs::Reducer( mcf::Machine_Op,
                      mcf::rgk::Codetemplists,
                      mcf::Operand,
                      mcf::Addressing_Mode,
                      #
                      mcg::Machcode_Controlflow_Graph
                   );

    compile_sext
        :
        Reducer 
        ->
        { void_expression:      treecode_extension_sext_pwrpc32::Sext ( mcf::tcf::Void_Expression,
                                                                        mcf::tcf::Int_Expression,
                                                                        mcf::tcf::Float_Expression,
                                                                        mcf::tcf::Flag_Expression       # flag expressions handle zero/parity/overflow/... flag stuff.
                                                                      ), 
          #
          notes:        List( mcf::tcf::Note )
        } 
        ->
        Void;
};


stipulate
    package lem =  lowhalf_error_message;                               # lowhalf_error_message                         is from   src/lib/compiler/back/low/control/lowhalf-error-message.pkg
    package x   =  treecode_extension_sext_pwrpc32;                     # treecode_extension_sext_pwrpc32               is from   src/lib/compiler/back/low/pwrpc32/code/treecode-extension-sext-pwrpc.pkg
herein

    # We are nowhere invoked.

    generic package   treecode_extension_sext_compiler_pwrpc32_g   (
        #             ===========================================
        #
        package mcf: Machcode_Pwrpc32;                                  # Machcode_Pwrpc32                              is from   src/lib/compiler/back/low/pwrpc32/code/machcode-pwrpc32.codemade.api

        package tcs: Treecode_Codebuffer                                        # Treecode_Codebuffer                           is from   src/lib/compiler/back/low/treecode/treecode-codebuffer.api
                     where                                              # "tcs" == "treecode_stream".
                        tcf == mcf::tcf;                                # "tcf" == "treecode_form".

        package mcg: Machcode_Controlflow_Graph                         # Machcode_Controlflow_Graph                    is from   src/lib/compiler/back/low/mcg/machcode-controlflow-graph.api
                     where                                              # "mcg" == "machcode_controlflow_graph".
                          pop == tcs::cst::pop                          # "pop" == "pseudo_op".
                     also mcf == mcf;                                   # "mcf" == "machcode_form" (abstract machine code).

    )
    : (weak) Treecode_Extension_Sext_Compiler_Pwrpc32                   # Treecode_Extension_Sext_Compiler_Pwrpc32      is from   src/lib/compiler/back/low/pwrpc32/code/treecode-extension-sext-compiler-pwrpc32-g.pkg
    {
        # Export to client packages:
        #
        package mcf =  mcf;                                             # "mcf" == "machcode_form" (abstract machine code).
        package tcs =  tcs;                                             # "tcs" == "treecode_stream".
        package mcg =  mcg;                                             # "mcg" == "machcode_controlflow_graph".

        stipulate
            package tcf =  tcs::tcf;                                    # "tcf" == "treecode_form".
            package rgk =  mcf::rgk;                                    # "rgk" == "registerkinds".
        herein

            Void_Expression
                =
                x::Sext(
                  tcf::Void_Expression,
                  tcf::Int_Expression,
                  tcf::Float_Expression,
                  tcf::Flag_Expression
                );

            Reducer
                = 
                tcs::Reducer
                  (
                    mcf::Machine_Op,
                    rgk::Codetemplists,
                    mcf::Operand,
                    mcf::Addressing_Mode,
                    mcg::Machcode_Controlflow_Graph
                  );

            fun error msg
                =
                lem::error("treecode_extension_sext_compiler_pwrpc32_g", msg);

            fun compile_sext
                    #
                    (reducer:   Reducer)
                    #
                    { void_expression:  Void_Expression,
                      notes:    List( tcf::Note )
                    }
                =
                {   reducer ->   tcs::REDUCER { reduce_int_expression, operand, put_op, codestream, address_of, ... };

                    codestream
                        ->
                        { put_op => put_i, ... };

                    fun emit' inst
                        =
                        put_op (mcf::BASE_OP inst, notes);

                    case void_expression
                        #       
                        x::STWU { src, ea } => {

                            (address_of  ea) ->    (base, disp);

                            emit' (mcf::ST { st  =>  mcf::STWU,
                                             rs  =>  reduce_int_expression  src,
                                             ra  =>  base,
                                             d   =>  disp,
                                             #  
                                             ramregion =>  tcf::rgn::memory
                                           }
                                  );
                          };
                    esac;
                 };
        end;
    };
end;

## COPYRIGHT (c) 2004 John Reppy (http://www.cs.uchicago.edu/~jhr)
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext