summaryrefslogtreecommitdiff
path: root/src/spec_analysis.ml
AgeCommit message (Collapse)Author
2018-07-27Make type annotations abstract in type_check.mliAlasdair Armstrong
Rather than exporting the implementation of type annotations as type tannot = (Env.t * typ * effect) option we leave it abstract as type tannot Some additional functions have been added to type_check.mli to work with these abstract type annotations. Most use cases where the type was constructed explicitly can be handled by using either mk_tannot or empty_tannot. For pattern matching on a tannot there is a function val destruct_tannot : tannot -> (Env.t * typ * effect) option Note that it is specifically not guaranteed that using mk_tannot on the elements returned by destruct_tannot re-constructs the same tannot, as destruct_tannot is only used to give the old view of a type annotation, and we may add additional information that will not be returned by destruct_tannot.
2018-07-25Remove unused internal AST nodesAlasdair Armstrong
E_internal_cast, E_sizeof_internal, E_internal_exp, E_internal_exp_user, E_comment, and E_comment_struc were all unused. For a lem based interpreter, we want to be able to compile it to iUsabelle, and due to slowness inherent in Isabelle's datatype package we want to remove unused constructors in our AST type. Also remove the lem_ast backend - it's heavily bitrotted, and for loading the ARM ast into the interpreter it's just not viable to use this approach as it just doesn't scale. We really need a way to be able to serialise and deserialise the AST efficiently in Lem.
2018-06-26Add configuration registers so __SetConfig ASL can be translatedAlasdair Armstrong
Registers can now be marked as configuration registers, for example: register configuration CFG_RVBAR = 0x1300000 They work like ordinary registers except they can only be set by functions with the 'configuration' effect and have no effect when read. They also have an initialiser, like a let-binding. Internally there is a new reg_dec constructor DEC_config. They are intended to represent configuration parameters for the model, which can change between runs, but don't change during execution. Currently they'll only work when compiled to C. Internally registers can now have custom effects for reads and writes rather than just rreg and wreg, so the type signatures of Env.add_register and Env.get_register have changed, as well as the Register lvar, so in the type checker we now write: Env.add_register id read_effect write_effect typ rather than Env.add_register id typ For the corresponding change to ASL parser there's a function is_config in asl_to_sail.ml which controls what becomes a configuration register for ARM. Some things we have to keep as let-bindings because Sail can't handle them changing at runtime - e.g. the length of vectors in other top-level definitions. Luckily __SetConfig doesn't (yet) try to change those options. Together these changes allow us to translate the ASL __SetConfig function, which means we should get command-line option compatibility with ArchEx for running the ARM conformance tests.
2018-05-01fv funcs for bidir typesJon French
2018-03-12ELF loading for C backendAlasdair Armstrong
Add a flag to Sail that allows for an image of an elf file to be dumped in a simple format using linksem, used as sail -elf test.elf -o test.bin This image file can then be used by a compiled C version of a sail spec as with ocaml simply by ./a.out test.bin
2018-03-07Make union types consistent in the ASTAlasdair Armstrong
Previously union types could have no-argument constructors, for example the option type was previously: union option ('a : Type) = { Some : 'a, None } Now every union constructor must have a type, so option becomes: union option ('a : Type) = { Some : 'a, None : unit } The reason for this is because previously these two different types of constructors where very different in the AST, constructors with arguments were used the E_app AST node, and no-argument constructors used the E_id node. This was particularly awkward, because it meant that E_id nodes could have polymorphic types, i.e. every E_id node that was also a union constructor had to be annotated with a type quantifier, in constrast with all other identifiers that have unquantified types. This became an issue when monomorphising types, because the machinery for figuring out function instantiations can't be applied to identifier nodes. The same story occurs in patterns, where previously unions were split across P_id and P_app nodes - now the P_app node alone is used solely for unions. This is a breaking change because it changes the syntax for union constructors - where as previously option was matched as: function is_none opt = match opt { Some(_) => false, None => true } it is now matched as function is_none opt = match opt { Some(_) => false, None() => true } note that constructor() is syntactic sugar for constructor(()), i.e. a one argument constructor with unit as it's value. This is exactly the same as for functions where a unit-function can be called as f() and not as f(()). (This commit also makes exit() work consistently in the same way) An attempt to pattern match a variable with the same name as a union-constructor now gives an error as a way to guard against mistakes made because of this change. There is probably an argument for supporting the old syntax via some syntactic sugar, as it is slightly prettier that way, but for now I have chosen to keep the implementation as simple as possible. The RISCV spec, ARM spec, and tests have been updated to account for this change. Furthermore the option type can now be included from $SAIL_DIR/lib/ using $include <option.sail>
2018-01-18Merge remote-tracking branch 'origin/experiments' into sail2Alasdair Armstrong
2018-01-17Rewrite topological sortingThomas Bauereiss
Use Tarjan's algorithm for finding strongly connected components (and finding a topological sorting of components at the same time), in order to properly take into account mutually recursive functions. The sorting is stable, i.e., definitions are only moved when necessary. Exceptions to this are statements that do not have any dependencies: default bitvector order declarations, operator fixity declarations, and top-level comments. These are moved to the beginning (like with the previous sorting implementation). Any dependency cycles that are found are additionally printed to the console in dot-format, for easy visualisation with graphviz.
2018-01-12OCaml interactive mode can now run full aarch64 examples, and ocaml test cases.Alasdair Armstrong
2018-01-05Moved parser, lexer and pretty printer to correct locations.Alasdair Armstrong
2018-01-05Added bitfield syntax to replicate register bits typeAlasdair Armstrong
For example: bitfield cr : vector(8, dec, bit) = { CR0 : 7 .. 4, LT : 7, CR1 : 3 .. 2, CR2 : 1, CR3 : 0, } The difference this creates a newtype wrapper around the vector type, then generates getters and setters for all the fields once, rather than having to handle this construct separately in every backend.
2018-01-02Experimenting with power specAlasdair Armstrong
2017-12-14Fix all compiler warning except in lem pretty printer and monomorphisationAlasdair Armstrong
2017-12-13Use big_nums from LemAlasdair Armstrong
2017-12-06Add top-level pattern match guards internallyBrian Campbell
Also fix bug in mono analysis with generated variables Breaks lots of typechecking tests because it generates unnecessary equality tests on units (and the tests don't have generic equality), which I'll fix next.
2017-12-06Merge remote branch 'experiments' into experimentsThomas Bauereiss
2017-12-06Make AST after rewriting for Lem backend type-checkableThomas Bauereiss
- Add support for some internal nodes to type checker - Add more explicit type annotations during rewriting - Remove hardcoded rewrites for E_vector_update etc from Lem pretty-printer; these will be resolved by the type checker during rewriting now
2017-12-05Update license headers for Sail sourceAlasdair Armstrong
2017-11-16Remove unused Typ_wild constructorAlasdair Armstrong
2017-10-31Fix bug in topological sorting of val-specsThomas Bauereiss
Put them before the function they declare
2017-10-25Allow mutually recursive functionsThomas Bauereiss
2017-10-24Remove special case for boolean (as opposed to bool)Brian Campbell
2017-10-19Follow AST changes in (Lem) pretty-printersThomas Bauereiss
2017-09-21Refactored AST valspecs into single constructorAlasdair Armstrong
2017-09-21Remove unused kind_def (KD_) nodes from ASTAlasdair Armstrong
2017-09-21Simplify AST by removing LB_val_explicit and replace LB_val_implicit with ↵Alasdair Armstrong
just LB_val in AST also rename functions in rewriter.ml appropriately.
2017-09-21Cleaning up the AST and removing redundant and/or unused nodesAlasdair Armstrong
2017-09-14Fix bug in topological sortingThomas Bauereiss
2017-08-14Existentials in free type var functionsBrian Campbell
2017-08-01Modified the typechecker for ASL generationAlasdair Armstrong
2017-07-27Add cons patterns to pretty-printersThomas Bauereiss
2017-07-21Switch to new typechecker (almost)Thomas Bauereiss
Initial typecheck still uses previous typechecker
2017-02-03fix headersPeter Sewell
2016-10-13make sail-to-lem rewriting passes use dependency analysis, make dependency ↵Christopher Pulte
analysis include type information, small pp fix
2016-10-12Add free variable and dependency sorting functions, lifted from internal to ↵Kathy Gray
external repository
2016-01-21Start splitting values/etc into int/big_int for ocaml generationKathy Gray
2016-01-19Put None and Some into interpreter environmentsKathy Gray
Also making progress towards separating int sized things from integer sized things
2015-11-10Make first half of sequential interpreter driver compile againKathy Gray
2015-11-06fixesChristopher Pulte
2015-11-04Add a new module for writing queries/analyses that aren't type checking but ↵Kathy Gray
could be useful Define in that a function for determining a default direction for vectors