summaryrefslogtreecommitdiff
path: root/src/initial_check.ml
AgeCommit message (Collapse)Author
2017-10-25Merge branch 'experiments' into mono-experimentsBrian Campbell
2017-10-24Generate undefined_bitvector function when targeting machine wordsBrian Campbell
2017-10-23Added support for better tracing in ocaml backendAlasdair Armstrong
Fixed an issue in ast.ml with uneccessary type variables
2017-10-10More improvements to menhir parserAlasdair Armstrong
2017-10-09Improvements to menhir pretty printer and ocaml backendAlasdair Armstrong
Menhir pretty printer can now print enough sail to be useful with ASL parser Fixity declarations are now preserved in the AST Menhir parser now runs without the Pre-lexer Ocaml backend now supports variant typedefs, as the machinery to generate arbitrary instances of variant types has been added to the -undefined_gen flag
2017-10-06Remove BK_effect constructorAlasdair Armstrong
2017-10-06Various improvements to menhir parser, and performance improvments for Z3 callsAlasdair Armstrong
New option -memo_z3 memoizes calls to the Z3 solver, and saves these results between calls to sail. This greatly increases the performance of sail when re-checking large specifications by about an order of magnitude. For example: time sail -no_effects prelude.sail aarch64_no_vector.sail real 0m4.391s user 0m0.856s sys 0m0.464s After running with -memo_z3 once, running again gives: time sail -memo_z3 -no_effects prelude.sail aarch64_no_vector.sail real 0m0.457s user 0m0.448s sys 0m0.008s Both the old and the new parser should now have better error messages where the location of the parse error is displayed visually in the error message and highlighted.
2017-10-04Merge branch 'cleanup' into experimentsAlasdair Armstrong
2017-10-03Fixes to new parserAlasdair Armstrong
2017-09-26Added while-do and repeat-until loops to sail for translating ASLAlasdair Armstrong
2017-09-21Refactored AST valspecs into single constructorAlasdair Armstrong
2017-09-21Remove unused kind_def (KD_) nodes from ASTAlasdair Armstrong
2017-09-21Change NC_fixed to NC_equal to match NC_not_equalAlasdair Armstrong
also rename NC_nat_set_bounded to NC_set (it was an int set not a nat set anyway)
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-13Work on improving Sail error messagesAlasdair Armstrong
- Modified how sail type error messages are displayed. The typechecker, rather than immediately outputing a string has a datatype for error types, which are the pretty-printed using a PPrint pretty-printer. Needs more work for all the error messages. - Error messages now attempt to highlight the part of the file where the error occurred, by printing the line the error is on and highlighting where the error message is in red. Again, this needs to be made more robust, especially when the error messages span multiple lines. Other things - Improved new parser and lexer. Made the lexer & parser handling of colons simpler and more intuitive. - Added some more typechecking test cases
2017-09-07Merge branch 'experiments' of https://bitbucket.org/Peter_Sewell/sail into ↵Alasdair Armstrong
experiments
2017-09-07Add ocaml run-time and updates to sail for ocaml backendAlasdair Armstrong
2017-08-29More work on ocaml backend.Alasdair Armstrong
Works for basic examples with arbitrary register types, so for example we can compile: val extern string -> unit effect pure print = "print_endline" val unit -> string effect pure hello_world function hello_world () = { return "Hello, World!"; "Unreachable" } val unit -> unit effect {wreg, rreg} main register string REG function main () = { REG := "Hello, Sail!"; print(REG); REG := hello_world (); print(REG); return () } into open Sail_lib;; let zhello_world () = with_return (fun r -> begin r.return "Hello, World!"; "Unreachable" end);; let zREG : (string) ref = ref (undefined_string ());; let zmain () = with_return (fun r -> begin zREG := "Hello, Sail!"; print_endline !zREG; zREG := zhello_world (); print_endline !zREG; r.return () end);; let initialize_registers () = with_return (fun r -> zREG := undefined_string ());; with the arbitrary register types and early returns being handled appropriately, given a suitable implementation for Sail_lib
2017-08-24More work on undefined elimination pass.Alasdair Armstrong
Also generate a function which initializes all the registers in a spec to undefined. This gives us the information we need post-rewriting to generate registers of any arbitrary type.
2017-08-23Started work on an undefined literal removal pass for the ocamlAlasdair Armstrong
backed. Ocaml doesn't support undefined values, so we need a way to remove them from the specification in order to generate good ocaml code. There are more subtle issues to - like if we initialize a mutable variable with an undefined list, then the ocaml runtime has no way of telling what it's length should be (as this information is removed by the simple_types pass). We therefore rewrite undefined literals with calls to functions that create undefined types, e.g. (bool) undefined becomes undefined_bool () (vector<'n,'m,dec,bit>) undefined becomes undefined_vector(sizeof 'n, sizeof 'm, undefined_bit ()) We therefore have to generate undefined_X functions for any user defined datatype X. initial_check seems to be the logical place for this. This is straightforward provided the user defined types are not-recursive (and it shouldn't be too bad even if they are).
2017-08-16Added the feature to bind type variables in patterns.Alasdair Armstrong
The reason you want this is to do something like (note new parser only): ********* default Order dec type bits 'n:Int = vector('n - 1, 'n, dec, bit) val zeros : forall 'n. atom('n) -> bits('n) val decode : bool -> unit function decode b = { let 'datasize: {|32, 64|} = if b then 32 else 64; let imm: bits('datasize) = zeros(datasize); () } ********* for the ASL decode functions, where the typechecker now knows that the datasize variable and the length of imm are the same.
2017-08-15Removed Typ_arg_effect - nobody used it and it isn't supported by the backends.Alasdair Armstrong
2017-08-15Added exceptions and try/catch blocks to AST and typechecker in orderAlasdair Armstrong
to translate exceptions in ASL. See test/typecheck/pass/trycatch.sail.
2017-08-14More constructs in menhir parser, plus support for both left and right infix ↵Alasdair Armstrong
operators.
2017-08-10Improved existentials and type synonymsAlasdair Armstrong
2017-08-07Improvements to existentials for ASL parserAlasdair Armstrong
2017-07-28Merge remote-tracking branch 'origin/sail_new_tc' into experimentsAlasdair Armstrong
2017-07-27Parameterise convert_ast by the bitvector orderAlasdair Armstrong
2017-07-26Added syntax for existential typesAlasdair Armstrong
2017-07-26Allow arbitrary identifiers in nexp expressionsAlasdair Armstrong
Fixed some bugs in the initial check that caused valid code to fail to parse Add a nid utility function that creates an id n-expression, similar to nvar, nconstant etc
2017-07-24Added cons patterns to sailAlasdair Armstrong
See test/typecheck/pass/cons_pattern.sail for an example. Also cleaned up the propagating effects code by making some of the variable names less verbose
2017-07-21Everything moved to new typecheckerAlasdair Armstrong
Modified initial_check.ml so it no longer requires type_internal. It's still needs cleaned up in a few ways. Most of the things it's trying to do could be done nicer if we took some time to re-factor it, and some of the things should just be handled by the main typechecker, leaving it as a think layer between the parse_ast and the ast. Now that's done everything can be switched to the new typechecker and the _new suffixes were deleted from everything except the monomorphisation pass because I don't know the status of that.
2017-07-21Improvements to sail n_constraintsAlasdair Armstrong
1) Added a new construct to the expression level: constraint. This is the essentially the boolean form of sizeof. Whereas sizeof takes a nexp and has type [:'n:], constraint takes a n_constraint and returns a boolean. The hope is this will allow for flow typing to be represented more explicitly in the generatated sail from ASL. For example we could have something like: default Order dec val bit[64] -> unit effect pure test64 val forall 'n, ('n = 32 | 'n = 64 | 'n = 10) & 'n != 43. bit['n] -> unit effect pure test function forall 'n. unit test addr = { if constraint('n = 32) then { () } else { assert(constraint('n = 64), "64-bit mode"); test64(addr) } } 2) The other thing this example demonstrates is that flow constraints now work with assert and not just if. Even though flow typing will only guarantee us that 'n != 32 in the else branch, the assert gives us 'n = 64. This is very useful as it's a common idiom in the ARM spec to guarantee such things with an assert. 3) Added != to the n_constraint language 4) Changed the n_constraint language to add or and and as constructs in constraints. Previously one could have a list of conjuncts each of which were simple inequalites or set constraints, now one can do for example: val forall 'n, ('n = 32 | 'n = 64) & 'n in {32, 64}. bit['n] -> unit effect pure test This has the very nice upside that every n_constraint can now be negatated when flow-typing if statements. Note also that 'in' has been introduced as a synonym for 'IN' in the constraint 'n in {32,64}. The use of a block capital keyword was a bit odd there because all the other keywords are lowercase.
2017-07-18Added real number literals to sail, to better support full ASL translationAlasdair Armstrong
2017-07-17Added pattern guards to sailAlasdair Armstrong
Introduces a when keyword for case statements, as the Pat_when constructor for pexp's in the AST. This allows us to write things like: typedef T = const union { int C1; int C2 } function int test ((int) x, (T) y) = switch y { case (C1(z)) when z == 0 -> 0 case (C1(z)) when z != 0 -> x quot z case (C2(z)) -> z } this should make translation from ASL's patterns much more straightforward
2017-07-12Various small changesAlasdair Armstrong
* Experimented with using list<bit> to clean up manually monomorphised code in MIPS tlb * Added option -dtc_verbose to control verbosity of new typechecker * Allowed functions with val specs to omit their type declarations
2017-06-28User defined overloaded operatorsAlasdair Armstrong
New typechecker has no builtin overloaded operators - instead can now write something in SAIL like: overload (deinfix +) [id1; id2; id3] to set up functions id1, id2, and id3 as overloadings for the + operator. Any identifier can be overloaded, not just infix ones. This is done in a backwards compatible way, so the old typechecker removes the DEF_overload nodes from the ast so the various backends never see it.
2017-06-28Improvements to implicit type castingAlasdair Armstrong
Added a new feature for implicit casts - now allowable implicit casts can be specified by the user via a valspec such as val cast forall Type 'a, Type 'b. 'a -> 'b effect pure cast_anything with a new AST constructor to represent this as VS_cast_spec. This constructor is removed and replaced with the standard val spec by the old typechecker for backwards compatability, so it's only used by the new typechecker, and won't appear in the ast once it reaches the backends. Also added Num as a synonym for the Nat kind in the parser, via the confusingly named NatNum token (Num by itself was already taken for a numeric constant).
2017-05-24Merge branch 'master' of bitbucket.org:Peter_Sewell/sailShaked Flur
# Conflicts: # src/lem_interp/interp.lem # src/lem_interp/interp_inter_imp.lem # src/lem_interp/interp_interface.lem # src/parser.mly # src/pretty_print_lem.ml
2017-05-24added the exmem effect for AArch64 store-exclusiveShaked Flur
2017-05-24Change types of MEMr_tag, MEMval_tag and co. so that tag is separate from ↵Robert Norton
data and invent rmemt and wmvt effects for them. Extend the interpreter context to include lists of tagged memory read and write functions. The memory model must round down the address to the nearest capability aligned address when reading/writing tags. Remove TAGw which is no longer needed as a result.
2017-02-03fix headersPeter Sewell
2016-08-14Start adding form for (a,b,c) := foo()Kathy Gray
Not working yet
2016-07-24Make sure that all type constructors with unit type have a type union with ↵Kathy Gray
just an id (hopefully fixes Christopher issue).
2016-07-23Add a return exp form to Sail, supported in type checker and in interpreter.Kathy Gray
TODO: add an event for a return so that rewriters can find and remove them as needed for OCaml and Lem
2016-05-27Add sizeof to sail. Documentation to followKathy Gray
2016-03-02Add new language feature to permit definitions of items of kind Nat, etc as ↵Kathy Gray
well as items of kind Type. Syntax for the feature is: def Nat id = nexp Note: some useful nexps may not parse properly. All typedef forms can also be used as def Type ... if desired, but this is not required.
2016-02-23Several fixesKathy Gray
Improve printing for asl to sail readability; Add -o option for selecting the name of file generation; Add additional initial check module for turning generated ast nodes into ready-to-type-check ast nodes
2016-01-06Add new assert expression to SailKathy Gray
This splits the former functionality of exit into errors, which should now use assert(bool,option<string>), and a means of signalling actions such as instruction-level exceptions, interrupts, or other features that impact the ISA. The latter will now be tracked with an effect escape, and so any function containing exit and declared pure will generate a type error. WARNING: ARM spec will not build with this commit until I modify it. MIPS spec will not build with this commit until modified.