## treecode-extension-compiler-intel32-g.pkg
#
# Background comments may be found in:
#
#
src/lib/compiler/back/low/treecode/treecode-extension.api# Compiled by:
#
src/lib/compiler/mythryl-compiler-support-for-intel32.libstipulate
package ext = treecode_extension_intel32; # treecode_extension_intel32 is from
src/lib/compiler/back/low/main/intel32/treecode-extension-intel32.pkg package lem = lowhalf_error_message; # lowhalf_error_message is from
src/lib/compiler/back/low/control/lowhalf-error-message.pkg package rkj = registerkinds_junk; # registerkinds_junk is from
src/lib/compiler/back/low/code/registerkinds-junk.pkgherein
# We are invoked from:
#
#
src/lib/compiler/back/low/main/intel32/backend-lowhalf-intel32-g.pkg #
generic package treecode_extension_compiler_intel32_g (
# =====================================
#
package tcf: Treecode_Form # Treecode_Form is from
src/lib/compiler/back/low/treecode/treecode-form.api where
trx == treecode_extension_intel32;
package mcf: Machcode_Intel32 # Machcode_Intel32 is from
src/lib/compiler/back/low/intel32/code/machcode-intel32.codemade.api where
tcf == tcf; # "tcf" == "treecode_form".
package tcs: Treecode_Codebuffer # Treecode_Codebuffer is from
src/lib/compiler/back/low/treecode/treecode-codebuffer.api where
tcf == 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".
fast_fp: Ref( Bool );
)
: (weak) Treecode_Extension_Compiler # Treecode_Extension_Compiler is from
src/lib/compiler/back/low/treecode/treecode-extension-compiler.api {
# Export to client packages:
#
package tcf = tcf; # "tcf" == "treecode_form".
package mcf = mcf; # "mcf" == "machcode_form" (abstract machine code).
package mcg = mcg; # "mcg" == "machcode_controlflow_graph".
package tcs = tcs; # "tcs" == "treecode_stream".
stipulate
package rgk = mcf::rgk; # "rgk" == "registerkinds".
#
package treecode_extension_sext_compiler_intel32
= treecode_extension_sext_compiler_intel32_g ( # treecode_extension_sext_compiler_intel32_g is from
src/lib/compiler/back/low/intel32/code/treecode-extension-sext-compiler-intel32-g.pkg #
package mcf = mcf; # "mcf" == "machcode_form" (abstract machine code).
package tcs = tcs; # "tcs" == "treecode_stream".
package mcg = mcg; # "mcg" == "machcode_controlflow_graph".
);
herein
Reducer = tcs::Reducer
(
mcf::Machine_Op,
rgk::Codetemplists,
mcf::Operand,
mcf::Addressing_Mode,
mcg::Machcode_Controlflow_Graph
);
fun unimplemented _
=
lem::impossible "treecode-extension-compiler-intel32";
# "Functions compile_sext, compile_rext, etc. are callbacks
# that are responsible for compiling Treecode extensions."
# -- http://www.cs.nyu.edu/leunga/MLRISC/Doc/html/instrsel.html
compile_sext = treecode_extension_sext_compiler_intel32::compile_sext;
compile_rext = unimplemented;
compile_ccext = unimplemented;
fun compile_fext (tcs::REDUCER { reduce_float_expression, put_op, ... }: Reducer)
=
if *fast_fp fast_comp;
else comp;
fi
where
fun comp { e=>(64, float_expression), fd: rkj::Codetemp_Info, notes: List( tcf::Note ) }
=>
{ fun trig (f, foper)
=
{ reduce_float_expression f;
put_op (mcf::funary foper, notes);
};
case float_expression
#
ext::FSINE f => trig (f, mcf::FSIN);
ext::FCOSINE f => trig (f, mcf::FCOS);
ext::FTANGENT f
=>
{ trig (f, mcf::FPTAN);
put_op (mcf::fstpl (mcf::ST (rgk::st 0)), []);
};
esac;
};
comp _ => lem::impossible "compileFext";
end;
fun fast_comp { e=>(64, float_expression), fd: rkj::Codetemp_Info, notes: List( tcf::Note ) }
=>
{ fun freg f
=
{ fx = rkj::intrakind_register_id_of f;
if (fx >= 8 and fx < 32) mcf::FDIRECT f; # hardwired!
else mcf::FPR f;
fi;
};
my (un_op, f)
=
case float_expression
#
ext::FSINE f => (mcf::FSIN, f);
ext::FCOSINE f => (mcf::FCOS, f);
ext::FTANGENT f => (mcf::FPTAN, f);
esac;
put_op ( mcf::funop { fsize => mcf::FP64,
un_op,
src => freg (reduce_float_expression f),
dst => freg fd
},
notes
);
};
fast_comp _ => lem::impossible "treecode-extension-compiler-intel32-g.pkg";
end;
end;
end;
};
end;