SPIRVAvailability.td
3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//===- SPIRVAvailability.td - Op Availability Base file ----*- tablegen -*-===//
//
// Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef SPIRV_AVAILABILITY
#define SPIRV_AVAILABILITY
include "mlir/IR/OpBase.td"
//===----------------------------------------------------------------------===//
// Op availaility definitions
//===----------------------------------------------------------------------===//
// The base class for defining op availability dimensions.
class Availability {
// The following are fields for controlling the generated C++ OpInterface.
// The name for the generated C++ OpInterface subclass.
string interfaceName = ?;
// The documentation for the generated C++ OpInterface subclass.
string interfaceDescription = "";
// The following are fields for controlling the query function signature.
// The query function's return type in the generated C++ OpInterface subclass.
string queryFnRetType = ?;
// The query function's name in the generated C++ OpInterface subclass.
string queryFnName = ?;
// The following are fields for controlling the query function implementation.
// The logic for merging two availability requirements. This is used to derive
// the final availability requirement when, for example, an op has two
// operands and these two operands have different availability requirements.
//
// The code should use `$overall` as the placeholder for the final requirement
// and `$instance` for the current availability requirement instance.
code mergeAction = ?;
// The initializer for the final availability requirement.
string initializer = ?;
// An availability instance's type.
string instanceType = ?;
// The following are fields for a concrete availability instance.
// The availability requirement carried by a concrete instance.
string instance = ?;
}
class MinVersionBase<string name, I32EnumAttr scheme, I32EnumAttrCase min>
: Availability {
let interfaceName = name;
let queryFnRetType = scheme.returnType;
let queryFnName = "getMinVersion";
let mergeAction = "$overall = static_cast<" # scheme.returnType # ">("
"std::max($overall, $instance))";
let initializer = "static_cast<" # scheme.returnType # ">(uint32_t(0))";
let instanceType = scheme.cppNamespace # "::" # scheme.className;
let instance = scheme.cppNamespace # "::" # scheme.className # "::" #
min.symbol;
}
class MaxVersionBase<string name, I32EnumAttr scheme, I32EnumAttrCase max>
: Availability {
let interfaceName = name;
let queryFnRetType = scheme.returnType;
let queryFnName = "getMaxVersion";
let mergeAction = "$overall = static_cast<" # scheme.returnType # ">("
"std::min($overall, $instance))";
let initializer = "static_cast<" # scheme.returnType # ">(~uint32_t(0))";
let instanceType = scheme.cppNamespace # "::" # scheme.className;
let instance = scheme.cppNamespace # "::" # scheme.className # "::" #
max.symbol;
}
#endif // SPIRV_AVAILABILITY