@@ -217,48 +217,6 @@ class InlineAsm final : public Value {
217
217
Extra_MayLoad = 8 ,
218
218
Extra_MayStore = 16 ,
219
219
Extra_IsConvergent = 32 ,
220
-
221
- // Memory constraint codes.
222
- // These could be tablegenerated but there's little need to do that since
223
- // there's plenty of space in the encoding to support the union of all
224
- // constraint codes for all targets.
225
- // Addresses are included here as they need to be treated the same by the
226
- // backend, the only difference is that they are not used to actaully
227
- // access memory by the instruction.
228
- // TODO: convert to enum?
229
- Constraint_Unknown = 0 ,
230
- Constraint_es,
231
- Constraint_i,
232
- Constraint_k,
233
- Constraint_m,
234
- Constraint_o,
235
- Constraint_v,
236
- Constraint_A,
237
- Constraint_Q,
238
- Constraint_R,
239
- Constraint_S,
240
- Constraint_T,
241
- Constraint_Um,
242
- Constraint_Un,
243
- Constraint_Uq,
244
- Constraint_Us,
245
- Constraint_Ut,
246
- Constraint_Uv,
247
- Constraint_Uy,
248
- Constraint_X,
249
- Constraint_Z,
250
- Constraint_ZB,
251
- Constraint_ZC,
252
- Constraint_Zy,
253
-
254
- // Address constraints
255
- Constraint_p,
256
- Constraint_ZQ,
257
- Constraint_ZR,
258
- Constraint_ZS,
259
- Constraint_ZT,
260
-
261
- Constraints_Max = Constraint_ZT,
262
220
};
263
221
264
222
// Inline asm operands map to multiple SDNode / MachineInstr operands.
@@ -274,6 +232,46 @@ class InlineAsm final : public Value {
274
232
Func = 7 , // Address operand of function call
275
233
};
276
234
235
+ // Memory constraint codes.
236
+ // Addresses are included here as they need to be treated the same by the
237
+ // backend, the only difference is that they are not used to actaully
238
+ // access memory by the instruction.
239
+ enum class ConstraintCode : uint32_t {
240
+ Unknown = 0 ,
241
+ es,
242
+ i,
243
+ k,
244
+ m,
245
+ o,
246
+ v,
247
+ A,
248
+ Q,
249
+ R,
250
+ S,
251
+ T,
252
+ Um,
253
+ Un,
254
+ Uq,
255
+ Us,
256
+ Ut,
257
+ Uv,
258
+ Uy,
259
+ X,
260
+ Z,
261
+ ZB,
262
+ ZC,
263
+ Zy,
264
+
265
+ // Address constraints
266
+ p,
267
+ ZQ,
268
+ ZR,
269
+ ZS,
270
+ ZT,
271
+
272
+ Max = ZT,
273
+ };
274
+
277
275
// These are helper methods for dealing with flags in the INLINEASM SDNode
278
276
// in the backend.
279
277
//
@@ -375,11 +373,14 @@ class InlineAsm final : public Value {
375
373
return true ;
376
374
}
377
375
378
- // TODO: convert to enum?
379
- unsigned getMemoryConstraintID () const {
376
+ ConstraintCode getMemoryConstraintID () const {
380
377
assert ((isMemKind () || isFuncKind ()) &&
381
378
" Not expected mem or function flag!" );
382
- return getData ();
379
+ uint32_t D = getData ();
380
+ assert (D <= static_cast <uint32_t >(ConstraintCode::Max) &&
381
+ D >= static_cast <uint32_t >(ConstraintCode::Unknown) &&
382
+ " unexpected value for memory constraint" );
383
+ return static_cast <ConstraintCode>(D);
383
384
}
384
385
385
386
// / setMatchingOp - Augment an existing flag with information indicating
@@ -403,12 +404,11 @@ class InlineAsm final : public Value {
403
404
404
405
// / setMemConstraint - Augment an existing flag with the constraint code for
405
406
// / a memory constraint.
406
- void setMemConstraint (unsigned Constraint ) {
407
+ void setMemConstraint (ConstraintCode C ) {
407
408
assert ((isMemKind () || isFuncKind ()) &&
408
409
" Flag is not a memory or function constraint!" );
409
- assert (Constraint <= Constraints_Max && " Unknown constraint ID" );
410
410
assert (getData () == 0 && " Mem constraint already set" );
411
- setData (Constraint );
411
+ setData (static_cast < uint32_t >(C) );
412
412
}
413
413
// / clearMemConstraint - Similar to setMemConstraint(0), but without the
414
414
// / assertion checking that the constraint has not been set previously.
@@ -443,63 +443,63 @@ class InlineAsm final : public Value {
443
443
return Result;
444
444
}
445
445
446
- static StringRef getMemConstraintName (unsigned Constraint ) {
447
- switch (Constraint ) {
448
- case InlineAsm::Constraint_es :
446
+ static StringRef getMemConstraintName (ConstraintCode C ) {
447
+ switch (C ) {
448
+ case ConstraintCode::es :
449
449
return " es" ;
450
- case InlineAsm::Constraint_i :
450
+ case ConstraintCode::i :
451
451
return " i" ;
452
- case InlineAsm::Constraint_k :
452
+ case ConstraintCode::k :
453
453
return " k" ;
454
- case InlineAsm::Constraint_m :
454
+ case ConstraintCode::m :
455
455
return " m" ;
456
- case InlineAsm::Constraint_o :
456
+ case ConstraintCode::o :
457
457
return " o" ;
458
- case InlineAsm::Constraint_v :
458
+ case ConstraintCode::v :
459
459
return " v" ;
460
- case InlineAsm::Constraint_A :
460
+ case ConstraintCode::A :
461
461
return " A" ;
462
- case InlineAsm::Constraint_Q :
462
+ case ConstraintCode::Q :
463
463
return " Q" ;
464
- case InlineAsm::Constraint_R :
464
+ case ConstraintCode::R :
465
465
return " R" ;
466
- case InlineAsm::Constraint_S :
466
+ case ConstraintCode::S :
467
467
return " S" ;
468
- case InlineAsm::Constraint_T :
468
+ case ConstraintCode::T :
469
469
return " T" ;
470
- case InlineAsm::Constraint_Um :
470
+ case ConstraintCode::Um :
471
471
return " Um" ;
472
- case InlineAsm::Constraint_Un :
472
+ case ConstraintCode::Un :
473
473
return " Un" ;
474
- case InlineAsm::Constraint_Uq :
474
+ case ConstraintCode::Uq :
475
475
return " Uq" ;
476
- case InlineAsm::Constraint_Us :
476
+ case ConstraintCode::Us :
477
477
return " Us" ;
478
- case InlineAsm::Constraint_Ut :
478
+ case ConstraintCode::Ut :
479
479
return " Ut" ;
480
- case InlineAsm::Constraint_Uv :
480
+ case ConstraintCode::Uv :
481
481
return " Uv" ;
482
- case InlineAsm::Constraint_Uy :
482
+ case ConstraintCode::Uy :
483
483
return " Uy" ;
484
- case InlineAsm::Constraint_X :
484
+ case ConstraintCode::X :
485
485
return " X" ;
486
- case InlineAsm::Constraint_Z :
486
+ case ConstraintCode::Z :
487
487
return " Z" ;
488
- case InlineAsm::Constraint_ZB :
488
+ case ConstraintCode::ZB :
489
489
return " ZB" ;
490
- case InlineAsm::Constraint_ZC :
490
+ case ConstraintCode::ZC :
491
491
return " ZC" ;
492
- case InlineAsm::Constraint_Zy :
492
+ case ConstraintCode::Zy :
493
493
return " Zy" ;
494
- case InlineAsm::Constraint_p :
494
+ case ConstraintCode::p :
495
495
return " p" ;
496
- case InlineAsm::Constraint_ZQ :
496
+ case ConstraintCode::ZQ :
497
497
return " ZQ" ;
498
- case InlineAsm::Constraint_ZR :
498
+ case ConstraintCode::ZR :
499
499
return " ZR" ;
500
- case InlineAsm::Constraint_ZS :
500
+ case ConstraintCode::ZS :
501
501
return " ZS" ;
502
- case InlineAsm::Constraint_ZT :
502
+ case ConstraintCode::ZT :
503
503
return " ZT" ;
504
504
default :
505
505
llvm_unreachable (" Unknown memory constraint" );
0 commit comments