[lld] [lld] [MinGW] Support targeting ARM64EC (PR #78911)

Billy Laws via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 21 12:24:59 PST 2024


https://github.com/bylaws created https://github.com/llvm/llvm-project/pull/78911

'arm64ecpe' was chosen arbitrarily as gcc MinGW doesn't provide EC support.

CC: @cjacek 

>From 087acc05bf1bd6f5bad94597536fa92e53ba3eec Mon Sep 17 00:00:00 2001
From: Billy Laws <blaws05 at gmail.com>
Date: Wed, 18 Oct 2023 21:26:04 +0100
Subject: [PATCH] [lld] [MinGW] Support targeting ARM64EC

---
 lld/Common/DriverDispatcher.cpp | 3 ++-
 lld/MinGW/Driver.cpp            | 3 +++
 lld/test/MinGW/driver.test      | 6 ++++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lld/Common/DriverDispatcher.cpp b/lld/Common/DriverDispatcher.cpp
index 435acfd277654b1..f5c8bcdef4e0f09 100644
--- a/lld/Common/DriverDispatcher.cpp
+++ b/lld/Common/DriverDispatcher.cpp
@@ -44,7 +44,8 @@ static cl::TokenizerCallback getDefaultQuotingStyle() {
 }
 
 static bool isPETargetName(StringRef s) {
-  return s == "i386pe" || s == "i386pep" || s == "thumb2pe" || s == "arm64pe";
+  return s == "i386pe" || s == "i386pep" || s == "thumb2pe" || s == "arm64pe" ||
+         s == "arm64ecpe";
 }
 
 static std::optional<bool> isPETarget(llvm::ArrayRef<const char *> args) {
diff --git a/lld/MinGW/Driver.cpp b/lld/MinGW/Driver.cpp
index 4752d92e3b1d71d..290eecaacda7d49 100644
--- a/lld/MinGW/Driver.cpp
+++ b/lld/MinGW/Driver.cpp
@@ -346,6 +346,7 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
 
   if (args.getLastArgValue(OPT_m) != "thumb2pe" &&
       args.getLastArgValue(OPT_m) != "arm64pe" &&
+      args.getLastArgValue(OPT_m) != "arm64ecpe" &&
       args.hasFlag(OPT_disable_dynamicbase, OPT_dynamicbase, false))
     add("-dynamicbase:no");
   if (args.hasFlag(OPT_disable_high_entropy_va, OPT_high_entropy_va, false))
@@ -409,6 +410,8 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
       add("-machine:arm");
     else if (s == "arm64pe")
       add("-machine:arm64");
+    else if (s == "arm64ecpe")
+      add("-machine:arm64ec");
     else
       error("unknown parameter: -m" + s);
   }
diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test
index 559a32bfa242f8c..46b3b6d7a862a65 100644
--- a/lld/test/MinGW/driver.test
+++ b/lld/test/MinGW/driver.test
@@ -25,6 +25,12 @@ ARM64-SAME: -machine:arm64
 ARM64-SAME: -alternatename:__image_base__=__ImageBase
 ARM64-SAME: foo.o
 
+RUN: ld.lld -### foo.o -m arm64ecpe 2>&1 | FileCheck -check-prefix=ARM64EC %s
+ARM64EC:      -out:a.exe
+ARM64EC-SAME: -machine:arm64ec
+ARM64EC-SAME: -alternatename:__image_base__=__ImageBase
+ARM64EC-SAME: foo.o
+
 RUN: ld.lld -### foo.o -m i386pep -shared 2>&1 | FileCheck -check-prefix=SHARED %s
 RUN: ld.lld -### foo.o -m i386pep --shared 2>&1 | FileCheck -check-prefix=SHARED %s
 RUN: ld.lld -### foo.o -m i386pep --dll 2>&1 | FileCheck -check-prefix=SHARED %s



More information about the llvm-commits mailing list