summaryrefslogtreecommitdiff
path: root/src/jib
AgeCommit message (Collapse)Author
2021-03-05Add more location information to IRAlasdair
2021-01-05Fix some cases when monomorphising vectors containing variable-length bitvectorsAlasdair
2020-11-21Make coverage support look a little harder for location informationBrian Campbell
2020-11-20Add coverage output to short-circuiting operatorsBrian Campbell
2020-11-18Fix coverage information in case branches that immediately returnBrian Campbell
2020-10-14Support C coverage when sail_exit is usedBrian Campbell
2020-09-29Refactor: Change AST type from a union to a structAlasdair
2020-09-28Refactor: Rename 'a defs to 'a astAlasdair
Change internal terminology so we more clearly distinguish between a list of definitions 'defs' and functions that take an entire abstract syntax trees 'ast'.
2020-09-28Move the ast defs wrapper into it's own fileAlasdair
This refactoring is intended to allow this type to have more than just a list of definitions in future.
2020-09-16C codegen: remove an unnecessary declaration in the header fileJulien Freche
2020-08-25Add function sail_set_coverage_file to sail_coverage headerAlasdair
Can be set by C emulator to control where coverage information is written
2020-08-24Merge pull request #83 from julienfreche/configure_get_setAlasdair Armstrong
c2: make the global state API configurable for externally defined get/set functions
2020-08-21C generation tweaksAlasdair
2020-08-21c2: make the global state API configurable for externally defined get/set ↵Julien Freche
functions
2020-08-18Move sail_state declaration into it's own fileAlasdair
Useful for RISC-V with it's custom C emulator
2020-08-10Fix a C backend bug with letbindings in guards shadowing body definitionsAlasdair
2020-08-06Fix a small bug with nested structs test in -c2 state apiAlasdair
2020-08-05Generate accessors for scalar types, array of scalars and scalars in struct ↵Julien Freche
in the sail state
2020-07-15Update duplicate ctor warningAlasdair
2020-07-14c2: primop: -O: make sure to pick global or name correctlyJulien Freche
2020-06-23Fix bug with duplicate enum identifiers in patternsAlasdair
2020-06-12Use output file for generated branch information.Prashanth Mundkur
2020-05-22Fix atomicity of register field writesAlasdair
Previous merge commit caused some code that was generating register.field = value to instead generate temp = register temp.field = value register = temp This was caused by rewriter changes affecting the ANF form, and the Jib compilation was sensitive to small changes in the ANF form when compiling l-expressions. Rather than applying a band-aid fix in the rewriter this commit re-factors the ANF translation of l-expressions to ensure that the jib compilation is more robust and able to consistently generate the correct l-expressions without introducing additional read-modify-write expressions in the code.
2020-05-21Merge branch 'sail2' into mono-tweaksAlasdair
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-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 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-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-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-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-03-13SMT fixes for some corner cases of vector updatesThomas Bauereiss
2020-03-02Add arith_shiftr to SMT and interpreterThomas Bauereiss
2020-02-21SMT: Implement a few more primopsThomas Bauereiss
2020-02-20More list C codegen fixes for issue #59Alasdair Armstrong
2020-02-20Fix missing code generation builtins for lists. Fixes #59Alasdair Armstrong
Also uncovered a few other issues w.r.t lists
2020-01-17Keep track of source locations for all IR branchesAlasdair
Useful for tracking down non-determinism
2020-01-16Allow effects on mappingsAlasdair Armstrong
2020-01-16Keep track of (non-bit) vectors known to be fixed size in JibAlasdair Armstrong
This is useful because an arbitrary vector of a fixed size N can be represented symbolically as a vector of N symbolic values, whereas an arbitrary vector of arbitrary size cannot be easily represented.
2020-01-14Basic support to track uncaught exceptions in Sail->CAlasdair
2020-01-10Don't do any C specific name mangling for the cons operator in jib_compileAlasdair Armstrong
Instead handle it specially in c_backend, leaving the type information in the IR available for other consumers
2019-12-18Make sure we generate literals of precisely the right length for symbolic ↵Alasdair Armstrong
execution