Skip to content

Commit 940d56c

Browse files
committed
Merging r324645:
------------------------------------------------------------------------ r324645 | dwmw2 | 2018-02-08 12:06:05 -0800 (Thu, 08 Feb 2018) | 5 lines [X86] Support 'V' register operand modifier This allows the register name to be printed without the leading '%'. This can be used for emitting calls to the retpoline thunks from inline asm. ------------------------------------------------------------------------ llvm-svn: 325089
1 parent 754e957 commit 940d56c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

llvm/lib/Target/X86/X86AsmPrinter.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ static void printIntelMemReference(X86AsmPrinter &P, const MachineInstr *MI,
344344
static bool printAsmMRegister(X86AsmPrinter &P, const MachineOperand &MO,
345345
char Mode, raw_ostream &O) {
346346
unsigned Reg = MO.getReg();
347+
bool EmitPercent = true;
348+
347349
switch (Mode) {
348350
default: return true; // Unknown mode.
349351
case 'b': // Print QImode register
@@ -358,14 +360,20 @@ static bool printAsmMRegister(X86AsmPrinter &P, const MachineOperand &MO,
358360
case 'k': // Print SImode register
359361
Reg = getX86SubSuperRegister(Reg, 32);
360362
break;
363+
case 'V':
364+
EmitPercent = false;
365+
LLVM_FALLTHROUGH;
361366
case 'q':
362367
// Print 64-bit register names if 64-bit integer registers are available.
363368
// Otherwise, print 32-bit register names.
364369
Reg = getX86SubSuperRegister(Reg, P.getSubtarget().is64Bit() ? 64 : 32);
365370
break;
366371
}
367372

368-
O << '%' << X86ATTInstPrinter::getRegisterName(Reg);
373+
if (EmitPercent)
374+
O << '%';
375+
376+
O << X86ATTInstPrinter::getRegisterName(Reg);
369377
return false;
370378
}
371379

@@ -438,6 +446,7 @@ bool X86AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
438446
case 'w': // Print HImode register
439447
case 'k': // Print SImode register
440448
case 'q': // Print DImode register
449+
case 'V': // Print native register without '%'
441450
if (MO.isReg())
442451
return printAsmMRegister(*this, MO, ExtraCode[0], O);
443452
printOperand(*this, MI, OpNo, O);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
; RUN: llc < %s -mtriple=i686-- -no-integrated-as | FileCheck -check-prefix=X86 %s
2+
; RUN: llc < %s -mtriple=x86_64-- -no-integrated-as | FileCheck -check-prefix=X64 %s
3+
4+
; If the target does not have 64-bit integer registers, emit 32-bit register
5+
; names.
6+
7+
; X86: call __x86_indirect_thunk_e{{[abcd]}}x
8+
; X64: call __x86_indirect_thunk_r
9+
10+
define void @q_modifier(i32* %p) {
11+
entry:
12+
tail call void asm sideeffect "call __x86_indirect_thunk_${0:V}", "r,~{dirflag},~{fpsr},~{flags}"(i32* %p)
13+
ret void
14+
}

0 commit comments

Comments
 (0)