summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2020-05-21Merge branch 'sail2' into mono-tweaksAlasdair
2020-05-18Add a prefix option for generated coverage filesAlasdair
2020-05-18Add a header and a default page to the index in coverage reportsAlasdair
2020-05-15Merge pull request #67 from arichardson/add-staticAlasdair Armstrong
Add static to more C functions
2020-05-15Remove some left over debug statementsAlasdair
2020-05-15Generate index for coverageAlasdair
2020-05-15C backend: Only add static to model_{init,fini} if -static is passedAlex Richardson
Otherwise the C emulator doesn't build.
2020-05-15C backend: Add a static () helperAlex Richardson
This simplifies some of the code.
2020-05-15Fix more typosAlasdair
2020-05-15Tweak readmeAlasdair
2020-05-15Add colour options to sailcovAlasdair
Colours can be tweaked for aesthetics by setting hue and saturation individually or there is an --alt-colo[u]rs flag which switches to a yellow/blue mode that should be better for red/green colourblindness.
2020-05-15Add static to registers if -static is passedAlex Richardson
This was the final missing step for me to link two almost identical C files generated from sail into the same library.
2020-05-15Also make the letbinding C variables staticAlex Richardson
I was getting run-time failures when code generate from cheri128 and cheri64 in the same process. This was caused because my compiler defaults to -fcommon so it merged multiple variables (with conflicting types!). When initializing the second set of letbindings, the first one was overwritten (first variable was lbits, the other was uint64_t). Compiling with -fno-common exposes this problem.
2020-05-15Also allow adding static to model_{init,fini,main}()Alex Richardson
Without this I get the following linker error when trying to include both 64 and 128 bit sail-riscv code in the same binary: duplicate symbol '_model_init' in: libsail_wrapper128.a(sail_wrapper_128.c.o) libsail_wrapper128.a(sail_wrapper_64.c.o) duplicate symbol '_model_main' in: libsail_wrapper128.a(sail_wrapper_128.c.o) libsail_wrapper128.a(sail_wrapper_64.c.o) duplicate symbol '_model_fini' in: libsail_wrapper128.a(sail_wrapper_128.c.o) libsail_wrapper128.a(sail_wrapper_64.c.o) # Conflicts: # src/jib/c_backend.ml
2020-05-15Add static to more C functionsAlex Richardson
This allows me to compile sail-riscv64 and sail-riscv128 code in the same static library.
2020-05-15Add --tab-width option to sailcovAlasdair
2020-05-15Update type error messages for jenkinsAlasdair
Location info fixes changed the location reported for an expected type error very slightly
2020-05-15Move riscv_vmem_sv39 example to a separate page so it renders nicelyAlasdair
2020-05-15Add example output for coverage visualisationAlasdair
2020-05-15Add coverage headerAlasdair
2020-05-15Fix linksAlasdair
2020-05-15Add sailcov readmeAlasdair
2020-05-15Add coverage tracking toolAlasdair
See sailcov/README.md for a short description Fix many location info bugs discovered by eyeballing output
2020-05-14Output INT64_MIN in code generator for min 64-bit integer literalAlasdair
Fixes the warning generated because in C -X where X is the minimum integer is parsed as a positive integer which is then negated. This causes a (I believe spurious) warning that the integer literal is too large for the type. Also using INT64_C so we get either long or long long depending on platform
2020-05-14Merge remote-tracking branch 'origin' into codegenAlasdair
2020-05-14Re-activate some testsAlasdair
2020-05-14Attempt to fix CI errorAlasdair
2020-05-14Various bugfixes and improvements for updated codegenAlasdair
2020-05-12Add support for instrumenting generated C with branch coverage metricsAlasdair
Will call: void sail_branch_reached(int branch_id, char *source_file, int l1, int c1, int l2, int c2); on each branch caused by a match or if statement in the source code For each branch that is taken, will call: void sail_branch_taken(int branch_id, char *source_file, int l1, int c1, int l2, int c2) Every branch gets a unique identifier, and the functions are called with the source file location and line/character information for the start and end of each match case or then/else branch. sail_branch_reached is given the location info for the whole match statement.
2020-05-12Support for user-defined state and headers in new codegenAlasdair
All the code-generator options can now be controlled via a json configuration file Extra fields can be added to the sail_state struct using a codegen.extra_state key in the configuration json for the code generator If primitives want to modify the state they can be specified via codegen.state_primops To import such state, codegen.extra_headers can be used to add user-defined headers to the generated .h file
2020-05-11Functorise and refactor C code generatorAlasdair
Currently uses the -c2 option Now generates a sail_state struct which is passed as a pointer to all generated functions. This contains all registers, letbindings, and the exception state. (Letbindings must be included as they can contain pointers to registers). This should make it possible to use sail models in a multi-threaded program by creating multiple sail_states, provided a suitable set of thread-safe memory builtins are provided. Currently the sail_state cannot be passed to the memory builtins. For foo.sail, now generate a foo.c, foo.h, and (optionally) a foo_emu.c. foo_emu.c wraps the generated library into an emulator that behaves the same as the one we previously generated. The sail_assert and sail_match_failure builtins are now in a separate file, as they must exist even when the RTS is not used. Name mangling can be controlled via the exports and exports_mangled fields of the configuration struct (currently not exposed outside of OCaml). exports allows specifying a name in C for any Sail identifier (before name mangling) and exports_mangled allows specifiying a name for a mangled Sail identifier - this is primarily useful for generic functions and data structures which have been specialised.
2020-04-28Update test error messages, hopefully will make Jenkins happy againAlasdair
2020-04-28Add flooring division in preludeAlasdair
Defined in terms of tdiv so we don't have to add it to backends that don't already have it
2020-04-27Fix try in exception handler jib bugBrian Campbell
The have_exception flag wasn't being cleared until after the handler, resulting in false exception reporting.
2020-04-22Add an interactive command to evaluate until the end of a functionAlasdair
Callable as either :f or :step_function Allow // to be used as a comment in the interactive toplevel
2020-04-21Fix build with OCaml 4.06.1Thomas Bauereiss
2020-04-21Lem: Print more type annotationsThomas Bauereiss
In particular tuple types containing bitvectors.
2020-04-21Add more SMT builtinsThomas Bauereiss
Also add support for intialising variables with an "undefined" literal; make the SMT solver treat the value as arbitrary but fixed.
2020-04-21Fix sub_bits interpreter bindingThomas Bauereiss
2020-04-21Add more monomorphisation rewritesThomas Bauereiss
Supporting more ASL idioms
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-21Mono: Check for non-constant calls to make_the_valueThomas Bauereiss
... and try to resolve them using constant propagation.
2020-04-21Mono: Extract more kid instantiations from assertionsThomas Bauereiss
Ask the type checker instead of looking at the expression syntax. This also discovers implied instantiations, e.g. if we previously knew ('N in {32, 64}) and we have an assertion ('N != 32), then we know ('N == 64).
2020-04-21Mono: Propagate constants after applying pattern choicesThomas Bauereiss
This will propagate constant assignments in chosen branches of case expressions after applying pattern choices, e.g. the assignment to datasize in match size { [bitone, _] => datasize = 64, ... } when pattern [bitone, _] is chosen for size.
2020-04-21Add rewrite for constant-folding top-level letbindingsThomas Bauereiss
This will constant-fold letbindings such as let LOG2_TAG_GRANULE : int(4) = 4 let TAG_GRANULE : int = (1 << LOG2_TAG_GRANULE) which is useful for the translation to Lem if TAG_GRANULE is used in bitvector lengths.
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
2020-04-21Consider literals in pattern disjointness checkThomas Bauereiss
This check is used in the guarded pattern rewrite step, which would previously generate some impossible matches (e.g. matching expression "true" against pattern "false").
2020-04-21Mono: Extract set constraints from (in)equalitiesThomas Bauereiss
2020-04-21Handle more cases in bitvector cast rewriteThomas Bauereiss
Add casts for function arguments using the constraints in the environment of the function clause (not just assertions within the function body). Also pass in the global typing environment for comparison with the environment within the function clause (and make a corresponding change in the Lem pretty-printer so that it uses the right environments).
2020-04-21Add support for some ASL idioms in mono rewritesThomas Bauereiss