From 99f535242c71d795c11bf54aa6d30ddbed465e9a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 1 Nov 2010 21:06:34 +0000 Subject: [PATCH] use our fancy new MnemonicAlias mechanism to remove a bunch of hacks from X86AsmParser.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117952 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmParser/X86AsmParser.cpp | 48 ----------------------- lib/Target/X86/X86InstrInfo.td | 19 +++++++-- 2 files changed, 16 insertions(+), 51 deletions(-) diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 21faa962a91..e57e34fb457 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -969,14 +969,6 @@ ParseInstruction(StringRef Name, SMLoc NameLoc, NameLoc); } - // call foo is not ambiguous with callw. - if (Name == "call" && Operands.size() == 2) { - const char *NewName = Is64Bit ? "callq" : "calll"; - delete Operands[0]; - Operands[0] = X86Operand::CreateToken(NewName, NameLoc); - Name = NewName; - } - // movsd -> movsl (when no operands are specified). if (Name == "movsd" && Operands.size() == 1) { delete Operands[0]; @@ -1009,46 +1001,6 @@ ParseInstruction(StringRef Name, SMLoc NameLoc, Operands.push_back(X86Operand::CreateImm(A, NameLoc, NameLoc)); } - // "lgdtl" is not ambiguous 32-bit mode and is the same as "lgdt". - // "lgdtq" is not ambiguous 64-bit mode and is the same as "lgdt". - if ((Name == "lgdtl" && Is64Bit == false) || - (Name == "lgdtq" && Is64Bit == true)) { - const char *NewName = "lgdt"; - delete Operands[0]; - Operands[0] = X86Operand::CreateToken(NewName, NameLoc); - Name = NewName; - } - - // "lidtl" is not ambiguous 32-bit mode and is the same as "lidt". - // "lidtq" is not ambiguous 64-bit mode and is the same as "lidt". - if ((Name == "lidtl" && Is64Bit == false) || - (Name == "lidtq" && Is64Bit == true)) { - const char *NewName = "lidt"; - delete Operands[0]; - Operands[0] = X86Operand::CreateToken(NewName, NameLoc); - Name = NewName; - } - - // "sgdtl" is not ambiguous 32-bit mode and is the same as "sgdt". - // "sgdtq" is not ambiguous 64-bit mode and is the same as "sgdt". - if ((Name == "sgdtl" && Is64Bit == false) || - (Name == "sgdtq" && Is64Bit == true)) { - const char *NewName = "sgdt"; - delete Operands[0]; - Operands[0] = X86Operand::CreateToken(NewName, NameLoc); - Name = NewName; - } - - // "sidtl" is not ambiguous 32-bit mode and is the same as "sidt". - // "sidtq" is not ambiguous 64-bit mode and is the same as "sidt". - if ((Name == "sidtl" && Is64Bit == false) || - (Name == "sidtq" && Is64Bit == true)) { - const char *NewName = "sidt"; - delete Operands[0]; - Operands[0] = X86Operand::CreateToken(NewName, NameLoc); - Name = NewName; - } - return false; } diff --git a/lib/Target/X86/X86InstrInfo.td b/lib/Target/X86/X86InstrInfo.td index 114f3d380cc..2eaf328ffe7 100644 --- a/lib/Target/X86/X86InstrInfo.td +++ b/lib/Target/X86/X86InstrInfo.td @@ -1306,10 +1306,10 @@ def : InstAlias<(outs GR64:$dst), (ins GR16:$src), (MOVZX64rr16_Q GR64:$dst, GR16:$src)>; // Note: No GR32->GR64 movzx form. -// TODO: lidtl/lidtq can be opcode aliases, perhaps others. -def : MnemonicAlias<"iret", "iretl">; -def : MnemonicAlias<"sysret", "sysretl">; +def : MnemonicAlias<"call", "calll">, Requires<[In32BitMode]>; +def : MnemonicAlias<"call", "callq">, Requires<[In64BitMode]>; + def : MnemonicAlias<"cbw", "cbtw">; def : MnemonicAlias<"cwd", "cwtd">; def : MnemonicAlias<"cdq", "cltd">; @@ -1351,6 +1351,19 @@ def : MnemonicAlias<"smovq", "movsq">; def : MnemonicAlias<"ud2a", "ud2">; def : MnemonicAlias<"verrw", "verr">; +// System instruction aliases. +def : MnemonicAlias<"iret", "iretl">; +def : MnemonicAlias<"sysret", "sysretl">; + +def : MnemonicAlias<"lgdtl", "lgdt">, Requires<[In32BitMode]>; +def : MnemonicAlias<"lgdtq", "lgdt">, Requires<[In64BitMode]>; +def : MnemonicAlias<"lidtl", "lidt">, Requires<[In32BitMode]>; +def : MnemonicAlias<"lidtq", "lidt">, Requires<[In64BitMode]>; +def : MnemonicAlias<"sgdtl", "sgdt">, Requires<[In32BitMode]>; +def : MnemonicAlias<"sgdtq", "sgdt">, Requires<[In64BitMode]>; +def : MnemonicAlias<"sidtl", "sidt">, Requires<[In32BitMode]>; +def : MnemonicAlias<"sidtq", "sidt">, Requires<[In64BitMode]>; + // Floating point stack aliases. def : MnemonicAlias<"fcmovz", "fcmove">;