mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 01:43:35 +00:00
With almost 6000 lines, mercury_to_mercury.m was one of the biggest modules
of compiler, but it was far from cohesive. This diff carves seven new modules
out of it, each of which is much more cohesive. The stuff remaining in
mercury_to_mercury.m is still not as cohesive as one would like, but it is
now small enough that moving its individually-cohesive parts into modules
of their own would be overkill.
Three consequences of the old mercury_to_mercury.m's lack of cohesion
were that
- the order of predicate declarations often did not match the order of
their implementation;
- related predicates were not grouped together;
- even when they were grouped together, the order of those groups
was often random.
This diff fixes all three of these problems for all eight successor modules
of mercury_to_mercury.m: the seven new modules, and the new
mercury_to_mercury.m itself.
In some cases, this diff adds or improves the documentation of the predicates
in mercury_to_mercury.m's successor modules. In some other cases, it just
documents the lack of documentation :-(. In yet other cases, it removes
"documentation" that says nothing that isn't obvious from the predicate's name.
There are some algorithmic changes, but they are all trivial.
compiler/parse_tree_out.m:
New module containing the code to print out the top levels of parse trees,
including most sorts of items.
compiler/parse_tree_out_clause.m:
New module containing the code to print out clauses and goals.
compiler/parse_tree_out_pragma.m:
New module containing the code to print out pragmas.
compiler/parse_tree_out_pred_decl.m:
New module containing the code to print out predicate, function and
mode declarations. It is separate from parse_tree_out.m because a
significant number of compiler modules need only its functionality,
and not parse_tree_out.m's functionality.
compiler/parse_tree_out_inst.m:
New module containing the code to print out insts and modes.
compiler/parse_tree_out_term.m:
New module containing the code to print out variables and terms.
compiler/parse_tree_out_info.m:
New module containing the infrastructure of both mercury_to_mercury.m
and the other new modules.
compiler/parse_tree.m:
Include the new modules.
compiler/notes/compiler_design.html:
Document the new modules.
compiler/Mercury.options:
Transfer an option from mercury_to_mercury.m to the successor module
that needs it.
compiler/*.m:
Import one of the new modules either as well as, or instead of,
mercury_to_mercury.m. In most cases, we need to import only one
or two of mercury_to_mercury.m's successor modules; nowhere do we
need to import all eight.
Clean up some code in termination.m around a call to one of the
new modules.
tools/speedtest:
Replace mercury_to_mercury.m on the list of the ten largest modules
of the compiler.
282 lines
5.5 KiB
Bash
Executable File
282 lines
5.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# vim: ts=4 sw=4 et
|
|
#
|
|
# A program to test different versions of the compiler.
|
|
|
|
usage="Usage: speedtest [-dsmtz] [-l | -1] [-e dir] [-g grade] [-c cmd] [-o option]* [-nN] [-ON] [-fFILE] batchname"
|
|
|
|
single_modulelist="typecheck.m"
|
|
# As of 6 sep 2015, these are the ten largest modules of the compiler.
|
|
short_modulelist="
|
|
options.m
|
|
polymorphism.m
|
|
mlds_to_java.m
|
|
mlds_to_c.m
|
|
table_gen.m
|
|
mlds_to_il.m
|
|
code_loc_dep.m
|
|
dep_par_conj.m
|
|
typecheck.m
|
|
hlds_pred.m
|
|
"
|
|
# As of 6 sep 2015, these are the ten next largest modules of the compiler.
|
|
long_modulelist="$short_modulelist
|
|
higher_order.m
|
|
prog_io_pragma.m
|
|
mlds_to_cs.m
|
|
ml_unify_gen.m
|
|
handle_options.m
|
|
compile_target_code.m
|
|
hlds_goal.m
|
|
layout_out.m
|
|
module_qual.m
|
|
fact_table.m
|
|
"
|
|
cmd=""
|
|
debug=false
|
|
execdir="arena"
|
|
grade="--grade asm_fast.gc"
|
|
framesizefile=""
|
|
mix=false
|
|
modulelist="$short_modulelist"
|
|
limit=6
|
|
options=""
|
|
optlevel="-O2"
|
|
size=false
|
|
table_io=false
|
|
zip=false
|
|
|
|
while test $# -gt 0
|
|
do
|
|
case $1 in
|
|
|
|
-c|--cmd)
|
|
cmd="$2"
|
|
shift
|
|
;;
|
|
-c*)
|
|
cmd="`expr $1 : '-c\(.*\)'`"
|
|
;;
|
|
|
|
-d)
|
|
debug=true
|
|
;;
|
|
|
|
-e)
|
|
execdir="$2"
|
|
shift
|
|
;;
|
|
-e*)
|
|
execdir="`expr $1 : '-e\(.*\)'`"
|
|
;;
|
|
|
|
-g)
|
|
grade="--grade $2"
|
|
shift
|
|
;;
|
|
-g*)
|
|
grade="--grade `expr $1 : '-g\(.*\)'`"
|
|
;;
|
|
|
|
-f)
|
|
framesizefile="$2"
|
|
shift
|
|
;;
|
|
-f*)
|
|
framesizefile="`expr $1 : '-f\(.*\)'`"
|
|
;;
|
|
|
|
-l)
|
|
modulelist="${long_modulelist}"
|
|
;;
|
|
|
|
-1)
|
|
modulelist="${single_modulelist}"
|
|
;;
|
|
|
|
-m)
|
|
mix=true
|
|
;;
|
|
|
|
-n)
|
|
limit="$2"
|
|
shift
|
|
;;
|
|
-n*)
|
|
limit="`expr $1 : '-n\(.*\)'`"
|
|
;;
|
|
|
|
-o)
|
|
options="${options} $2"
|
|
shift
|
|
;;
|
|
-o*)
|
|
options="${options} ` expr $1 : '-f\(.*\)' `"
|
|
;;
|
|
|
|
-O)
|
|
optlevel="-O$2"
|
|
shift
|
|
;;
|
|
-O*)
|
|
optlevel="$1"
|
|
;;
|
|
|
|
-s)
|
|
size=true
|
|
;;
|
|
|
|
-t)
|
|
table_io=true
|
|
;;
|
|
|
|
-z)
|
|
zip=true
|
|
;;
|
|
|
|
-*)
|
|
echo "$0: unknown option \`$1'" 2>&1
|
|
echo ${usage}
|
|
exit 1
|
|
;;
|
|
|
|
*)
|
|
break
|
|
;;
|
|
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if test "${cmd}" = ""
|
|
then
|
|
cmd="mmc -C $optlevel ${options} $grade $modulelist"
|
|
fi
|
|
|
|
if test $# != 1
|
|
then
|
|
echo ${usage}
|
|
exit 1
|
|
fi
|
|
|
|
batch=$1
|
|
|
|
root=`/bin/pwd`
|
|
|
|
if $zip
|
|
then
|
|
trap 'gzip ${root}/batch/${batch}.mercury_compile.*[0-9] > /dev/null 2>&1; exit 0' 0 1 2 3 15
|
|
fi
|
|
|
|
if test -x /usr/ucb/echo
|
|
then
|
|
ECHO=/usr/ucb/echo
|
|
else
|
|
ECHO=echo
|
|
fi
|
|
|
|
maybe_zipped_files=`ls batch/$batch.mercury_compile.*`
|
|
for maybe_zipped_file in ${maybe_zipped_files}
|
|
do
|
|
case ${maybe_zipped_file} in
|
|
*.gz)
|
|
gunzip ${maybe_zipped_file}
|
|
;;
|
|
esac
|
|
done
|
|
|
|
files=`ls batch/$batch.mercury_compile.*`
|
|
if ${mix}
|
|
then
|
|
count=1
|
|
cd ${execdir}
|
|
while test ${count} -le ${limit}
|
|
do
|
|
for file in ${files}
|
|
do
|
|
MERCURY_COMPILER=${root}/${file}
|
|
export MERCURY_COMPILER
|
|
briefname=`echo "${file}" | sed "s:batch/$batch.::"`
|
|
$ECHO -n "${briefname} "
|
|
if ${debug}
|
|
then
|
|
if ${table_io}
|
|
then
|
|
(echo "table_io start" ; echo "c" ) \
|
|
| ${root}/tools/dotime mdb ${cmd}
|
|
else
|
|
echo "c" | ${root}/tools/dotime mdb ${cmd}
|
|
fi
|
|
else
|
|
${root}/tools/dotime ${cmd}
|
|
fi
|
|
done
|
|
count=`expr ${count} + 1`
|
|
done
|
|
cd ${root}
|
|
else
|
|
for file in ${files}
|
|
do
|
|
paramfile=`echo ${file} | sed 's/mercury_compile/params/'`
|
|
if test -r ${paramfile}
|
|
then
|
|
cat ${paramfile}
|
|
fi
|
|
|
|
if ${size}
|
|
then
|
|
size ${file}
|
|
fi
|
|
|
|
MERCURY_COMPILER=${root}/${file}
|
|
export MERCURY_COMPILER
|
|
cd ${execdir}
|
|
count=1
|
|
while test ${count} -le ${limit}
|
|
do
|
|
if test "${framesizefile}" != ""
|
|
then
|
|
rm ${framesizefile} > /dev/null 2>&1
|
|
fi
|
|
|
|
briefname=`echo "${file}" | sed "s:batch/$batch.::"`
|
|
$ECHO -n "${briefname} "
|
|
if ${debug}
|
|
then
|
|
if ${table_io}
|
|
then
|
|
(echo "table_io start" ; echo "c" ) \
|
|
| ${root}/tools/dotime mdb ${cmd}
|
|
else
|
|
echo "c" | ${root}/tools/dotime mdb ${cmd}
|
|
fi
|
|
else
|
|
${root}/tools/dotime ${cmd}
|
|
fi
|
|
|
|
if test -s Deep.data
|
|
then
|
|
mv Deep.data \
|
|
${root}/batch/Deep.data.`basename ${file} .gz`.run${count}
|
|
fi
|
|
|
|
if test "${count}" -eq 1 -a "${framesizefile}" != ""
|
|
then
|
|
echo
|
|
cat ${framesizefile}
|
|
echo
|
|
fi
|
|
|
|
count=`expr ${count} + 1`
|
|
done
|
|
|
|
cd ${root}
|
|
if ${zip}
|
|
then
|
|
gzip ${file}
|
|
fi
|
|
done
|
|
fi
|
|
|
|
exit 0
|