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

Eric Astor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 1 11:52:43 PDT 2020


epastor updated this revision to Diff 289243.
epastor added a comment.

Sync to HEAD


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86946/new/

https://reviews.llvm.org/D86946

Files:
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/test/tools/llvm-ml/variable.test


Index: llvm/test/tools/llvm-ml/variable.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ml/variable.test
@@ -0,0 +1,12 @@
+# 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
+
+END
Index: llvm/lib/MC/MCParser/MasmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/MasmParser.cpp
+++ llvm/lib/MC/MCParser/MasmParser.cpp
@@ -3076,6 +3076,11 @@
   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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86946.289243.patch
Type: text/x-patch
Size: 1045 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200901/724fb8ae/attachment.bin>


More information about the llvm-commits mailing list