@@ -138,17 +138,13 @@ void IntAttr::print(AsmPrinter &printer) const {
138
138
139
139
LogicalResult IntAttr::verify (function_ref<InFlightDiagnostic()> emitError,
140
140
Type type, APInt value) {
141
- if (!mlir::isa<IntType>(type)) {
142
- emitError () << " expected 'simple.int' type" ;
143
- return failure ();
144
- }
141
+ if (!mlir::isa<IntType>(type))
142
+ return emitError () << " expected 'simple.int' type" ;
145
143
146
144
auto intType = mlir::cast<IntType>(type);
147
- if (value.getBitWidth () != intType.getWidth ()) {
148
- emitError () << " type and value bitwidth mismatch: " << intType.getWidth ()
149
- << " != " << value.getBitWidth ();
150
- return failure ();
151
- }
145
+ if (value.getBitWidth () != intType.getWidth ())
146
+ return emitError () << " type and value bitwidth mismatch: "
147
+ << intType.getWidth () << " != " << value.getBitWidth ();
152
148
153
149
return success ();
154
150
}
@@ -182,10 +178,8 @@ FPAttr FPAttr::getZero(Type type) {
182
178
LogicalResult FPAttr::verify (function_ref<InFlightDiagnostic()> emitError,
183
179
CIRFPTypeInterface fpType, APFloat value) {
184
180
if (APFloat::SemanticsToEnum (fpType.getFloatSemantics ()) !=
185
- APFloat::SemanticsToEnum (value.getSemantics ())) {
186
- emitError () << " floating-point semantics mismatch" ;
187
- return failure ();
188
- }
181
+ APFloat::SemanticsToEnum (value.getSemantics ()))
182
+ return emitError () << " floating-point semantics mismatch" ;
189
183
190
184
return success ();
191
185
}
@@ -195,22 +189,21 @@ LogicalResult FPAttr::verify(function_ref<InFlightDiagnostic()> emitError,
195
189
// ===----------------------------------------------------------------------===//
196
190
197
191
LogicalResult
198
- ConstArrayAttr::verify (function_ref<::mlir:: InFlightDiagnostic()> emitError,
199
- Type type, Attribute elts, int trailingZerosNum) {
192
+ ConstArrayAttr::verify (function_ref<InFlightDiagnostic()> emitError, Type type ,
193
+ Attribute elts, int trailingZerosNum) {
200
194
201
- if (!(mlir::isa<ArrayAttr>(elts) || mlir::isa< StringAttr>(elts)))
195
+ if (!(mlir::isa<ArrayAttr, StringAttr>(elts)))
202
196
return emitError () << " constant array expects ArrayAttr or StringAttr" ;
203
197
204
198
if (auto strAttr = mlir::dyn_cast<StringAttr>(elts)) {
205
199
const auto arrayTy = mlir::cast<ArrayType>(type);
206
200
const auto intTy = mlir::dyn_cast<IntType>(arrayTy.getElementType ());
207
201
208
202
// TODO: add CIR type for char.
209
- if (!intTy || intTy.getWidth () != 8 ) {
210
- emitError () << " constant array element for string literals expects "
211
- " !cir.int<u, 8> element type" ;
212
- return failure ();
213
- }
203
+ if (!intTy || intTy.getWidth () != 8 )
204
+ return emitError ()
205
+ << " constant array element for string literals expects "
206
+ " !cir.int<u, 8> element type" ;
214
207
return success ();
215
208
}
216
209
@@ -303,22 +296,20 @@ void ConstArrayAttr::print(AsmPrinter &printer) const {
303
296
// CIR ConstVectorAttr
304
297
// ===----------------------------------------------------------------------===//
305
298
306
- LogicalResult cir::ConstVectorAttr::verify (
307
- function_ref<::mlir:: InFlightDiagnostic()> emitError, Type type ,
308
- ArrayAttr elts) {
299
+ LogicalResult
300
+ cir::ConstVectorAttr::verify (function_ref< InFlightDiagnostic()> emitError,
301
+ Type type, ArrayAttr elts) {
309
302
310
- if (!mlir::isa<cir::VectorType>(type)) {
303
+ if (!mlir::isa<cir::VectorType>(type))
311
304
return emitError () << " type of cir::ConstVectorAttr is not a "
312
305
" cir::VectorType: "
313
306
<< type;
314
- }
315
307
316
308
const auto vecType = mlir::cast<cir::VectorType>(type);
317
309
318
- if (vecType.getSize () != elts.size ()) {
310
+ if (vecType.getSize () != elts.size ())
319
311
return emitError ()
320
312
<< " number of constant elements should match vector size" ;
321
- }
322
313
323
314
// Check if the types of the elements match
324
315
LogicalResult elementTypeCheck = success ();
0 commit comments