## spill-instructions-sparc32-g.pkg
# Compiled by:
#
src/lib/compiler/back/low/sparc32/backend-sparc32.lib# Sparc instructions to emit when spilling an instruction.
### "Flight by machines heavier than air
### is unpractical and insignificant,
### if not utterly impossible."
###
### -- Simon Newcom
### "The demonstration that no possible combination
### of known substances, known forms of machinery
### and known forms of force, can be united in a
### practical machine by which men shall fly along
### distances through the air, seems to the writer as
### complete as it is possible for the demonstration
### to be."
###
### --Simon Newcomb
### "Quite likely the twentieth century
### is destined to see the natural forces
### which will enable us to fly from
### continent to continent with a speed
### far exceeding that of a bird."
###
### -- Simon Newcomb
# We are invoked from:
#
#
src/lib/compiler/back/low/main/sparc32/backend-lowhalf-sparc32.pkgstipulate
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
generic package spill_instructions_sparc32_g (
# ============================
#
mcf: Machcode_Sparc32 # Machcode_Sparc32 is from
src/lib/compiler/back/low/sparc32/code/machcode-sparc32.codemade.api )
: (weak) Architecture_Specific_Spill_Instructions # Architecture_Specific_Spill_Instructions is from
src/lib/compiler/back/low/regor/arch-spill-instruction.api {
# Export to client packages:
#
package mcf = mcf; # "mcf" == "machcode_form" (abstract machine code).
stipulate
package rgk = mcf::rgk; # "rgk" == "registerkinds".
package rewrite
=
instructions_rewrite_sparc32_g ( # instructions_rewrite_sparc32_g is from
src/lib/compiler/back/low/sparc32/regor/instructions-rewrite-sparc32-g.pkg mcf
);
herein
fun error msg
=
lem::error ("spill_instructions_sparc32_g", msg);
fun store_at_ea rkj::INT_REGISTER (reg, mcf::DISPLACE { base, disp, ramregion } )
=>
mcf::store { s=>mcf::ST, r=>base, i=>mcf::LAB disp, d=>reg, ramregion };
store_at_ea rkj::FLOAT_REGISTER (reg, mcf::DISPLACE { base, disp, ramregion } )
=>
mcf::fstore { s=>mcf::STDF, r=>base, i=>mcf::LAB disp, d=>reg, ramregion };
store_at_ea _ _
=>
error "storeAtEA";
end;
fun load_from_ea rkj::INT_REGISTER (reg, mcf::DISPLACE { base, disp, ramregion } )
=>
mcf::load { l=>mcf::LD, d=>reg, r=>base, i=>mcf::LAB disp, ramregion };
load_from_ea rkj::FLOAT_REGISTER (reg, mcf::DISPLACE { base, disp, ramregion } )
=>
mcf::fload { l=>mcf::LDDF, d=>reg, r=>base, i=>mcf::LAB disp, ramregion };
load_from_ea _ _
=>
error "loadFromEA";
end;
fun spill_to_ea ck reg_ea
=
{ code => [store_at_ea ck reg_ea], prohibitions => [], make_reg=>NULL };
fun reload_from_ea ck reg_ea
=
{ code => [load_from_ea ck reg_ea], prohibitions => [], make_reg=>NULL };
# Spill a register to spill_loc
#
fun spill_r (instruction, reg, spill_loc)
=
{ new_r = rgk::make_int_codetemp_info ();
instruction' = rewrite::rewrite_def (instruction, reg, new_r);
{ code => [instruction', store_at_ea rkj::INT_REGISTER (new_r, spill_loc)],
prohibitions => [new_r],
make_reg=>THE new_r
};
};
fun spill_f (instruction, reg, spill_loc)
=
{ new_r = rgk::make_float_codetemp_info ();
#
instruction' = rewrite::frewrite_def (instruction, reg, new_r);
{ code => [instruction', store_at_ea rkj::FLOAT_REGISTER (new_r, spill_loc)],
prohibitions => [new_r],
make_reg=>THE new_r
};
};
# Reload a register from spill_loc
#
fun reload_r (instruction, reg, spill_loc)
=
{ new_r = rgk::make_int_codetemp_info ();
instruction' = rewrite::rewrite_use (instruction, reg, new_r);
{ code => [load_from_ea rkj::INT_REGISTER (new_r, spill_loc), instruction'],
prohibitions => [new_r],
make_reg=>THE new_r
};
};
fun reload_f (instruction, reg, spill_loc)
=
{ new_r = rgk::make_float_codetemp_info ();
#
instruction' = rewrite::frewrite_use (instruction, reg, new_r);
{ code => [load_from_ea rkj::FLOAT_REGISTER (new_r, spill_loc), instruction'],
prohibitions => [new_r],
make_reg=>THE new_r
};
};
fun spill rkj::INT_REGISTER => spill_r;
spill rkj::FLOAT_REGISTER => spill_f;
spill _ => error "spill";
end;
fun reload rkj::INT_REGISTER => reload_r;
reload rkj::FLOAT_REGISTER => reload_f;
reload _ => error "reload";
end;
end;
};
end;
## COPYRIGHT (c) 2002 Bell Labs, Lucent Technologies
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.