From 7683ca04eb3cefac4d23e4fc9593d98ab546c9c2 Mon Sep 17 00:00:00 2001 From: Coby Tayree Date: Wed, 9 Aug 2017 21:49:17 +0000 Subject: [PATCH] [X86][Asm] Allow negative immediate to appear before bracketed expression Currently, only non-negative immediate is allowed prior to a brac expression (memory reference). MASM / GAS does not have any problem cope with the left side of the real line, so we should be able to as well. Differntial Revision: https://reviews.llvm.org/D36229 llvm-svn: 310528 --- llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h | 4 ++-- llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h b/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h index b8d3180..4e2303f 100644 --- a/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h +++ b/llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h @@ -66,11 +66,11 @@ struct AsmRewrite { AsmRewriteKind Kind; SMLoc Loc; unsigned Len; - unsigned Val; + int64_t Val; StringRef Label; public: - AsmRewrite(AsmRewriteKind kind, SMLoc loc, unsigned len = 0, unsigned val = 0) + AsmRewrite(AsmRewriteKind kind, SMLoc loc, unsigned len = 0, int64_t val = 0) : Kind(kind), Loc(loc), Len(len), Val(val) {} AsmRewrite(AsmRewriteKind kind, SMLoc loc, unsigned len, StringRef label) : Kind(kind), Loc(loc), Len(len), Val(0), Label(label) {} diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp index dd6727a..fd083b0 100644 --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -1962,11 +1962,6 @@ std::unique_ptr X86AsmParser::ParseIntelOperand() { return X86Operand::CreateImm(ImmExpr, Start, End); } - // Only positive immediates are valid. - if (Imm < 0) - return ErrorOperand(Start, "expected a positive immediate displacement " - "before bracketed expr."); - return ParseIntelBracExpression(/*SegReg=*/0, Start, Imm, isSymbol, Size); } -- 2.7.4