summaryrefslogtreecommitdiff
path: root/src/monomorphise.ml
AgeCommit message (Collapse)Author
2019-08-14Add a mono rewrite for (ones(n) @ zeros(m))Thomas Bauereiss
2019-08-14Use bitvector type in mono rewritesThomas Bauereiss
Also don't require a previously declared default vector indexing order in vector_dec.sail.
2019-08-02Fix all warnings (except for two lem warnings)Alasdair Armstrong
Remove P_record as it's never been implemented in parser/typechecker/rewriter, and is not likely to be. This also means we can get rid of some ugliness with the fpat and mfpat types. Stubs for P_or and P_not are left as they still may get added to ASL and we might want to support them, although there are good reasons to keep our patterns simple. The lem warning for while -> while0 for ocaml doesn't matter because it's only used in lem, and the 32-bit number warning is just noise.
2019-07-16Get monomorphisation tests working with separate bitvectorsAlasdair Armstrong
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-28Monomorphisation: add some alternative names for ones and zero_extend as ↵Robert Norton
used in risc-v spec.
2019-06-20Handle more uses of mutable variables during monomorphisation cast insertionBrian Campbell
In particular, bitvector subrange updates work with this version.
2019-06-19Monomorphisation improvements for aarch64_smallBrian Campbell
- additional rewrites (signed extend of subrange@zeros, subrange assignment, variants with casts) - drop # from new top-level type variables (e.g., n_times_8) so that the rewriter knows that they're safe to include in casts - add casts in else-branches when only one possible value for a size is left - add casts when assertions force a size to be a particular value - don't use types to detect set constraints in analysis because we won't know which part of the assertion should be replaced - also use non-top-level type variables when simplifying sizes in analysis (useful when it can from pattern matching on an ast) - cope with repeated int('n) in a pattern match (!)
2019-06-13Add AST for greater-than and less-than constraintsBrian Campbell
Mostly to make constraints sent to the SMT solver and Coq nicer, but also makes it easy to remove uninformative constraints in the Coq back-end.
2019-06-10Add well-formedness check for type schemes in valspecs.Brian Campbell
Fixes #47. Also adjust the nexp substitution so that the error message points to a useful location, and replace the empty environment with the initial environment in a few functions that do type checking to ensure that the prover is set up (which may be needed for the wf check).
2019-06-04Remove unused AST constructorAlasdair Armstrong
Clean up ott grammar a bit
2019-05-22Move Util.warn to Reporting, and make it take the location as a parameterAlasdair Armstrong
Also add a $suppress_warnings directive that ensures that no warnings are generated for a specific file.
2019-05-14Add feature that allows functions to require type variables are constantAlasdair Armstrong
can now write e.g. forall (constant 'n : Int) rather than forall ('n: Int) which requires 'n to be a constant integer value whenever the function is called. I added this to the 'addrsize variable on memory reads/writes to absolutely guarantee in the SMT generation that we don't have to worry about the address being a variable length bitvector.
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-06Avoid degenerate construction monomorphisation, use # in generated namesBrian Campbell
2019-05-06Apply constructor monomorphisation in preference to variable splitsBrian Campbell
Note that we might need to do both in future. Also report more information when constructor refinement fails.
2019-05-06Handle global constants in monomorphisationBrian Campbell
2019-05-06Cope with irrelevant existentials when monomorphising constructorsBrian Campbell
2019-05-06Expand constraints while looking for sets during 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-25Make constructor splitting in monomorphisation obey -dall_split_errorsBrian Campbell
2019-04-25Don't try to insert monomorphisation casts when the types are the sameBrian Campbell
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-15Various monomorphisation tweaks and fixesThomas Bauereiss
2019-03-14Merge branch 'sail2' into rmem_interpreterJon French
2019-03-07Fix bug in a mono rewrite helper functionThomas Bauereiss
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.
2019-03-04Merge branch 'sail2' into rmem_interpreterJon French
2019-03-01Fill in some edge cases in monomorphisationBrian Campbell
2019-02-25Monomorphisation: fix check for effects in constant propagationBrian Campbell
The old check used the wrong part of the AST. It would stop when it reached the actual effect, anyway, but this should improve performance.
2019-02-25Merge branch 'sail2' into rmem_interpreterJon French
2019-02-21Fix specialization bug involving function annotations not matching valspecsAlasdair
Perhaps suprisingly to some, this did not mean that Sail was unable to typecheck the identify function. While doing this rename Effect_opt_pure to Effect_opt_none - as Effect_opt_pure was the effect equivalent of Typ_annot_opt_none, and actually means that the function definition lacks an effect annnotation, not that the function is actually pure, so this was *extremely* misleading. The effect_opt that actually indicated a function is pure was (and still is) the succinct: Effect_opt_aux (Effect_opt_effect (Effect_aux (Effect_set [], _)), _) In fact because in the grammar we only specify effects on valspecs (they can always be inferred for fundefs in the absence of a valspec) effect_opts are basically vestigial and are always Effect_opt_none. What might actually be super nice would be to remove rec_opt, effect_opt and typ_annot_opt from fundefs in ast.ml altogether and if we want them in the syntax just have them in parse_ast.ml and pull them into a valspec during the initial check.
2019-02-19Refactor specializationAlasdair Armstrong
specialize functions now take a 'specialization' parameter that specifies how they will specialize the AST. typ_ord_specialization gives the previous behaviour, whereas int_specialization allows specializing on Int-kinded arguments. Note that this can loop forever unless the appropriate case splits are inserted beforehand, presumably by monomorphisation. rename is_nat_kopt -> is_int_kopt for consistency
2019-02-18Rename Type_check.solve -> Type_check.solve_uniqueAlasdair Armstrong
2019-02-13Merge branch 'sail2' into rmem_interpreterJon French
2019-02-07Monomorphisation tweaks for v8.5Thomas Bauereiss
Various tweaks to the monomorphisation rewrites. Disable old sizeof rewriting for Lem backend and rely on the type checker rewriting implicit arguments. Also avoid unifying nexps with sums, as this can easily fail due to commutativity and associativity.
2019-02-07Add a symbol for new implicit arguments for backwards compatabilityAlasdair Armstrong
Fix monomorphisation tests
2019-02-05Handle a few more cases in mono rewritesThomas Bauereiss
2019-02-02Monomorphisation tests all pass so add them to standard regression testsAlasdair
2019-02-02Merge remote-tracking branch 'origin/sail2' into asl_flow2Alasdair
2019-01-31Fix an unnecessary cast insertion on assignmentsBrian Campbell
2019-01-31Turn on cast insertion for -lem_mwords and revert b826df25Brian Campbell
now that cast insertion can handle RISC-V Also inserts specs for casts in they're not present
2019-01-31Drop type annotations in top-level nexp rewriting in favour of valspecsBrian Campbell
otherwise the valspec rewriting will be inconsistent with the type annotation. Note that the type checker will have introduced valspecs where necessary.
2019-01-31Make cast insertion handle more complex nexps and pushing casts into blocksBrian Campbell
# Conflicts: # src/monomorphise.ml
2019-01-31Further restrict attention to Int kidsThomas Bauereiss