## treecode-form-g.pkg
#
# See comments in:
#
#
src/lib/compiler/back/low/treecode/treecode-form.api# Compiled by:
#
src/lib/compiler/back/low/lib/lowhalf.lib### "The clearest way into the Universe
### is through a forest wilderness."
###
### -- John Muir
stipulate
package lbl = codelabel; # codelabel is from
src/lib/compiler/back/low/code/codelabel.pkg package rkj = registerkinds_junk; # registerkinds_junk is from
src/lib/compiler/back/low/code/registerkinds-junk.pkg # # Late_Constant is from
src/lib/compiler/back/low/code/late-constant.api package tcp = treecode_pith; # treecode_pith is from
src/lib/compiler/back/low/treecode/treecode-pith.pkgherein
# We are invoked from:
#
#
src/lib/compiler/back/low/main/intel32/backend-lowhalf-intel32-g.pkg #
src/lib/compiler/back/low/main/pwrpc32/backend-lowhalf-pwrpc32.pkg #
src/lib/compiler/back/low/main/sparc32/backend-lowhalf-sparc32.pkg #
src/lib/compiler/back/low/tools/arch/adl-rtl.pkg #
generic package treecode_form_g (
# ===============
#
# late_constant is from
src/lib/compiler/back/low/main/nextcode/late-constant.pkg
package lac: Late_Constant; # Late_Constant is from
src/lib/compiler/back/low/code/late-constant.api
# nextcode_ramregions is from
src/lib/compiler/back/low/main/nextcode/nextcode-ramregions.pkg package rgn: Ramregion; # Ramregion is from
src/lib/compiler/back/low/code/ramregion.api
# treecode_extension_intel32 is from
src/lib/compiler/back/low/main/intel32/treecode-extension-intel32.pkg package trx: Treecode_Extension; # Treecode_Extension is from
src/lib/compiler/back/low/treecode/treecode-extension.api
)
: (weak) Treecode_Form # Treecode_Form is from
src/lib/compiler/back/low/treecode/treecode-form.api {
# Export to client packages:
#
package lac = lac; # late_constant is from
src/lib/compiler/back/low/main/nextcode/late-constant.pkg package rgn = rgn; # "rgn" == "ramregion".
package trx = trx; # "trx" == "treecode_extension".
package mi = machine_int; # machine_int is from
src/lib/compiler/back/low/treecode/machine-int.pkg Int_Bitsize = tcp::Int_Bitsize;
Float_Bitsize = tcp::Float_Bitsize;
Var = rkj::Codetemp_Info; # variable
#
Src_Reg = Var; # source variable
Dst_Reg = Var; # Destination variable
Register = Var; # physical register
Note = note::Note;
Cond == tcp::Cond;
Fcond == tcp::Fcond;
Rounding_Mode == tcp::Rounding_Mode;
package d {
Div_Rounding_Mode == tcp::d::Div_Rounding_Mode; # Wrapped in private package 'd' to keep this TO_ZERO and TO_NEGINF from conflicting with preceding ones.
};
Ext == tcp::Ext;
# Statements/effects. These types are parameterized
# by the statement extension type. Unfortunately,
# this has to be made typeagnostic to make it possible
# for mutually recursive type extension definitions to work.
#
Void_Expression
# Assignment:
#
= LOAD_INT_REGISTER (Int_Bitsize, Dst_Reg, Int_Expression)
| LOAD_INT_REGISTER_FROM_FLAGS_REGISTER (Dst_Reg, Flag_Expression)
# flag expressions handle zero/parity/overflow/... flag stuff.
| LOAD_FLOAT_REGISTER (Float_Bitsize, Dst_Reg, Float_Expression)
# Parallel copies:
#
| MOVE_INT_REGISTERS ( Int_Bitsize, List(Dst_Reg), List(Src_Reg))
| MOVE_FLOAT_REGISTERS (Float_Bitsize, List(Dst_Reg), List(Src_Reg))
# Control flow:
#
| GOTO (Int_Expression, Mightbranchto_Labels)
| IF_GOTO (Flag_Expression, lbl::Codelabel)
| CALL { funct: Int_Expression,
targets: Mightbranchto_Labels,
#
defs: List( Expression ),
uses: List( Expression ),
#
region: rgn::Ramregion,
pops: one_word_int::Int
}
| FLOW_TO (Void_Expression, Mightbranchto_Labels)
| RET Mightbranchto_Labels
| IF (Flag_Expression, Void_Expression, Void_Expression)
# Memory update: ea, data:
#
| STORE_INT (Int_Bitsize, Int_Expression, Int_Expression, rgn::Ramregion)
| STORE_FLOAT (Float_Bitsize, Int_Expression, Float_Expression, rgn::Ramregion)
# Control dependence:
#
| REGION (Void_Expression, Ctrl)
| SEQ List( Void_Expression )
# sequencing.
| DEFINE lbl::Codelabel
# Define local label.
| NOTE (Void_Expression, Note)
| EXT Sext
# Hook allowing architecture-specific extensions to Void_Expression.
| LIVE List( Expression )
| DEAD List( Expression )
# RTL operators:
# The following are used internally
# for describing instruction semantics.
# The frontend must not use these.
#
| PHI { preds: List(Int), block: Int }
| ASSIGN (Int_Bitsize, Int_Expression, Int_Expression)
| SOURCE
| SINK
| RTL { hash: Unt,
attributes: Ref( tcp::Attributes ),
e: Void_Expression
}
also
Int_Expression
= CODETEMP_INFO (Int_Bitsize, rkj::Codetemp_Info)
# Size-in-bits of a constant is inferred from context:
#
| LITERAL mi::Machine_Int
| LABEL lbl::Codelabel
| LATE_CONSTANT lac::Late_Constant
| LABEL_EXPRESSION Int_Expression
| NEG (Int_Bitsize, Int_Expression)
| ADD (Int_Bitsize, Int_Expression, Int_Expression)
| SUB (Int_Bitsize, Int_Expression, Int_Expression)
# signed multiplication etc.
| MULS (Int_Bitsize, Int_Expression, Int_Expression)
| DIVS (d::Div_Rounding_Mode, Int_Bitsize, Int_Expression, Int_Expression)
| REMS (d::Div_Rounding_Mode, Int_Bitsize, Int_Expression, Int_Expression)
# unsigned multiplication etc.
| MULU (Int_Bitsize, Int_Expression, Int_Expression)
| DIVU (Int_Bitsize, Int_Expression, Int_Expression)
| REMU (Int_Bitsize, Int_Expression, Int_Expression)
# overflow-trapping versions of above. These are all signed
| NEG_OR_TRAP (Int_Bitsize, Int_Expression)
| ADD_OR_TRAP (Int_Bitsize, Int_Expression, Int_Expression)
| SUB_OR_TRAP (Int_Bitsize, Int_Expression, Int_Expression)
| MULS_OR_TRAP (Int_Bitsize, Int_Expression, Int_Expression)
| DIVS_OR_TRAP (d::Div_Rounding_Mode, Int_Bitsize, Int_Expression, Int_Expression)
# Bit operations:
#
| BITWISE_AND (Int_Bitsize, Int_Expression, Int_Expression)
| BITWISE_OR (Int_Bitsize, Int_Expression, Int_Expression)
| BITWISE_XOR (Int_Bitsize, Int_Expression, Int_Expression)
| BITWISE_EQV (Int_Bitsize, Int_Expression, Int_Expression)
| BITWISE_NOT (Int_Bitsize, Int_Expression)
| RIGHT_SHIFT (Int_Bitsize, Int_Expression, Int_Expression)
# Value, shift.
| RIGHT_SHIFT_U (Int_Bitsize, Int_Expression, Int_Expression)
| LEFT_SHIFT (Int_Bitsize, Int_Expression, Int_Expression)
# Type promotion/conversion:
#
| SIGN_EXTEND (Int_Bitsize, Int_Bitsize, Int_Expression)
# toType, fromType
| ZERO_EXTEND (Int_Bitsize, Int_Bitsize, Int_Expression)
# toType, fromType
| FLOAT_TO_INT (Int_Bitsize, Rounding_Mode, Float_Bitsize, Float_Expression)
# COND (Int_Bitsize, cc, e1, e2):
# Evaluate into either e1 or e2, depending on cc.
# Both e1 and e2 are allowed to be evaluated eagerly.
| CONDITIONAL_LOAD (Int_Bitsize, Flag_Expression, Int_Expression, Int_Expression)
| LOAD (Int_Bitsize, Int_Expression, rgn::Ramregion)
# integer load
| PRED (Int_Expression, Ctrl)
# predication (== control dependence: may-not-hoist-above).
| LET (Void_Expression, Int_Expression)
| REXT (Int_Bitsize, Rext)
# Hook allowing architecture-specific extensions to Int_Expression.
| RNOTE (Int_Expression, Note)
| OP (Int_Bitsize, Operator, List( Int_Expression ))
| ARG (Int_Bitsize, Ref( Rep ), String)
| ATATAT (Int_Bitsize, rkj::Registerkind, Int_Expression)
| PARAM Int
| BITSLICE (Int_Bitsize, List ((Int, Int)), Int_Expression)
| QQQ
also
Operator = OPERATOR tcp::Misc_Op # Never used; support for the RTL system that was never completed.
also
Rep = REPX String # Never used; possibly more RTL-related unfinished stuff.
also
Float_Expression
= CODETEMP_INFO_FLOAT (Float_Bitsize, Src_Reg)
| FLOAD (Float_Bitsize, Int_Expression, rgn::Ramregion)
#
| FADD (Float_Bitsize, Float_Expression, Float_Expression)
| FMUL (Float_Bitsize, Float_Expression, Float_Expression)
| FSUB (Float_Bitsize, Float_Expression, Float_Expression)
| FDIV (Float_Bitsize, Float_Expression, Float_Expression)
| FABS (Float_Bitsize, Float_Expression)
| FNEG (Float_Bitsize, Float_Expression)
| FSQRT (Float_Bitsize, Float_Expression)
| FCONDITIONAL_LOAD (Float_Bitsize, Flag_Expression, Float_Expression, Float_Expression)
| COPY_FLOAT_SIGN (Float_Bitsize, Float_Expression, Float_Expression)
# (size, sign, magnitude)
| INT_TO_FLOAT (Float_Bitsize, Int_Bitsize, Int_Expression)
# From signed integer.
| FLOAT_TO_FLOAT (Float_Bitsize, Float_Bitsize, Float_Expression)
# Float-to-float conversion.
| FPRED (Float_Expression, Ctrl)
| FEXT (Float_Bitsize, Fext)
# Hook allowing architecture-specific extensions to Float_Expression.
| FNOTE (Float_Expression, Note)
also # Controlcode expressions (zero/parity/overflow flags etc) vary wildly from
Flag_Expression # machine to machine so we strictly segregate them.
= CC (tcp::Cond, Src_Reg)
| FCC (tcp::Fcond, Src_Reg)
| TRUE
| FALSE
| NOT Flag_Expression
| AND (Flag_Expression, Flag_Expression)
| OR (Flag_Expression, Flag_Expression)
| XOR (Flag_Expression, Flag_Expression)
| EQV (Flag_Expression, Flag_Expression)
| CMP ( Int_Bitsize, tcp::Cond, Int_Expression, Int_Expression)
| FCMP (Float_Bitsize, tcp::Fcond, Float_Expression, Float_Expression)
| CCNOTE (Flag_Expression, Note)
| CCEXT (Int_Bitsize, Ccext)
# Hook allowing architecture-specific extensions to Flag_Expression.
also
Expression
= FLAG_EXPRESSION Flag_Expression
| INT_EXPRESSION Int_Expression
| FLOAT_EXPRESSION Float_Expression
withtype
Mightbranchto_Labels = List( lbl::Codelabel ) # Control flow info
also Ctrl = Var # Control dependence info
also Ctrls = List( Ctrl )
also Sext = trx::Sx (Void_Expression, Int_Expression, Float_Expression, Flag_Expression) # "s" for "statement" (i.e., void expression).
also Rext = trx::Rx (Void_Expression, Int_Expression, Float_Expression, Flag_Expression) # "r" for "int"
also Fext = trx::Fx (Void_Expression, Int_Expression, Float_Expression, Flag_Expression) # "f" for "float"
also Ccext = trx::Ccx (Void_Expression, Int_Expression, Float_Expression, Flag_Expression) # "cc" for "condition code" -- zero/parity/overflow/... flag stuff.
also Label_Expression = Int_Expression;
# Type abbreviations useful when working with Treecode:
Rewrite_Fns # Rewriting functions.
=
{ void_expression: Void_Expression -> Void_Expression,
int_expression: Int_Expression -> Int_Expression,
float_expression: Float_Expression -> Float_Expression,
flag_expression: Flag_Expression -> Flag_Expression # flag expressions handle zero/parity/overflow/... flag stuff.
};
Fold_Fns(X) # Aggregation functions.
=
{ void_expression: (Void_Expression, X) -> X,
int_expression: (Int_Expression, X) -> X,
float_expression: (Float_Expression, X) -> X,
flag_expression: (Flag_Expression, X) -> X
};
Hash_Fns # Hashing functions
=
{ void_expression: Void_Expression -> Unt,
int_expression: Int_Expression -> Unt,
float_expression: Float_Expression -> Unt,
flag_expression: Flag_Expression -> Unt
};
Eq_Fns # Comparison functions.
=
{ void_expression: (Void_Expression, Void_Expression) -> Bool,
int_expression: (Int_Expression, Int_Expression) -> Bool,
float_expression: (Float_Expression, Float_Expression) -> Bool,
flag_expression: (Flag_Expression, Flag_Expression) -> Bool
};
Prettyprint_Fns # Prettyprinting functions.
=
{ void_expression: Void_Expression -> String,
int_expression: Int_Expression -> String,
float_expression: Float_Expression -> String,
flag_expression: Flag_Expression -> String,
#
dst_reg: (Int_Bitsize, Var) -> String,
src_reg: (Int_Bitsize, Var) -> String
};
}; # package treecode_form_g
end; # stipulate
## COPYRIGHT (c) 1994 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.