-
Notifications
You must be signed in to change notification settings - Fork 201
Add ineg legalization for scalar integer types #1385
Conversation
Please also add one test for |
Ya ok I have to admit defeat: I added an i8 test, and I tried debugging it, but it makes no sense: the ineg legalization of the i8 returns "done", not "legalized", presumably because it thinks that the ineg is already legal?? https://pastebin.com/0E1Bs06A I added print statements that trace the result of |
To summarize: everything is working except the i64 test I added, and I still have to remove the comments I added and add a better error message to the panic |
v1 = ineg v0 | ||
; check: v2 = iconst.i32 1 | ||
; check: v3 = iconst.i32 0 | ||
; check: v0 = iconcat v2, v3 |
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.
@bjorn3, I would not expect this iconcat
; can't we directly encode an iconst.i64
?
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 file has target i686
before target x86_64
. How is that handled? Does it test both or only the first?
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.
Learn something new every day: apparently parsing tests accumulates the targets and test_tuples
will expand the different targets (in this case since the legalizer needs_isa
we should have a test tuple for each target
from here).
But then this doesn't make sense: how could these checks pass when target x86_64
is set? Is that the build failure? No, it looks like the current build failure happens because ineg
isn't getting legalized at all for i64
?
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.
Yeah the build failure is happening because ineg
still isn't getting legalized for i64
, I still haven't figured out why that is. This must be because I need to extend another transform group right? That was the reason for i8
and i16
not getting legalized initially (I think)
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.
There is also the narrow
group for ints > pointer size.
Ok, so, I think the changes are finally done (
This is the generated file:
I'm not sure exactly how to fix this, is there a way I could just add the custom legalization to the existing |
@@ -32,13 +32,12 @@ pub(crate) fn define(shared_defs: &mut SharedDefinitions) -> TargetIsa { | |||
let mut x86_32 = CpuMode::new("I32"); | |||
|
|||
let expand_flags = shared_defs.transform_groups.by_name("expand_flags"); | |||
let narrow_flags = shared_defs.transform_groups.by_name("narrow_flags"); | |||
let widen = shared_defs.transform_groups.by_name("widen"); | |||
let widen = shared_defs.transform_groups.by_name("x86_widen"); |
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.
Perhaps we should rename this to x86_widen
(here and where used) to be very clear about what is going on.
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.
Oh yeah I can definitely do that!
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.
Sounds good, I'll merge this after your push.
@peterdelevoryas, thanks! |
Hey no thank you @abrown, and everyone else, for helping with this! I really got stuck on the whole transform group thing, but I think I get the idea now. I've really been enjoying using Cranelift, and it was fun making these changes! |
bnjbvr
orbjorn3
?I added some comments in the diff that refer to concerns I had