[ms] [llvm-ml] Add missing built-in type aliases
authorEric Astor <epastor@google.com>
Mon, 14 Sep 2020 18:07:33 +0000 (14:07 -0400)
committerEric Astor <epastor@google.com>
Mon, 14 Sep 2020 18:09:24 +0000 (14:09 -0400)
Add signed aliases for integral types, as well as the "DF" abbreviation for the FWORD type.

Reviewed By: thakis

Differential Revision: https://reviews.llvm.org/D87246

llvm/lib/MC/MCParser/MasmParser.cpp
llvm/test/tools/llvm-ml/builtin_types.test [new file with mode: 0644]

index 4d62174..ea18cf8 100644 (file)
@@ -623,6 +623,7 @@ private:
     DK_SQWORD,
     DK_DB,
     DK_DD,
+    DK_DF,
     DK_DQ,
     DK_DW,
     DK_REAL4,
@@ -2114,6 +2115,7 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
     case DK_DD:
       return parseDirectiveValue(IDVal, 4);
     case DK_FWORD:
+    case DK_DF:
       return parseDirectiveValue(IDVal, 6);
     case DK_QWORD:
     case DK_SQWORD:
@@ -2325,21 +2327,26 @@ bool MasmParser::parseStatement(ParseStatementInfo &Info,
     Lex();
     return parseDirectiveEquate(nextVal, IDVal, DirKind);
   case DK_BYTE:
+  case DK_SBYTE:
   case DK_DB:
     Lex();
     return parseDirectiveNamedValue(nextVal, 1, IDVal, IDLoc);
   case DK_WORD:
+  case DK_SWORD:
   case DK_DW:
     Lex();
     return parseDirectiveNamedValue(nextVal, 2, IDVal, IDLoc);
   case DK_DWORD:
+  case DK_SDWORD:
   case DK_DD:
     Lex();
     return parseDirectiveNamedValue(nextVal, 4, IDVal, IDLoc);
   case DK_FWORD:
+  case DK_DF:
     Lex();
     return parseDirectiveNamedValue(nextVal, 6, IDVal, IDLoc);
   case DK_QWORD:
+  case DK_SQWORD:
   case DK_DQ:
     Lex();
     return parseDirectiveNamedValue(nextVal, 8, IDVal, IDLoc);
@@ -6284,6 +6291,7 @@ void MasmParser::initializeDirectiveKindMap() {
   // DirectiveKindMap[".noaltmacro"] = DK_NOALTMACRO;
   DirectiveKindMap["db"] = DK_DB;
   DirectiveKindMap["dd"] = DK_DD;
+  DirectiveKindMap["df"] = DK_DF;
   DirectiveKindMap["dq"] = DK_DQ;
   DirectiveKindMap["dw"] = DK_DW;
   DirectiveKindMap["echo"] = DK_ECHO;
diff --git a/llvm/test/tools/llvm-ml/builtin_types.test b/llvm/test/tools/llvm-ml/builtin_types.test
new file mode 100644 (file)
index 0000000..b99c491
--- /dev/null
@@ -0,0 +1,77 @@
+# RUN: llvm-ml -filetype=asm %s | FileCheck %s
+
+.data
+
+t1_long BYTE 1
+t1_short DB 1
+t1_signed SBYTE -1
+
+; CHECK-LABEL: t1_long:
+; CHECK: .byte 1
+; CHECK-LABEL: t1_short:
+; CHECK: .byte 1
+; CHECK-LABEL: t1_signed:
+; CHECK: .byte -1
+
+t2_long WORD 2
+t2_short DW 2
+t2_signed SWORD -2
+
+; CHECK-LABEL: t2_long:
+; CHECK: .short 2
+; CHECK-LABEL: t2_short:
+; CHECK: .short 2
+; CHECK-LABEL: t2_signed:
+; CHECK: .short -2
+
+t3_long DWORD 3
+t3_short DD 3
+t3_signed SDWORD -3
+
+; CHECK-LABEL: t3_long:
+; CHECK: .long 3
+; CHECK-LABEL: t3_short:
+; CHECK: .long 3
+; CHECK-LABEL: t3_signed:
+; CHECK: .long -3
+
+t4_long FWORD 4
+t4_short DF 4
+t4_long_large FWORD 4294967298
+t4_short_large FWORD 4294967298
+
+; CHECK-LABEL: t4_long:
+; CHECK-NEXT: .long 4
+; CHECK-NEXT: .short 0
+; CHECK-LABEL: t4_short:
+; CHECK-NEXT: .long 4
+; CHECK-NEXT: .short 0
+; CHECK-LABEL: t4_long_large:
+; CHECK-NEXT: .long 2
+; CHECK-NEXT: .short 1
+; CHECK-LABEL: t4_short_large:
+; CHECK-NEXT: .long 2
+; CHECK-NEXT: .short 1
+
+t5_long QWORD 4611686018427387904
+t5_short DQ 4611686018427387904
+t5_signed SQWORD -4611686018427387904
+
+; CHECK-LABEL: t5_long:
+; CHECK-NEXT: .quad 4611686018427387904
+; CHECK-LABEL: t5_short:
+; CHECK-NEXT: .quad 4611686018427387904
+; CHECK-LABEL: t5_signed:
+; CHECK-NEXT: .quad -4611686018427387904
+
+t6_single REAL4 1.3
+t6_double REAL8 1.3
+
+; CHECK-LABEL: t6_single:
+; CHECK-NEXT: .long 1067869798
+; CHECK-LABEL: t6_double:
+; CHECK-NEXT: .quad 4608533498688228557
+
+.code
+
+END