ptitSeb opened issue #5653:
Thanks for filing a feature request! Please fill out the TODOs below.
Feature
With 0.90 of Cranelift,
InsBuilder::trap_if(...)
was removed, and replaced withInsbuild::trapnz(...)
andInsBuilder::trapz(...)
, but thetrap_if(...)
allowed for more case than just Equal and Different (like for exampleUnsignedGreaterThanOrEqual
).Benefit
Easy
OutOfBound
trap for exampleImplementation
Add more
trapXX(...)
liketrapnz(..)
/trapz(..)
Alternatives
Manual jmp over / unconditional trap, but that's a bit cumbersome.
cfallin commented on issue #5653:
You should be able to do a
trapnz
on anicmp
result with any comparison op, I think?
ptitSeb commented on issue #5653:
so, an
icmp
to get a value, than a test on that value to finaly do a trapz() or trapnz()? That's a solution, but still lot more complex then previoustrap_if
bjorn3 commented on issue #5653:
You can do
icmp
with the IntCC for the condition in which you want to trap and then directly pass the result oficmp
totrapnz
. For exampletrap_if uge v0, v1
would turn into
v2 = icmp uge v0, v1 trapnz v2
jameysharp commented on issue #5653:
I believe the intent was that for
UnsignedGreaterThanOrEqual
you'd useicmp
like this:v2 = icmp uge v0, v1 trapnz v2, user0
There are some special cases which might help, like the
uadd_overflow_trap
instruction, or using the carry output ofiadd_cout
as the input totrapnz
.Do those options cover your needs?
ptitSeb commented on issue #5653:
Ok, thanks. the icmp / trapnz is good enough. I'll check the
uadd_overflow_trap
too also.
ptitSeb commented on issue #5653:
I guess I can close the ticket as my understanding of
trapz
/trapnz
was eronuous: it doesn't take a CFlag but a Value (and so it's not a direct replacement totrap_if
)
jameysharp commented on issue #5653:
Right,
trapif
was removed as part of our effort to remove integer/floating-point CPU flags from CLIF. So yeah, I'll go ahead and close this. Thanks for asking the question though—it's always good to hear from folks who are using Cranelift!
jameysharp closed issue #5653:
Thanks for filing a feature request! Please fill out the TODOs below.
Feature
With 0.90 of Cranelift,
InsBuilder::trap_if(...)
was removed, and replaced withInsbuild::trapnz(...)
andInsBuilder::trapz(...)
, but thetrap_if(...)
allowed for more case than just Equal and Different (like for exampleUnsignedGreaterThanOrEqual
).Benefit
Easy
OutOfBound
trap for exampleImplementation
Add more
trapXX(...)
liketrapnz(..)
/trapz(..)
Alternatives
Manual jmp over / unconditional trap, but that's a bit cumbersome.
Last updated: Dec 23 2024 at 12:05 UTC