Skip to content

Commit 4f71068

Browse files
committed
[X86] Correct the asm comment for compression NF_ND -> NF
1 parent 6752f15 commit 4f71068

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,8 @@ enum : uint64_t {
818818
/// Encoding
819819
EncodingShift = SSEDomainShift + 2,
820820
EncodingMask = 0x3 << EncodingShift,
821+
/// LEGACY - encoding using REX/REX2 or w/o opcode prefix.
822+
LEGACY = 0 << EncodingShift,
821823
/// VEX - encoding using 0xC4/0xC5
822824
VEX = 1 << EncodingShift,
823825
/// XOP - Opcode prefix used by XOP instructions.

llvm/lib/Target/X86/X86CompressEVEX.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,9 +286,22 @@ static bool CompressEVEXImpl(MachineInstr &MI, const X86Subtarget &ST) {
286286

287287
const MCInstrDesc &NewDesc = ST.getInstrInfo()->get(I->NewOpc);
288288
MI.setDesc(NewDesc);
289-
uint64_t Encoding = NewDesc.TSFlags & X86II::EncodingMask;
290-
auto AsmComment =
291-
(Encoding == X86II::VEX) ? X86::AC_EVEX_2_VEX : X86::AC_EVEX_2_LEGACY;
289+
unsigned AsmComment;
290+
switch (NewDesc.TSFlags & X86II::EncodingMask) {
291+
case X86II::LEGACY:
292+
AsmComment = X86::AC_EVEX_2_LEGACY;
293+
break;
294+
case X86II::VEX:
295+
AsmComment = X86::AC_EVEX_2_VEX;
296+
break;
297+
case X86II::EVEX:
298+
AsmComment = X86::AC_EVEX_2_EVEX;
299+
assert(IsND && (NewDesc.TSFlags & X86II::EVEX_NF) &&
300+
"Unknown EVEX2EVEX compression");
301+
break;
302+
default:
303+
llvm_unreachable("Unknown EVEX compression");
304+
}
292305
MI.setAsmPrinterFlag(AsmComment);
293306
if (IsND)
294307
MI.tieOperands(0, 1);

llvm/lib/Target/X86/X86InstrInfo.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ enum AsmComments {
3232
// For instr that was compressed from EVEX to LEGACY.
3333
AC_EVEX_2_LEGACY = MachineInstr::TAsmComments,
3434
// For instr that was compressed from EVEX to VEX.
35-
AC_EVEX_2_VEX = AC_EVEX_2_LEGACY << 1
35+
AC_EVEX_2_VEX = AC_EVEX_2_LEGACY << 1,
36+
// For instr that was compressed from EVEX to EVEX.
37+
AC_EVEX_2_EVEX = AC_EVEX_2_VEX << 1
3638
};
3739

3840
/// Return a pair of condition code for the given predicate and whether

llvm/lib/Target/X86/X86MCInstLower.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,6 +2061,8 @@ void X86AsmPrinter::emitInstruction(const MachineInstr *MI) {
20612061
OutStreamer->AddComment("EVEX TO LEGACY Compression ", false);
20622062
else if (MI->getAsmPrinterFlags() & X86::AC_EVEX_2_VEX)
20632063
OutStreamer->AddComment("EVEX TO VEX Compression ", false);
2064+
else if (MI->getAsmPrinterFlags() & X86::AC_EVEX_2_EVEX)
2065+
OutStreamer->AddComment("EVEX TO EVEX Compression ", false);
20642066
}
20652067

20662068
// Add comments for values loaded from constant pool.

llvm/test/CodeGen/X86/apx/compress-evex.mir

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,13 @@ body: |
5151
renamable $rax = XOR64rr_ND killed renamable $rax, killed renamable $r16, implicit-def dead $eflags
5252
RET64 $rax
5353
...
54+
---
55+
name: ndd_2_non_ndd_egpr_nf
56+
body: |
57+
bb.0.entry:
58+
liveins: $rdi, $r16
59+
; CHECK: {nf} xorq %r16, %rax # EVEX TO EVEX Compression encoding: [0x62,0xe4,0xfc,0x0c,0x31,0xc0]
60+
renamable $rax = ADD64rr_ND killed renamable $rdi, renamable $r16, implicit-def dead $eflags
61+
renamable $rax = XOR64rr_NF_ND killed renamable $rax, killed renamable $r16
62+
RET64 $rax
63+
...

0 commit comments

Comments
 (0)