[m-dev.] for review: another dependency restructuring change
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Jul 9 15:41:50 AEST 1999
A lot of the diff for this change is utterly trivial.
I've included the most interesting parts first.
--------------------
Estimated hours taken: 2
Some more changes to minimize the complexity of the intermodule dependencies.
In particular, ensure that bytecode.m does not need to import llds.m.
compiler/llds.m:
compiler/builtin_ops.m:
Move the definitions of the unary_op and binary_op types into
a new module `builtin_ops'. These types are used by three of the
different back-ends (bytecode, llds, and mlds) and therefore deserve
to be in their own module.
compiler/bytecode.m:
Define a type `byte_reg_type' and use that instead of llds__reg_type.
Delete the import of module llds.
compiler/notes/compiler_design.html:
Document the new module builtin_ops.
compiler/rl_exprn.m:
Add a comment explaining why we need to import llds (and builtin_ops).
compiler/base_type_layout.m:
compiler/bytecode.m:
compiler/code_util.m:
compiler/dense_switch.m:
compiler/ite_gen.m:
compiler/jumpopt.m:
compiler/llds_out.m:
compiler/lookup_switch.m:
compiler/middle_rec.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/rl_exprn.m:
compiler/string_switch.m:
compiler/tag_switch.m:
compiler/transform_llds.m:
compiler/unify_gen.m:
compiler/value_number.m:
compiler/vn_block.m:
compiler/vn_cost.m:
compiler/vn_flush.m:
compiler/vn_type.m:
compiler/vn_util.m:
compiler/vn_verify.m:
Add imports of module builtin_ops to lots of modules that
imported llds.
Workspace: /home/mercury0/fjh/mercury-other
Index: builtin_ops.m
===================================================================
RCS file: builtin_ops.m
diff -N builtin_ops.m
--- /dev/null Fri Jul 9 15:34:44 1999
+++ builtin_ops.m Fri Jul 9 14:35:51 1999
@@ -0,0 +1,71 @@
+%-----------------------------------------------------------------------------%
+% Copyright (C) 1999 The University of Melbourne.
+% This file may only be copied under the terms of the GNU General
+% Public License - see the file COPYING in the Mercury distribution.
+%-----------------------------------------------------------------------------%
+
+% builtin_ops.m -- defines the builtin operator types.
+% Main author: fjh.
+%
+% This module defines various types which enumerate the different builtin
+% operators. Several of the different back-ends -- the bytecode back-end,
+% the LLDS, and the MLDS -- all use the same set of builtin operators.
+% These operators are defined here.
+
+%-----------------------------------------------------------------------------%
+
+:- module builtin_ops.
+:- interface.
+
+:- type unary_op
+ ---> mktag
+ ; tag
+ ; unmktag
+ ; mkbody
+ ; body
+ ; unmkbody
+ ; cast_to_unsigned
+ ; hash_string
+ ; bitwise_complement
+ ; (not).
+
+:- type binary_op
+ ---> (+) % integer arithmetic
+ ; (-)
+ ; (*)
+ ; (/) % integer division
+ % assumed to truncate toward zero
+ ; (mod) % remainder (w.r.t. truncating integer division)
+ % XXX `mod' should be renamed `rem'
+ ; (<<) % unchecked left shift
+ ; (>>) % unchecked right shift
+ ; (&) % bitwise and
+ ; ('|') % bitwise or
+ ; (^) % bitwise xor
+ ; (and) % logical and
+ ; (or) % logical or
+ ; eq % ==
+ ; ne % !=
+ ; array_index
+ ; str_eq % string comparisons
+ ; str_ne
+ ; str_lt
+ ; str_gt
+ ; str_le
+ ; str_ge
+ ; (<) % integer comparions
+ ; (>)
+ ; (<=)
+ ; (>=)
+ ; float_plus
+ ; float_minus
+ ; float_times
+ ; float_divide
+ ; float_eq
+ ; float_ne
+ ; float_lt
+ ; float_gt
+ ; float_le
+ ; float_ge.
+
+%-----------------------------------------------------------------------------%
Index: compiler/notes/compiler_design.html
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/notes/compiler_design.html,v
retrieving revision 1.26
diff -u -r1.26 compiler_design.html
--- compiler_design.html 1999/06/30 17:13:13 1.26
+++ compiler_design.html 1999/07/09 04:38:05
@@ -852,6 +852,12 @@
<h2> MISCELLANEOUS </h2>
<dl>
+ <dt> builtin_ops:
+ <dd>
+ This module defines the types unary_op and binary_op
+ which are used by several of the different back-ends:
+ bytecode.m, llds.m, and mlds.m.
+
<dt> det_util:
<dd>
This module contains utility predicates needed by the parts
Index: compiler/rl_exprn.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rl_exprn.m,v
retrieving revision 1.7
diff -u -r1.7 rl_exprn.m
--- rl_exprn.m 1999/06/30 17:12:39 1.7
+++ rl_exprn.m 1999/07/09 05:14:08
@@ -82,7 +82,13 @@
:- import_module code_util, hlds_pred, hlds_data, inst_match.
:- import_module instmap, mode_util, tree, type_util, prog_out.
-:- import_module rl_out, llds, inlining, hlds_goal, prog_util.
+:- import_module rl_out, inlining, hlds_goal, prog_util.
+
+% Note: the reason that we need to import llds and builtin_ops here is that
+% we generate code for builtins by first converting the builtin to LLDS
+% and then converting the LLDS to RL.
+:- import_module llds, builtin_ops.
+
:- import_module assoc_list, bool, char, int, map.
:- import_module require, set, std_util, string, term, varset.
Index: compiler/bytecode.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode.m,v
retrieving revision 1.38
diff -u -r1.38 bytecode.m
--- bytecode.m 1999/04/22 01:04:05 1.38
+++ bytecode.m 1999/07/09 05:19:00
@@ -14,7 +14,7 @@
:- interface.
-:- import_module hlds_data, prog_data, llds, tree.
+:- import_module hlds_data, prog_data, tree, builtin_ops.
:- import_module char, list, std_util, io.
:- type byte_tree == tree(list(byte_code)).
@@ -53,8 +53,8 @@
list(pair(byte_var, byte_dir)))
; complex_deconstruct(byte_var, byte_cons_id,
list(pair(byte_var, byte_dir)))
- ; place_arg(reg_type, int, byte_var)
- ; pickup_arg(reg_type, int, byte_var)
+ ; place_arg(byte_reg_type, int, byte_var)
+ ; pickup_arg(byte_reg_type, int, byte_var)
; call(byte_module_id, byte_pred_id,
arity, byte_proc_id)
; higher_order_call(byte_var, arity, arity,
@@ -71,6 +71,11 @@
; not_supported
.
+ % Currently we only support integer registers.
+ % This might one day be extended to support separate
+ % floating-point registers.
+:- type byte_reg_type ---> r. % general-purpose (integer) register.
+
:- type byte_cons_id ---> cons(byte_module_id, string,
arity, byte_cons_tag)
; int_const(int)
@@ -487,21 +492,17 @@
%---------------------------------------------------------------------------%
-:- pred output_reg(reg_type, int, io__state, io__state).
+:- pred output_reg(byte_reg_type, int, io__state, io__state).
:- mode output_reg(in, in, di, uo) is det.
output_reg(r, N) -->
output_byte(N).
-output_reg(f, _) -->
- { error("we do not handle floating point registers yet") }.
-:- pred debug_reg(reg_type, int, io__state, io__state).
+:- pred debug_reg(byte_reg_type, int, io__state, io__state).
:- mode debug_reg(in, in, di, uo) is det.
debug_reg(r, N) -->
debug_int(N).
-debug_reg(f, _) -->
- { error("we do not handle floating point registers yet") }.
%---------------------------------------------------------------------------%
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.241
diff -u -r1.241 llds.m
--- llds.m 1999/05/28 05:26:19 1.241
+++ llds.m 1999/07/09 04:30:24
@@ -17,6 +17,8 @@
:- interface.
:- import_module hlds_pred, hlds_data, tree, prog_data, (inst).
+:- import_module builtin_ops.
+
:- import_module bool, assoc_list, list, map, set, std_util.
%-----------------------------------------------------------------------------%
@@ -768,57 +770,6 @@
% layout information
; functors.
% information on functors
-
-:- type unary_op
- ---> mktag
- ; tag
- ; unmktag
- ; mkbody
- ; body
- ; unmkbody
- ; cast_to_unsigned
- ; hash_string
- ; bitwise_complement
- ; (not).
-
-:- type binary_op
- ---> (+) % integer arithmetic
- ; (-)
- ; (*)
- ; (/) % integer division
- % assumed to truncate toward zero
- ; (mod) % remainder (w.r.t. truncating integer division)
- % XXX `mod' should be renamed `rem'
- ; (<<) % unchecked left shift
- ; (>>) % unchecked right shift
- ; (&) % bitwise and
- ; ('|') % bitwise or
- ; (^) % bitwise xor
- ; (and) % logical and
- ; (or) % logical or
- ; eq % ==
- ; ne % !=
- ; array_index
- ; str_eq % string comparisons
- ; str_ne
- ; str_lt
- ; str_gt
- ; str_le
- ; str_ge
- ; (<) % integer comparions
- ; (>)
- ; (<=)
- ; (>=)
- ; float_plus
- ; float_minus
- ; float_times
- ; float_divide
- ; float_eq
- ; float_ne
- ; float_lt
- ; float_gt
- ; float_le
- ; float_ge.
:- type reg_type
---> r % general-purpose (integer) regs
-------------------------------------------------------------------------------
****************************************
THE REST OF THE DIFF IS UTTERLY TRIVIAL!
****************************************
-------------------------------------------------------------------------------
Index: compiler/base_type_layout.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/base_type_layout.m,v
retrieving revision 1.44
diff -u -r1.44 base_type_layout.m
--- base_type_layout.m 1999/05/27 05:14:21 1.44
+++ base_type_layout.m 1999/07/09 05:06:10
@@ -238,7 +238,7 @@
:- implementation.
-:- import_module hlds_data, hlds_pred, hlds_out, type_util.
+:- import_module hlds_data, hlds_pred, hlds_out, builtin_ops, type_util.
:- import_module code_util, globals, options, special_pred, prog_util.
:- import_module term.
:- import_module assoc_list, bool, string, int, map, std_util, require.
Index: compiler/code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_util.m,v
retrieving revision 1.109
diff -u -r1.109 code_util.m
--- code_util.m 1999/06/30 17:12:16 1.109
+++ code_util.m 1999/07/09 05:04:12
@@ -172,8 +172,9 @@
:- implementation.
-:- import_module prog_data, type_util, term, varset, special_pred.
-:- import_module bool, char, int, string, set, map.
+:- import_module prog_data, builtin_ops, type_util, special_pred.
+
+:- import_module bool, char, int, string, set, map, term, varset.
:- import_module require, std_util, assoc_list.
%---------------------------------------------------------------------------%
Index: compiler/dense_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dense_switch.m,v
retrieving revision 1.35
diff -u -r1.35 dense_switch.m
--- dense_switch.m 1998/11/20 04:07:21 1.35
+++ dense_switch.m 1999/07/09 05:01:14
@@ -50,7 +50,8 @@
:- implementation.
-:- import_module hlds_module, hlds_goal, hlds_data, code_gen, trace.
+:- import_module builtin_ops, hlds_module, code_gen, trace.
+
:- import_module char, map, tree, int, std_util, require, list.
dense_switch__is_dense_switch(CaseVar, TaggedCases, CanFail0, ReqDensity,
Index: compiler/ite_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ite_gen.m,v
retrieving revision 1.61
diff -u -r1.61 ite_gen.m
--- ite_gen.m 1998/11/20 04:08:00 1.61
+++ ite_gen.m 1999/07/09 05:19:58
@@ -31,9 +31,10 @@
:- implementation.
+:- import_module prog_data, tree, builtin_ops.
:- import_module code_gen, code_util, trace, options, globals, instmap.
-:- import_module prog_data, term.
-:- import_module bool, set, tree, list, map, std_util, require.
+
+:- import_module bool, set, term, list, map, std_util, require.
ite_gen__generate_ite(CodeModel, CondGoal0, ThenGoal, ElseGoal, StoreMap, Code)
-->
Index: compiler/jumpopt.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/jumpopt.m,v
retrieving revision 1.46
diff -u -r1.46 jumpopt.m
--- jumpopt.m 1999/05/28 05:26:18 1.46
+++ jumpopt.m 1999/07/09 05:02:58
@@ -24,7 +24,7 @@
:- implementation.
-:- import_module code_util, opt_util.
+:- import_module builtin_ops, code_util, opt_util.
:- import_module std_util, map, string, require.
% We first build up a bunch of tables giving information about labels.
Index: compiler/llds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds_out.m,v
retrieving revision 1.113
diff -u -r1.113 llds_out.m
--- llds_out.m 1999/05/28 05:26:22 1.113
+++ llds_out.m 1999/07/09 05:04:27
@@ -17,7 +17,7 @@
:- interface.
-:- import_module llds, prog_data, hlds_data, rl_file.
+:- import_module llds, builtin_ops, prog_data, hlds_data, rl_file.
:- import_module set_bbbtree, bool, io, std_util.
% Given a 'c_file' structure, output the LLDS code inside it
Index: compiler/lookup_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lookup_switch.m,v
retrieving revision 1.34
diff -u -r1.34 lookup_switch.m
--- lookup_switch.m 1999/06/16 00:35:48 1.34
+++ lookup_switch.m 1999/07/09 05:09:10
@@ -68,10 +68,11 @@
:- implementation.
-:- import_module int, require, bool, assoc_list.
-:- import_module code_gen, type_util, tree.
+:- import_module builtin_ops, code_gen, type_util, tree.
:- import_module dense_switch, globals, options, mode_util.
:- import_module exprn_aux, getopt, prog_data, instmap.
+
+:- import_module int, require, bool, assoc_list.
% Most of this predicate is taken from dense_switch.m
Index: compiler/middle_rec.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/middle_rec.m,v
retrieving revision 1.76
diff -u -r1.76 middle_rec.m
--- middle_rec.m 1999/04/30 06:19:40 1.76
+++ middle_rec.m 1999/07/09 05:16:25
@@ -25,7 +25,7 @@
:- implementation.
-:- import_module hlds_module, hlds_data, prog_data, prog_out.
+:- import_module builtin_ops, hlds_module, hlds_data, prog_data, prog_out.
:- import_module code_gen, unify_gen, code_util, code_aux, opt_util.
:- import_module bool, set, int, std_util, tree, list, assoc_list, require.
Index: compiler/opt_debug.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/opt_debug.m,v
retrieving revision 1.92
diff -u -r1.92 opt_debug.m
--- opt_debug.m 1999/05/28 05:26:29 1.92
+++ opt_debug.m 1999/07/09 04:57:47
@@ -15,7 +15,7 @@
:- interface.
:- import_module vn_type, vn_table, livemap.
-:- import_module llds, atsort.
+:- import_module llds, builtin_ops, atsort.
:- import_module io, bool, list, assoc_list, std_util.
Index: compiler/opt_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/opt_util.m,v
retrieving revision 1.99
diff -u -r1.99 opt_util.m
--- opt_util.m 1999/04/30 06:19:44 1.99
+++ opt_util.m 1999/07/09 05:20:09
@@ -303,7 +303,7 @@
:- implementation.
-:- import_module exprn_aux, llds_out, hlds_pred.
+:- import_module builtin_ops, exprn_aux, llds_out, hlds_pred.
:- import_module int, string, set, require.
opt_util__get_prologue(Instrs0, ProcLabel, LabelInstr, Comments, Instrs) :-
Index: compiler/string_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/string_switch.m,v
retrieving revision 1.32
diff -u -r1.32 string_switch.m
--- string_switch.m 1999/04/30 06:19:53 1.32
+++ string_switch.m 1999/07/09 05:10:28
@@ -29,7 +29,7 @@
:- implementation.
-:- import_module code_gen, trace, tree.
+:- import_module builtin_ops, code_gen, trace, tree.
:- import_module bool, int, string, list, map, std_util, assoc_list, require.
string_switch__generate(Cases, Var, CodeModel, _CanFail, StoreMap,
Index: compiler/tag_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/tag_switch.m,v
retrieving revision 1.47
diff -u -r1.47 tag_switch.m
--- tag_switch.m 1999/04/22 01:04:13 1.47
+++ tag_switch.m 1999/07/09 05:09:45
@@ -27,8 +27,9 @@
:- implementation.
-:- import_module hlds_module, hlds_pred, code_gen, trace.
+:- import_module builtin_ops, hlds_module, hlds_pred, code_gen, trace.
:- import_module options, globals, type_util, prog_data.
+
:- import_module assoc_list, map, tree, bool, int, string.
:- import_module require, std_util.
Index: compiler/transform_llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/transform_llds.m,v
retrieving revision 1.3
diff -u -r1.3 transform_llds.m
--- transform_llds.m 1998/11/24 03:57:22 1.3
+++ transform_llds.m 1999/07/09 05:08:08
@@ -31,7 +31,7 @@
:- implementation.
-:- import_module globals, options, opt_util, prog_data.
+:- import_module builtin_ops, globals, options, opt_util, prog_data.
:- import_module bool, int, list, require, std_util.
transform_llds(LLDS0, LLDS) -->
Index: compiler/unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.99
diff -u -r1.99 unify_gen.m
--- unify_gen.m 1999/06/30 17:12:44 1.99
+++ unify_gen.m 1999/07/09 05:07:02
@@ -37,9 +37,11 @@
:- implementation.
+:- import_module builtin_ops.
:- import_module hlds_module, hlds_pred, prog_data, prog_out, code_util.
:- import_module mode_util, type_util, code_aux, hlds_out, tree, arg_info.
:- import_module globals, options, continuation_info, stack_layout.
+
:- import_module term, bool, string, int, list, map, require, std_util.
:- type uni_val ---> ref(prog_var)
Index: compiler/value_number.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/value_number.m,v
retrieving revision 1.97
diff -u -r1.97 value_number.m
--- value_number.m 1999/03/12 05:53:29 1.97
+++ value_number.m 1999/07/09 05:20:29
@@ -39,6 +39,7 @@
:- implementation.
+:- import_module builtin_ops.
:- import_module vn_type, vn_table, vn_block, vn_order, vn_flush, vn_temploc.
:- import_module vn_cost, vn_debug, vn_util, vn_verify, vn_filter.
:- import_module opt_debug, opt_util, peephole, labelopt.
Index: compiler/vn_block.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_block.m,v
retrieving revision 1.58
diff -u -r1.58 vn_block.m
--- vn_block.m 1998/09/18 09:48:10 1.58
+++ vn_block.m 1999/07/09 05:20:48
@@ -35,7 +35,7 @@
:- implementation.
-:- import_module vn_util, vn_cost, opt_util, opt_debug.
+:- import_module builtin_ops, vn_util, vn_cost, opt_util, opt_debug.
:- import_module map, int, string, require, std_util, assoc_list.
%-----------------------------------------------------------------------------%
Index: compiler/vn_cost.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_cost.m,v
retrieving revision 1.36
diff -u -r1.36 vn_cost.m
--- vn_cost.m 1999/04/30 06:19:58 1.36
+++ vn_cost.m 1999/07/09 05:22:45
@@ -29,7 +29,7 @@
:- implementation.
-:- import_module vn_debug.
+:- import_module builtin_ops, vn_debug.
:- import_module require, string, std_util, int.
vn_cost__block_cost(Instr, Params, PrintInstr, Cost) -->
Index: compiler/vn_flush.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_flush.m,v
retrieving revision 1.48
diff -u -r1.48 vn_flush.m
--- vn_flush.m 1999/04/30 06:20:03 1.48
+++ vn_flush.m 1999/07/09 05:19:24
@@ -31,7 +31,7 @@
:- import_module bool, map, int, string, require, std_util.
-:- import_module vn_table, vn_util, vn_debug, opt_debug.
+:- import_module builtin_ops, vn_table, vn_util, vn_debug, opt_debug.
vn_flush__nodelist([], _, _, _, _, []) --> [].
vn_flush__nodelist([Node0 | Nodes0], Ctrlmap, VnTables0, Templocs0, Params,
Index: compiler/vn_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_type.m,v
retrieving revision 1.40
diff -u -r1.40 vn_type.m
--- vn_type.m 1999/04/30 06:20:08 1.40
+++ vn_type.m 1999/07/09 04:42:11
@@ -13,7 +13,7 @@
:- module vn_type.
:- interface.
-:- import_module llds, livemap, options.
+:- import_module llds, builtin_ops, livemap, options.
:- import_module getopt, map, set, list, std_util.
:- type vn == int.
Index: compiler/vn_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_util.m,v
retrieving revision 1.65
diff -u -r1.65 vn_util.m
--- vn_util.m 1999/04/30 06:20:10 1.65
+++ vn_util.m 1999/07/09 05:18:13
@@ -35,7 +35,7 @@
:- import_module int, float, string, set, map, require.
-:- import_module opt_util.
+:- import_module builtin_ops, opt_util.
vn_util__find_specials(vn_reg(_, _), []).
vn_util__find_specials(vn_temp(_, _), []).
Index: compiler/vn_verify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/vn_verify.m,v
retrieving revision 1.20
diff -u -r1.20 vn_verify.m
--- vn_verify.m 1999/04/30 06:20:13 1.20
+++ vn_verify.m 1999/07/09 05:21:04
@@ -26,7 +26,7 @@
:- implementation.
-:- import_module opt_debug, vn_debug, vn_util.
+:- import_module builtin_ops, opt_debug, vn_debug, vn_util.
:- import_module map, set, string, std_util, require.
vn_verify__ok(Instrs, Uinstr0, SeenIncr0, SeenIncr, Liveset0, Liveset,
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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