@@ -337,14 +337,22 @@ void X86AsmPrinter::PrintMemReference(const MachineInstr *MI, unsigned OpNo,
337
337
PrintLeaMemReference (MI, OpNo, O, Modifier);
338
338
}
339
339
340
+
340
341
void X86AsmPrinter::PrintIntelMemReference (const MachineInstr *MI,
341
- unsigned OpNo, raw_ostream &O) {
342
+ unsigned OpNo, raw_ostream &O,
343
+ const char *Modifier) {
342
344
const MachineOperand &BaseReg = MI->getOperand (OpNo + X86::AddrBaseReg);
343
345
unsigned ScaleVal = MI->getOperand (OpNo + X86::AddrScaleAmt).getImm ();
344
346
const MachineOperand &IndexReg = MI->getOperand (OpNo + X86::AddrIndexReg);
345
347
const MachineOperand &DispSpec = MI->getOperand (OpNo + X86::AddrDisp);
346
348
const MachineOperand &SegReg = MI->getOperand (OpNo + X86::AddrSegmentReg);
347
349
350
+ // If we really don't want to print out (rip), don't.
351
+ bool HasBaseReg = BaseReg.getReg () != 0 ;
352
+ if (HasBaseReg && Modifier && !strcmp (Modifier, " no-rip" ) &&
353
+ BaseReg.getReg () == X86::RIP)
354
+ HasBaseReg = false ;
355
+
348
356
// If this has a segment register, print it.
349
357
if (SegReg.getReg ()) {
350
358
PrintOperand (MI, OpNo + X86::AddrSegmentReg, O);
@@ -354,7 +362,7 @@ void X86AsmPrinter::PrintIntelMemReference(const MachineInstr *MI,
354
362
O << ' [' ;
355
363
356
364
bool NeedPlus = false ;
357
- if (BaseReg. getReg () ) {
365
+ if (HasBaseReg ) {
358
366
PrintOperand (MI, OpNo + X86::AddrBaseReg, O);
359
367
NeedPlus = true ;
360
368
}
@@ -372,7 +380,7 @@ void X86AsmPrinter::PrintIntelMemReference(const MachineInstr *MI,
372
380
PrintOperand (MI, OpNo + X86::AddrDisp, O);
373
381
} else {
374
382
int64_t DispVal = DispSpec.getImm ();
375
- if (DispVal || (!IndexReg.getReg () && !BaseReg. getReg () )) {
383
+ if (DispVal || (!IndexReg.getReg () && !HasBaseReg )) {
376
384
if (NeedPlus) {
377
385
if (DispVal > 0 )
378
386
O << " + " ;
@@ -525,11 +533,6 @@ bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
525
533
bool X86AsmPrinter::PrintAsmMemoryOperand (const MachineInstr *MI, unsigned OpNo,
526
534
const char *ExtraCode,
527
535
raw_ostream &O) {
528
- if (MI->getInlineAsmDialect () == InlineAsm::AD_Intel) {
529
- PrintIntelMemReference (MI, OpNo, O);
530
- return false ;
531
- }
532
-
533
536
if (ExtraCode && ExtraCode[0 ]) {
534
537
if (ExtraCode[1 ] != 0 ) return true ; // Unknown modifier.
535
538
@@ -543,14 +546,26 @@ bool X86AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
543
546
// These only apply to registers, ignore on mem.
544
547
break ;
545
548
case ' H' :
546
- PrintMemReference (MI, OpNo, O, " H" );
549
+ if (MI->getInlineAsmDialect () == InlineAsm::AD_Intel) {
550
+ return true ; // Unsupported modifier in Intel inline assembly.
551
+ } else {
552
+ PrintMemReference (MI, OpNo, O, " H" );
553
+ }
547
554
return false ;
548
555
case ' P' : // Don't print @PLT, but do print as memory.
549
- PrintMemReference (MI, OpNo, O, " no-rip" );
556
+ if (MI->getInlineAsmDialect () == InlineAsm::AD_Intel) {
557
+ PrintIntelMemReference (MI, OpNo, O, " no-rip" );
558
+ } else {
559
+ PrintMemReference (MI, OpNo, O, " no-rip" );
560
+ }
550
561
return false ;
551
562
}
552
563
}
553
- PrintMemReference (MI, OpNo, O, nullptr );
564
+ if (MI->getInlineAsmDialect () == InlineAsm::AD_Intel) {
565
+ PrintIntelMemReference (MI, OpNo, O, nullptr );
566
+ } else {
567
+ PrintMemReference (MI, OpNo, O, nullptr );
568
+ }
554
569
return false ;
555
570
}
556
571
0 commit comments