[PATCH] D83348: [ms] [llvm-ml] Add support for bitwise named operators (AND, NOT, OR) in MASM

Eric Astor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 07:00:43 PDT 2020


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

Rebase on parent


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83348

Files:
  llvm/lib/MC/MCParser/MasmParser.cpp


Index: llvm/lib/MC/MCParser/MasmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/MasmParser.cpp
+++ llvm/lib/MC/MCParser/MasmParser.cpp
@@ -1779,8 +1779,18 @@
                                SMLoc &EndLoc) {
   SMLoc StartLoc = Lexer.getLoc();
   while (true) {
+    AsmToken::TokenKind TokKind = Lexer.getKind();
+    if (Lexer.getKind() == AsmToken::Identifier) {
+      StringRef Identifier = Lexer.getTok().getString();
+      if (Identifier.equals_lower("and"))
+        TokKind = AsmToken::Amp;
+      else if (Identifier.equals_lower("not"))
+        TokKind = AsmToken::Exclaim;
+      else if (Identifier.equals_lower("or"))
+        TokKind = AsmToken::Pipe;
+    }
     MCBinaryExpr::Opcode Kind = MCBinaryExpr::Add;
-    unsigned TokPrec = getBinOpPrecedence(Lexer.getKind(), Kind);
+    unsigned TokPrec = getBinOpPrecedence(TokKind, Kind);
 
     // If the next token is lower precedence than we are allowed to eat, return
     // successfully with what we ate already.
@@ -3236,7 +3246,7 @@
     Lex();
   } else {
     const MCExpr *Value;
-    if (checkForValidSection() || parseExpression(Value))
+    if (parseExpression(Value))
       return true;
     if (getTok().is(AsmToken::Identifier) &&
         getTok().getString().equals_lower("dup")) {
@@ -3456,6 +3466,9 @@
 
 // Initialize real data values.
 bool MasmParser::emitRealValues(const fltSemantics &Semantics) {
+  if (checkForValidSection())
+    return true;
+
   SmallVector<APInt, 1> ValuesAsInt;
   if (parseRealInstList(Semantics, ValuesAsInt))
     return true;
@@ -3475,8 +3488,7 @@
 
   Field.SizeOf = 0;
 
-  if (checkForValidSection() ||
-      parseRealInstList(Semantics, RealInfo.AsIntValues))
+  if (parseRealInstList(Semantics, RealInfo.AsIntValues))
     return true;
 
   Field.Type = RealInfo.AsIntValues.back().getBitWidth() / 8;
@@ -3493,9 +3505,6 @@
 ///  ::= (real4 | real8) [ expression (, expression)* ]
 bool MasmParser::parseDirectiveRealValue(StringRef IDVal,
                                          const fltSemantics &Semantics) {
-  if (checkForValidSection())
-    return true;
-
   if (StructInProgress.empty()) {
     // Initialize data value.
     if (emitRealValues(Semantics))
@@ -3511,9 +3520,6 @@
 bool MasmParser::parseDirectiveNamedRealValue(StringRef IDVal,
                                               const fltSemantics &Semantics,
                                               StringRef Name, SMLoc NameLoc) {
-  if (checkForValidSection())
-    return true;
-
   if (StructInProgress.empty()) {
     // Initialize named data value.
     MCSymbol *Sym = getContext().getOrCreateSymbol(Name);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83348.277420.patch
Type: text/x-patch
Size: 2675 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200713/3351debe/attachment.bin>


More information about the llvm-commits mailing list