@@ -30,8 +30,7 @@ static FailureOr<uint32_t> getIndexRepresentation(Operation *op) {
3030 if (auto imm = dyn_cast<dxsa::IndexImm>(op)) {
3131 auto attr = dyn_cast<IntegerAttr>(imm.getImm ());
3232 if (!attr) {
33- emitError (op->getLoc (), " invalid immediate index" );
34- return failure ();
33+ return emitError (op->getLoc (), " invalid immediate index" );
3534 }
3635
3736 if (attr.getType ().isInteger (32 )) {
@@ -42,8 +41,7 @@ static FailureOr<uint32_t> getIndexRepresentation(Operation *op) {
4241 return D3D10_SB_OPERAND_INDEX_IMMEDIATE64;
4342 }
4443
45- emitError (op->getLoc (), " invalid immediate index type" );
46- return failure ();
44+ return emitError (op->getLoc (), " invalid immediate index type" );
4745 }
4846
4947 if (isa<dxsa::IndexRel>(op)) {
@@ -54,8 +52,7 @@ static FailureOr<uint32_t> getIndexRepresentation(Operation *op) {
5452 return D3D10_SB_OPERAND_INDEX_IMMEDIATE32_PLUS_RELATIVE;
5553 }
5654
57- emitError (op->getLoc (), " invalid index type" );
58- return failure ();
55+ return emitError (op->getLoc (), " invalid index type" );
5956}
6057
6158class Writer {
@@ -67,8 +64,7 @@ class Writer {
6764 LogicalResult emitModule (ModuleOp source) {
6865 Region ®ion = source.getRegion ();
6966 if (!region.hasOneBlock ()) {
70- emitError (region.getLoc (), " region should contain only one block" );
71- return failure ();
67+ return emitError (region.getLoc (), " region should contain only one block" );
7268 }
7369
7470 for (auto &op : region.front ()) {
@@ -90,8 +86,7 @@ class Writer {
9086
9187 auto opcodeIt = opcodeMap.find (inst.getMnemonic ());
9288 if (opcodeIt == opcodeMap.end ()) {
93- emitError (inst.getLoc (), " unknown mnemonic" );
94- return failure ();
89+ return emitError (inst.getLoc (), " unknown mnemonic" );
9590 }
9691
9792 // First token is an opcode and length. Length is unknown until we
@@ -103,8 +98,7 @@ class Writer {
10398 for (Value value : inst.getOperands ()) {
10499 Operation *op = value.getDefiningOp ();
105100 if (!op) {
106- emitError (value.getLoc (), " undefined operand" );
107- return failure ();
101+ return emitError (value.getLoc (), " undefined operand" );
108102 }
109103
110104 if (auto operand = dyn_cast<dxsa::Operand>(*op)) {
@@ -121,8 +115,7 @@ class Writer {
121115 continue ;
122116 }
123117
124- emitError (op->getLoc (), " unexpected operand kind" );
125- return failure ();
118+ return emitError (op->getLoc (), " unexpected operand kind" );
126119 }
127120
128121 // Fixup instruction length after all operands are accumulated in
@@ -164,8 +157,7 @@ class Writer {
164157 values.push_back (v.getZExtValue ());
165158 }
166159 if (values.size () != 4 ) {
167- emitError (op.getLoc (), " invalid number of swizzle values" );
168- return failure ();
160+ return emitError (op.getLoc (), " invalid number of swizzle values" );
169161 }
170162 token |= ENCODE_D3D10_SB_OPERAND_4_COMPONENT_SELECTION_MODE (
171163 D3D10_SB_OPERAND_4_COMPONENT_SWIZZLE_MODE);
@@ -181,8 +173,7 @@ class Writer {
181173 break ;
182174 }
183175 default : {
184- emitError (op.getLoc (), " invalid number of components" );
185- return failure ();
176+ return emitError (op.getLoc (), " invalid number of components" );
186177 }
187178 }
188179
@@ -193,8 +184,7 @@ class Writer {
193184 for (Value value : op.getOperands ()) {
194185 Operation *index = value.getDefiningOp ();
195186 if (!index) {
196- emitError (value.getLoc (), " index must be defined" );
197- return failure ();
187+ return emitError (value.getLoc (), " index must be defined" );
198188 }
199189
200190 FailureOr<uint32_t > repr = getIndexRepresentation (index);
@@ -211,8 +201,7 @@ class Writer {
211201 for (Value value : op.getOperands ()) {
212202 Operation *index = value.getDefiningOp ();
213203 if (!index) {
214- emitError (value.getLoc (), " index must be defined" );
215- return failure ();
204+ return emitError (value.getLoc (), " index must be defined" );
216205 }
217206
218207 if (auto indexImm = dyn_cast<dxsa::IndexImm>(*index)) {
@@ -236,8 +225,7 @@ class Writer {
236225 continue ;
237226 }
238227
239- emitError (value.getLoc (), " invalid index type" );
240- return failure ();
228+ return emitError (value.getLoc (), " invalid index type" );
241229 }
242230
243231 return success ();
@@ -249,7 +237,7 @@ class Writer {
249237 LogicalResult emitOperandImm (dxsa::OperandImm op) {
250238 auto attr = dyn_cast<DenseIntElementsAttr>(op.getImm ());
251239 if (!attr) {
252- emitError (op.getLoc (), " invalid immediate operand" );
240+ return emitError (op.getLoc (), " invalid immediate operand" );
253241 }
254242
255243 uint32_t token = 0 ;
@@ -260,8 +248,7 @@ class Writer {
260248 } else if (elementType.isInteger (64 )) {
261249 token |= ENCODE_D3D10_SB_OPERAND_TYPE (D3D10_SB_OPERAND_TYPE_IMMEDIATE64);
262250 } else {
263- emitError (op.getLoc (), " invalid immediate operand type" );
264- return failure ();
251+ return emitError (op.getLoc (), " invalid immediate operand type" );
265252 }
266253
267254 // Split immediates into tokens. 32 bit immediate values are
@@ -283,9 +270,8 @@ class Writer {
283270 token |=
284271 ENCODE_D3D10_SB_OPERAND_NUM_COMPONENTS (D3D10_SB_OPERAND_4_COMPONENT);
285272 } else {
286- emitError (op.getLoc (),
287- " immediate operand should be either 1- or 4- component" );
288- return failure ();
273+ return emitError (op.getLoc (),
274+ " immediate operand should be either 1- or 4- component" );
289275 }
290276
291277 buffer.push_back (token);
@@ -301,8 +287,7 @@ class Writer {
301287 LogicalResult emitIndexImm (dxsa::IndexImm op) {
302288 auto attr = dyn_cast<IntegerAttr>(op.getImm ());
303289 if (!attr) {
304- emitError (op.getLoc (), " invalid immediate index" );
305- return failure ();
290+ return emitError (op.getLoc (), " invalid immediate index" );
306291 }
307292
308293 uint64_t value = attr.getInt ();
@@ -317,22 +302,19 @@ class Writer {
317302 return success ();
318303 }
319304
320- emitError (op.getLoc (), " invalid type of an immediate index" );
321- return failure ();
305+ return emitError (op.getLoc (), " invalid type of an immediate index" );
322306 }
323307
324308 // Emit an operand used as an index.
325309 LogicalResult emitIndexRel (dxsa::IndexRel index) {
326310 Operation *def = index.getOperand ().getDefiningOp ();
327311 if (!def) {
328- emitError (index.getLoc (), " index must be defined" );
329- return failure ();
312+ return emitError (index.getLoc (), " index must be defined" );
330313 }
331314
332315 auto operand = dyn_cast<dxsa::Operand>(*def);
333316 if (!operand) {
334- emitError (def->getLoc (), " invalid index relative operand" );
335- return failure ();
317+ return emitError (def->getLoc (), " invalid index relative operand" );
336318 }
337319
338320 // Recursively emit an operand, which may also have other indices.
@@ -343,14 +325,12 @@ class Writer {
343325 LogicalResult emitIndexRelImm (dxsa::IndexRelImm index) {
344326 Operation *def = index.getOperand ().getDefiningOp ();
345327 if (!def) {
346- emitError (index.getLoc (), " index must be defined" );
347- return failure ();
328+ return emitError (index.getLoc (), " index must be defined" );
348329 }
349330
350331 auto operand = dyn_cast<dxsa::Operand>(*def);
351332 if (!operand) {
352- emitError (def->getLoc (), " invalid index relative operand" );
353- return failure ();
333+ return emitError (def->getLoc (), " invalid index relative operand" );
354334 }
355335
356336 if (failed (emitOperand (operand))) {
0 commit comments