Skip to content

Commit 8fa3e8f

Browse files
committed
[X86] Force VIA PadLock crypto instructions to emit a 0xF3 prefix when they encode to match what GNU as does.
The spec for these says they need 0xf3 but also mentions REP before the mnemonic. But I don't think its fair to users to make them write REP first. And gas doesn't make them. objdump seems to disassemble with or without the prefix and just prints any 0xf3 as REP.
1 parent 6239d67 commit 8fa3e8f

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

llvm/lib/Target/X86/X86InstrSystem.td

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -564,25 +564,25 @@ def XRSTORS64 : RI<0xC7, MRM3m, (outs), (ins opaquemem:$dst),
564564
//===----------------------------------------------------------------------===//
565565
// VIA PadLock crypto instructions
566566
let Defs = [RAX, RDI], Uses = [RDX, RDI], SchedRW = [WriteSystem] in
567-
def XSTORE : I<0xa7, MRM_C0, (outs), (ins), "xstore", []>, TB;
567+
def XSTORE : I<0xa7, MRM_C0, (outs), (ins), "xstore", []>, TB, REP;
568568

569569
def : InstAlias<"xstorerng", (XSTORE)>;
570570

571571
let SchedRW = [WriteSystem] in {
572572
let Defs = [RSI, RDI], Uses = [RBX, RDX, RSI, RDI] in {
573-
def XCRYPTECB : I<0xa7, MRM_C8, (outs), (ins), "xcryptecb", []>, TB;
574-
def XCRYPTCBC : I<0xa7, MRM_D0, (outs), (ins), "xcryptcbc", []>, TB;
575-
def XCRYPTCTR : I<0xa7, MRM_D8, (outs), (ins), "xcryptctr", []>, TB;
576-
def XCRYPTCFB : I<0xa7, MRM_E0, (outs), (ins), "xcryptcfb", []>, TB;
577-
def XCRYPTOFB : I<0xa7, MRM_E8, (outs), (ins), "xcryptofb", []>, TB;
573+
def XCRYPTECB : I<0xa7, MRM_C8, (outs), (ins), "xcryptecb", []>, TB, REP;
574+
def XCRYPTCBC : I<0xa7, MRM_D0, (outs), (ins), "xcryptcbc", []>, TB, REP;
575+
def XCRYPTCTR : I<0xa7, MRM_D8, (outs), (ins), "xcryptctr", []>, TB, REP;
576+
def XCRYPTCFB : I<0xa7, MRM_E0, (outs), (ins), "xcryptcfb", []>, TB, REP;
577+
def XCRYPTOFB : I<0xa7, MRM_E8, (outs), (ins), "xcryptofb", []>, TB, REP;
578578
}
579579

580580
let Defs = [RAX, RSI, RDI], Uses = [RAX, RSI, RDI] in {
581-
def XSHA1 : I<0xa6, MRM_C8, (outs), (ins), "xsha1", []>, TB;
582-
def XSHA256 : I<0xa6, MRM_D0, (outs), (ins), "xsha256", []>, TB;
581+
def XSHA1 : I<0xa6, MRM_C8, (outs), (ins), "xsha1", []>, TB, REP;
582+
def XSHA256 : I<0xa6, MRM_D0, (outs), (ins), "xsha256", []>, TB, REP;
583583
}
584584
let Defs = [RAX, RDX, RSI], Uses = [RAX, RSI] in
585-
def MONTMUL : I<0xa6, MRM_C0, (outs), (ins), "montmul", []>, TB;
585+
def MONTMUL : I<0xa6, MRM_C0, (outs), (ins), "montmul", []>, TB, REP;
586586
} // SchedRW
587587

588588
//==-----------------------------------------------------------------------===//

llvm/test/MC/X86/padlock.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
xstore
44
// CHECK: xstore
5-
// CHECK: encoding: [0x0f,0xa7,0xc0]
5+
// CHECK: encoding: [0xf3,0x0f,0xa7,0xc0]

0 commit comments

Comments
 (0)