From 6b40b0def1304f9f17db3d3fcbd490bc9b2ef4e2 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 15 Sep 2010 04:37:18 +0000 Subject: [PATCH] implement aliases for shld/shrd, part of rdar://8418316 llvm-svn: 113937 --- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 9 +++++++++ llvm/test/MC/AsmParser/X86/x86_instructions.s | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index 4856cc9283c9..7afa7e66d5e1 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -833,6 +833,15 @@ ParseInstruction(StringRef Name, SMLoc NameLoc, Operands.push_back(X86Operand::CreateImm(One, NameLoc, NameLoc)); std::swap(Operands[1], Operands[2]); } + + // FIXME: Hack to handle recognize "sh[lr]d op,op" -> "shld $1, op,op". + if ((Name.startswith("shld") || Name.startswith("shrd")) && + Operands.size() == 3) { + const MCExpr *One = MCConstantExpr::Create(1, getParser().getContext()); + Operands.insert(Operands.begin()+1, + X86Operand::CreateImm(One, NameLoc, NameLoc)); + } + // FIXME: Hack to handle recognize "in[bwl] ". Canonicalize it to // "inb , %al". diff --git a/llvm/test/MC/AsmParser/X86/x86_instructions.s b/llvm/test/MC/AsmParser/X86/x86_instructions.s index 3bd2a3050445..0f0c1ed76a32 100644 --- a/llvm/test/MC/AsmParser/X86/x86_instructions.s +++ b/llvm/test/MC/AsmParser/X86/x86_instructions.s @@ -268,3 +268,14 @@ rcl %bl rcll 0xdeadbeef(%ebx,%ecx,8) rcr %ecx rcrl 0x12345678 + +// rdar://8418316 +// CHECK: shldw $1, %bx, %bx +// CHECK: shldw $1, %bx, %bx +// CHECK: shrdw $1, %bx, %bx +// CHECK: shrdw $1, %bx, %bx + +shld %bx,%bx +shld $1, %bx,%bx +shrd %bx,%bx +shrd $1, %bx,%bx