From 4307172b8413fd40a63cd9adf54973e641a891ba Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 1 Apr 2019 19:08:15 +0000 Subject: [PATCH] [X86] Classify the AVX512 rounding control operand as X86::OPERAND_ROUNDING_CONTROL instead of MCOI::OPERAND_IMMEDIATE. Add an assert on legal values of rounding control in the encoder and remove an explicit mask. This should allow llvm-exegesis to intelligently constrain the rounding mode. The mask in the encoder shouldn't be necessary any more. We used to allow codegen to use 8-11 for rounding mode and the assembler would use 0-3 to mean the same thing so we masked here and in the printer. Codegen now matches the assembler and the printer was updated, but I forgot to update the encoder. llvm-svn: 357419 --- llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h | 5 +++++ llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp | 3 ++- llvm/lib/Target/X86/X86InstrInfo.td | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h index 5bd4709..7df5872 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h +++ b/llvm/lib/Target/X86/MCTargetDesc/X86BaseInfo.h @@ -62,6 +62,11 @@ namespace X86 { IP_HAS_LOCK = 16, IP_HAS_NOTRACK = 32 }; + + enum OperandType : unsigned { + /// AVX512 embedded rounding control. This should only have values 0-3. + OPERAND_ROUNDING_CONTROL = MCOI::OPERAND_FIRST_TARGET, + }; } // end namespace X86; /// X86II - This namespace holds all of the target specific flags that diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp index fd95387..353f52a 100644 --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp @@ -879,7 +879,8 @@ void X86MCCodeEmitter::EmitVEXOpcodePrefix(uint64_t TSFlags, unsigned &CurByte, if (HasEVEX_RC) { unsigned RcOperand = NumOps-1; assert(RcOperand >= CurOp); - EVEX_rc = MI.getOperand(RcOperand).getImm() & 0x3; + EVEX_rc = MI.getOperand(RcOperand).getImm(); + assert(EVEX_rc <= 3 && "Invalid rounding control!"); } EncodeRC = true; } diff --git a/llvm/lib/Target/X86/X86InstrInfo.td b/llvm/lib/Target/X86/X86InstrInfo.td index 67ceceb..f9e7290 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.td +++ b/llvm/lib/Target/X86/X86InstrInfo.td @@ -610,7 +610,8 @@ def AVX512RCOperand : AsmOperandClass { } def AVX512RC : Operand { let PrintMethod = "printRoundingControl"; - let OperandType = "OPERAND_IMMEDIATE"; + let OperandNamespace = "X86"; + let OperandType = "OPERAND_ROUNDING_CONTROL"; let ParserMatchClass = AVX512RCOperand; } -- 2.7.4