[all-commits] [llvm/llvm-project] 2dab55: [mlir][spirv] Change numeric constant's bit-extens...
Md Abdullah Shahneous Bari via All-commits
all-commits at lists.llvm.org
Mon Jun 5 07:54:02 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 2dab551d649cb57127f7b3bea183f069883d76e4
https://github.com/llvm/llvm-project/commit/2dab551d649cb57127f7b3bea183f069883d76e4
Author: Md Abdullah Shahneous Bari <Md.Abdullah.Shahneous.Bari at intel.com>
Date: 2023-06-05 (Mon, 05 Jun 2023)
Changed paths:
M mlir/lib/Target/SPIRV/Serialization/Serializer.cpp
M mlir/test/Target/SPIRV/constant.mlir
M mlir/unittests/Dialect/SPIRV/SerializationTest.cpp
Log Message:
-----------
[mlir][spirv] Change numeric constant's bit-extension decision to be based on type
Integer constants with bit width less than a word (e.g., i8, i16)
should be bit extended based on its type to be SPIR-V spec-compliant.
Previously, the decision was based on the most significant bit of the
value which ignores the signless semantics and causes problems when
interfacing with SPIR-V tools.
Dealing with numeric literals: the SPIR-V spec says, "If a numeric
type’s bit width is less than 32-bits, the value appears in the
low-order bits of the word, and the high-order bits must be 0 for
a floating-point type or integer type with Signedness of 0, or sign
extended for an integer type with a Signedness of 1 (similarly for the
remaining bits of widths larger than 32 bits but not a multiple of 32
bits)."
Therefore, signless integers (e.g., i8, i16) and unsigned integers
should be 0-extended, and signed integers (e.g., si8, si16) should be
sign-extended.
Patch By: mshahneo
Reviewed By: kuhar
Differential Revision: https://reviews.llvm.org/D151767
More information about the All-commits
mailing list