aboutsummaryrefslogtreecommitdiff
path: root/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
diff options
context:
space:
mode:
Diffstat (limited to 'mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td')
-rw-r--r--mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td56
1 files changed, 49 insertions, 7 deletions
diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
index aad8b9f2ec7e..4dc1886fae2d 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
+++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVBase.td
@@ -22,7 +22,7 @@ include "mlir/Dialect/SPIRV/SPIRVAvailability.td"
// SPIR-V dialect definitions
//===----------------------------------------------------------------------===//
-def SPV_Dialect : Dialect {
+def SPIRV_Dialect : Dialect {
let name = "spv";
let summary = "The SPIR-V dialect in MLIR.";
@@ -46,6 +46,43 @@ def SPV_Dialect : Dialect {
}];
let cppNamespace = "spirv";
+ let hasConstantMaterializer = 1;
+ let extraClassDeclaration = [{
+ //===------------------------------------------------------------------===//
+ // Type
+ //===------------------------------------------------------------------===//
+
+ /// Checks if the given `type` is valid in SPIR-V dialect.
+ static bool isValidType(Type type);
+
+ /// Checks if the given `scalar type` is valid in SPIR-V dialect.
+ static bool isValidScalarType(Type type);
+
+ //===------------------------------------------------------------------===//
+ // Attribute
+ //===------------------------------------------------------------------===//
+
+ /// Returns the attribute name to use when specifying decorations on results
+ /// of operations.
+ static std::string getAttributeName(Decoration decoration);
+
+ /// Provides a hook for verifying SPIR-V dialect attributes attached to the
+ /// given op.
+ LogicalResult verifyOperationAttribute(Operation *op,
+ NamedAttribute attribute) override;
+
+ /// Provides a hook for verifying SPIR-V dialect attributes attached to the
+ /// given op's region argument.
+ LogicalResult verifyRegionArgAttribute(Operation *op, unsigned regionIndex,
+ unsigned argIndex,
+ NamedAttribute attribute) override;
+
+ /// Provides a hook for verifying SPIR-V dialect attributes attached to the
+ /// given op's region result.
+ LogicalResult verifyRegionResultAttribute(
+ Operation *op, unsigned regionIndex, unsigned resultIndex,
+ NamedAttribute attribute) override;
+ }];
}
//===----------------------------------------------------------------------===//
@@ -2953,7 +2990,8 @@ def SPV_SamplerUseAttr:
// SPIR-V attribute definitions
//===----------------------------------------------------------------------===//
-def SPV_VerCapExtAttr : Attr<
+def SPV_VerCapExtAttr : DialectAttr<
+ SPIRV_Dialect,
CPred<"$_self.isa<::mlir::spirv::VerCapExtAttr>()">,
"version-capability-extension attribute"> {
let storageType = "::mlir::spirv::VerCapExtAttr";
@@ -2993,10 +3031,14 @@ def SPV_Vector : VectorOfLengthAndType<[2, 3, 4],
[SPV_Bool, SPV_Integer, SPV_Float]>;
// Component type check is done in the type parser for the following SPIR-V
// dialect-specific types so we use "Any" here.
-def SPV_AnyPtr : Type<SPV_IsPtrType, "any SPIR-V pointer type">;
-def SPV_AnyArray : Type<SPV_IsArrayType, "any SPIR-V array type">;
-def SPV_AnyRTArray : Type<SPV_IsRTArrayType, "any SPIR-V runtime array type">;
-def SPV_AnyStruct : Type<SPV_IsStructType, "any SPIR-V struct type">;
+def SPV_AnyPtr : DialectType<SPIRV_Dialect, SPV_IsPtrType,
+ "any SPIR-V pointer type">;
+def SPV_AnyArray : DialectType<SPIRV_Dialect, SPV_IsArrayType,
+ "any SPIR-V array type">;
+def SPV_AnyRTArray : DialectType<SPIRV_Dialect, SPV_IsRTArrayType,
+ "any SPIR-V runtime array type">;
+def SPV_AnyStruct : DialectType<SPIRV_Dialect, SPV_IsStructType,
+ "any SPIR-V struct type">;
def SPV_Numerical : AnyTypeOf<[SPV_Integer, SPV_Float]>;
def SPV_Scalar : AnyTypeOf<[SPV_Numerical, SPV_Bool]>;
@@ -3264,7 +3306,7 @@ def SPV_OpcodeAttr :
// Base class for all SPIR-V ops.
class SPV_Op<string mnemonic, list<OpTrait> traits = []> :
- Op<SPV_Dialect, mnemonic, !listconcat(traits, [
+ Op<SPIRV_Dialect, mnemonic, !listconcat(traits, [
// TODO(antiagainst): We don't need all of the following traits for
// every op; only the suitabble ones should be added automatically
// after ODS supports dialect-specific contents.