Bug Summary

File:build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins/tools/mlir/include/mlir/Dialect/Tosa/IR/TosaAttributes.cpp.inc
Warning:line 169, column 5
Value stored to '_firstPrinted' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name TosaOps.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins -resource-dir /usr/lib/llvm-16/lib/clang/16.0.0 -D MLIR_CUDA_CONVERSIONS_ENABLED=1 -D MLIR_ROCM_CONVERSIONS_ENABLED=1 -D _DEBUG -D _GNU_SOURCE -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/mlir/lib/Dialect/Tosa -I /build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/mlir/lib/Dialect/Tosa -I include -I /build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/llvm/include -I /build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/mlir/include -I tools/mlir/include -D _FORTIFY_SOURCE=2 -D NDEBUG -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-16/lib/clang/16.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fmacro-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/= -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fcoverage-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/= -O2 -Wno-unused-command-line-argument -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -Wno-misleading-indentation -std=c++17 -fdeprecated-macro -fdebug-compilation-dir=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/= -ferror-limit 19 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2022-10-03-140002-15933-1 -x c++ /build/llvm-toolchain-snapshot-16~++20221003111214+1fa2019828ca/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp
1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* AttrDef Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#ifdef GET_ATTRDEF_LIST
10#undef GET_ATTRDEF_LIST
11
12mlir::tosa::ConvOpQuantizationAttr,
13mlir::tosa::MatMulOpQuantizationAttr,
14mlir::tosa::PadOpQuantizationAttr,
15mlir::tosa::UnaryOpQuantizationAttr
16
17#endif // GET_ATTRDEF_LIST
18
19#ifdef GET_ATTRDEF_CLASSES
20#undef GET_ATTRDEF_CLASSES
21
22static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) {
23 return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
24 .Case(mlir::tosa::ConvOpQuantizationAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
25 value = mlir::tosa::ConvOpQuantizationAttr::parse(parser, type);
26 return ::mlir::success(!!value);
27 })
28 .Case(mlir::tosa::MatMulOpQuantizationAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
29 value = mlir::tosa::MatMulOpQuantizationAttr::parse(parser, type);
30 return ::mlir::success(!!value);
31 })
32 .Case(mlir::tosa::PadOpQuantizationAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
33 value = mlir::tosa::PadOpQuantizationAttr::parse(parser, type);
34 return ::mlir::success(!!value);
35 })
36 .Case(mlir::tosa::UnaryOpQuantizationAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
37 value = mlir::tosa::UnaryOpQuantizationAttr::parse(parser, type);
38 return ::mlir::success(!!value);
39 })
40 .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
41 *mnemonic = keyword;
42 return llvm::None;
43 });
44}
45
46static ::mlir::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
47 return ::llvm::TypeSwitch<::mlir::Attribute, ::mlir::LogicalResult>(def) .Case<mlir::tosa::ConvOpQuantizationAttr>([&](auto t) {
48 printer << mlir::tosa::ConvOpQuantizationAttr::getMnemonic();
49t.print(printer);
50 return ::mlir::success();
51 })
52 .Case<mlir::tosa::MatMulOpQuantizationAttr>([&](auto t) {
53 printer << mlir::tosa::MatMulOpQuantizationAttr::getMnemonic();
54t.print(printer);
55 return ::mlir::success();
56 })
57 .Case<mlir::tosa::PadOpQuantizationAttr>([&](auto t) {
58 printer << mlir::tosa::PadOpQuantizationAttr::getMnemonic();
59t.print(printer);
60 return ::mlir::success();
61 })
62 .Case<mlir::tosa::UnaryOpQuantizationAttr>([&](auto t) {
63 printer << mlir::tosa::UnaryOpQuantizationAttr::getMnemonic();
64t.print(printer);
65 return ::mlir::success();
66 })
67 .Default([](auto) { return ::mlir::failure(); });
68}
69
70namespace mlir {
71namespace tosa {
72namespace detail {
73struct ConvOpQuantizationAttrStorage : public ::mlir::AttributeStorage {
74 using KeyTy = std::tuple<int64_t, int64_t>;
75 ConvOpQuantizationAttrStorage(int64_t input_zp, int64_t weight_zp) : input_zp(input_zp), weight_zp(weight_zp) {}
76
77 bool operator==(const KeyTy &tblgenKey) const {
78 return (input_zp == std::get<0>(tblgenKey)) && (weight_zp == std::get<1>(tblgenKey));
79 }
80
81 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
82 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey));
83 }
84
85 static ConvOpQuantizationAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, const KeyTy &tblgenKey) {
86 auto input_zp = std::get<0>(tblgenKey);
87 auto weight_zp = std::get<1>(tblgenKey);
88 return new (allocator.allocate<ConvOpQuantizationAttrStorage>()) ConvOpQuantizationAttrStorage(input_zp, weight_zp);
89 }
90
91 int64_t input_zp;
92 int64_t weight_zp;
93};
94} // namespace detail
95ConvOpQuantizationAttr ConvOpQuantizationAttr::get(::mlir::MLIRContext *context, int64_t input_zp, int64_t weight_zp) {
96 return Base::get(context, input_zp, weight_zp);
97}
98
99::mlir::Attribute ConvOpQuantizationAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
100 ::mlir::Builder odsBuilder(odsParser.getContext());
101 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
102 (void) odsLoc;
103 ::mlir::FailureOr<int64_t> _result_input_zp;
104 ::mlir::FailureOr<int64_t> _result_weight_zp;
105 // Parse literal '<'
106 if (odsParser.parseLess()) return {};
107 // Parse parameter struct
108 bool _seen_input_zp = false;
109 bool _seen_weight_zp = false;
110 {
111 const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool {
112 // Parse literal '='
113 if (odsParser.parseEqual()) return {};
114 if (!_seen_input_zp && _paramKey == "input_zp") {
115 _seen_input_zp = true;
116
117 // Parse variable 'input_zp'
118 _result_input_zp = ::mlir::FieldParser<int64_t>::parse(odsParser);
119 if (::mlir::failed(_result_input_zp)) {
120 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Tosa_ConvOpQuantizationAttr parameter 'input_zp' which is to be a `int64_t`");
121 return {};
122 }
123 } else if (!_seen_weight_zp && _paramKey == "weight_zp") {
124 _seen_weight_zp = true;
125
126 // Parse variable 'weight_zp'
127 _result_weight_zp = ::mlir::FieldParser<int64_t>::parse(odsParser);
128 if (::mlir::failed(_result_weight_zp)) {
129 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Tosa_ConvOpQuantizationAttr parameter 'weight_zp' which is to be a `int64_t`");
130 return {};
131 }
132 } else {
133 odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey;
134 return {};
135 }
136 return true;
137 };
138 for (unsigned odsStructIndex = 0; odsStructIndex < 2; ++odsStructIndex) {
139 ::llvm::StringRef _paramKey;
140 if (odsParser.parseKeyword(&_paramKey)) {
141 odsParser.emitError(odsParser.getCurrentLocation(),
142 "expected a parameter name in struct");
143 return {};
144 }
145 if (!_loop_body(_paramKey)) return {};
146 if ((odsStructIndex != 2 - 1) && odsParser.parseComma())
147 return {};
148 }
149 }
150 // Parse literal '>'
151 if (odsParser.parseGreater()) return {};
152 assert(::mlir::succeeded(_result_input_zp))(static_cast <bool> (::mlir::succeeded(_result_input_zp
)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_input_zp)"
, "tools/mlir/include/mlir/Dialect/Tosa/IR/TosaAttributes.cpp.inc"
, 152, __extension__ __PRETTY_FUNCTION__))
;
153 assert(::mlir::succeeded(_result_weight_zp))(static_cast <bool> (::mlir::succeeded(_result_weight_zp
)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_weight_zp)"
, "tools/mlir/include/mlir/Dialect/Tosa/IR/TosaAttributes.cpp.inc"
, 153, __extension__ __PRETTY_FUNCTION__))
;
154 return ConvOpQuantizationAttr::get(odsParser.getContext(),
155 int64_t((*_result_input_zp)),
156 int64_t((*_result_weight_zp)));
157}
158
159void ConvOpQuantizationAttr::print(::mlir::AsmPrinter &odsPrinter) const {
160 ::mlir::Builder odsBuilder(getContext());
161 odsPrinter << "<";
162 {
163 bool _firstPrinted = true;
164 if (!_firstPrinted) odsPrinter << ", ";
165 _firstPrinted = false;
166 odsPrinter << "input_zp = ";
167 odsPrinter.printStrippedAttrOrType(getInputZp());
168 if (!_firstPrinted) odsPrinter << ", ";
169 _firstPrinted = false;
Value stored to '_firstPrinted' is never read
170 odsPrinter << "weight_zp = ";
171 odsPrinter.printStrippedAttrOrType(getWeightZp());
172 }
173 odsPrinter << ">";
174}
175
176int64_t ConvOpQuantizationAttr::getInputZp() const {
177 return getImpl()->input_zp;
178}
179
180int64_t ConvOpQuantizationAttr::getWeightZp() const {
181 return getImpl()->weight_zp;
182}
183
184} // namespace tosa
185} // namespace mlir
186MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::ConvOpQuantizationAttr)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver
<mlir::tosa::ConvOpQuantizationAttr>::id = {}; } }
187namespace mlir {
188namespace tosa {
189namespace detail {
190struct MatMulOpQuantizationAttrStorage : public ::mlir::AttributeStorage {
191 using KeyTy = std::tuple<int64_t, int64_t>;
192 MatMulOpQuantizationAttrStorage(int64_t a_zp, int64_t b_zp) : a_zp(a_zp), b_zp(b_zp) {}
193
194 bool operator==(const KeyTy &tblgenKey) const {
195 return (a_zp == std::get<0>(tblgenKey)) && (b_zp == std::get<1>(tblgenKey));
196 }
197
198 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
199 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey));
200 }
201
202 static MatMulOpQuantizationAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, const KeyTy &tblgenKey) {
203 auto a_zp = std::get<0>(tblgenKey);
204 auto b_zp = std::get<1>(tblgenKey);
205 return new (allocator.allocate<MatMulOpQuantizationAttrStorage>()) MatMulOpQuantizationAttrStorage(a_zp, b_zp);
206 }
207
208 int64_t a_zp;
209 int64_t b_zp;
210};
211} // namespace detail
212MatMulOpQuantizationAttr MatMulOpQuantizationAttr::get(::mlir::MLIRContext *context, int64_t a_zp, int64_t b_zp) {
213 return Base::get(context, a_zp, b_zp);
214}
215
216::mlir::Attribute MatMulOpQuantizationAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
217 ::mlir::Builder odsBuilder(odsParser.getContext());
218 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
219 (void) odsLoc;
220 ::mlir::FailureOr<int64_t> _result_a_zp;
221 ::mlir::FailureOr<int64_t> _result_b_zp;
222 // Parse literal '<'
223 if (odsParser.parseLess()) return {};
224 // Parse parameter struct
225 bool _seen_a_zp = false;
226 bool _seen_b_zp = false;
227 {
228 const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool {
229 // Parse literal '='
230 if (odsParser.parseEqual()) return {};
231 if (!_seen_a_zp && _paramKey == "a_zp") {
232 _seen_a_zp = true;
233
234 // Parse variable 'a_zp'
235 _result_a_zp = ::mlir::FieldParser<int64_t>::parse(odsParser);
236 if (::mlir::failed(_result_a_zp)) {
237 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Tosa_MatMulOpQuantizationAttr parameter 'a_zp' which is to be a `int64_t`");
238 return {};
239 }
240 } else if (!_seen_b_zp && _paramKey == "b_zp") {
241 _seen_b_zp = true;
242
243 // Parse variable 'b_zp'
244 _result_b_zp = ::mlir::FieldParser<int64_t>::parse(odsParser);
245 if (::mlir::failed(_result_b_zp)) {
246 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Tosa_MatMulOpQuantizationAttr parameter 'b_zp' which is to be a `int64_t`");
247 return {};
248 }
249 } else {
250 odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey;
251 return {};
252 }
253 return true;
254 };
255 for (unsigned odsStructIndex = 0; odsStructIndex < 2; ++odsStructIndex) {
256 ::llvm::StringRef _paramKey;
257 if (odsParser.parseKeyword(&_paramKey)) {
258 odsParser.emitError(odsParser.getCurrentLocation(),
259 "expected a parameter name in struct");
260 return {};
261 }
262 if (!_loop_body(_paramKey)) return {};
263 if ((odsStructIndex != 2 - 1) && odsParser.parseComma())
264 return {};
265 }
266 }
267 // Parse literal '>'
268 if (odsParser.parseGreater()) return {};
269 assert(::mlir::succeeded(_result_a_zp))(static_cast <bool> (::mlir::succeeded(_result_a_zp)) ?
void (0) : __assert_fail ("::mlir::succeeded(_result_a_zp)",
"tools/mlir/include/mlir/Dialect/Tosa/IR/TosaAttributes.cpp.inc"
, 269, __extension__ __PRETTY_FUNCTION__))
;
270 assert(::mlir::succeeded(_result_b_zp))(static_cast <bool> (::mlir::succeeded(_result_b_zp)) ?
void (0) : __assert_fail ("::mlir::succeeded(_result_b_zp)",
"tools/mlir/include/mlir/Dialect/Tosa/IR/TosaAttributes.cpp.inc"
, 270, __extension__ __PRETTY_FUNCTION__))
;
271 return MatMulOpQuantizationAttr::get(odsParser.getContext(),
272 int64_t((*_result_a_zp)),
273 int64_t((*_result_b_zp)));
274}
275
276void MatMulOpQuantizationAttr::print(::mlir::AsmPrinter &odsPrinter) const {
277 ::mlir::Builder odsBuilder(getContext());
278 odsPrinter << "<";
279 {
280 bool _firstPrinted = true;
281 if (!_firstPrinted) odsPrinter << ", ";
282 _firstPrinted = false;
283 odsPrinter << "a_zp = ";
284 odsPrinter.printStrippedAttrOrType(getAZp());
285 if (!_firstPrinted) odsPrinter << ", ";
286 _firstPrinted = false;
287 odsPrinter << "b_zp = ";
288 odsPrinter.printStrippedAttrOrType(getBZp());
289 }
290 odsPrinter << ">";
291}
292
293int64_t MatMulOpQuantizationAttr::getAZp() const {
294 return getImpl()->a_zp;
295}
296
297int64_t MatMulOpQuantizationAttr::getBZp() const {
298 return getImpl()->b_zp;
299}
300
301} // namespace tosa
302} // namespace mlir
303MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::MatMulOpQuantizationAttr)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver
<mlir::tosa::MatMulOpQuantizationAttr>::id = {}; } }
304namespace mlir {
305namespace tosa {
306namespace detail {
307struct PadOpQuantizationAttrStorage : public ::mlir::AttributeStorage {
308 using KeyTy = std::tuple<int64_t>;
309 PadOpQuantizationAttrStorage(int64_t input_zp) : input_zp(input_zp) {}
310
311 bool operator==(const KeyTy &tblgenKey) const {
312 return (input_zp == std::get<0>(tblgenKey));
313 }
314
315 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
316 return ::llvm::hash_combine(std::get<0>(tblgenKey));
317 }
318
319 static PadOpQuantizationAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, const KeyTy &tblgenKey) {
320 auto input_zp = std::get<0>(tblgenKey);
321 return new (allocator.allocate<PadOpQuantizationAttrStorage>()) PadOpQuantizationAttrStorage(input_zp);
322 }
323
324 int64_t input_zp;
325};
326} // namespace detail
327PadOpQuantizationAttr PadOpQuantizationAttr::get(::mlir::MLIRContext *context, int64_t input_zp) {
328 return Base::get(context, input_zp);
329}
330
331::mlir::Attribute PadOpQuantizationAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
332 ::mlir::Builder odsBuilder(odsParser.getContext());
333 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
334 (void) odsLoc;
335 ::mlir::FailureOr<int64_t> _result_input_zp;
336 // Parse literal '<'
337 if (odsParser.parseLess()) return {};
338 // Parse parameter struct
339 bool _seen_input_zp = false;
340 {
341 const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool {
342 // Parse literal '='
343 if (odsParser.parseEqual()) return {};
344 if (!_seen_input_zp && _paramKey == "input_zp") {
345 _seen_input_zp = true;
346
347 // Parse variable 'input_zp'
348 _result_input_zp = ::mlir::FieldParser<int64_t>::parse(odsParser);
349 if (::mlir::failed(_result_input_zp)) {
350 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Tosa_PadOpQuantizationAttr parameter 'input_zp' which is to be a `int64_t`");
351 return {};
352 }
353 } else {
354 odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey;
355 return {};
356 }
357 return true;
358 };
359 for (unsigned odsStructIndex = 0; odsStructIndex < 1; ++odsStructIndex) {
360 ::llvm::StringRef _paramKey;
361 if (odsParser.parseKeyword(&_paramKey)) {
362 odsParser.emitError(odsParser.getCurrentLocation(),
363 "expected a parameter name in struct");
364 return {};
365 }
366 if (!_loop_body(_paramKey)) return {};
367 if ((odsStructIndex != 1 - 1) && odsParser.parseComma())
368 return {};
369 }
370 }
371 // Parse literal '>'
372 if (odsParser.parseGreater()) return {};
373 assert(::mlir::succeeded(_result_input_zp))(static_cast <bool> (::mlir::succeeded(_result_input_zp
)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_input_zp)"
, "tools/mlir/include/mlir/Dialect/Tosa/IR/TosaAttributes.cpp.inc"
, 373, __extension__ __PRETTY_FUNCTION__))
;
374 return PadOpQuantizationAttr::get(odsParser.getContext(),
375 int64_t((*_result_input_zp)));
376}
377
378void PadOpQuantizationAttr::print(::mlir::AsmPrinter &odsPrinter) const {
379 ::mlir::Builder odsBuilder(getContext());
380 odsPrinter << "<";
381 {
382 bool _firstPrinted = true;
383 if (!_firstPrinted) odsPrinter << ", ";
384 _firstPrinted = false;
385 odsPrinter << "input_zp = ";
386 odsPrinter.printStrippedAttrOrType(getInputZp());
387 }
388 odsPrinter << ">";
389}
390
391int64_t PadOpQuantizationAttr::getInputZp() const {
392 return getImpl()->input_zp;
393}
394
395} // namespace tosa
396} // namespace mlir
397MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::PadOpQuantizationAttr)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver
<mlir::tosa::PadOpQuantizationAttr>::id = {}; } }
398namespace mlir {
399namespace tosa {
400namespace detail {
401struct UnaryOpQuantizationAttrStorage : public ::mlir::AttributeStorage {
402 using KeyTy = std::tuple<int64_t, int64_t>;
403 UnaryOpQuantizationAttrStorage(int64_t input_zp, int64_t output_zp) : input_zp(input_zp), output_zp(output_zp) {}
404
405 bool operator==(const KeyTy &tblgenKey) const {
406 return (input_zp == std::get<0>(tblgenKey)) && (output_zp == std::get<1>(tblgenKey));
407 }
408
409 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
410 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey));
411 }
412
413 static UnaryOpQuantizationAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, const KeyTy &tblgenKey) {
414 auto input_zp = std::get<0>(tblgenKey);
415 auto output_zp = std::get<1>(tblgenKey);
416 return new (allocator.allocate<UnaryOpQuantizationAttrStorage>()) UnaryOpQuantizationAttrStorage(input_zp, output_zp);
417 }
418
419 int64_t input_zp;
420 int64_t output_zp;
421};
422} // namespace detail
423UnaryOpQuantizationAttr UnaryOpQuantizationAttr::get(::mlir::MLIRContext *context, int64_t input_zp, int64_t output_zp) {
424 return Base::get(context, input_zp, output_zp);
425}
426
427::mlir::Attribute UnaryOpQuantizationAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
428 ::mlir::Builder odsBuilder(odsParser.getContext());
429 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
430 (void) odsLoc;
431 ::mlir::FailureOr<int64_t> _result_input_zp;
432 ::mlir::FailureOr<int64_t> _result_output_zp;
433 // Parse literal '<'
434 if (odsParser.parseLess()) return {};
435 // Parse parameter struct
436 bool _seen_input_zp = false;
437 bool _seen_output_zp = false;
438 {
439 const auto _loop_body = [&](::llvm::StringRef _paramKey) -> bool {
440 // Parse literal '='
441 if (odsParser.parseEqual()) return {};
442 if (!_seen_input_zp && _paramKey == "input_zp") {
443 _seen_input_zp = true;
444
445 // Parse variable 'input_zp'
446 _result_input_zp = ::mlir::FieldParser<int64_t>::parse(odsParser);
447 if (::mlir::failed(_result_input_zp)) {
448 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Tosa_UnaryOpQuantizationAttr parameter 'input_zp' which is to be a `int64_t`");
449 return {};
450 }
451 } else if (!_seen_output_zp && _paramKey == "output_zp") {
452 _seen_output_zp = true;
453
454 // Parse variable 'output_zp'
455 _result_output_zp = ::mlir::FieldParser<int64_t>::parse(odsParser);
456 if (::mlir::failed(_result_output_zp)) {
457 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse Tosa_UnaryOpQuantizationAttr parameter 'output_zp' which is to be a `int64_t`");
458 return {};
459 }
460 } else {
461 odsParser.emitError(odsParser.getCurrentLocation(), "duplicate or unknown struct parameter name: ") << _paramKey;
462 return {};
463 }
464 return true;
465 };
466 for (unsigned odsStructIndex = 0; odsStructIndex < 2; ++odsStructIndex) {
467 ::llvm::StringRef _paramKey;
468 if (odsParser.parseKeyword(&_paramKey)) {
469 odsParser.emitError(odsParser.getCurrentLocation(),
470 "expected a parameter name in struct");
471 return {};
472 }
473 if (!_loop_body(_paramKey)) return {};
474 if ((odsStructIndex != 2 - 1) && odsParser.parseComma())
475 return {};
476 }
477 }
478 // Parse literal '>'
479 if (odsParser.parseGreater()) return {};
480 assert(::mlir::succeeded(_result_input_zp))(static_cast <bool> (::mlir::succeeded(_result_input_zp
)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_input_zp)"
, "tools/mlir/include/mlir/Dialect/Tosa/IR/TosaAttributes.cpp.inc"
, 480, __extension__ __PRETTY_FUNCTION__))
;
481 assert(::mlir::succeeded(_result_output_zp))(static_cast <bool> (::mlir::succeeded(_result_output_zp
)) ? void (0) : __assert_fail ("::mlir::succeeded(_result_output_zp)"
, "tools/mlir/include/mlir/Dialect/Tosa/IR/TosaAttributes.cpp.inc"
, 481, __extension__ __PRETTY_FUNCTION__))
;
482 return UnaryOpQuantizationAttr::get(odsParser.getContext(),
483 int64_t((*_result_input_zp)),
484 int64_t((*_result_output_zp)));
485}
486
487void UnaryOpQuantizationAttr::print(::mlir::AsmPrinter &odsPrinter) const {
488 ::mlir::Builder odsBuilder(getContext());
489 odsPrinter << "<";
490 {
491 bool _firstPrinted = true;
492 if (!_firstPrinted) odsPrinter << ", ";
493 _firstPrinted = false;
494 odsPrinter << "input_zp = ";
495 odsPrinter.printStrippedAttrOrType(getInputZp());
496 if (!_firstPrinted) odsPrinter << ", ";
497 _firstPrinted = false;
498 odsPrinter << "output_zp = ";
499 odsPrinter.printStrippedAttrOrType(getOutputZp());
500 }
501 odsPrinter << ">";
502}
503
504int64_t UnaryOpQuantizationAttr::getInputZp() const {
505 return getImpl()->input_zp;
506}
507
508int64_t UnaryOpQuantizationAttr::getOutputZp() const {
509 return getImpl()->output_zp;
510}
511
512} // namespace tosa
513} // namespace mlir
514MLIR_DEFINE_EXPLICIT_TYPE_ID(mlir::tosa::UnaryOpQuantizationAttr)namespace mlir { namespace detail { SelfOwningTypeID TypeIDResolver
<mlir::tosa::UnaryOpQuantizationAttr>::id = {}; } }
515namespace mlir {
516namespace tosa {
517
518/// Parse an attribute registered to this dialect.
519::mlir::Attribute TosaDialect::parseAttribute(::mlir::DialectAsmParser &parser,
520 ::mlir::Type type) const {
521 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
522 ::llvm::StringRef attrTag;
523 {
524 ::mlir::Attribute attr;
525 auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
526 if (parseResult.has_value())
527 return attr;
528 }
529
530 parser.emitError(typeLoc) << "unknown attribute `"
531 << attrTag << "` in dialect `" << getNamespace() << "`";
532 return {};
533}
534/// Print an attribute registered to this dialect.
535void TosaDialect::printAttribute(::mlir::Attribute attr,
536 ::mlir::DialectAsmPrinter &printer) const {
537 if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
538 return;
539
540}
541} // namespace tosa
542} // namespace mlir
543
544#endif // GET_ATTRDEF_CLASSES
545