@@ -30,6 +30,7 @@ class SYCLFuncRegistry;
30
30
// / needs to be created in SYCLFuncRegistry constructor.
31
31
class SYCLFuncDescriptor {
32
32
friend class SYCLFuncRegistry ;
33
+ friend llvm::raw_ostream &operator <<(llvm::raw_ostream &, const SYCLFuncDescriptor &);
33
34
34
35
public:
35
36
// / Enumerates SYCL functions.
@@ -44,26 +45,51 @@ class SYCLFuncDescriptor {
44
45
Id1CtorSizeT, // sycl::id<1>::id<1>(std::enable_if<(1)==(1), unsigned long>::type)
45
46
Id2CtorSizeT, // sycl::id<2>::id<2>(std::enable_if<(2)==(2), unsigned long>::type)
46
47
Id3CtorSizeT, // sycl::id<3>::id<3>(std::enable_if<(3)==(3), unsigned long>::type)
47
- Id1CtorRange, // sycl::id<1>::id<1>(std::enable_if<(1)==(1), unsigned long>::type, unsigned long)
48
- Id2CtorRange, // sycl::id<2>::id<2>(std::enable_if<(2)==(2), unsigned long>::type, unsigned long)
49
- Id3CtorRange, // sycl::id<3>::id<3>(std::enable_if<(3)==(3), unsigned long>::type, unsigned long)
50
- Id1CtorItem, // sycl::id<1>::id<1>(std::enable_if<(1)==(1), unsigned long>::type, unsigned long, unsigned long)
51
- Id2CtorItem, // sycl::id<2>::id<2>(std::enable_if<(2)==(2), unsigned long>::type, unsigned long, unsigned long)
52
- Id3CtorItem, // sycl::id<3>::id<3>(std::enable_if<(3)==(3), unsigned long>::type, unsigned long, unsigned long)
48
+ Id1Ctor2SizeT, // sycl::id<1>::id<1>(std::enable_if<(1)==(1), unsigned long>::type, unsigned long)
49
+ Id2Ctor2SizeT, // sycl::id<2>::id<2>(std::enable_if<(2)==(2), unsigned long>::type, unsigned long)
50
+ Id3Ctor2SizeT, // sycl::id<3>::id<3>(std::enable_if<(3)==(3), unsigned long>::type, unsigned long)
51
+ Id1Ctor3SizeT, // sycl::id<1>::id<1>(std::enable_if<(1)==(1), unsigned long>::type, unsigned long, unsigned long)
52
+ Id2Ctor3SizeT, // sycl::id<2>::id<2>(std::enable_if<(2)==(2), unsigned long>::type, unsigned long, unsigned long)
53
+ Id3Ctor3SizeT, // sycl::id<3>::id<3>(std::enable_if<(3)==(3), unsigned long>::type, unsigned long, unsigned long)
53
54
Id1CopyCtor, // sycl::id<1>::id(sycl::id<1> const&)
54
55
Id2CopyCtor, // sycl::id<2>::id(sycl::id<2> const&)
55
56
Id3CopyCtor, // sycl::id<3>::id(sycl::id<3> const&)
56
57
57
- // Member functions for ..TODO..
58
+ // Member functions for the sycl::Range<n> class.
59
+ Range1CtorDefault, // sycl::Range<1>::range()
60
+ Range2CtorDefault, // sycl::range<2>::range()
61
+ Range3CtorDefault, // sycl::range<3>::range()
62
+ Range1CtorSizeT, // sycl::range<1>::range<1>(std::enable_if<(1)==(1), unsigned long>::type)
63
+ Range2CtorSizeT, // sycl::range<2>::range<2>(std::enable_if<(2)==(2), unsigned long>::type)
64
+ Range3CtorSizeT, // sycl::range<3>::range<3>(std::enable_if<(3)==(3), unsigned long>::type)
65
+ Range1Ctor2SizeT, // sycl::range<1>::range<1>(std::enable_if<(1)==(1), unsigned long>::type, unsigned long)
66
+ Range2Ctor2SizeT, // sycl::range<2>::range<2>(std::enable_if<(2)==(2), unsigned long>::type, unsigned long)
67
+ Range3Ctor2SizeT, // sycl::range<3>::range<3>(std::enable_if<(3)==(3), unsigned long>::type, unsigned long)
68
+ Range1Ctor3SizeT, // sycl::range<1>::range<1>(std::enable_if<(1)==(1), unsigned long>::type, unsigned long, unsigned long)
69
+ Range2Ctor3SizeT, // sycl::range<2>::range<2>(std::enable_if<(2)==(2), unsigned long>::type, unsigned long, unsigned long)
70
+ Range3Ctor3SizeT, // sycl::range<3>::range<3>(std::enable_if<(3)==(3), unsigned long>::type, unsigned long, unsigned long)
71
+ Range1CopyCtor, // sycl::range<1>::range(sycl::range<1> const&)
72
+ Range2CopyCtor, // sycl::range<2>::range(sycl::range<2> const&)
73
+ Range3CopyCtor, // sycl::range<3>::range(sycl::range<3> const&)
58
74
};
59
75
// clang-format on
60
76
61
77
// / Enumerates the kind of FuncId.
62
78
enum class FuncIdKind {
63
79
Unknown,
64
- IdCtor, // any sycl::id<n> constructors
80
+ IdCtor, // any sycl::id<n> constructors.
81
+ RangeCtor // any sycl::range<n> constructors.
65
82
};
66
83
84
+ // / Returns the funcIdKind given a \p funcId.
85
+ static FuncIdKind getFuncIdKind (FuncId funcId);
86
+
87
+ // / Retuns a descriptive name for the given \p funcIdKind.
88
+ static std::string funcIdKindToName (FuncIdKind funcIdKind);
89
+
90
+ // / Retuns the FuncIdKind given a descriptive \p name.
91
+ static FuncIdKind nameToFuncIdKind (Twine name);
92
+
67
93
// Call the SYCL constructor identified by \p id with the given \p args.
68
94
static Value call (FuncId id, ValueRange args,
69
95
const SYCLFuncRegistry ®istry, OpBuilder &b,
@@ -73,8 +99,11 @@ class SYCLFuncDescriptor {
73
99
// / Private constructor: only available to 'SYCLFuncRegistry'.
74
100
SYCLFuncDescriptor (FuncId id, StringRef name, Type outputTy,
75
101
ArrayRef<Type> argTys)
76
- : id(id), name(name), outputTy(outputTy),
77
- argTys (argTys.begin(), argTys.end()) {}
102
+ : funcId(id), funcIdKind(getFuncIdKind(id)), name(name),
103
+ outputTy (outputTy), argTys(argTys.begin(), argTys.end()) {
104
+ assert (funcId != FuncId::Unknown && " Illegal function id" );
105
+ assert (funcIdKind != FuncIdKind::Unknown && " Illegal function id kind" );
106
+ }
78
107
79
108
// / Inject the declaration for this function into the module.
80
109
void declareFunction (ModuleOp &module , OpBuilder &b);
@@ -83,13 +112,22 @@ class SYCLFuncDescriptor {
83
112
static bool isIdCtor (FuncId funcId);
84
113
85
114
private:
86
- FuncId id; // unique identifier for a SYCL function
115
+ FuncId funcId = FuncId::Unknown; // SYCL function identifier
116
+ FuncIdKind funcIdKind = FuncIdKind::Unknown; // SYCL function kind
87
117
StringRef name; // SYCL function name
88
118
Type outputTy; // SYCL function output type
89
119
SmallVector<Type, 4 > argTys; // SYCL function arguments types
90
- FlatSymbolRefAttr funcRef; // Reference to the SYCL function declaration
120
+ FlatSymbolRefAttr funcRef; // Reference to the SYCL function
91
121
};
92
122
123
+ inline llvm::raw_ostream &operator <<(llvm::raw_ostream &os,
124
+ const SYCLFuncDescriptor &desc) {
125
+ os << " funcId=" << (int )desc.funcId
126
+ << " , funcIdKind=" << SYCLFuncDescriptor::funcIdKindToName (desc.funcIdKind )
127
+ << " , name='" << desc.name .str () << " ')" ;
128
+ return os;
129
+ }
130
+
93
131
// / \class SYCLFuncRegistry
94
132
// / Singleton class representing the set of SYCL functions callable from the
95
133
// / compiler.
0 commit comments