@@ -2784,6 +2784,7 @@ bool X86AsmParser::MatchAndEmitIntelInstruction(SMLoc IDLoc, unsigned &Opcode,
2784
2784
assert (Op.isToken () && " Leading operand should always be a mnemonic!" );
2785
2785
StringRef Mnemonic = Op.getToken ();
2786
2786
SMRange EmptyRange = None;
2787
+ StringRef Base = Op.getToken ();
2787
2788
2788
2789
// First, handle aliases that expand to multiple instructions.
2789
2790
MatchFPUWaitAlias (IDLoc, Op, Operands, Out, MatchingInlineAsm);
@@ -2810,11 +2811,37 @@ bool X86AsmParser::MatchAndEmitIntelInstruction(SMLoc IDLoc, unsigned &Opcode,
2810
2811
}
2811
2812
}
2812
2813
2814
+ SmallVector<unsigned , 8 > Match;
2815
+ uint64_t ErrorInfoMissingFeature = 0 ;
2816
+
2817
+ // If unsized push has immediate operand we should default the default pointer
2818
+ // size for the size.
2819
+ if (Mnemonic == " push" && Operands.size () == 2 ) {
2820
+ auto *X86Op = static_cast <X86Operand *>(Operands[1 ].get ());
2821
+ if (X86Op->isImm ()) {
2822
+ // If it's not a constant fall through and let remainder take care of it.
2823
+ const auto *CE = dyn_cast<MCConstantExpr>(X86Op->getImm ());
2824
+ unsigned Size = getPointerWidth ();
2825
+ if (CE &&
2826
+ (isIntN (Size , CE->getValue ()) || isUIntN (Size , CE->getValue ()))) {
2827
+ SmallString<16 > Tmp;
2828
+ Tmp += Base;
2829
+ Tmp += (is64BitMode ())
2830
+ ? " q"
2831
+ : (is32BitMode ()) ? " l" : (is16BitMode ()) ? " w" : " " ;
2832
+ Op.setTokenValue (Tmp);
2833
+ // Do match in ATT mode to allow explicit suffix usage.
2834
+ Match.push_back (MatchInstruction (Operands, Inst, ErrorInfo,
2835
+ MatchingInlineAsm,
2836
+ false /* isParsingIntelSyntax()*/ ));
2837
+ Op.setTokenValue (Base);
2838
+ }
2839
+ }
2840
+ }
2841
+
2813
2842
// If an unsized memory operand is present, try to match with each memory
2814
2843
// operand size. In Intel assembly, the size is not part of the instruction
2815
2844
// mnemonic.
2816
- SmallVector<unsigned , 8 > Match;
2817
- uint64_t ErrorInfoMissingFeature = 0 ;
2818
2845
if (UnsizedMemOp && UnsizedMemOp->isMemUnsized ()) {
2819
2846
static const unsigned MopSizes[] = {8 , 16 , 32 , 64 , 80 , 128 , 256 , 512 };
2820
2847
for (unsigned Size : MopSizes) {
0 commit comments