diff --git a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp --- a/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/TargetAndABI.cpp @@ -205,6 +205,11 @@ // from TargetEnvAttr to selected between Physical32 and Physical64. if (cap == Capability::Kernel) return spirv::AddressingModel::Physical64; + // TODO PhysicalStorageBuffer64 is hard-coded here, but some information + // should come from TargetEnvAttr to select between PhysicalStorageBuffer64 + // and PhysicalStorageBuffer64EXT + if (cap == Capability::PhysicalStorageBufferAddresses) + return spirv::AddressingModel::PhysicalStorageBuffer64; } // Logical addressing doesn't need any capabilities so return it as default. return spirv::AddressingModel::Logical; diff --git a/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir b/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir --- a/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir +++ b/mlir/test/Dialect/SPIRV/Transforms/vce-deduction.mlir @@ -63,6 +63,16 @@ } } +// CHECK: requires #spv.vce +spv.module PhysicalStorageBuffer64 GLSL450 attributes { + spv.target_env = #spv.target_env< + #spv.vce, {}> +} { + spv.func @physical_ptr(%val : !spv.ptr) "None" { + spv.Return + } +} + // Test selecting the capability available in the target environment. // spv.GroupNonUniform op itself can be enabled via any of // * GroupNonUniformArithmetic @@ -73,13 +83,13 @@ // * GroupNonUniformArithmetic // * GroupNonUniformBallot -// CHECK: requires #spv.vce +// CHECK: requires #spv.vce spv.module Logical GLSL450 attributes { spv.target_env = #spv.target_env< - #spv.vce, {}> + #spv.vce, {}> } { - spv.func @group_non_uniform_iadd(%val : i32) -> i32 "None" { - %0 = spv.GroupNonUniformIAdd "Subgroup" "Reduce" %val : i32 + spv.func @iadd(%val : i32) -> i32 "None" { + %0 = spv.IAdd %val, %val: i32 spv.ReturnValue %0: i32 } }