compiler/const_prop.m:
Extend this module to support compile time evaluation of uint operations.
compiler/uint_emu.m:
A new module that emulates `uint' operations for the bits-per-uint in
a manner similar to the int_emu module.
compiler/libs.m:
Include the new module.
tests/hard_coded/constant_prop_1.{m,exp}:
tests/hard_coded/constant_prop_2.{m,exp}:
Test compile time evaluation of uint operations.
Update coding style in these tests.
tests/hard_coded/Mmakefile:
Conform to the above changes. (XXX the existing check
for the Java grade doesn't actually work.)
Delete left over IL and GCC backend stuff.
Estimated hours taken: 4
Branches: main
Do constant propagation for calls to private_builtin.typed_unify and
std_util.dynamic_cast, i.e. evaluate them at compile time if the types
are known, and optimize the implementation of dynamic_cast.
Also clean up the code in const_prop.m.
library/std_util.m:
Implement dynamic_cast more efficiently, using typed_unify(X, Y)
rather than univ_to_type(univ(X), Y). This avoids allocating a
cell on the heap.
compiler/const_prop.m:
Keep track of the types of the arguments.
Add new code for evaluating semidet calls with one output,
and use this to evaluate calls to dynamic_cast and typed_unify.
Rename evaluate_builtin to evaluate_call, since it may evaluate
any standard library procedure, not just those which are builtin
(in the sense of pred_info_is_builtin). Likewise for its subroutines.
Various other clean-ups, e.g. combine evaluate_builtin_bi and
evaluate_builtin_tri into a single predicate evaluate_det_call,
delete unused arguments, reorder arguments so that inputs precede
outputs, use combined pred-mode declarations, and add some comments.
compiler/simplify.m:
Update to reflect the new interface to const_prop.m.
tests/hard_coded/constant_prop_2.m:
tests/hard_coded/constant_prop_2.exp:
Test that we do constant propagation for calls to typed_unify
and dynamic_cast.
Estimated hours taken: 1
Branches: main
Improve the testing of constant propagation.
tests/hard_coded/Mmakefile:
tests/hard_coded/constant_prop_1.m:
tests/hard_coded/constant_prop_1.exp:
tests/hard_coded/constant_prop_2.m:
tests/hard_coded/constant_prop_2.exp:
tests/hard_coded/Mercury.options:
Add two new tests of constant propagation.
For the first test, we test by grepping the generated target code
for the expected constants.
For the second test, we test by including a reference to an
undefined external procedure "link_error" which will get
optimized away iff the compiler does constant propagation.