@@ -71,11 +71,11 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t Address,
71
71
" reference expression if it is an expression at all." );
72
72
73
73
O << " \t addis " ;
74
- printOperand (MI, 0 , O);
74
+ printOperand (MI, 0 , STI, O);
75
75
O << " , " ;
76
- printOperand (MI, 2 , O);
76
+ printOperand (MI, 2 , STI, O);
77
77
O << " (" ;
78
- printOperand (MI, 1 , O);
78
+ printOperand (MI, 1 , STI, O);
79
79
O << " )" ;
80
80
return ;
81
81
}
@@ -94,7 +94,7 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t Address,
94
94
if (SymExpr && SymExpr->getKind () == MCSymbolRefExpr::VK_PPC_PCREL_OPT) {
95
95
const MCSymbol &Symbol = SymExpr->getSymbol ();
96
96
if (MI->getOpcode () == PPC::PLDpc) {
97
- printInstruction (MI, Address, O);
97
+ printInstruction (MI, Address, STI, O);
98
98
O << " \n " ;
99
99
Symbol.print (O, &MAI);
100
100
O << " :" ;
@@ -124,9 +124,9 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t Address,
124
124
SH = 32 -SH;
125
125
}
126
126
if (useSubstituteMnemonic) {
127
- printOperand (MI, 0 , O);
127
+ printOperand (MI, 0 , STI, O);
128
128
O << " , " ;
129
- printOperand (MI, 1 , O);
129
+ printOperand (MI, 1 , STI, O);
130
130
O << " , " << (unsigned int )SH;
131
131
132
132
printAnnotation (O, Annot);
@@ -141,9 +141,9 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t Address,
141
141
// rldicr RA, RS, SH, 63-SH == sldi RA, RS, SH
142
142
if (63 -SH == ME) {
143
143
O << " \t sldi " ;
144
- printOperand (MI, 0 , O);
144
+ printOperand (MI, 0 , STI, O);
145
145
O << " , " ;
146
- printOperand (MI, 1 , O);
146
+ printOperand (MI, 1 , STI, O);
147
147
O << " , " << (unsigned int )SH;
148
148
printAnnotation (O, Annot);
149
149
return ;
@@ -171,9 +171,9 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t Address,
171
171
if (IsBookE && TH != 0 && TH != 16 )
172
172
O << (unsigned int ) TH << " , " ;
173
173
174
- printOperand (MI, 1 , O);
174
+ printOperand (MI, 1 , STI, O);
175
175
O << " , " ;
176
- printOperand (MI, 2 , O);
176
+ printOperand (MI, 2 , STI, O);
177
177
178
178
if (!IsBookE && TH != 0 && TH != 16 )
179
179
O << " , " << (unsigned int ) TH;
@@ -198,21 +198,22 @@ void PPCInstPrinter::printInst(const MCInst *MI, uint64_t Address,
198
198
O << " stps" ;
199
199
O << " " ;
200
200
201
- printOperand (MI, 1 , O);
201
+ printOperand (MI, 1 , STI, O);
202
202
O << " , " ;
203
- printOperand (MI, 2 , O);
203
+ printOperand (MI, 2 , STI, O);
204
204
205
205
printAnnotation (O, Annot);
206
206
return ;
207
207
}
208
208
}
209
209
210
- if (!printAliasInstr (MI, Address, O))
211
- printInstruction (MI, Address, O);
210
+ if (!printAliasInstr (MI, Address, STI, O))
211
+ printInstruction (MI, Address, STI, O);
212
212
printAnnotation (O, Annot);
213
213
}
214
214
215
215
void PPCInstPrinter::printPredicateOperand (const MCInst *MI, unsigned OpNo,
216
+ const MCSubtargetInfo &STI,
216
217
raw_ostream &O,
217
218
const char *Modifier) {
218
219
unsigned Code = MI->getOperand (OpNo).getImm ();
@@ -306,10 +307,11 @@ void PPCInstPrinter::printPredicateOperand(const MCInst *MI, unsigned OpNo,
306
307
307
308
assert (StringRef (Modifier) == " reg" &&
308
309
" Need to specify 'cc', 'pm' or 'reg' as predicate op modifier!" );
309
- printOperand (MI, OpNo+ 1 , O);
310
+ printOperand (MI, OpNo + 1 , STI , O);
310
311
}
311
312
312
313
void PPCInstPrinter::printATBitsAsHint (const MCInst *MI, unsigned OpNo,
314
+ const MCSubtargetInfo &STI,
313
315
raw_ostream &O) {
314
316
unsigned Code = MI->getOperand (OpNo).getImm ();
315
317
if (Code == 2 )
@@ -319,62 +321,71 @@ void PPCInstPrinter::printATBitsAsHint(const MCInst *MI, unsigned OpNo,
319
321
}
320
322
321
323
void PPCInstPrinter::printU1ImmOperand (const MCInst *MI, unsigned OpNo,
324
+ const MCSubtargetInfo &STI,
322
325
raw_ostream &O) {
323
326
unsigned int Value = MI->getOperand (OpNo).getImm ();
324
327
assert (Value <= 1 && " Invalid u1imm argument!" );
325
328
O << (unsigned int )Value;
326
329
}
327
330
328
331
void PPCInstPrinter::printU2ImmOperand (const MCInst *MI, unsigned OpNo,
332
+ const MCSubtargetInfo &STI,
329
333
raw_ostream &O) {
330
334
unsigned int Value = MI->getOperand (OpNo).getImm ();
331
335
assert (Value <= 3 && " Invalid u2imm argument!" );
332
336
O << (unsigned int )Value;
333
337
}
334
338
335
339
void PPCInstPrinter::printU3ImmOperand (const MCInst *MI, unsigned OpNo,
340
+ const MCSubtargetInfo &STI,
336
341
raw_ostream &O) {
337
342
unsigned int Value = MI->getOperand (OpNo).getImm ();
338
343
assert (Value <= 8 && " Invalid u3imm argument!" );
339
344
O << (unsigned int )Value;
340
345
}
341
346
342
347
void PPCInstPrinter::printU4ImmOperand (const MCInst *MI, unsigned OpNo,
348
+ const MCSubtargetInfo &STI,
343
349
raw_ostream &O) {
344
350
unsigned int Value = MI->getOperand (OpNo).getImm ();
345
351
assert (Value <= 15 && " Invalid u4imm argument!" );
346
352
O << (unsigned int )Value;
347
353
}
348
354
349
355
void PPCInstPrinter::printS5ImmOperand (const MCInst *MI, unsigned OpNo,
356
+ const MCSubtargetInfo &STI,
350
357
raw_ostream &O) {
351
358
int Value = MI->getOperand (OpNo).getImm ();
352
359
Value = SignExtend32<5 >(Value);
353
360
O << (int )Value;
354
361
}
355
362
356
363
void PPCInstPrinter::printImmZeroOperand (const MCInst *MI, unsigned OpNo,
364
+ const MCSubtargetInfo &STI,
357
365
raw_ostream &O) {
358
366
unsigned int Value = MI->getOperand (OpNo).getImm ();
359
367
assert (Value == 0 && " Operand must be zero" );
360
368
O << (unsigned int )Value;
361
369
}
362
370
363
371
void PPCInstPrinter::printU5ImmOperand (const MCInst *MI, unsigned OpNo,
372
+ const MCSubtargetInfo &STI,
364
373
raw_ostream &O) {
365
374
unsigned int Value = MI->getOperand (OpNo).getImm ();
366
375
assert (Value <= 31 && " Invalid u5imm argument!" );
367
376
O << (unsigned int )Value;
368
377
}
369
378
370
379
void PPCInstPrinter::printU6ImmOperand (const MCInst *MI, unsigned OpNo,
380
+ const MCSubtargetInfo &STI,
371
381
raw_ostream &O) {
372
382
unsigned int Value = MI->getOperand (OpNo).getImm ();
373
383
assert (Value <= 63 && " Invalid u6imm argument!" );
374
384
O << (unsigned int )Value;
375
385
}
376
386
377
387
void PPCInstPrinter::printU7ImmOperand (const MCInst *MI, unsigned OpNo,
388
+ const MCSubtargetInfo &STI,
378
389
raw_ostream &O) {
379
390
unsigned int Value = MI->getOperand (OpNo).getImm ();
380
391
assert (Value <= 127 && " Invalid u7imm argument!" );
@@ -385,56 +396,64 @@ void PPCInstPrinter::printU7ImmOperand(const MCInst *MI, unsigned OpNo,
385
396
// of XXSPLTIB which are unsigned. So we simply truncate to 8 bits and
386
397
// print as unsigned.
387
398
void PPCInstPrinter::printU8ImmOperand (const MCInst *MI, unsigned OpNo,
399
+ const MCSubtargetInfo &STI,
388
400
raw_ostream &O) {
389
401
unsigned char Value = MI->getOperand (OpNo).getImm ();
390
402
O << (unsigned int )Value;
391
403
}
392
404
393
405
void PPCInstPrinter::printU10ImmOperand (const MCInst *MI, unsigned OpNo,
406
+ const MCSubtargetInfo &STI,
394
407
raw_ostream &O) {
395
408
unsigned short Value = MI->getOperand (OpNo).getImm ();
396
409
assert (Value <= 1023 && " Invalid u10imm argument!" );
397
410
O << (unsigned short )Value;
398
411
}
399
412
400
413
void PPCInstPrinter::printU12ImmOperand (const MCInst *MI, unsigned OpNo,
414
+ const MCSubtargetInfo &STI,
401
415
raw_ostream &O) {
402
416
unsigned short Value = MI->getOperand (OpNo).getImm ();
403
417
assert (Value <= 4095 && " Invalid u12imm argument!" );
404
418
O << (unsigned short )Value;
405
419
}
406
420
407
421
void PPCInstPrinter::printS16ImmOperand (const MCInst *MI, unsigned OpNo,
422
+ const MCSubtargetInfo &STI,
408
423
raw_ostream &O) {
409
424
if (MI->getOperand (OpNo).isImm ())
410
425
O << (short )MI->getOperand (OpNo).getImm ();
411
426
else
412
- printOperand (MI, OpNo, O);
427
+ printOperand (MI, OpNo, STI, O);
413
428
}
414
429
415
430
void PPCInstPrinter::printS34ImmOperand (const MCInst *MI, unsigned OpNo,
431
+ const MCSubtargetInfo &STI,
416
432
raw_ostream &O) {
417
433
if (MI->getOperand (OpNo).isImm ()) {
418
434
long long Value = MI->getOperand (OpNo).getImm ();
419
435
assert (isInt<34 >(Value) && " Invalid s34imm argument!" );
420
436
O << (long long )Value;
421
437
}
422
438
else
423
- printOperand (MI, OpNo, O);
439
+ printOperand (MI, OpNo, STI, O);
424
440
}
425
441
426
442
void PPCInstPrinter::printU16ImmOperand (const MCInst *MI, unsigned OpNo,
443
+ const MCSubtargetInfo &STI,
427
444
raw_ostream &O) {
428
445
if (MI->getOperand (OpNo).isImm ())
429
446
O << (unsigned short )MI->getOperand (OpNo).getImm ();
430
447
else
431
- printOperand (MI, OpNo, O);
448
+ printOperand (MI, OpNo, STI, O);
432
449
}
433
450
434
451
void PPCInstPrinter::printBranchOperand (const MCInst *MI, uint64_t Address,
435
- unsigned OpNo, raw_ostream &O) {
452
+ unsigned OpNo,
453
+ const MCSubtargetInfo &STI,
454
+ raw_ostream &O) {
436
455
if (!MI->getOperand (OpNo).isImm ())
437
- return printOperand (MI, OpNo, O);
456
+ return printOperand (MI, OpNo, STI, O);
438
457
int32_t Imm = SignExtend32<32 >((unsigned )MI->getOperand (OpNo).getImm () << 2 );
439
458
if (PrintBranchImmAsAddress) {
440
459
uint64_t Target = Address + Imm;
@@ -457,16 +476,16 @@ void PPCInstPrinter::printBranchOperand(const MCInst *MI, uint64_t Address,
457
476
}
458
477
459
478
void PPCInstPrinter::printAbsBranchOperand (const MCInst *MI, unsigned OpNo,
479
+ const MCSubtargetInfo &STI,
460
480
raw_ostream &O) {
461
481
if (!MI->getOperand (OpNo).isImm ())
462
- return printOperand (MI, OpNo, O);
482
+ return printOperand (MI, OpNo, STI, O);
463
483
464
484
O << SignExtend32<32 >((unsigned )MI->getOperand (OpNo).getImm () << 2 );
465
485
}
466
486
467
-
468
487
void PPCInstPrinter::printcrbitm (const MCInst *MI, unsigned OpNo,
469
- raw_ostream &O) {
488
+ const MCSubtargetInfo &STI, raw_ostream &O) {
470
489
unsigned CCReg = MI->getOperand (OpNo).getReg ();
471
490
unsigned RegNo;
472
491
switch (CCReg) {
@@ -484,47 +503,51 @@ void PPCInstPrinter::printcrbitm(const MCInst *MI, unsigned OpNo,
484
503
}
485
504
486
505
void PPCInstPrinter::printMemRegImm (const MCInst *MI, unsigned OpNo,
506
+ const MCSubtargetInfo &STI,
487
507
raw_ostream &O) {
488
- printS16ImmOperand (MI, OpNo, O);
508
+ printS16ImmOperand (MI, OpNo, STI, O);
489
509
O << ' (' ;
490
510
if (MI->getOperand (OpNo+1 ).getReg () == PPC::R0)
491
511
O << " 0" ;
492
512
else
493
- printOperand (MI, OpNo+ 1 , O);
513
+ printOperand (MI, OpNo + 1 , STI , O);
494
514
O << ' )' ;
495
515
}
496
516
497
517
void PPCInstPrinter::printMemRegImm34PCRel (const MCInst *MI, unsigned OpNo,
518
+ const MCSubtargetInfo &STI,
498
519
raw_ostream &O) {
499
- printS34ImmOperand (MI, OpNo, O);
520
+ printS34ImmOperand (MI, OpNo, STI, O);
500
521
O << ' (' ;
501
- printImmZeroOperand (MI, OpNo + 1 , O);
522
+ printImmZeroOperand (MI, OpNo + 1 , STI, O);
502
523
O << ' )' ;
503
524
}
504
525
505
526
void PPCInstPrinter::printMemRegImm34 (const MCInst *MI, unsigned OpNo,
506
- raw_ostream &O) {
507
- printS34ImmOperand (MI, OpNo, O);
527
+ const MCSubtargetInfo &STI,
528
+ raw_ostream &O) {
529
+ printS34ImmOperand (MI, OpNo, STI, O);
508
530
O << ' (' ;
509
- printOperand (MI, OpNo + 1 , O);
531
+ printOperand (MI, OpNo + 1 , STI, O);
510
532
O << ' )' ;
511
533
}
512
534
513
535
void PPCInstPrinter::printMemRegReg (const MCInst *MI, unsigned OpNo,
536
+ const MCSubtargetInfo &STI,
514
537
raw_ostream &O) {
515
538
// When used as the base register, r0 reads constant zero rather than
516
539
// the value contained in the register. For this reason, the darwin
517
540
// assembler requires that we print r0 as 0 (no r) when used as the base.
518
541
if (MI->getOperand (OpNo).getReg () == PPC::R0)
519
542
O << " 0" ;
520
543
else
521
- printOperand (MI, OpNo, O);
544
+ printOperand (MI, OpNo, STI, O);
522
545
O << " , " ;
523
- printOperand (MI, OpNo+ 1 , O);
546
+ printOperand (MI, OpNo + 1 , STI , O);
524
547
}
525
548
526
549
void PPCInstPrinter::printTLSCall (const MCInst *MI, unsigned OpNo,
527
- raw_ostream &O) {
550
+ const MCSubtargetInfo &STI, raw_ostream &O) {
528
551
// On PPC64, VariantKind is VK_None, but on PPC32, it's VK_PLT, and it must
529
552
// come at the _end_ of the expression.
530
553
const MCOperand &Op = MI->getOperand (OpNo);
@@ -544,7 +567,7 @@ void PPCInstPrinter::printTLSCall(const MCInst *MI, unsigned OpNo,
544
567
if (RefExp->getKind () == MCSymbolRefExpr::VK_PPC_NOTOC)
545
568
O << ' @' << MCSymbolRefExpr::getVariantKindName (RefExp->getKind ());
546
569
O << ' (' ;
547
- printOperand (MI, OpNo+ 1 , O);
570
+ printOperand (MI, OpNo + 1 , STI , O);
548
571
O << ' )' ;
549
572
if (RefExp->getKind () != MCSymbolRefExpr::VK_None &&
550
573
RefExp->getKind () != MCSymbolRefExpr::VK_PPC_NOTOC)
@@ -602,7 +625,7 @@ bool PPCInstPrinter::showRegistersWithPrefix() const {
602
625
}
603
626
604
627
void PPCInstPrinter::printOperand (const MCInst *MI, unsigned OpNo,
605
- raw_ostream &O) {
628
+ const MCSubtargetInfo &STI, raw_ostream &O) {
606
629
const MCOperand &Op = MI->getOperand (OpNo);
607
630
if (Op.isReg ()) {
608
631
unsigned Reg = Op.getReg ();
@@ -631,4 +654,3 @@ void PPCInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
631
654
assert (Op.isExpr () && " unknown operand kind in printOperand" );
632
655
Op.getExpr ()->print (O, &MAI);
633
656
}
634
-
0 commit comments