From 0aa36b89a2bb6c1dfc0499af8d2995983169c262 Mon Sep 17 00:00:00 2001 From: Martin Storsjo Date: Sun, 13 Aug 2017 19:42:05 +0000 Subject: [PATCH] [COFF, ARM64] Use '//' as comment character in assembly files in GNU environments This allows using semicolons for bundling up more than one statement per line. This is used within the mingw-w64 project in some assembly files that contain code for multiple architectures. Differential Revision: https://reviews.llvm.org/D36366 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310797 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp | 9 ++++++++- lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.h | 8 ++++++++ lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp | 4 +++- test/MC/AArch64/coff-gnu.s | 11 +++++++++++ 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 test/MC/AArch64/coff-gnu.s diff --git a/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp b/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp index 2613d242a3b..7fba4849438 100644 --- a/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp +++ b/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp @@ -102,10 +102,17 @@ AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) { } AArch64MCAsmInfoCOFF::AArch64MCAsmInfoCOFF() { - CommentString = ";"; PrivateGlobalPrefix = ".L"; PrivateLabelPrefix = ".L"; AlignmentIsInBytes = false; SupportsDebugInformation = true; ExceptionsType = ExceptionHandling::WinEH; } + +AArch64MCAsmInfoMicrosoftCOFF::AArch64MCAsmInfoMicrosoftCOFF() { + CommentString = ";"; +} + +AArch64MCAsmInfoGNUCOFF::AArch64MCAsmInfoGNUCOFF() { + CommentString = "//"; +} diff --git a/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.h b/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.h index 2d7107a3724..afde87b4092 100644 --- a/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.h +++ b/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.h @@ -38,6 +38,14 @@ struct AArch64MCAsmInfoCOFF : public MCAsmInfoCOFF { explicit AArch64MCAsmInfoCOFF(); }; +struct AArch64MCAsmInfoMicrosoftCOFF : public AArch64MCAsmInfoCOFF { + explicit AArch64MCAsmInfoMicrosoftCOFF(); +}; + +struct AArch64MCAsmInfoGNUCOFF : public AArch64MCAsmInfoCOFF { + explicit AArch64MCAsmInfoGNUCOFF(); +}; + } // namespace llvm #endif diff --git a/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp b/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp index 3141f259ac2..8618069fb0d 100644 --- a/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp +++ b/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp @@ -69,8 +69,10 @@ static MCAsmInfo *createAArch64MCAsmInfo(const MCRegisterInfo &MRI, MCAsmInfo *MAI; if (TheTriple.isOSBinFormatMachO()) MAI = new AArch64MCAsmInfoDarwin(); + else if (TheTriple.isWindowsMSVCEnvironment()) + MAI = new AArch64MCAsmInfoMicrosoftCOFF(); else if (TheTriple.isOSBinFormatCOFF()) - MAI = new AArch64MCAsmInfoCOFF(); + MAI = new AArch64MCAsmInfoGNUCOFF(); else { assert(TheTriple.isOSBinFormatELF() && "Invalid target"); MAI = new AArch64MCAsmInfoELF(TheTriple); diff --git a/test/MC/AArch64/coff-gnu.s b/test/MC/AArch64/coff-gnu.s new file mode 100644 index 00000000000..df0dc7d33cf --- /dev/null +++ b/test/MC/AArch64/coff-gnu.s @@ -0,0 +1,11 @@ +// RUN: llvm-mc -triple aarch64-windows-gnu -filetype obj -o %t.obj %s +// RUN: llvm-objdump -d %t.obj | FileCheck %s + +func: +// Check that the nop instruction after the semicolon also is handled +nop; nop +add x0, x0, #42 + +// CHECK: 0: 1f 20 03 d5 nop +// CHECK: 4: 1f 20 03 d5 nop +// CHECK: 8: 00 a8 00 91 add x0, x0, #42 -- 2.11.4.GIT