@@ -90,6 +90,8 @@ class X86AsmParser : public MCTargetAsmParser {
9090
9191 enum OpcodePrefix {
9292 OpcodePrefix_Default,
93+ OpcodePrefix_REX,
94+ OpcodePrefix_REX2,
9395 OpcodePrefix_VEX,
9496 OpcodePrefix_VEX2,
9597 OpcodePrefix_VEX3,
@@ -3201,7 +3203,11 @@ bool X86AsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name,
32013203 return Error (Parser.getTok ().getLoc (), " Expected '}'" );
32023204 Parser.Lex (); // Eat curly.
32033205
3204- if (Prefix == " vex" )
3206+ if (Prefix == " rex" )
3207+ ForcedOpcodePrefix = OpcodePrefix_REX;
3208+ else if (Prefix == " rex2" )
3209+ ForcedOpcodePrefix = OpcodePrefix_REX2;
3210+ else if (Prefix == " vex" )
32053211 ForcedOpcodePrefix = OpcodePrefix_VEX;
32063212 else if (Prefix == " vex2" )
32073213 ForcedOpcodePrefix = OpcodePrefix_VEX2;
@@ -4025,9 +4031,13 @@ bool X86AsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
40254031
40264032 MCInst Inst;
40274033
4028- // If VEX/EVEX encoding is forced, we need to pass the USE_* flag to the
4029- // encoder and printer.
4030- if (ForcedOpcodePrefix == OpcodePrefix_VEX)
4034+ // If REX/REX2/VEX/EVEX encoding is forced, we need to pass the USE_* flag to
4035+ // the encoder and printer.
4036+ if (ForcedOpcodePrefix == OpcodePrefix_REX)
4037+ Prefixes |= X86::IP_USE_REX;
4038+ else if (ForcedOpcodePrefix == OpcodePrefix_REX2)
4039+ Prefixes |= X86::IP_USE_REX2;
4040+ else if (ForcedOpcodePrefix == OpcodePrefix_VEX)
40314041 Prefixes |= X86::IP_USE_VEX;
40324042 else if (ForcedOpcodePrefix == OpcodePrefix_VEX2)
40334043 Prefixes |= X86::IP_USE_VEX2;
@@ -4095,24 +4105,34 @@ bool X86AsmParser::ErrorMissingFeature(SMLoc IDLoc,
40954105unsigned X86AsmParser::checkTargetMatchPredicate (MCInst &Inst) {
40964106 unsigned Opc = Inst.getOpcode ();
40974107 const MCInstrDesc &MCID = MII.get (Opc);
4108+ uint64_t TSFlags = MCID.TSFlags ;
40984109
40994110 if (UseApxExtendedReg && !X86II::canUseApxExtendedReg (MCID))
41004111 return Match_Unsupported;
4101- if (ForcedNoFlag == !(MCID. TSFlags & X86II::EVEX_NF) && !X86::isCFCMOVCC (Opc))
4112+ if (ForcedNoFlag == !(TSFlags & X86II::EVEX_NF) && !X86::isCFCMOVCC (Opc))
41024113 return Match_Unsupported;
41034114
4104- if (ForcedOpcodePrefix == OpcodePrefix_EVEX &&
4105- (MCID.TSFlags & X86II::EncodingMask) != X86II::EVEX)
4106- return Match_Unsupported;
4107-
4108- if ((ForcedOpcodePrefix == OpcodePrefix_VEX ||
4109- ForcedOpcodePrefix == OpcodePrefix_VEX2 ||
4110- ForcedOpcodePrefix == OpcodePrefix_VEX3) &&
4111- (MCID.TSFlags & X86II::EncodingMask) != X86II::VEX)
4112- return Match_Unsupported;
4115+ switch (ForcedOpcodePrefix) {
4116+ case OpcodePrefix_Default:
4117+ break ;
4118+ case OpcodePrefix_REX:
4119+ case OpcodePrefix_REX2:
4120+ if (TSFlags & X86II::EncodingMask)
4121+ return Match_Unsupported;
4122+ break ;
4123+ case OpcodePrefix_VEX:
4124+ case OpcodePrefix_VEX2:
4125+ case OpcodePrefix_VEX3:
4126+ if ((TSFlags & X86II::EncodingMask) != X86II::VEX)
4127+ return Match_Unsupported;
4128+ break ;
4129+ case OpcodePrefix_EVEX:
4130+ if ((TSFlags & X86II::EncodingMask) != X86II::EVEX)
4131+ return Match_Unsupported;
4132+ break ;
4133+ }
41134134
4114- if ((MCID.TSFlags & X86II::ExplicitOpPrefixMask) ==
4115- X86II::ExplicitVEXPrefix &&
4135+ if ((TSFlags & X86II::ExplicitOpPrefixMask) == X86II::ExplicitVEXPrefix &&
41164136 (ForcedOpcodePrefix != OpcodePrefix_VEX &&
41174137 ForcedOpcodePrefix != OpcodePrefix_VEX2 &&
41184138 ForcedOpcodePrefix != OpcodePrefix_VEX3))
0 commit comments