[Mlir-commits] [mlir] [mlir][spirv] Fix spirv dialect to support Specialization constants as GlobalVar initializer (PR #75660)
Jakub Kuderski
llvmlistbot at llvm.org
Fri Dec 15 15:34:01 PST 2023
================
@@ -637,14 +637,24 @@ spirv::Deserializer::processGlobalVariable(ArrayRef<uint32_t> operands) {
// Initializer.
FlatSymbolRefAttr initializer = nullptr;
+
if (wordIndex < operands.size()) {
- auto initializerOp = getGlobalVariable(operands[wordIndex]);
- if (!initializerOp) {
+ Operation *op = nullptr;
+
+ if ((op = getGlobalVariable(operands[wordIndex])))
+ initializer = SymbolRefAttr::get(
+ (dyn_cast<spirv::GlobalVariableOp>(op)).getOperation());
+ else if ((op = getSpecConstant(operands[wordIndex])))
+ initializer = SymbolRefAttr::get(
+ (dyn_cast<spirv::SpecConstantOp>(op)).getOperation());
+ else if ((op = getSpecConstantComposite(operands[wordIndex])))
+ initializer = SymbolRefAttr::get(
+ (dyn_cast<spirv::SpecConstantCompositeOp>(op)).getOperation());
----------------
kuhar wrote:
Since this is accessing cast results unconditionally, I'd expect to see `cast<T>(op)` used instead of `dynamic_cast<T>`
https://github.com/llvm/llvm-project/pull/75660
More information about the Mlir-commits
mailing list