summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2019-02-22Generalize CT_int64 for arbitrary fixed size integersAlasdair
If we want to use our low-level intermediate representation to generate SMT, then we want to be more precise than just splitting integers into 64-bits and larger. This commit changes CT_int and CT_int64 into CT_lint for large integers and CT_fint n for (signed) fixed precision integers that fit within n bits. This follows the convention for bitvectors where we have CT_fbits for fixed-length bitvectors and CT_lbits for large arbitrary precision bitvectors.
2019-02-22Fix more bugs in int-specializationAlasdair Armstrong
2019-02-22Fix some bugs in int-specializationAlasdair Armstrong
2019-02-21Allow monomorphisation with C generationAlasdair
Run C tests with -O -Oconstant_fold -auto_mono
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-20Fix bug with missing satisfiablity check in subtypingAlasdair
Thanks to Mark for finding this bug. Regression test is complex_exist_sat in test/typecheck/pass/
2019-02-20Record the type of loaded ELF for sanity checks.Prashanth Mundkur
2019-02-20Support 32-bit ELF in OCaml loader.Prashanth Mundkur
2019-02-20Remove dead branches when compiling to CAlasdair Armstrong
Specifically remove branches where flow-typing implies false, as this allows the optimizer to prove anything, which can result in nonsense code. This does incur something of a performance hit.
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-18Add option to linearize constraints containing exponentialsAlasdair Armstrong
When adding a constraint such as `x <= 2^n-1` to an environment containing e.g. `n in {32, 64}` or similar, we can enumerate all values of n and add `n == 32 & x <= 2^32-1 | n == 64 & x <= 2^64-1` instead. The exponentials then get simplified away, which means that we stay on the SMT solver's happy path. This is enabled by the (experimental, name subject to change) flag -smt_linearize, as this both allows some things to typecheck that didn't before (see pow_32_64.sail in test/typecheck/pass), but also may potentially cause some things that typecheck to no longer typecheck for SMT solvers like z3 that have some support for reasoning with power functions, or where we could simply treat the exponential as a uninterpreted function. Also make the -dsmt_verbose option print the smtlib2 files for the solve functions in constraint.ml. We currently ignore the -smt_solver option for these, because smtlib does not guarantee a standard format for the output of get-model, so we always use z3 in this case. Following the last commit where solve got renamed solve_unique, there are now 3 functions for solving constraints: * Constraint.solve_smt, which finds a solution if one exists * Constraint.solve_all_smt, which returns all possible solutions. Currently there's no bound, so this could loop forever if there are infinite solutions. * Constraint.solve_unique, which returns a unique solution if one exists Fix a bug where $option pragmas were dropped unnecessarily.
2019-02-18Rename Type_check.solve -> Type_check.solve_uniqueAlasdair Armstrong
2019-02-18Make sure we remove bitvector patterns within guardsAlasdair Armstrong
Fixes #34
2019-02-18Fix latex outputAlasdair Armstrong
Fixes #33
2019-02-15Fix bug in Int-synonym expansionAlasdair Armstrong
2019-02-15Tweak intermediate language names for loop combinators to allow reparsingBrian Campbell
This should produce identical Lem and Coq output, but allow dumped Sail ASTs from the final stages of rewriting to be reread with -dmagic_hash.
2019-02-15Coq: Partial simplification of rich bool typesBrian Campbell
This uses the SMT solver to spot rich `atom_bool` types which don't contain any information, replaces them with bool, and handles most of the construction and projection of them. The SMT part will be replaced by a simplification procedure soon, because it can't handle some important cases.
2019-02-15Use multiple solversAlasdair
Useful to see what constraints we are generating that are particularly hard, and which of our specs work with different solvers. Refactor code to use smt in names rather than specifically z3
2019-02-14Improve sizeof-rewriting performanceAlasdair
Simple heuristic to try local variables with the same name as type variables first, roughly doubles typechecking speed.
2019-02-14Fix issues for versions of z3 confused by 2^nAlasdair Armstrong
Some versions of z3 do not like any constraints with the form 2^f(n), even when such constraints are completely trivial, or only exist in the environment yet no bearing on the current goal. Unfortunately the z3 in Ubuntu LTS has these issues. We can mitigate these issues somewhat by removing any 2^f(n) containing conjuncts from the environment when z3 returns unknown, and attempting to reprove the goal. In practice Type_check.prove only guarantees that the goal is provable when it returns true, and does not guarantee that it is false when it returns false, only that it wasn't provable in the specified timeout. Similarly for Type_check.solve. Mostly this is fine, because prove returning false usually triggers a type error, or e.g. in the C optimizer always has a sensible fallback (where it just won't optimize that specific case). What is slightly concerning is that this z3 issues means that Sail written using the latest z3 from git may not compile using Ubuntu LTS z3. We could if we wanted to put additional restrictions on Nexp_exp to avoid this issue. We should also look over uses of Type_check.prove in Sail to make sure callers are using it correctly.
2019-02-14Fix a bug that caused constant propagation option to fail for v8.5Alasdair Armstrong
Make type-at-cursor work for scattered function clauses in emacs
2019-02-14Don't do any rewrites when checking files for EmacsAlasdair Armstrong
This makes sure we don't do any kind of re-writing or de-scatter any definitions when loading files into emacs. The difference here is that normally all files are processed together, but the emacs mode loads each file one by one. This is probably what we want to be doing anyway, so location information stays accurate for scattered functions for things like type-at-cursor commands and similar. Also fix some warnings. Fixes #32
2019-02-14Coq: special case printing of bind-if-then-else trees for decodingBrian Campbell
Reduces the current arm model output from 268MB to 15MB.
2019-02-13Attempt to parse sail version from opam file for manifest.ml. Update version ↵Robert Norton
in opam file in anticipation of release and add yojson dependency.
2019-02-12Add a CHANGELOG fileAlasdair Armstrong
Fix a bug where we generated empty definitions which pre 4.07 versions of OCaml don't appear to support.
2019-02-12Merge remote-tracking branch 'origin/sail2' into asl_flow2Alasdair Armstrong
2019-02-12Improvements for emacs modeAlasdair Armstrong
2019-02-11Add an additional test caseAlasdair
Make LEXP_deref an inference rule. This should allow strictly more programs to type-check.
2019-02-11Expand type synonyms for E_constraint and E_sizeofAlasdair
2019-02-11Add tests for implicit argumentsAlasdair Armstrong
2019-02-11Get the order of overrides correct during topsortBrian Campbell
2019-02-08Cleanup src MakefileAlasdair
When we are building from git, we put the git version info in manifest.ml, so we'll get the following from sail -v Sail $last_git_tag ($branch @ $commit_sha) If we are be built from opam we can't assume we are in a git repository as opam downloads specific tags as tarballs, so instead we check for the precense of SHARE_DIR which is set by our opam build script, and instead output Sail 0.8 (sail2 @ opam) which is the next git tag (current is 0.7.1, this must be updated by hand), the branch name from which opam releases are generated and then opam rather than the commit SHA. I also removed the Makefile-non-opam file as it's bitrotted and unused
2019-02-08Slightly tweak the help message.Prashanth Mundkur
2019-02-08Add parameterization support for bitfields.Prashanth Mundkur
This supports the following syntax: type xlen : Int = 64 type ylen : Int = 1 type xlenbits = bits(xlen) bitfield Mstatus : xlenbits = { SD : xlen - ylen, SXL : xlen - ylen - 1 .. xlen - ylen - 3 }
2019-02-08Add missing functions to HOL monad wrapperThomas Bauereiss
Also make the rewriter keep failed assertions in output when pruning blocks.
2019-02-08Resurrect Sail output option (with new name: -output_sail)Brian Campbell
2019-02-08Prevent top_sort throwing away overloads (and other multiple definitions)Brian Campbell
Previously it would quietly throw away all definitions for an id except one. This usually doesn't matter, but some rewrites use overloaded identifiers and can break if the definition is lost.
2019-02-08Allow internal AST nodes in input when -dmagic_hash is onBrian Campbell
2019-02-08Updates for asl_parserAlasdair Armstrong
Tweak colours of monomorphistion test output
2019-02-08Rewrite type definitions in rewrite_nexp_idsThomas Bauereiss
For example, in type xlen : Int = 64 type xlenbits = bits(xlen) rewrite the 'xlen' in the definition of 'xlenbits' to the constant 64 in order to simplify Lem generation. In order to facilitate this, pass through the global typing environment to the rewriting steps (in the AST itself, type definitions don't carry annotations with environments).
2019-02-08Remove dead code from type-checkerAlasdair
add_num_def and get_num_def are no longer used. The rewrite pass that used them would fail on Nexp_ids because of this, but seeing as that never happened we can probably assume that particular line of code is simply never touched by any of our models or test suite?
2019-02-07Replace equality check for declared effects by subset checkThomas Bauereiss
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-07Fix implicits in v8.2 public ARM specAlasdair Armstrong
2019-02-06Emacs mode understands relationships between Sail filesAlasdair
Allow a file sail.json in the same directory as the sail source file which contains the ordering and options needed for sail files involved in a specific ISA definition. I have an example for v8.5 in sail-arm. The interactive Sail process running within emacs then knows about the relationship between Sail files, so C-c C-l works for files in the ARM spec. Also added a C-c C-x command to jump to a type error. Requires yojson library to build interactive Sail.
2019-02-06Improve emacs modeAlasdair Armstrong
Can now use C-c C-s to start an interactive Sail process, C-c C-l to load a file, and C-c C-q to kill the sail process. Type errors are highlighted in the emacs buffer (like with merlin for OCaml) with a tooltip for the type-error, as well as being displayed in the minibuffer. Need to add a C-c C-x command like merlin to jump to the error, and figure out how to handle multiple files nicely, as well as hooking the save function like tuareg/merlin, but this is already enough to make working with small examples quite a bit more pleasant.
2019-02-06Fix some testsAlasdair Armstrong
2019-02-06Make sure type synonym errors have correct location infoAlasdair Armstrong
2019-02-06Remove all sizeof rewriting from C compilationAlasdair
All sizeof expressions now removed by the type-checker, so it's now properly a type error if they cannot be removed rather than a bizarre re-write error. This also greatly improves compilation speed overall, at the expense of the first type-checking pass.