summaryrefslogtreecommitdiff
path: root/src/sail_lib.ml
AgeCommit message (Collapse)Author
2020-03-29Implement set_slice_int in the interpreterAlasdair
2020-02-20Fix missing code generation builtins for lists. Fixes #59Alasdair Armstrong
Also uncovered a few other issues w.r.t lists
2019-11-21Implement -cycle-limit option for OCaml emulator similar to one for C.Robert Norton
2019-11-04Allow overriding the interpreter effectsAlasdair Armstrong
This allows read_mem and read_reg effects to be handled by GDB
2019-07-16Merge remote-tracking branch 'origin/sail2' into separate_bvAlasdair Armstrong
2019-06-19Fix buggy ocaml implementation of count_leading_zeros and also make tail ↵Robert Norton
recursive.
2019-06-17Implement a count_leading_zeros builtin for ocaml and c. This may be a ↵Robert Norton
slight performance improvement and keeps compatibility with smt backend that already had a builtin for this because it can't handle the loop in the sail version. Will need implementations for prover backends.
2019-06-06Add arith_shiftr to C and OCaml librariesThomas Bauereiss
2019-06-04Merge branch 'sail2' into separate_bvAlasdair Armstrong
2019-05-30Implement ones builtin in sail_lib and add to interpreter. However currently ↵Robert Norton
this is implemented in lib/vector_dec.sail as sail function that calls not_vec on sail_zeros.
2019-05-17Experiment with making vector and bitvector distinct typesAlasdair Armstrong
Only change that should be needed for 99.9% of uses is to change vector('n, 'ord, bit) to bitvector('n, 'ord), and adding $ifndef FEATURE_BITVECTOR_TYPE type bitvector('n, dec) = vector('n, dec, bit) $endif for to support any Sail before this Currently I have all C, Typechecking, and SMT tests passing, as well as the RISC-V spec building OCaml and C completely unmodified.
2019-05-13Merge branch 'sail2' into smt_experimentsAlasdair
2019-05-13Changes to toFromInterp backend to support aarch64_smallJon French
* Includes adding support for bitlist-Lem * Adds new command-line option -Ofast_undefined
2019-05-10SMT: Experiment with symbolic memory reads and writesAlasdair Armstrong
2019-03-22Tidy up of div and mod operators (C implementation was previously ↵Robert Norton
inconsistent with ocaml etc.). Rename div and mod builtins to ediv_int/emod_int and tdiv_int/tmod_int and add corresponding implementations. Add a test with negative operands. This will break existing models but will mean users have to think about which versions they want and won't accidentally use the wrong one.
2019-03-15Various monomorphisation tweaks and fixesThomas Bauereiss
2019-01-22Make sure there is an ocaml representation for optimized memory read forAlasdair
RISC-V
2018-12-14Add truncateLSB builtin useful for implementing Cheri Concentrate. Also add ↵Robert Norton
bool_of_bit and bit_of_bool in sail_lib
2018-12-14Get real number tests working in OCaml/InterpreterAlasdair
2018-12-13Fixing rationals in Sail interpreter and OCamlAlasdair Armstrong
2018-12-13Add hooks to call cgen stub file for RISC-VAlasdair Armstrong
2018-10-16Re-implement space-related mapping functions in Sail rather than backendsJon French
Uses new primop 'string_take' which is much easier to implement in e.g. C
2018-10-10refer to Util.list_init.ml rather than List.init in sail_lib.mlChristopher Pulte
2018-10-03Drop unnecessary thunking; more trouble than it's worthBrian Campbell
2018-10-02Rough code to generate random instructions for testingBrian Campbell
(aimed at RISC-V)
2018-09-19separate decimal_string_of_bits from string_of_bitsJon French
2018-09-14Sail_lib.string_of_bits: print in decimal (properly, with bigints) rather ↵Jon French
than binary
2018-09-14(oops, should have been with "more hex_bits_N monomorphs")Jon French
2018-09-14Sail_lib.int_of_string_opt: use Big_int.of_string rather than OCaml ↵Jon French
int_of_string This fixes e.g. problems with 64-bit bitmask immediates in ARM assembly.
2018-09-14More monomorphisations for hex_bits_N...Jon French
I got bored of this so I wrote a Python script to generate all of them between 1 and 33, plus 48 and 64. It's in a comment. We should really get around to making the typechecker work with polymorphic mappings...
2018-09-14Sail_lib and RISCV prelude: functions for bitwise operations on intsJon French
2018-09-10Various fixesAlasdair Armstrong
C: Don't print usage message and quit when called with no arguments, as this is used for testing C output OCaml: Fix generation of datatypes with multiple type arguments OCaml: Generate P_cons pattern correctly C: Fix constant propagation to not propagate letbindings with type annotations. This behaviour could cause type errors due to how type variables are introduced. Now we only propagate letbindings when the type of the propagated variable is guaranteed to be the same as the inferred type of the binding. Tests: Add OCaml tests to the C end-to-end tests (which really shouldn't be in test/c/ any more, something like test/compile might be better). Currently some issues with reals there like interpreter. Tests: Rename list.sail -> list_test.sail because ocaml doesn't want to compile files called list.ml.
2018-09-04C: Tweaks to RISC-V to get compiling to CAlasdair Armstrong
Revert a change to string_of_bits because it broke all the RISC-V tests in OCaml. string_of_int (int_of_string x) is not valid because x may not fit within an integer.
2018-08-31riscv prelude: yet more manual monomorphisations for hex_bitsJon French
2018-08-16Various cleanups to ott grammarAlasdair Armstrong
Add additional well-formedness check when calling typing rules
2018-07-11RISC-V model fixes for RMEMJon French
2018-07-09Initialize fresh memory to 0 in the OCaml backend.Prashanth Mundkur
This makes it consistent with the C backend, and also makes it easier to compare traces across execution re-runs.
2018-06-22add support for new cycle_limit feature in mips.Robert Norton
2018-06-21Merge branch 'tracing' into sail2Alasdair Armstrong
2018-06-14provide impl of int_of_string_opt in Sail_lib to support older Ocaml versionsJon French
2018-06-13Tracing instrumentation for C backendAlasdair Armstrong
2018-06-11add 'pat as id' mapping-patternsJon French
2018-06-11Merge branch 'sail2' into mappingsJon French
(involved some manual tinkering with gitignore, type_check, riscv)
2018-06-04switch to using a Map data structure for cheri tags in ocaml backend. This ↵Robert Norton
solves a problem where the Hashtbl module was encountering a stack overflow booting CheriBSD. There seems to be little or no performance impact.
2018-06-04Use Util.split_on_char in sail_lib.mlAlasdair Armstrong
2018-05-31Fix for Jenkins buildAlasdair Armstrong
Looks like Jenkins is still on OCaml 4.02.3. We should probably upgrade to 4.05 at some point.
2018-05-31Fixes to get ARM u-boot working in Sail.Alasdair Armstrong
Also fixes to C backend for compiling MIPS spec to C - Fix an issue with const correctness in internal_vector_update functions generated by C backend - Add builtins for MIPS to sail.h - Fix an issue where reg_deref didn't work when called on pointers to large bitvectors, i.e. vectors containing references to large bitfields as in the MIPS TLB code - Various bug fixes and changes for running U-boot on ARM model, including for interpreter and OCaml compilation. - Fix memory leak issues and incorrect shadowing for foreach loops - Update C header file. Fixes memory leak in memory read/write builtins. - Add aux constructor to ANF representation to hold environment information. - Fix undefined behavior caused by optimisation left shifting uint64_t vectors 64 or more times. Unfortunately there's more issues because the same happens for X >> 64 right shifts. It would make sense for this to be zero, because that would guarantee the property that ((X >> n) >> m) == (X >> (n + m)) but we probably need to do (X >> (n - 1) >> 1) in the optimisation to ensure that we don't cause UB. Shifting by 63 and then by 1 is well-defined, but shifting by 64 in one go isn't according to the C standard. This issue with right-shifts only occurs for zero-length vectors, so it's not a huge deal, but it's still annoying. - Add versions of print_bits and print_int that print to stderr. Follows OCaml convention of print/prerr. Should make things more explicit. Different backends had different ideas about where print should output to, not every backend needs to have this (e.g. theorem prover backends don't need to print) but having both stderr and stdout seperate and clear is useful for executable models (UART needs to be stdout, debug messages should be stderr).
2018-05-31Some tweaks to ocaml compilation and sail_lib for ARM with system registersAlasdair Armstrong
2018-05-25Use paged memory storage for ocaml backend memory. This is slightly slower ↵Robert Norton
(<5% on a simple test) but dramatically reduces memory usage compared to having a hash table entry per byte!
2018-05-23riscv decode now uses mapping-decode and passes testsJon French