PreviousUpNext

15.4.251  src/lib/compiler/back/low/intel32/code/instruction-frequency-properties-intel32-g.pkg

## instruction-frequency-properties-intel32-g.pkg

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



# Extract frequency information from the Intel32 (x86) architecture
#
# -- Allen Leung



###                  "But the beauty of Einstein's equations,
###                   for example, is just as real to anyone who has
###                   experienced it as the beauty of music.
###
###                  "We've learned in the 20th century that
###                   the equations that work have inner harmony."
###
###                                       -- Edward Witten 



# We are nowhere invoked.

stipulate
    package prb =  probability;                                                 # probability                           is from   src/lib/compiler/back/low/library/probability.pkg
herein

    generic package   instruction_frequency_properties_intel32_g   (
        #             ==========================================
        #
        mcf:  Machcode_Intel32                                                  # Machcode_Intel32                      is from   src/lib/compiler/back/low/intel32/code/machcode-intel32.codemade.api
    )
    : (weak) Instruction_Frequency_Properties                                   # Instruction_Frequency_Properties      is from   src/lib/compiler/back/low/code/instruction-frequency-properties.api
    {
        package mcf = mcf;                                                      # "mcf" == "machcode_form" (abstract machine code).

        p0_001 = prb::prob (1, 1000);
        p10    = prb::percent 10;
        p50    = prb::percent 50;
        p90    = prb::percent 90;
        p100   = prb::always;

        fun intel32branch_probability (mcf::JCC { cond => mcf::EQ, ... } ) => p10;
            intel32branch_probability (mcf::JCC { cond => mcf::OO, ... } ) => p0_001;
            intel32branch_probability (mcf::JCC { cond => mcf::NE, ... } ) => p90;
            intel32branch_probability (mcf::JCC { cond => mcf::NO, ... } ) => p100;
            intel32branch_probability (mcf::JCC { cond => mcf::PP, ... } ) => p0_001; #  fp unordered test 
            intel32branch_probability (mcf::JCC { cond => mcf::NP, ... } ) => p100;

            intel32branch_probability (mcf::JCC _) => p50; #  Default 
            intel32branch_probability (mcf::JMP _) => p100; 

            intel32branch_probability _ => prb::never;
        end

        also
        fun branch_probability (mcf::NOTE { note, op } )
                => 
                case (lowhalf_notes::branch_probability.peek note)
                    #
                    THE b =>   b;
                    NULL  =>   branch_probability  op;
                esac;

            branch_probability (mcf::BASE_OP i)
                =>
                intel32branch_probability i;

            branch_probability _
                =>
                prb::never;
         end;

    };
end;


## COPYRIGHT (c) 2002 Bell Labs, Lucent Technologies
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext