This patch introduces conversion pattern for spv.constant with scalar and vector types. There is a special case when the constant value is a signed/unsigned integer (vector of integers). Since LLVM dialect does not have signedness semantics, the types had to be converted to signless ints.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp | ||
---|---|---|
146 | Please format this. | |
172 | nit: Drop the newline. | |
173 | dyn_cast can return null. Please either check for null here or use cast instead. | |
175 | nit: Please avoid using the attribute values whenever you possibly can. They have to be reconstructed, meaning locking the context per element. Use the APInt range instead if you know it is an integer, getValues<APInt>(). | |
179 | getIntegerAttr can't fail, so there is no need to check anything here. | |
184 | Seems like what you really want here is to do something like: dstElementsAttr = dstElementsAttr.mapValues(signlessType, [](APInt value) { return value; }); That would remove the need for the loop above. | |
194 | Please just use the APInt methods instead. |
- [MLIR][SPIRVToLLVM] Addressed comments on constant conversion
- [MLIR][SPIRVToLLVM] Refactored the code to follow clang style
Changed code style:
- Ckang reformatted, removed extra newlines
- Used mapValues() with a lambda instead of the loop
- Removed sign extension for APInt values in favour of APInt method
Also used cast() instead of dyn_cast().
Please format this.