From 7135686104c0414c5f2b0817ac1e7f6508ab4b97 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 2 Dec 2017 08:27:46 +0000 Subject: [PATCH] [X86] Teach the assembler to support %db8-%db15 as aliases for %dr8-%dr15. llvm-svn: 319612 --- lib/Target/X86/AsmParser/X86AsmParser.cpp | 38 +++++++++++++++-------- test/MC/X86/x86-64.s | 3 ++ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 4dc0466344b..87c65347e33 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1098,19 +1098,31 @@ bool X86AsmParser::ParseRegister(unsigned &RegNo, EndLoc = Parser.getTok().getEndLoc(); - // If this is "db[0-7]", match it as an alias - // for dr[0-7]. - if (RegNo == 0 && Tok.getString().size() == 3 && - Tok.getString().startswith("db")) { - switch (Tok.getString()[2]) { - case '0': RegNo = X86::DR0; break; - case '1': RegNo = X86::DR1; break; - case '2': RegNo = X86::DR2; break; - case '3': RegNo = X86::DR3; break; - case '4': RegNo = X86::DR4; break; - case '5': RegNo = X86::DR5; break; - case '6': RegNo = X86::DR6; break; - case '7': RegNo = X86::DR7; break; + // If this is "db[0-15]", match it as an alias + // for dr[0-15]. + if (RegNo == 0 && Tok.getString().startswith("db")) { + if (Tok.getString().size() == 3) { + switch (Tok.getString()[2]) { + case '0': RegNo = X86::DR0; break; + case '1': RegNo = X86::DR1; break; + case '2': RegNo = X86::DR2; break; + case '3': RegNo = X86::DR3; break; + case '4': RegNo = X86::DR4; break; + case '5': RegNo = X86::DR5; break; + case '6': RegNo = X86::DR6; break; + case '7': RegNo = X86::DR7; break; + case '8': RegNo = X86::DR8; break; + case '9': RegNo = X86::DR9; break; + } + } else if (Tok.getString().size() == 4 && Tok.getString()[2] == '1') { + switch (Tok.getString()[3]) { + case '0': RegNo = X86::DR10; break; + case '1': RegNo = X86::DR11; break; + case '2': RegNo = X86::DR12; break; + case '3': RegNo = X86::DR13; break; + case '4': RegNo = X86::DR14; break; + case '5': RegNo = X86::DR15; break; + } } if (RegNo != 0) { diff --git a/test/MC/X86/x86-64.s b/test/MC/X86/x86-64.s index 326e58c409d..27d68f173ea 100644 --- a/test/MC/X86/x86-64.s +++ b/test/MC/X86/x86-64.s @@ -455,6 +455,9 @@ mov %rdx, %cr15 mov %rdx, %dr15 // CHECK: movq %rdx, %dr15 // CHECK: encoding: [0x44,0x0f,0x23,0xfa] +mov %rdx, %db15 +// CHECK: movq %rdx, %db15 +// CHECK: encoding: [0x44,0x0f,0x23,0xfa] // rdar://8456371 - Handle commutable instructions written backward. // CHECK: faddp %st(1)