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