[m-dev.] diff: improve speed of comparison of LLDS labels
Simon Taylor
stayl at cs.mu.OZ.AU
Tue Oct 31 13:16:58 AEDT 2000
Estimated hours taken: 0.25
compiler/llds.m:
compiler/*.m:
Reverse the order of the arguments of internal labels
to make comparison more efficient (the proc_labels will
almost always be equal). This change reduces the time
taken by `mmc -C make_hlds' by 1-2%.
Index: basic_block.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/basic_block.m,v
retrieving revision 1.10
diff -u -u -r1.10 basic_block.m
--- basic_block.m 2000/08/11 08:18:53 1.10
+++ basic_block.m 2000/10/28 08:02:23
@@ -81,7 +81,7 @@
C1 = C0
;
counter__allocate(N, C0, C1),
- Label = local(ProcLabel, N),
+ Label = local(N, ProcLabel),
LabelInstr = label(Label) - "",
RestInstrs = [OrigInstr0 | OrigInstrs0]
),
Index: code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_util.m,v
retrieving revision 1.126
diff -u -u -r1.126 code_util.m
--- code_util.m 2000/10/13 04:04:20 1.126
+++ code_util.m 2000/10/30 03:42:19
@@ -272,7 +272,7 @@
code_util__make_internal_label(ModuleInfo, PredId, ProcId, LabelNum, Label) :-
code_util__make_proc_label(ModuleInfo, PredId, ProcId, ProcLabel),
- Label = local(ProcLabel, LabelNum).
+ Label = local(LabelNum, ProcLabel).
code_util__make_proc_label(ModuleInfo, PredId, ProcId, ProcLabel) :-
RttiProcLabel = rtti__make_proc_label(ModuleInfo, PredId, ProcId),
@@ -379,7 +379,7 @@
CodeAddr = imported(ProcLabel)
).
-code_util__extract_proc_label_from_label(local(ProcLabel, _), ProcLabel).
+code_util__extract_proc_label_from_label(local(_, ProcLabel), ProcLabel).
code_util__extract_proc_label_from_label(c_local(ProcLabel), ProcLabel).
code_util__extract_proc_label_from_label(local(ProcLabel), ProcLabel).
code_util__extract_proc_label_from_label(exported(ProcLabel), ProcLabel).
Index: frameopt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/frameopt.m,v
retrieving revision 1.77
diff -u -u -r1.77 frameopt.m
--- frameopt.m 2000/10/13 04:04:26 1.77
+++ frameopt.m 2000/10/28 08:02:25
@@ -231,7 +231,7 @@
Instrs = [Instr0 | Instrs1]
;
counter__allocate(N, C0, C1),
- NewLabel = local(ProcLabel, N),
+ NewLabel = local(N, ProcLabel),
NewInstr = label(NewLabel) - "",
divide_into_basic_blocks(Instrs0, ProcLabel,
C1, Instrs1, C),
@@ -295,7 +295,7 @@
Instrs2 = Instrs1
;
counter__allocate(N, C0, C1),
- NewLabel = local(ProcLabel, N),
+ NewLabel = local(N, ProcLabel),
NewInstr = label(NewLabel) - "",
Instrs2 = [NewInstr | Instrs1]
),
@@ -324,7 +324,7 @@
[], no, ordinary(Needs)),
MaybeTailInfo = yes(TailInfo - Label),
counter__allocate(N, C0, C1),
- NewLabel = local(ProcLabel, N),
+ NewLabel = local(N, ProcLabel),
NewInstr = label(NewLabel) - "",
LabelledBlock = [NewInstr | Teardown],
TeardownLabel = NewLabel,
@@ -1088,7 +1088,7 @@
% stack frame, so we must create one.
counter__allocate(N, C1, C2),
- NewLabel = local(ProcLabel, N),
+ NewLabel = local(N, ProcLabel),
MaybeFallThrough = yes(NewLabel),
MaybeNewLabel = yes(NewLabel),
SetupCode = [
@@ -1191,7 +1191,7 @@
ParMap = ParMap0
;
counter__allocate(N, C0, C),
- NewParallel = local(ProcLabel, N),
+ NewParallel = local(N, ProcLabel),
Label = NewParallel,
map__det_insert(ParMap0, Label0, NewParallel, ParMap)
).
Index: jumpopt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/jumpopt.m,v
retrieving revision 1.56
diff -u -u -r1.56 jumpopt.m
--- jumpopt.m 2000/10/26 05:36:19 1.56
+++ jumpopt.m 2000/10/28 08:02:26
@@ -308,7 +308,7 @@
not set__member(RetLabel, LayoutLabels)
->
counter__allocate(LabelNum, Counter0, Counter1),
- NewLabel = local(ProcLabel, LabelNum),
+ NewLabel = local(LabelNum, ProcLabel),
NewInstrs = [
if_val(binop(ne, lval(curfr), lval(maxfr)),
label(NewLabel))
Index: llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.267
diff -u -u -r1.267 llds.m
--- llds.m 2000/10/16 01:33:32 1.267
+++ llds.m 2000/10/30 03:42:44
@@ -923,7 +923,7 @@
; f. % floating point regs
:- type label
- ---> local(proc_label, int) % not proc entry; internal to a
+ ---> local(int, proc_label) % not proc entry; internal to a
% procedure
; c_local(proc_label) % proc entry; internal to a C module
; local(proc_label) % proc entry; internal to a Mercury
Index: llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.160
diff -u -u -r1.160 llds_out.m
--- llds_out.m 2000/10/26 03:27:55 1.160
+++ llds_out.m 2000/10/30 04:04:03
@@ -1122,7 +1122,7 @@
get_proc_label(exported(ProcLabel)) = ProcLabel.
get_proc_label(local(ProcLabel)) = ProcLabel.
get_proc_label(c_local(ProcLabel)) = ProcLabel.
-get_proc_label(local(ProcLabel, _)) = ProcLabel.
+get_proc_label(local(_, ProcLabel)) = ProcLabel.
:- func get_defining_module_name(proc_label) = module_name.
get_defining_module_name(proc(ModuleName, _, _, _, _, _)) = ModuleName.
@@ -3421,9 +3421,9 @@
io__write_string("LABEL("),
output_label(c_local(ProcLabel)),
io__write_string(")").
-output_label_as_code_addr(local(ProcLabel, N)) -->
+output_label_as_code_addr(local(N, ProcLabel)) -->
io__write_string("LABEL("),
- output_label(local(ProcLabel, N)),
+ output_label(local(N, ProcLabel)),
io__write_string(")").
:- pred output_label_list(list(label), io__state, io__state).
@@ -3474,9 +3474,9 @@
io__write_string("Define_local("),
output_label(c_local(ProcLabel)),
io__write_string(");\n").
-output_label_defn(local(ProcLabel, Num)) -->
+output_label_defn(local(Num, ProcLabel)) -->
io__write_string("Define_label("),
- output_label(local(ProcLabel, Num)),
+ output_label(local(Num, ProcLabel)),
io__write_string(");\n").
% Note that the suffixes _l and _iN used to be interpreted by mod2c,
@@ -3501,7 +3501,7 @@
llds_out__get_proc_label(ProcLabel, AddPrefix, ProcLabelStr).
llds_out__get_label(c_local(ProcLabel), AddPrefix, ProcLabelStr) :-
llds_out__get_proc_label(ProcLabel, AddPrefix, ProcLabelStr).
-llds_out__get_label(local(ProcLabel, Num), AddPrefix, LabelStr) :-
+llds_out__get_label(local(Num, ProcLabel), AddPrefix, LabelStr) :-
llds_out__get_proc_label(ProcLabel, AddPrefix, ProcLabelStr),
string__int_to_string(Num, NumStr),
string__append("_i", NumStr, NumSuffix),
Index: opt_debug.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/opt_debug.m,v
retrieving revision 1.107
diff -u -u -r1.107 opt_debug.m
--- opt_debug.m 2000/10/13 04:05:03 1.107
+++ opt_debug.m 2000/10/30 03:44:54
@@ -863,7 +863,7 @@
opt_debug__dump_code_addrs(Addrs, A2_str),
string__append_list([" ", A_str, A2_str], Str).
-opt_debug__dump_label(local(ProcLabel, N), Str) :-
+opt_debug__dump_label(local(N, ProcLabel), Str) :-
opt_debug__dump_proclabel(ProcLabel, P_str),
string__int_to_string(N, N_str),
string__append_list([P_str, "_", N_str], Str).
Index: opt_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/opt_util.m,v
retrieving revision 1.110
diff -u -u -r1.110 opt_util.m
--- opt_util.m 2000/10/13 04:05:05 1.110
+++ opt_util.m 2000/10/30 03:45:06
@@ -1470,7 +1470,7 @@
% that uses a temp var without defining it.
opt_util__count_temps_rval(_, R, R, F, F).
-opt_util__format_label(local(ProcLabel, _), Str) :-
+opt_util__format_label(local(_, ProcLabel), Str) :-
opt_util__format_proclabel(ProcLabel, Str).
opt_util__format_label(c_local(ProcLabel), Str) :-
opt_util__format_proclabel(ProcLabel, Str).
Index: transform_llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/transform_llds.m,v
retrieving revision 1.6
diff -u -u -r1.6 transform_llds.m
--- transform_llds.m 2000/08/11 08:19:19 1.6
+++ transform_llds.m 2000/10/28 08:02:32
@@ -171,8 +171,8 @@
{ Index = binop((-), Rval, const(int_const(Mid))) },
{ Test = binop((>=), Rval, const(int_const(Mid))) },
- { ElseAddr = label(local(ProcLabel, N)) },
- { ElseLabel = label(local(ProcLabel, N)) - ""},
+ { ElseAddr = label(local(N, ProcLabel)) },
+ { ElseLabel = label(local(N, ProcLabel)) - ""},
{ IfInstr = if_val(Test, ElseAddr ) - "Binary search"},
{ ThenInstr = computed_goto(Rval, Start) - "Then section" },
Index: value_number.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/value_number.m,v
retrieving revision 1.106
diff -u -u -r1.106 value_number.m
--- value_number.m 2000/10/13 04:05:20 1.106
+++ value_number.m 2000/10/28 08:02:33
@@ -141,7 +141,7 @@
( Uinstr0 = if_val(Test, TrueAddr) ->
( ( TrueAddr = do_redo ; TrueAddr = do_fail ) ->
counter__allocate(N0, C0, C1),
- MaybeBeforeLabel = yes(local(ProcLabel, N0))
+ MaybeBeforeLabel = yes(local(N0, ProcLabel))
;
MaybeBeforeLabel = no,
C1 = C0
@@ -152,7 +152,7 @@
C2 = C1
;
counter__allocate(N1, C1, C2),
- FalseLabel = local(ProcLabel, N1),
+ FalseLabel = local(N1, ProcLabel),
MaybeNewFalseLabel = yes(FalseLabel)
),
FalseAddr = label(FalseLabel),
@@ -179,7 +179,7 @@
; Uinstr0 = incr_hp(_, _, _, _) ->
( SeenAlloc = yes ->
counter__allocate(N0, C0, C1),
- NewLabel = local(ProcLabel, N0),
+ NewLabel = local(N0, ProcLabel),
value_number__prepare_for_vn(Instrs0, ProcLabel,
yes, ContainsReconstruction,
AllocSet0, BreakSet, C1, C, Instrs1),
@@ -219,10 +219,10 @@
)
->
counter__allocate(N0, C0, C1),
- BeforeLabel = local(ProcLabel, N0),
+ BeforeLabel = local(N0, ProcLabel),
BeforeInstr = label(BeforeLabel) - "vn stack ctrl before label",
counter__allocate(N1, C1, C2),
- AfterLabel = local(ProcLabel, N1),
+ AfterLabel = local(N1, ProcLabel),
AfterInstr = label(AfterLabel) - "vn stack ctrl after label",
value_number__prepare_for_vn(Instrs0, ProcLabel, yes,
ContainsReconstruction, AllocSet, BreakSet0,
@@ -245,7 +245,7 @@
ProcLabel, C0, C, Instrs) :-
( Test = binop(and, Test1, Test2) ->
counter__allocate(N0, C0, C1),
- NewLabel = local(ProcLabel, N0),
+ NewLabel = local(N0, ProcLabel),
NewAddr = label(NewLabel),
value_number__breakup_complex_if(Test1, NewAddr, FalseAddr,
NewAddr, ProcLabel, C1, C2, Instrs1),
@@ -254,7 +254,7 @@
list__append(Instrs1, [label(NewLabel) - "" | Instrs2], Instrs)
; Test = binop(or, Test1, Test2) ->
counter__allocate(N0, C0, C1),
- NewLabel = local(ProcLabel, N0),
+ NewLabel = local(N0, ProcLabel),
NewAddr = label(NewLabel),
value_number__breakup_complex_if(Test1, TrueAddr, NewAddr,
NewAddr, ProcLabel, C1, C2, Instrs1),
Index: vn_block.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_block.m,v
retrieving revision 1.66
diff -u -u -r1.66 vn_block.m
--- vn_block.m 2000/10/13 04:05:24 1.66
+++ vn_block.m 2000/10/28 08:02:34
@@ -731,9 +731,9 @@
C = C0,
Parallels = []
;
- ( Label = local(ProcLabel, _) ->
+ ( Label = local(_, ProcLabel) ->
counter__allocate(N, C0, C),
- NewLabel = local(ProcLabel, N),
+ NewLabel = local(N, ProcLabel),
Parallels = [parallel(Label, NewLabel,
ParEntries)]
;
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list