Move towards packing args with secondary tags.

compiler/hlds_data.m:
    Add bespoke types to record information about local and remote secondary
    tags. The one for local secondary tags includes the value of the
    primary and secondary tag together, since construct unifications
    need to assign this value, and it is better to compute this once,
    instead leaving the target language compiler to do it, potentially
    many times.

    Use a wrapped uint8 to record primary tag values, and wrapped uints
    to record secondary tag values. The wrap is to prevent any accidental
    confusion with other values. The use of uint8 and uint has two purposes.
    First, using the tighest possible representation. Tags are never negative,
    and primary tags cannot exceed 7. Second, using these types in the compiler
    help us eat our own dogfood; if a change causes a problem affecting
    these types, its bootcheck should fail, alerting us to the problem.

    Add commented-out types and fields that will be needed for packing
    sub-word-sized arguments together with both local and remote secondary
    tags.

compiler/du_type_layout.m:
    Generate references to tags in the new format.

compiler/ml_unify_gen.m:
compiler/unify_gen.m:

compiler/modecheck_goal.m:
    Conform to the changes above.

    Fix an old bug: the inst corresponding to a constant with a primary
    and a local secondary tag is not the secondary tag alone, but both tags
    together.

compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/closure_gen.m:
compiler/disj_gen.m:
compiler/export.m:
compiler/hlds_code_util.m:
compiler/jumpopt.m:
compiler/lco.m:
compiler/llds_out_data.m:
compiler/llds_out_instr.m:
compiler/lookup_switch.m:
compiler/lookup_util.m:
compiler/ml_accurate_gc.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/ml_string_switch.m:
compiler/ml_switch_gen.m:
compiler/ml_tag_switch.m:
compiler/ml_type_gen.m:
compiler/mlds_dump.m:
compiler/mlds_to_c_data.m:
compiler/mlds_to_c_stmt.m:
compiler/opt_debug.m:
compiler/peephole.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/string_switch.m:
compiler/switch_util.m:
compiler/tag_switch.m:
compiler/type_ctor_info.m:
    Conform to the change to hlds_data.m.

    In two places, in rtti_out.m and rtti_to_mlds.m, delete old code
    that was needed only to implement reserved tags, which we have
    stopped supporting a few months ago.

library/uint8.m:
library/uint16.m:
library/uint32.m:
library/uint64.m:
    Add predicates to cast from each of these types to uint.
This commit is contained in:
Zoltan Somogyi
2018-06-06 03:35:20 +02:00
parent 38df1e42a8
commit b06b2621b3
42 changed files with 1019 additions and 573 deletions

View File

@@ -331,8 +331,8 @@ dump_lval(MaybeProcLabel, Lval) = Str :-
;
Lval = field(MT, N, F),
(
MT = yes(T),
string.int_to_string(T, T_str)
MT = yes(Ptag),
T_str = dump_ptag(Ptag)
;
MT = no,
T_str = "no"
@@ -353,6 +353,12 @@ dump_lval(MaybeProcLabel, Lval) = Str :-
Str = "global_var_ref(env_var_ref(" ++ VarName ++ "))"
).
:- func dump_ptag(ptag) = string.
dump_ptag(Ptag) = Str :-
Ptag = ptag(PtagUint8),
Str = string.uint8_to_string(PtagUint8).
dump_lvals(MaybeProcLabel, Lvals) =
dump_lvals_2(MaybeProcLabel, Lvals, "").
@@ -372,11 +378,11 @@ dump_rval(MaybeProcLabel, Rval) = Str :-
Str = "var(" ++ int_to_string(term.var_to_int(Var)) ++ ")"
;
Rval = mkword(T, N),
Str = "mkword(" ++ int_to_string(T) ++ ", " ++
Str = "mkword(" ++ dump_ptag(T) ++ ", " ++
dump_rval(MaybeProcLabel, N) ++ ")"
;
Rval = mkword_hole(T),
Str = "mkword_hole(" ++ int_to_string(T) ++ ")"
Str = "mkword_hole(" ++ dump_ptag(T) ++ ")"
;
Rval = const(C),
Str = dump_const(MaybeProcLabel, C)
@@ -424,8 +430,8 @@ dump_mem_ref(MaybeProcLabel, MemRef) = Str :-
;
MemRef = heap_ref(R, MaybeTag, N),
(
MaybeTag = yes(Tag),
TagString = int_to_string(Tag)
MaybeTag = yes(Ptag),
TagString = dump_ptag(Ptag)
;
MaybeTag = no,
TagString = "unknown_tag"
@@ -595,13 +601,13 @@ dump_rtti_name(RttiName) = Str :-
Str = "du_name_ordered_table"
;
RttiName = type_ctor_du_stag_ordered_table(Ptag),
Str = "du_stag_ordered_table_" ++ int_to_string(Ptag)
Str = "du_stag_ordered_table_" ++ dump_ptag(Ptag)
;
RttiName = type_ctor_du_ptag_ordered_table,
Str = "du_ptag_ordered_table"
;
RttiName = type_ctor_du_ptag_layout(Ptag),
Str = "du_ptag_layout" ++ int_to_string(Ptag)
Str = "du_ptag_layout" ++ dump_ptag(Ptag)
;
RttiName = type_ctor_type_layout,
Str = "type_layout"
@@ -1185,8 +1191,8 @@ dump_instr(MaybeProcLabel, AutoComments, Instr) = Str :-
MaybeTag = no,
T_str = "no"
;
MaybeTag = yes(Tag),
string.int_to_string(Tag, T_str)
MaybeTag = yes(Ptag),
T_str = dump_ptag(Ptag)
),
(
MaybeOffset = no,