From 772e4734d9d6733b60adfbe1e62ac7f1ab2db849 Mon Sep 17 00:00:00 2001 From: Sander de Smalen Date: Thu, 4 Apr 2019 09:11:17 +0000 Subject: [PATCH] [AArch64][AsmParser] Fix .arch_extension directive parsing This patch fixes .arch_extension directive parsing to handle a wider range of architecture extension options. The existing parser was parsing extensions as an identifier which breaks for extensions containing a "-", such as the "tlb-rmi" extension. The extension is now parsed as a string. This is consistent with the extension parsing in the .arch and .cpu directive parsing. Patch by Cullen Rhodes (c-rhodes) Reviewed By: SjoerdMeijer Differential Revision: https://reviews.llvm.org/D60118 llvm-svn: 357677 --- .../AArch64/AsmParser/AArch64AsmParser.cpp | 10 +-- .../SVE/directive-arch_extension-negative.s | 7 ++ .../MC/AArch64/SVE/directive-arch_extension.s | 6 ++ .../directive-arch_extension-negative.s | 80 +++++++++++++++++++ .../AArch64/directive-arch_extension-nosimd.s | 6 -- .../AArch64/directive-arch_extension-simd.s | 6 -- .../MC/AArch64/directive-arch_extension.s | 61 ++++++++++++++ 7 files changed, 156 insertions(+), 20 deletions(-) create mode 100644 llvm/test/MC/AArch64/SVE/directive-arch_extension-negative.s create mode 100644 llvm/test/MC/AArch64/SVE/directive-arch_extension.s create mode 100644 llvm/test/MC/AArch64/directive-arch_extension-negative.s delete mode 100644 llvm/test/MC/AArch64/directive-arch_extension-nosimd.s delete mode 100644 llvm/test/MC/AArch64/directive-arch_extension-simd.s create mode 100644 llvm/test/MC/AArch64/directive-arch_extension.s diff --git a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 7c3cdb1423e8..37d4c9a3f8a7 100644 --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -5153,15 +5153,9 @@ bool AArch64AsmParser::parseDirectiveArch(SMLoc L) { /// parseDirectiveArchExtension /// ::= .arch_extension [no]feature bool AArch64AsmParser::parseDirectiveArchExtension(SMLoc L) { - MCAsmParser &Parser = getParser(); + SMLoc ExtLoc = getLoc(); - if (getLexer().isNot(AsmToken::Identifier)) - return Error(getLexer().getLoc(), "expected architecture extension name"); - - const AsmToken &Tok = Parser.getTok(); - StringRef Name = Tok.getString(); - SMLoc ExtLoc = Tok.getLoc(); - Lex(); + StringRef Name = getParser().parseStringToEndOfStatement().trim(); if (parseToken(AsmToken::EndOfStatement, "unexpected token in '.arch_extension' directive")) diff --git a/llvm/test/MC/AArch64/SVE/directive-arch_extension-negative.s b/llvm/test/MC/AArch64/SVE/directive-arch_extension-negative.s new file mode 100644 index 000000000000..b07afa6d5d07 --- /dev/null +++ b/llvm/test/MC/AArch64/SVE/directive-arch_extension-negative.s @@ -0,0 +1,7 @@ +// RUN: not llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s + +.arch_extension nosve + +ptrue p0.b, pow2 +// CHECK: error: instruction requires: sve +// CHECK-NEXT: ptrue p0.b, pow2 diff --git a/llvm/test/MC/AArch64/SVE/directive-arch_extension.s b/llvm/test/MC/AArch64/SVE/directive-arch_extension.s new file mode 100644 index 000000000000..72351b69f58b --- /dev/null +++ b/llvm/test/MC/AArch64/SVE/directive-arch_extension.s @@ -0,0 +1,6 @@ +// RUN: llvm-mc -triple=aarch64 < %s | FileCheck %s + +.arch_extension sve + +ptrue p0.b, pow2 +// CHECK: ptrue p0.b, pow2 diff --git a/llvm/test/MC/AArch64/directive-arch_extension-negative.s b/llvm/test/MC/AArch64/directive-arch_extension-negative.s new file mode 100644 index 000000000000..61351e171b59 --- /dev/null +++ b/llvm/test/MC/AArch64/directive-arch_extension-negative.s @@ -0,0 +1,80 @@ +// RUN: not llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s + +.arch_extension axp64 +// CHECK: error: unknown architectural extension: axp64 +// CHECK-NEXT: .arch_extension axp64 + +.arch_extension nocrc +crc32cx w0, w1, x3 +// CHECK: error: instruction requires: crc +// CHECK-NEXT: crc32cx w0, w1, x3 + +.arch_extension nosm4 +sm4e v2.4s, v15.4s +// CHECK: error: instruction requires: sm4 +// CHECK-NEXT: sm4e v2.4s, v15.4s + +.arch_extension nosha3 +sha512h q0, q1, v2.2d +// CHECK: error: instruction requires: sha3 +// CHECK-NEXT: sha512h q0, q1, v2.2d + +.arch_extension nosha2 +sha1h s0, s1 +// CHECK: error: instruction requires: sha2 +// CHECK-NEXT: sha1h s0, s1 + +.arch_extension noaes +aese v0.16b, v1.16b +// CHECK: error: instruction requires: aes +// CHECK-NEXT: aese v0.16b, v1.16b + +.arch_extension nofp +fminnm d0, d0, d1 +// CHECK: error: instruction requires: fp +// CHECK-NEXT: fminnm d0, d0, d1 + +.arch_extension nosimd +addp v0.4s, v0.4s, v0.4s +// CHECK: error: instruction requires: neon +// CHECK-NEXT: addp v0.4s, v0.4s, v0.4s + +.arch_extension noras +esb +// CHECK: error: instruction requires: ras +// CHECK-NEXT: esb + +.arch_extension nolse +casa w5, w7, [x20] +// CHECK: error: instruction requires: lse +// CHECK-NEXT: casa w5, w7, [x20] + +.arch_extension nopredres +cfp rctx, x0 +// CHECK: error: CFPRCTX requires predres +// CHECK-NEXT: cfp rctx, x0 + +.arch_extension noccdp +dc cvadp, x7 +// CHECK: error: DC CVADP requires ccdp +// CHECK-NEXT: dc cvadp, x7 + +.arch_extension nomte +irg x0, x1 +// CHECK: error: instruction requires: mte +// CHECK-NEXT: irg x0, x1 + +.arch_extension notlb-rmi +tlbi vmalle1os +// CHECK: error: TLBI VMALLE1OS requires tlb-rmi +// CHECK-NEXT: tlbi vmalle1os + +.arch_extension nopan-rwv +at s1e1wp, x2 +// CHECK: error: AT S1E1WP requires pan-rwv +// CHECK-NEXT: at s1e1wp, x2 + +.arch_extension noccpp +dc cvap, x7 +// CHECK: error: DC CVAP requires ccpp +// CHECK-NEXT: dc cvap, x7 diff --git a/llvm/test/MC/AArch64/directive-arch_extension-nosimd.s b/llvm/test/MC/AArch64/directive-arch_extension-nosimd.s deleted file mode 100644 index cbc03d05b342..000000000000 --- a/llvm/test/MC/AArch64/directive-arch_extension-nosimd.s +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: not llvm-mc -triple aarch64 -filetype asm -o - %s 2>&1 | FileCheck %s - - .arch_extension nosimd - - add v0.8b, v0.8b, v0.8b -// CHECK: error: instruction requires: neon diff --git a/llvm/test/MC/AArch64/directive-arch_extension-simd.s b/llvm/test/MC/AArch64/directive-arch_extension-simd.s deleted file mode 100644 index 04ebeee86344..000000000000 --- a/llvm/test/MC/AArch64/directive-arch_extension-simd.s +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: llvm-mc -triple aarch64 -mattr=-simd -filetype asm -o - %s | FileCheck %s - - .arch_extension simd - - add v0.8b, v0.8b, v0.8b -// CHECK: add v0.8b, v0.8b, v0.8b diff --git a/llvm/test/MC/AArch64/directive-arch_extension.s b/llvm/test/MC/AArch64/directive-arch_extension.s new file mode 100644 index 000000000000..6f1a65113462 --- /dev/null +++ b/llvm/test/MC/AArch64/directive-arch_extension.s @@ -0,0 +1,61 @@ +// RUN: llvm-mc -triple aarch64 -filetype asm -o - %s | FileCheck %s + +.arch_extension crc +crc32cx w0, w1, x3 +// CHECK: crc32cx w0, w1, x3 + +.arch_extension sm4 +sm4e v2.4s, v15.4s +// CHECK: sm4e v2.4s, v15.4s + +.arch_extension sha3 +sha512h q0, q1, v2.2d +// CHECK: sha512h q0, q1, v2.2d + +.arch_extension sha2 +sha1h s0, s1 +// CHECK: sha1h s0, s1 + +.arch_extension aes +aese v0.16b, v1.16b +// CHECK: aese v0.16b, v1.16b + +.arch_extension fp +fminnm d0, d0, d1 +// CHECK: fminnm d0, d0, d1 + +.arch_extension simd +addp v0.4s, v0.4s, v0.4s +// CHECK: addp v0.4s, v0.4s, v0.4s + +.arch_extension ras +esb +// CHECK: esb + +.arch_extension lse +casa w5, w7, [x20] +// CHECK: casa w5, w7, [x20] + +.arch_extension predres +cfp rctx, x0 +// CHECK: cfp rctx, x0 + +.arch_extension ccdp +dc cvadp, x7 +// CHECK: dc cvadp, x7 + +.arch_extension mte +irg x0, x1 +// CHECK: irg x0, x1 + +.arch_extension tlb-rmi +tlbi vmalle1os +// CHECK: tlbi vmalle1os + +.arch_extension pan-rwv +at s1e1wp, x2 +// CHECK: at s1e1wp, x2 + +.arch_extension ccpp +dc cvap, x7 +// CHECK: dc cvap, x7