Added support for unsigned int in addition to the already-existing signless int
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Standard operations are explicitly signless by design, i.e. they purposefully don't support signed/unsigned integers.
https://mlir.llvm.org/docs/Rationale/Rationale/#integer-signedness-semantics
I might be misunderstanding the situation, but if the Ops are signless why does SIToFOp exist? If we handle the explicitly signed case, why not the explicitly unsigned one?
I might be misunderstanding the situation, but if the Ops are signless why does SIToFOp exist?
When you design operations like this on Integer, you need to decide if you encode the sign in the type or in the operation name. For example you can have:
%uquotient = div %ua, %ub : uint32 %squotient = div %sa, %sb : sint32
where you decide to encode the sign in the type itself. In this case you only need one div operation. The alternative is to have a "signless" type for integer and encode the difference in the operation:
%squotient = sdiv %sa, %sb : int32 %uquotient = udiv %ua, %ub : int32
This last solution is what is preferred in the standard dialect. This is consistent with the existence of SIToFOp and UIToFOp: the sign aspect is carried by the operation and not by the type.
Oh, I completely missed that SItoFOp also checks for it to be signless, not signed. This makes sense. Thank you!