diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 37ffeb806a5..6d4849bc7c9 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -771,7 +771,9 @@ ParseInstruction(StringRef Name, SMLoc NameLoc, // FIXME: Hack to handle recognize s{hr,ar,hl} $1, . Canonicalize to // "shift ". if ((Name.startswith("shr") || Name.startswith("sar") || - Name.startswith("shl") || Name.startswith("sal")) && + Name.startswith("shl") || Name.startswith("sal") || + Name.startswith("rcl") || Name.startswith("rcr") || + Name.startswith("rol") || Name.startswith("ror")) && Operands.size() == 3) { X86Operand *Op1 = static_cast(Operands[1]); if (Op1->isImm() && isa(Op1->getImm()) && @@ -781,14 +783,6 @@ ParseInstruction(StringRef Name, SMLoc NameLoc, } } - // FIXME: Hack to handle recognize "rc[lr] " -> "rcl $1, ". - if ((Name.startswith("rcl") || Name.startswith("rcr")) && - Operands.size() == 2) { - const MCExpr *One = MCConstantExpr::Create(1, getParser().getContext()); - 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) { diff --git a/lib/Target/X86/X86InstrInfo.td b/lib/Target/X86/X86InstrInfo.td index fc6d4aa24ee..8ae51b29286 100644 --- a/lib/Target/X86/X86InstrInfo.td +++ b/lib/Target/X86/X86InstrInfo.td @@ -1504,6 +1504,33 @@ def : InstAlias<"outl $port", (OUT32ir i8imm:$port)>; // errors, since its encoding is the most compact. def : InstAlias<"sldt $mem", (SLDT16m i16mem:$mem)>; +// "rc[lr] X" is an alias for "rcl X, 1" +/* +multiclass RotateAlias { + def : InstAlias(!strconcat(Opc, "8r1")) GR8:$op)>; + def : InstAlias(!strconcat(Opc, "16r1")) GR16:$op)>; + def : InstAlias(!strconcat(Opc, "32r1")) GR32:$op)>; + def : InstAlias(!strconcat(Opc, "64r1")) GR64:$op)>; + def : InstAlias(!strconcat(Opc, "8m1")) i8mem:$op)>; + def : InstAlias(!strconcat(Opc, "16m1")) i16mem:$op)>; + def : InstAlias(!strconcat(Opc, "32m1")) i32mem:$op)>; + def : InstAlias(!strconcat(Opc, "64m1")) i64mem:$op)>; +} + +defm : RotateAlias<"rcl", "RCL">; +defm : RotateAlias<"rcr", "RCR">; +defm : RotateAlias<"rol", "ROL">; +defm : RotateAlias<"ror", "ROR">; +*/ + // test: We accept "testX , " and "testX , " as synonyms. def : InstAlias<"testb $val, $mem", (TEST8rm GR8 :$val, i8mem :$mem)>; diff --git a/lib/Target/X86/X86InstrShiftRotate.td b/lib/Target/X86/X86InstrShiftRotate.td index e7643bec07c..8278568184f 100644 --- a/lib/Target/X86/X86InstrShiftRotate.td +++ b/lib/Target/X86/X86InstrShiftRotate.td @@ -290,7 +290,7 @@ def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst), let Constraints = "$src1 = $dst" in { def RCL8r1 : I<0xD0, MRM2r, (outs GR8:$dst), (ins GR8:$src1), - "rcl{b}\t{1, $dst|$dst, 1}", []>; + "rcl{b}\t$dst", []>; def RCL8ri : Ii8<0xC0, MRM2r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt), "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>; let Uses = [CL] in @@ -298,7 +298,7 @@ def RCL8rCL : I<0xD2, MRM2r, (outs GR8:$dst), (ins GR8:$src1), "rcl{b}\t{%cl, $dst|$dst, CL}", []>; def RCL16r1 : I<0xD1, MRM2r, (outs GR16:$dst), (ins GR16:$src1), - "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize; + "rcl{w}\t$dst", []>, OpSize; def RCL16ri : Ii8<0xC1, MRM2r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt), "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize; let Uses = [CL] in @@ -306,7 +306,7 @@ def RCL16rCL : I<0xD3, MRM2r, (outs GR16:$dst), (ins GR16:$src1), "rcl{w}\t{%cl, $dst|$dst, CL}", []>, OpSize; def RCL32r1 : I<0xD1, MRM2r, (outs GR32:$dst), (ins GR32:$src1), - "rcl{l}\t{1, $dst|$dst, 1}", []>; + "rcl{l}\t$dst", []>; def RCL32ri : Ii8<0xC1, MRM2r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt), "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>; let Uses = [CL] in @@ -315,7 +315,7 @@ def RCL32rCL : I<0xD3, MRM2r, (outs GR32:$dst), (ins GR32:$src1), def RCL64r1 : RI<0xD1, MRM2r, (outs GR64:$dst), (ins GR64:$src1), - "rcl{q}\t{1, $dst|$dst, 1}", []>; + "rcl{q}\t$dst", []>; def RCL64ri : RIi8<0xC1, MRM2r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$cnt), "rcl{q}\t{$cnt, $dst|$dst, $cnt}", []>; let Uses = [CL] in @@ -324,7 +324,7 @@ def RCL64rCL : RI<0xD3, MRM2r, (outs GR64:$dst), (ins GR64:$src1), def RCR8r1 : I<0xD0, MRM3r, (outs GR8:$dst), (ins GR8:$src1), - "rcr{b}\t{1, $dst|$dst, 1}", []>; + "rcr{b}\t$dst", []>; def RCR8ri : Ii8<0xC0, MRM3r, (outs GR8:$dst), (ins GR8:$src1, i8imm:$cnt), "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>; let Uses = [CL] in @@ -332,7 +332,7 @@ def RCR8rCL : I<0xD2, MRM3r, (outs GR8:$dst), (ins GR8:$src1), "rcr{b}\t{%cl, $dst|$dst, CL}", []>; def RCR16r1 : I<0xD1, MRM3r, (outs GR16:$dst), (ins GR16:$src1), - "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize; + "rcr{w}\t$dst", []>, OpSize; def RCR16ri : Ii8<0xC1, MRM3r, (outs GR16:$dst), (ins GR16:$src1, i8imm:$cnt), "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize; let Uses = [CL] in @@ -340,7 +340,7 @@ def RCR16rCL : I<0xD3, MRM3r, (outs GR16:$dst), (ins GR16:$src1), "rcr{w}\t{%cl, $dst|$dst, CL}", []>, OpSize; def RCR32r1 : I<0xD1, MRM3r, (outs GR32:$dst), (ins GR32:$src1), - "rcr{l}\t{1, $dst|$dst, 1}", []>; + "rcr{l}\t$dst", []>; def RCR32ri : Ii8<0xC1, MRM3r, (outs GR32:$dst), (ins GR32:$src1, i8imm:$cnt), "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>; let Uses = [CL] in @@ -348,7 +348,7 @@ def RCR32rCL : I<0xD3, MRM3r, (outs GR32:$dst), (ins GR32:$src1), "rcr{l}\t{%cl, $dst|$dst, CL}", []>; def RCR64r1 : RI<0xD1, MRM3r, (outs GR64:$dst), (ins GR64:$src1), - "rcr{q}\t{1, $dst|$dst, 1}", []>; + "rcr{q}\t$dst", []>; def RCR64ri : RIi8<0xC1, MRM3r, (outs GR64:$dst), (ins GR64:$src1, i8imm:$cnt), "rcr{q}\t{$cnt, $dst|$dst, $cnt}", []>; let Uses = [CL] in @@ -358,36 +358,36 @@ def RCR64rCL : RI<0xD3, MRM3r, (outs GR64:$dst), (ins GR64:$src1), } // Constraints = "$src = $dst" def RCL8m1 : I<0xD0, MRM2m, (outs), (ins i8mem:$dst), - "rcl{b}\t{1, $dst|$dst, 1}", []>; + "rcl{b}\t$dst", []>; def RCL8mi : Ii8<0xC0, MRM2m, (outs), (ins i8mem:$dst, i8imm:$cnt), "rcl{b}\t{$cnt, $dst|$dst, $cnt}", []>; def RCL16m1 : I<0xD1, MRM2m, (outs), (ins i16mem:$dst), - "rcl{w}\t{1, $dst|$dst, 1}", []>, OpSize; + "rcl{w}\t$dst", []>, OpSize; def RCL16mi : Ii8<0xC1, MRM2m, (outs), (ins i16mem:$dst, i8imm:$cnt), "rcl{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize; def RCL32m1 : I<0xD1, MRM2m, (outs), (ins i32mem:$dst), - "rcl{l}\t{1, $dst|$dst, 1}", []>; + "rcl{l}\t$dst", []>; def RCL32mi : Ii8<0xC1, MRM2m, (outs), (ins i32mem:$dst, i8imm:$cnt), "rcl{l}\t{$cnt, $dst|$dst, $cnt}", []>; def RCL64m1 : RI<0xD1, MRM2m, (outs), (ins i64mem:$dst), - "rcl{q}\t{1, $dst|$dst, 1}", []>; + "rcl{q}\t$dst", []>; def RCL64mi : RIi8<0xC1, MRM2m, (outs), (ins i64mem:$dst, i8imm:$cnt), "rcl{q}\t{$cnt, $dst|$dst, $cnt}", []>; def RCR8m1 : I<0xD0, MRM3m, (outs), (ins i8mem:$dst), - "rcr{b}\t{1, $dst|$dst, 1}", []>; + "rcr{b}\t$dst", []>; def RCR8mi : Ii8<0xC0, MRM3m, (outs), (ins i8mem:$dst, i8imm:$cnt), "rcr{b}\t{$cnt, $dst|$dst, $cnt}", []>; def RCR16m1 : I<0xD1, MRM3m, (outs), (ins i16mem:$dst), - "rcr{w}\t{1, $dst|$dst, 1}", []>, OpSize; + "rcr{w}\t$dst", []>, OpSize; def RCR16mi : Ii8<0xC1, MRM3m, (outs), (ins i16mem:$dst, i8imm:$cnt), "rcr{w}\t{$cnt, $dst|$dst, $cnt}", []>, OpSize; def RCR32m1 : I<0xD1, MRM3m, (outs), (ins i32mem:$dst), - "rcr{l}\t{1, $dst|$dst, 1}", []>; + "rcr{l}\t$dst", []>; def RCR32mi : Ii8<0xC1, MRM3m, (outs), (ins i32mem:$dst, i8imm:$cnt), "rcr{l}\t{$cnt, $dst|$dst, $cnt}", []>; def RCR64m1 : RI<0xD1, MRM3m, (outs), (ins i64mem:$dst), - "rcr{q}\t{1, $dst|$dst, 1}", []>; + "rcr{q}\t$dst", []>; def RCR64mi : RIi8<0xC1, MRM3m, (outs), (ins i64mem:$dst, i8imm:$cnt), "rcr{q}\t{$cnt, $dst|$dst, $cnt}", []>; diff --git a/test/MC/X86/x86-64.s b/test/MC/X86/x86-64.s index 87b38cf7174..3df90217d8d 100644 --- a/test/MC/X86/x86-64.s +++ b/test/MC/X86/x86-64.s @@ -284,16 +284,19 @@ fnstsw %eax fnstsw %al // rdar://8431880 -// CHECK: rclb $1, %bl -// CHECK: rcll $1, 3735928559(%ebx,%ecx,8) -// CHECK: rcrl $1, %ecx -// CHECK: rcrl $1, 305419896 - +// CHECK: rclb %bl +// CHECK: rcll 3735928559(%ebx,%ecx,8) +// CHECK: rcrl %ecx +// CHECK: rcrl 305419896 rcl %bl rcll 0xdeadbeef(%ebx,%ecx,8) rcr %ecx rcrl 0x12345678 +rclb %bl // CHECK: rclb %bl # encoding: [0xd0,0xd3] +rclb $1, %bl // CHECK: rclb %bl # encoding: [0xd0,0xd3] +rclb $2, %bl // CHECK: rclb $2, %bl # encoding: [0xc0,0xd3,0x02] + // rdar://8418316 // CHECK: shldw $1, %bx, %bx // CHECK: shldw $1, %bx, %bx