|
73 | 73 | // e.g., "x[7:0]" --> "x[0 +: 8]"
|
74 | 74 | :xform_lower
|
75 | 75 |
|
76 |
| -// Eliminate slices of integers by first converting the integer to a bitvector. |
77 |
| -// e.g., if "x : integer", then "x[1 +: 8]" to "cvt_int_bits(x, 9)[1 +: 8]" |
78 |
| -:xform_int_bitslices |
| 76 | +{xform_int_bitslices} |
79 | 77 |
|
80 | 78 | // Convert use of getter/setter syntax to function calls.
|
81 | 79 | // e.g., "Mem[a, sz] = x" --> "Mem_set(a, sz, x)"
|
@@ -329,10 +327,17 @@ def mk_script(args, output_directory):
|
329 | 327 | 'output_dir': output_directory,
|
330 | 328 | 'split_state': "",
|
331 | 329 | 'suppress_bitslice_xform': "",
|
| 330 | + 'xform_int_bitslices': "", |
332 | 331 | 'track_valid': "",
|
333 | 332 | 'wrap_variables': "",
|
334 | 333 | }
|
335 | 334 | if args.instrument_unknown: substitutions['track_valid'] = ":xform_valid track-valid"
|
| 335 | + if args.transform_int_slices: |
| 336 | + substitutions["xform_int_bitslices"] = textwrap.dedent("""\ |
| 337 | + // Eliminate slices of integers by first converting the integer to a bitvector. |
| 338 | + // e.g., if "x : integer", then "x[1 +: 8]" to "cvt_int_bits(x, 9)[1 +: 8]" |
| 339 | + :xform_int_bitslices |
| 340 | + """) |
336 | 341 | if args.wrap_variables: substitutions['wrap_variables'] = ":xform_wrap"
|
337 | 342 | if not args.auto_case_split:
|
338 | 343 | substitutions['auto_case_split'] = '--no-auto-case-split'
|
@@ -492,6 +497,7 @@ def main() -> int:
|
492 | 497 | parser.add_argument("--new-ffi", help="use the new FFI", action="store_true", default=False)
|
493 | 498 | parser.add_argument("--runtime-checks", help="perform runtime checks (array bounds, etc.)", action="store_true", default=False)
|
494 | 499 | parser.add_argument("--split-state", help="split state into multiple structs", action=argparse.BooleanOptionalAction)
|
| 500 | + parser.add_argument("--transform-int-slices", help="convert integer slices to bit slices", action=argparse.BooleanOptionalAction, default=False) |
495 | 501 | parser.add_argument("--instrument-unknown", help="instrument assignments of UNKNOWN", action=argparse.BooleanOptionalAction)
|
496 | 502 | parser.add_argument("--wrap-variables", help="wrap global variables into functions", action=argparse.BooleanOptionalAction)
|
497 | 503 | parser.add_argument("-O0", help="perform minimal set of transformations", action=argparse.BooleanOptionalAction)
|
|
0 commit comments