Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix runtime checks #12

Closed

Conversation

alastairreid
Copy link
Owner

This fixes a problem where constraint checks were failing because
of interference between the inserted checks and the handling of
expressions of the form '(a DIV b) * b == a'.

Also reduces the verbosity of running the test suite.

alastairreid and others added 30 commits February 24, 2025 12:07
Previously, when we created a monomorphic instance, we
did not generate a function prototype. This caused problems
for the downstream backends that then had to generate C
function prototypes from function definitions which often resulted
in duplicate function prototypes.

This change generates the missing prototype which will allow
the backends to be simplified.

Signed-off-by: Alastair Reid <[email protected]>
In the past, we treated the Prelude differently from user-written
code by not generating function prototypes for functions defined in
the Prelude.

This restriction is no longer needed and it was causing problems in
the backend where we could not rely on the existence of a function
prototype for every function.

This change ensures that we generate function prototypes for all functions
that have a FunDefn.

Signed-off-by: Alastair Reid <[email protected]>
This minor simplification in all the backends generates
cleaner C code by relying on earlier passes to have generated
function prototypes.

Signed-off-by: Alastair Reid <[email protected]>
This provides a way to perform an assertion in the middle
of an expression.

If condition e1 is TRUE, the result is e2.
If the condition e1 is FALSE, an assertion failure is reported.

This is intended for use in transformations and, in particular,
for performing runtime checks such as

    x[i]
-->
    __assert (i IN {0..31}) __in x[i]

Signed-off-by: Alastair Reid <[email protected]>
Signed-off-by: Alastair Reid <[email protected]>
Signed-off-by: Alastair Reid <[email protected]>
- We need 4 locations.

Signed-off-by: Alastair Reid <[email protected]>
- More usage using masks.

Signed-off-by: Alastair Reid <[email protected]>
- Extends typechecker to insert runtime checks:
  - All 4 variants of bitslice indexing (reads and writes)
  - Array indexing (reads and writes)
  - Division by zero
  (Checking exact division is not done because that breaks specs
  that still expect DIV to mean inexact division)

- Adds a disable flag to avoid insertion of runtime checks
  Intended to make it easier to update the ASLi version without
  having to fix all the runtime failures immediately.

- Disables runtime checking in some testsuites where the
  runtime checks would overwhelm whatever we were originally
  trying to test.

- Adds lit tests that the checks are being inserted.

Signed-off-by: Alastair Reid <[email protected]>
These tests confirm that errors are being caught at runtime

Signed-off-by: Alastair Reid <[email protected]>
This adds the option of using the C++ annotation 'const &'
on wide function arguments.

More specifically, this affects

    bits(N) if N > limit
    records

It does not affect

    integer
    __sint(N)
    boolean
    string

(But it would be easy to change each of these choices)

Signed-off-by: Alastair Reid <[email protected]>
The original exception check was a bit approximate.
It would report that a function could throw an exception even if
the function caught all exceptions safely.

The newer exception check that is based on exception markers
is much more accurate and avoids those false positives.

This change disables the original check when we are using
the new exception check to avoid those false positives.

Signed-off-by: Alastair Reid <[email protected]>
The tests were being built with exception marker checking off
which, inevitably meant that exception markers were
incorrect in some places.

Signed-off-by: Alastair Reid <[email protected]>
Signed-off-by: Alastair Reid <[email protected]>
Signed-off-by: Alastair Reid <[email protected]>
This adds a new runtime system based on the System-C library.
This library gives a significant performance benefit when
using hardware model checkers.

Note that this adds an additional submodule dependency.

Signed-off-by: Rafael Barbalho <[email protected]>
Signed-off-by: Alastair Reid <[email protected]>
The C++ backends (ac & sc) can handle the bitslice accesses directly.

Signed-off-by: Alastair Reid <[email protected]>
When constraints were added to the ASL language, they initially said that
in a mutable variable declaration like this

    var x = 0;

the type of x is "integer {0}".
This is because the type of "0" is "integer {0}".

But this makes no sense at all - the whole point of a *mutable* variable
is that you can assign it a value that is different from the
initial value.

This change corrects this weirdness by giving x the type "integer".

Signed-off-by: Alastair Reid <[email protected]>
Signed-off-by: Alastair Reid <[email protected]>
In particular:

- bitwidths
- array sizes
- array indexes
- bitslice indexes

Signed-off-by: Alastair Reid <[email protected]>
The backend/runtimes now special case the use of indexes of
the form "asl_cvt_sintN_int(ix)" so we need tests for these cases.

Signed-off-by: Alastair Reid <[email protected]>
Signed-off-by: Alastair Reid <[email protected]>
Signed-off-by: Alastair Reid <[email protected]>
Signed-off-by: Alastair Reid <[email protected]>
A long time ago, we renamed runtime_error to ASL_runtime_error
but we added a backwards compatibility shim to avoid breaking code.

The time has come to remove this since C++ stdlib has a conflicting name
@alastairreid alastairreid force-pushed the areid-fix-runtime-checks branch from 48f1dd8 to 4215bf6 Compare February 26, 2025 15:54
This fixes a problem where constraint checks were failing because
of interference between the inserted checks and the handling of
expressions of the form '(a DIV b) * b == a'.

Signed-off-by: Alastair Reid <[email protected]>
@alastairreid alastairreid force-pushed the areid-fix-runtime-checks branch from 4215bf6 to 5d0d4a5 Compare February 26, 2025 15:57
@alastairreid alastairreid deleted the areid-fix-runtime-checks branch February 28, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants