-
Notifications
You must be signed in to change notification settings - Fork 4
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
Make polymorhic bitvector #127
Conversation
Discovered some bugs closing for now |
Looks good, but could you add the following chained ite's to your tests? ite(Poly[A ,B], A) |
None of those are valid but I'll add tests for chaining. |
Poly[A,B] is just indicating the psuedo-code type of the argument. These should all be valid. |
|
||
def _rand_bv(width): | ||
return BitVector[width](random.randint(0, (1 << width) - 1)) | ||
|
||
def _rand_signed(width): | ||
return SIntVector[width](random.randint(0, (1 << width) - 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could use T.random(width)
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(and above)
|
||
m0 = inspect.getattr_static(T0, k) | ||
m1 = inspect.getattr_static(T1, k) | ||
namespace[k] = build_VCall(select, m0, m1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be the magic, a PolyType store's it's select condition, operators are dispatched based on that condition when invoked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory this might work with magma types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually not quite, Poly would need to implement the magma protocol, but then I think it could work, maybe just by concatenating the bits of the two subtypes together as the bits representation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan on handling magma with my MagmaBV proposal. phanrahan/magma#587
MagmaBV will use the same machinery to build ites as BitVector / SMTBitVector and implement the magma protocol.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Worth noting that this is going to generate a lot of terms of the form: cond.ite(
f(cond.ite(a, b), *fargs),
g(cond.ite(a, b), *gargs),
)
# as an optimization on RTL we will want to transform this to:
cond.ite(
f(a, *fargs),
g(b, *gargs),
) This transformation really shouldn't be too hard as its so structured. Further simplifying things |
Before this can be merged, this should be run with lassen. I think there is a bug somewhere in the ALU that this will address. |
@rdaly525 is that bug in rtl generation? Cause this won't fix anything with magma. |
Just make sure that lassen unit tests still pass before merging this PR. |
Passes all tests on lassen StanfordAHA/lassen#166 |
Addresses #122
Adds polymorphic types which allows "run-time polymorphism"
Enables the following:
where the final statement is effectively transformed to following by the type system