Skip to content

Xform_bitslices bugfix#113

Open
alastairreid wants to merge 1 commit into
masterfrom
areid-fix-xform-bitslices
Open

Xform_bitslices bugfix#113
alastairreid wants to merge 1 commit into
masterfrom
areid-fix-xform-bitslices

Conversation

@alastairreid

Copy link
Copy Markdown

Fixes a bug that occurs if you have code like this

let wide : bits(1024) = ...;
let r = [wide[0 +: 64], Zeros(64)];

The bug was causing us to generate a zero_extend from 1024 bits "up" to 64 bits.

This patch does not fully fix the bug but it prevents it from happening when the width of the bitslice is a constant - which fixes the problem case.

The most general fix would probably be to find the maximum width that appears anywhere in the transformed expression, widen everything to that maximum width and then use and/or/mask/etc. in the transformation. Leaving that to another day.

Fixes a bug that occurs if you have code like this

    let wide : bits(1024) = ...;
    let r = [wide[0 +: 64], Zeros(64)];

The bug was causing us to generate a zero_extend from 1024 bits "up" to
64 bits.

This patch does not fully fix the bug but it prevents it from happening
when the width of the bitslice is a constant - which fixes the problem
case.

The most general fix would probably be to find the maximum width that
appears anywhere in the transformed expression, widen everything to that
maximum width and then use and/or/mask/etc. in the transformation.
Leaving that to another day.
Comment thread libASL/xform_bitslices.ml
let transform_slices : bool ref = ref true

let rec transform_non_slices (loc : Loc.t) (n : AST.expr) (w : AST.expr) (i : AST.expr) (x : AST.expr) : AST.expr =
let is_constant (x : AST.expr) : bool =

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be reused:

let is_literal_constant (x : expr) : bool =

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