1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[ms] [llvm-ml] Allow use of locally-defined variables in expressions

MASM allows variables defined by equate statements to be used in expressions.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D86946
This commit is contained in:
Eric Astor 2020-09-07 14:00:05 -04:00
parent 7ae8eb3e82
commit ffbe9ff668
2 changed files with 18 additions and 0 deletions

View File

@ -3076,6 +3076,11 @@ bool MasmParser::parseDirectiveEquate(StringRef IDVal, StringRef Name,
SMLoc EndLoc, StartLoc = Lexer.getLoc();
if (parseExpression(Expr, EndLoc))
return addErrorSuffix(" in '" + Twine(IDVal) + "' directive");
MCSymbol *Sym = getContext().getOrCreateSymbol(Var.Name);
Sym->setRedefinable(Var.Redefinable);
Sym->setVariableValue(Expr);
Sym->setExternal(false);
if (Expr->evaluateAsAbsolute(Var.NumericValue,
getStreamer().getAssemblerPtr()))
return false;

View File

@ -0,0 +1,13 @@
# RUN: llvm-ml -filetype=asm %s | FileCheck %s
.data
t1_value equ 1 or 2
t1 BYTE t1_value DUP (0)
; CHECK: t1:
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .byte 0
; CHECK-NEXT: .byte 0
; CHECK-NOT: .byte 0
END