From 3604e9e94b766147b482c4c653c4d09bb4ee7a7c Mon Sep 17 00:00:00 2001 From: Alasdair Armstrong Date: Wed, 4 Apr 2018 15:03:45 +0100 Subject: Add generic prelude library that pulls in various basic sail definitions from sail/lib. --- src/gen_lib/sail_values.lem | 4 ++++ src/process_file.ml | 7 +++++++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/gen_lib/sail_values.lem b/src/gen_lib/sail_values.lem index a89456b9..2fe69211 100644 --- a/src/gen_lib/sail_values.lem +++ b/src/gen_lib/sail_values.lem @@ -276,6 +276,8 @@ let ext_list pad len xs = if longer < 0 then drop (nat_of_int (abs (longer))) xs else pad_list pad xs longer +let vector_truncate bs len = ext_list B0 len bs + let extz_bools len bs = ext_list false len bs let exts_bools len bs = match bs with @@ -341,6 +343,8 @@ let exts_bits len bits = | _ -> ext_list B0 len bits end +let zero_extend bits len = extz_bits len bits + let rec add_one_bit_ignore_overflow_aux bits = match bits with | [] -> [] | B0 :: bits -> B1 :: bits diff --git a/src/process_file.ml b/src/process_file.ml index 3f24f4c3..88220841 100644 --- a/src/process_file.ml +++ b/src/process_file.ml @@ -162,6 +162,13 @@ let rec preprocess = function | Parse_ast.DEF_pragma (p, arg, _) :: defs -> (Util.warn ("Bad pragma $" ^ p ^ " " ^ arg); preprocess defs) + | (Parse_ast.DEF_default (Parse_ast.DT_aux (Parse_ast.DT_order (_, Parse_ast.ATyp_aux (atyp, _)), _)) as def) :: defs -> + begin match atyp with + | Parse_ast.ATyp_inc -> symbols := StringSet.add "_DEFAULT_INC" !symbols; def :: preprocess defs + | Parse_ast.ATyp_dec -> symbols := StringSet.add "_DEFAULT_DEC" !symbols; def :: preprocess defs + | _ -> def :: preprocess defs + end + | def :: defs -> def :: preprocess defs let preprocess_ast (Parse_ast.Defs defs) = Parse_ast.Defs (preprocess defs) -- cgit v1.2.3