Skip to content

Commit

Permalink
Use cheaper way to access register allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
jnthn committed Sep 5, 2021
1 parent 1116b39 commit b14734f
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions src/vm/moar/Perl6/Ops.nqp
Expand Up @@ -72,16 +72,16 @@ $ops.add_hll_op('Raku', 'p6store', -> $qastcomp, $op {
my $cont_res := $qastcomp.as_mast($op[0], :want($MVM_reg_obj));
my $value_res := $qastcomp.as_mast($op[1], :want($MVM_reg_obj));

my $iscont_reg := $*REGALLOC.fresh_i();
my $decont_reg := $*REGALLOC.fresh_o();
my $iscont_reg := $qastcomp.regalloc.fresh_i();
my $decont_reg := $qastcomp.regalloc.fresh_o();
my $no_cont_lbl := MAST::Label.new();
my $done_lbl := MAST::Label.new();
MAST::Op.new( :op('iscont'), $iscont_reg, $cont_res.result_reg );
MAST::Op.new( :op('unless_i'), $iscont_reg, $no_cont_lbl );
$*REGALLOC.release_register($iscont_reg, $MVM_reg_int64);
$qastcomp.regalloc.release_register($iscont_reg, $MVM_reg_int64);
MAST::Op.new( :op('decont'), $decont_reg, $value_res.result_reg );
MAST::Op.new( :op('assign'), $cont_res.result_reg, $decont_reg );
$*REGALLOC.release_register($decont_reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($decont_reg, $MVM_reg_obj);
MAST::Op.new( :op('goto'), $done_lbl );

$*MAST_FRAME.add-label($no_cont_lbl);
Expand All @@ -97,13 +97,13 @@ $ops.add_hll_op('Raku', 'p6store', -> $qastcomp, $op {
});
$ops.add_hll_op('Raku', 'p6definite', -> $qastcomp, $op {
my $value_res := $qastcomp.as_mast($op[0], :want($MVM_reg_obj));
my $tmp_reg := $*REGALLOC.fresh_i();
my $res_reg := $*REGALLOC.fresh_o();
my $tmp_reg := $qastcomp.regalloc.fresh_i();
my $res_reg := $qastcomp.regalloc.fresh_o();
MAST::Op.new( :op('decont'), $res_reg, $value_res.result_reg );
MAST::Op.new( :op('isconcrete'), $tmp_reg, $res_reg );
MAST::Op.new( :op('hllbool'), $res_reg, $tmp_reg );
$*REGALLOC.release_register($value_res.result_reg, $MVM_reg_obj);
$*REGALLOC.release_register($tmp_reg, $MVM_reg_int64);
$qastcomp.regalloc.release_register($value_res.result_reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($tmp_reg, $MVM_reg_int64);
MAST::InstructionList.new($res_reg, $MVM_reg_obj)
});
$ops.add_hll_op('Raku', 'p6capturelex', -> $qastcomp, $op {
Expand Down Expand Up @@ -147,32 +147,32 @@ $ops.add_hll_moarop_mapping('Raku', 'p6setfirstflag', 'p6setfirstflag');
$ops.add_hll_moarop_mapping('Raku', 'p6takefirstflag', 'p6takefirstflag');
$ops.add_hll_op('Raku', 'p6return', :!inlinable, -> $qastcomp, $op {
my $value_res := $qastcomp.as_mast($op[0], :want($MVM_reg_obj));
my $ex_reg := $*REGALLOC.fresh_o();
my $ex_reg := $qastcomp.regalloc.fresh_o();
MAST::Op.new( :op('exception'), $ex_reg );
MAST::Op.new( :op('exreturnafterunwind'), $ex_reg );
$*REGALLOC.release_register($ex_reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($ex_reg, $MVM_reg_obj);
MAST::Op.new( :op('return_o'), $value_res.result_reg );
MAST::InstructionList.new($value_res.result_reg, $MVM_reg_obj)
});
$ops.add_hll_op('Raku', 'p6getouterctx', -> $qastcomp, $op {
my $code_res := $qastcomp.as_mast($op[0], :want($MVM_reg_obj));
my uint $callsite_id := $*MAST_FRAME.callsites.get_callsite_id_from_args(
[$op[0]], [$code_res]);
$*REGALLOC.release_register($code_res.result_reg, $MVM_reg_obj);
my $res_reg := $*REGALLOC.fresh_o();
$qastcomp.regalloc.release_register($code_res.result_reg, $MVM_reg_obj);
my $res_reg := $qastcomp.regalloc.fresh_o();
MAST::Op.new( :op('decont'), $res_reg, $code_res.result_reg);
op_dispatch_o($res_reg, 'raku-get-code-outer-ctx', $callsite_id, [$res_reg]);
MAST::InstructionList.new($res_reg, $MVM_reg_obj)
});
$ops.add_hll_moarop_mapping('nqp', 'p6captureouters2', 'p6captureouters', 0);
$ops.add_hll_op('Raku', 'p6argvmarray', -> $qastcomp, $op {
my $res_reg := $*REGALLOC.fresh_o();
my $res_reg := $qastcomp.regalloc.fresh_o();
MAST::Op.new( :op('param_sp'), $res_reg,
MAST::IVal.new( :value(0), :size(16) ));
my $i_reg := $*REGALLOC.fresh_i();
my $n_reg := $*REGALLOC.fresh_i();
my $cmp_reg := $*REGALLOC.fresh_i();
my $tmp_reg := $*REGALLOC.fresh_o();
my $i_reg := $qastcomp.regalloc.fresh_i();
my $n_reg := $qastcomp.regalloc.fresh_i();
my $cmp_reg := $qastcomp.regalloc.fresh_i();
my $tmp_reg := $qastcomp.regalloc.fresh_o();
my $lbl_next := MAST::Label.new();
my $lbl_done := MAST::Label.new();
MAST::Op.new( :op('elems'), $n_reg, $res_reg );
Expand All @@ -189,10 +189,10 @@ $ops.add_hll_op('Raku', 'p6argvmarray', -> $qastcomp, $op {
MAST::Op.new( :op('add_i'), $i_reg, $i_reg, $cmp_reg );
MAST::Op.new( :op('goto'), $lbl_next );
$*MAST_FRAME.add-label($lbl_done);
$*REGALLOC.release_register($i_reg, $MVM_reg_int64);
$*REGALLOC.release_register($n_reg, $MVM_reg_int64);
$*REGALLOC.release_register($cmp_reg, $MVM_reg_int64);
$*REGALLOC.release_register($tmp_reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($i_reg, $MVM_reg_int64);
$qastcomp.regalloc.release_register($n_reg, $MVM_reg_int64);
$qastcomp.regalloc.release_register($cmp_reg, $MVM_reg_int64);
$qastcomp.regalloc.release_register($tmp_reg, $MVM_reg_obj);
MAST::InstructionList.new($res_reg, $MVM_reg_obj)
});
$ops.add_hll_op('Raku', 'p6bindattrinvres', -> $qastcomp, $op {
Expand All @@ -217,11 +217,11 @@ $ops.add_hll_op('Raku', 'p6bindattrinvres', -> $qastcomp, $op {
my $nam_res := $qastcomp.as_mast($name, :want($MVM_reg_str));
MAST::Op.new( :op('bindattrs_o'), $inv_res.result_reg,
$ch_res.result_reg, $nam_res.result_reg, $val_res.result_reg);
$*REGALLOC.release_register($nam_res.result_reg, $MVM_reg_str);
$qastcomp.regalloc.release_register($nam_res.result_reg, $MVM_reg_str);
}

$*REGALLOC.release_register($ch_res.result_reg, $MVM_reg_obj);
$*REGALLOC.release_register($val_res.result_reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($ch_res.result_reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($val_res.result_reg, $MVM_reg_obj);
MAST::InstructionList.new($inv_res.result_reg, $MVM_reg_obj)
});
$ops.add_hll_moarop_mapping('Raku', 'p6staticouter', 'p6staticouter');
Expand All @@ -241,7 +241,7 @@ $ops.add_hll_op('Raku', 'p6sink', -> $qastcomp, $op {
my uint $callsite_id := $*MAST_FRAME.callsites.get_callsite_id_from_args(
[$op[0]], [$sinkee_res]);
op_dispatch_v('raku-sink', $callsite_id, [$sinkee_res.result_reg]);
$*REGALLOC.release_register($sinkee_res.result_reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($sinkee_res.result_reg, $MVM_reg_obj);
MAST::InstructionList.new(MAST::VOID, $MVM_reg_void);
}
else {
Expand Down Expand Up @@ -282,10 +282,10 @@ $ops.add_hll_op('Raku', 'defor', -> $qastcomp, $op {
# Boxing and unboxing configuration.
sub boxer($kind, $box_op, $type_op) {
-> $qastcomp, $reg {
my $res_reg := $*REGALLOC.fresh_register($MVM_reg_obj);
my $res_reg := $qastcomp.regalloc.fresh_register($MVM_reg_obj);
MAST::Op.new( :op($type_op), $res_reg );
MAST::Op.new( :op($box_op), $res_reg, $reg, $res_reg );
$*REGALLOC.release_register($reg, $kind);
$qastcomp.regalloc.release_register($reg, $kind);
MAST::InstructionList.new($res_reg, $MVM_reg_obj)
}
}
Expand All @@ -294,34 +294,34 @@ $ops.add_hll_box('Raku', $MVM_reg_num64, boxer($MVM_reg_num64, 'box_n', 'hllboxt
$ops.add_hll_box('Raku', $MVM_reg_str, boxer($MVM_reg_str, 'box_s', 'hllboxtype_s'));
$ops.add_hll_box('Raku', $MVM_reg_uint64, boxer($MVM_reg_uint64, 'box_u', 'hllboxtype_i'));
QAST::MASTOperations.add_hll_unbox('Raku', $MVM_reg_int64, -> $qastcomp, $reg {
my $res_reg := $*REGALLOC.fresh_register($MVM_reg_int64);
my $res_reg := $qastcomp.regalloc.fresh_register($MVM_reg_int64);
MAST::Op.new( :op('decont_i'), $res_reg, $reg );
$*REGALLOC.release_register($reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($reg, $MVM_reg_obj);
MAST::InstructionList.new($res_reg, $MVM_reg_int64)
});
QAST::MASTOperations.add_hll_unbox('Raku', $MVM_reg_num64, -> $qastcomp, $reg {
my $res_reg := $*REGALLOC.fresh_register($MVM_reg_num64);
my $res_reg := $qastcomp.regalloc.fresh_register($MVM_reg_num64);
MAST::Op.new( :op('decont_n'), $res_reg, $reg );
$*REGALLOC.release_register($reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($reg, $MVM_reg_obj);
MAST::InstructionList.new($res_reg, $MVM_reg_num64)
});
QAST::MASTOperations.add_hll_unbox('Raku', $MVM_reg_str, -> $qastcomp, $reg {
my $res_reg := $*REGALLOC.fresh_register($MVM_reg_str);
my $res_reg := $qastcomp.regalloc.fresh_register($MVM_reg_str);
MAST::Op.new( :op('decont_s'), $res_reg, $reg );
$*REGALLOC.release_register($reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($reg, $MVM_reg_obj);
MAST::InstructionList.new($res_reg, $MVM_reg_str)
});
QAST::MASTOperations.add_hll_unbox('Raku', $MVM_reg_uint64, -> $qastcomp, $reg {
my $res_reg := $*REGALLOC.fresh_register($MVM_reg_uint64);
my $res_reg := $qastcomp.regalloc.fresh_register($MVM_reg_uint64);
MAST::Op.new( :op('decont_u'), $res_reg, $reg );
$*REGALLOC.release_register($reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($reg, $MVM_reg_obj);
MAST::InstructionList.new($res_reg, $MVM_reg_uint64)
});

# Signature binding related bits.
our $Binder;
$ops.add_hll_op('Raku', 'p6bindsig', :!inlinable, -> $qastcomp, $op {
my $isnull_result := $*REGALLOC.fresh_i();
my $isnull_result := $qastcomp.regalloc.fresh_i();
my $dont_return_lbl := MAST::Label.new();
my $bind_res := $qastcomp.as_mast(
QAST::Op.new(
Expand All @@ -335,8 +335,8 @@ $ops.add_hll_op('Raku', 'p6bindsig', :!inlinable, -> $qastcomp, $op {
MAST::Op.new( :op('return_o'), $bind_res.result_reg );
$*MAST_FRAME.add-label($dont_return_lbl);

$*REGALLOC.release_register($bind_res.result_reg, $MVM_reg_obj);
$*REGALLOC.release_register($isnull_result, $MVM_reg_int64);
$qastcomp.regalloc.release_register($bind_res.result_reg, $MVM_reg_obj);
$qastcomp.regalloc.release_register($isnull_result, $MVM_reg_int64);
MAST::InstructionList.new(MAST::VOID, $MVM_reg_void);
});
$ops.add_hll_op('Raku', 'p6trybindsig', :!inlinable, -> $qastcomp, $op {
Expand Down

0 comments on commit b14734f

Please sign in to comment.