@@ -217,6 +217,48 @@ 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,
220
262
};
221
263
222
264
// Inline asm operands map to multiple SDNode / MachineInstr operands.
@@ -232,46 +274,6 @@ class InlineAsm final : public Value {
232
274
Func = 7 , // Address operand of function call
233
275
};
234
276
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
-
275
277
// These are helper methods for dealing with flags in the INLINEASM SDNode
276
278
// in the backend.
277
279
//
@@ -373,14 +375,11 @@ class InlineAsm final : public Value {
373
375
return true ;
374
376
}
375
377
376
- ConstraintCode getMemoryConstraintID () const {
378
+ // TODO: convert to enum?
379
+ unsigned getMemoryConstraintID () const {
377
380
assert ((isMemKind () || isFuncKind ()) &&
378
381
" Not expected mem or function flag!" );
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);
382
+ return getData ();
384
383
}
385
384
386
385
// / setMatchingOp - Augment an existing flag with information indicating
@@ -404,11 +403,12 @@ class InlineAsm final : public Value {
404
403
405
404
// / setMemConstraint - Augment an existing flag with the constraint code for
406
405
// / a memory constraint.
407
- void setMemConstraint (ConstraintCode C ) {
406
+ void setMemConstraint (unsigned Constraint ) {
408
407
assert ((isMemKind () || isFuncKind ()) &&
409
408
" 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 (static_cast < uint32_t >(C) );
411
+ setData (Constraint );
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 (ConstraintCode C ) {
447
- switch (C ) {
448
- case ConstraintCode::es :
446
+ static StringRef getMemConstraintName (unsigned Constraint ) {
447
+ switch (Constraint ) {
448
+ case InlineAsm::Constraint_es :
449
449
return " es" ;
450
- case ConstraintCode::i :
450
+ case InlineAsm::Constraint_i :
451
451
return " i" ;
452
- case ConstraintCode::k :
452
+ case InlineAsm::Constraint_k :
453
453
return " k" ;
454
- case ConstraintCode::m :
454
+ case InlineAsm::Constraint_m :
455
455
return " m" ;
456
- case ConstraintCode::o :
456
+ case InlineAsm::Constraint_o :
457
457
return " o" ;
458
- case ConstraintCode::v :
458
+ case InlineAsm::Constraint_v :
459
459
return " v" ;
460
- case ConstraintCode::A :
460
+ case InlineAsm::Constraint_A :
461
461
return " A" ;
462
- case ConstraintCode::Q :
462
+ case InlineAsm::Constraint_Q :
463
463
return " Q" ;
464
- case ConstraintCode::R :
464
+ case InlineAsm::Constraint_R :
465
465
return " R" ;
466
- case ConstraintCode::S :
466
+ case InlineAsm::Constraint_S :
467
467
return " S" ;
468
- case ConstraintCode::T :
468
+ case InlineAsm::Constraint_T :
469
469
return " T" ;
470
- case ConstraintCode::Um :
470
+ case InlineAsm::Constraint_Um :
471
471
return " Um" ;
472
- case ConstraintCode::Un :
472
+ case InlineAsm::Constraint_Un :
473
473
return " Un" ;
474
- case ConstraintCode::Uq :
474
+ case InlineAsm::Constraint_Uq :
475
475
return " Uq" ;
476
- case ConstraintCode::Us :
476
+ case InlineAsm::Constraint_Us :
477
477
return " Us" ;
478
- case ConstraintCode::Ut :
478
+ case InlineAsm::Constraint_Ut :
479
479
return " Ut" ;
480
- case ConstraintCode::Uv :
480
+ case InlineAsm::Constraint_Uv :
481
481
return " Uv" ;
482
- case ConstraintCode::Uy :
482
+ case InlineAsm::Constraint_Uy :
483
483
return " Uy" ;
484
- case ConstraintCode::X :
484
+ case InlineAsm::Constraint_X :
485
485
return " X" ;
486
- case ConstraintCode::Z :
486
+ case InlineAsm::Constraint_Z :
487
487
return " Z" ;
488
- case ConstraintCode::ZB :
488
+ case InlineAsm::Constraint_ZB :
489
489
return " ZB" ;
490
- case ConstraintCode::ZC :
490
+ case InlineAsm::Constraint_ZC :
491
491
return " ZC" ;
492
- case ConstraintCode::Zy :
492
+ case InlineAsm::Constraint_Zy :
493
493
return " Zy" ;
494
- case ConstraintCode::p :
494
+ case InlineAsm::Constraint_p :
495
495
return " p" ;
496
- case ConstraintCode::ZQ :
496
+ case InlineAsm::Constraint_ZQ :
497
497
return " ZQ" ;
498
- case ConstraintCode::ZR :
498
+ case InlineAsm::Constraint_ZR :
499
499
return " ZR" ;
500
- case ConstraintCode::ZS :
500
+ case InlineAsm::Constraint_ZS :
501
501
return " ZS" ;
502
- case ConstraintCode::ZT :
502
+ case InlineAsm::Constraint_ZT :
503
503
return " ZT" ;
504
504
default :
505
505
llvm_unreachable (" Unknown memory constraint" );
0 commit comments