mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-18 15:26:31 +00:00
unify_gen: Whenever we do a test of a variable against a non-constant functor, we now try to turn it into a negated test on a constant functor. This is possible if these two functors are the only ones. code_aux: Added an extra predicate to look up type definitions to make the previous change easier. llds, code_gen, opt_util, opt_debug, frameopt, jumpopt, peephole: Added a boolean argument to do_succeed to say whether the nondet frame should be discarded on success or not. The default is no, but peephole has an optimization that tries to turn on this flag. optimize, value_number, vn*: Restructured the top level of value numbering as part of an effort to identify blocks that could be optimized further given our knowledge that the contents of e.g. stackvars is also in registers when we jump to those blocks. Redone the interface between value_number and frameopt to allow value_number to be iterated, which is necessary to take advantage of the previously mentioned capability. Threated the I/O state through the relevant predicates; value numbering doesn't use non-logical I/O any more.
81 lines
2.0 KiB
Mathematica
81 lines
2.0 KiB
Mathematica
%-----------------------------------------------------------------------------%
|
|
|
|
% Vn_type.nl - types for value numbering.
|
|
|
|
% Author: zs.
|
|
|
|
%-----------------------------------------------------------------------------%
|
|
|
|
:- module vn_type.
|
|
|
|
:- interface.
|
|
:- import_module llds, bintree_set, list, std_util.
|
|
|
|
:- type vn == int.
|
|
|
|
:- type vnlval ---> vn_reg(reg)
|
|
; vn_stackvar(int)
|
|
; vn_framevar(int)
|
|
; vn_succip
|
|
; vn_maxfr
|
|
; vn_curfr
|
|
; vn_redoip(vn)
|
|
; vn_hp
|
|
; vn_sp
|
|
; vn_field(tag, vn, vn) % lval
|
|
; vn_temp(int).
|
|
|
|
% these lvals do not have vnlval parallels
|
|
% lvar(var)
|
|
|
|
:- type vnrval ---> vn_origlval(vnlval)
|
|
; vn_mkword(tag, vn) % rval
|
|
; vn_const(rval_const)
|
|
; vn_create(tag, list(maybe(rval)), int)
|
|
; vn_unop(unary_op, vn) % rval
|
|
; vn_binop(binary_op, vn, vn). % rval, rval
|
|
|
|
% these rvals do not have vnrval parallels
|
|
% var(var)
|
|
|
|
:- type vn_src ---> src_ctrl(int)
|
|
; src_liveval(vnlval)
|
|
; src_access(vnlval)
|
|
; src_vn(int).
|
|
|
|
:- type vn_node ---> node_shared(vn)
|
|
; node_lval(vnlval)
|
|
; node_origlval(vnlval)
|
|
; node_ctrl(int).
|
|
|
|
:- type vn_instr ---> vn_livevals(lvalset)
|
|
; vn_call(code_addr, code_addr, code_addr,
|
|
list(liveinfo))
|
|
; vn_call_closure(bool, code_addr, list(liveinfo))
|
|
; vn_mkframe(string, int, code_addr)
|
|
; vn_modframe(code_addr)
|
|
; vn_label(label)
|
|
; vn_goto(code_addr, code_addr)
|
|
; vn_computed_goto(vn, list(label))
|
|
; vn_if_val(vn, code_addr)
|
|
; vn_mark_hp(vnlval)
|
|
; vn_restore_hp(vn)
|
|
; vn_incr_sp(int)
|
|
; vn_decr_sp(int).
|
|
|
|
:- type parentry == pair(lval, list(rval)).
|
|
:- type parallel ---> parallel(label, label, list(parentry)).
|
|
|
|
:- type livemap == map(label, lvalset).
|
|
:- type lvalset == bintree_set(lval).
|
|
:- type vnlvalset == bintree_set(vnlval).
|
|
|
|
:- type ctrlmap == map(int, vn_instr).
|
|
:- type flushmap == map(int, flushmapentry).
|
|
:- type flushmapentry == map(vnlval, vn).
|
|
:- type parmap == map(int, list(parallel)).
|
|
|
|
:- type vn_ctrl_tuple ---> tuple(int, ctrlmap, flushmap, int, parmap).
|
|
|
|
% There is no implementation section.
|