summaryrefslogtreecommitdiff
path: root/src/constant_propagation.ml
AgeCommit message (Collapse)Author
2020-09-29Refactor: Change AST type from a union to a structAlasdair
2020-09-28Refactor: Rename 'a defs to 'a astAlasdair
Change internal terminology so we more clearly distinguish between a list of definitions 'defs' and functions that take an entire abstract syntax trees 'ast'.
2020-04-21Take kid synonyms into account when propagating constantsThomas Bauereiss
For example, in let datasize = e in ... the typechecker will generate a kid '_datasize if e has an existential type (with one kid), and in let 'datasize = e in ... the typechecker will bind both 'datasize and '_datasize. If we substitute one as part of constant propagation, this patch will make constant propagation also substitute the other.
2020-04-21Various monomorphisation fixesThomas Bauereiss
- Handle more combinations of patterns and expressions in constant propagation - Remove dead code after throw() in monomorphisation - Use correct val specs and environments when analysing and pretty-printing function clauses
2019-07-11Make sure constant folding won't fold external definitions that also have ↵Alasdair Armstrong
sail definitions Definitions can be made external on a per-backend basis, so we need to make sure constant folding doesn't inline external functions that have sail definitions for backends other than the ones we are currently targetting
2019-06-04Remove unused AST constructorAlasdair Armstrong
Clean up ott grammar a bit
2019-05-06Handle type variables generated while inferring applications in monomorphisationBrian Campbell
Also handle any type variables from assignments and degrade gracefully during constant propagation when unification is not possible.
2019-05-06Calculate some type variable substitutions during constant propagationBrian Campbell
Needed for constructor monomorphisation
2019-05-06Handle global constants in monomorphisationBrian Campbell
2019-04-26More constructor monomorphisation supportBrian Campbell
- handle multiple bitvector length variables - more fine-grained unnecessary cast insertion checks - add tuple matching support to constant propagation (for the test)
2019-04-25Get basic constructor monomorphisation working againBrian Campbell
- updates for type checking changes - handle a little more pattern matching in constant propagation - fix bug where false positive warnings were produced - ensure bitvectors in tuples are always monomorphised (to catch the case where the bitvectors only appear alone with a constant size)
2019-04-15Merge branch 'sail2' of github.com:rems-project/sail into sail2Jon French
2019-04-15Merge branch 'sail2' into rmem_interpreterJon French
2019-04-15Basic loop termination measures for CoqBrian Campbell
Currently only supports pure termination measures for loops with effects. The user syntax uses separate termination measure declarations, as in the previous recursive termination measures, which are rewritten into the loop AST nodes before type checking (because it would be rather difficult to calculate the correct environment to type check the separate declaration in).
2019-04-06Various bugfixes and improvementsAlasdair
- Rename DeIid to Operator. It corresponds to operator <string> in the syntax. The previous name is from when it was called deinfix in sail1. - Removed things that weren't actually common from pretty_print_common.ml, e.g. printing identifiers is backend specific. The doc_id function here was only used for a very specific use case in pretty_print_lem, so I simplified it and renamed it to doc_sia_id, as it is always used for a SIA.Id whatever that is. - There is some support for anonymous records in constructors, e.g. union Foo ('a : Type) = { MkFoo : { field1 : 'a, field2 : int } } somewhat similar to the enum syntax in Rust. I'm not sure when this was added, but there were a few odd things about it. It was desugared in the preprocessor, rather than initial_check, and the desugaring generated incorrect code for polymorphic anonymous records as above. I moved the code to initial_check, so the pre-processor now just deals with pre-processor things and not generating types, and I fixed the code to work with polymorphic types. This revealed some issues in the C backend w.r.t. polymorphic structs, which is the bulk of this commit. I also added some tests for this feature. - OCaml backend can now generate a valid string_of function for polymorphic structs, previously this would cause the ocaml to fail to compile. - Some cleanup in the Sail ott definition - Add support for E_var in interpreter previously this would just cause the interpreter to fail
2019-03-26Constant-fold __size calls if possibleThomas Bauereiss
2019-03-21Revert some constant propagation experimentationThomas Bauereiss
See comments on e92ff687.
2019-03-15Don't constant-fold undefined_X functions in monomorphisationThomas Bauereiss
These should be preserved for prover backends.
2019-03-15Add a rewriting pass for constant propagation in mutrecsThomas Bauereiss
Propagating constants into mutually recursive calls and removing dead branches might break mutually recursive cycles. Also make constant propagation use the existing interpreter-based constant folding to evaluate function calls with only constant arguments (as opposed to a mixture of inlining and hard-coded rewrite rules).
2019-03-07Remove more dead branchesThomas Bauereiss
2019-03-07Also remove impossible if-branchesThomas Bauereiss
2019-03-07Add a rewrite to remove impossible cases on integer literalsBrian Campbell
(e.g., for the dual 32/64 bit RISC-V model) Apply this rewrite in Coq backend.
2019-03-07Simplify handling of referenced variables in constant propagationBrian Campbell
2019-03-07Extract constant propagation and related functions from monomorphisation.Brian Campbell
This shouldn't change any functionality.