[clang] 34188f2 - [Driver][OpenBSD] Some improvements to the external assembler handling
Brad Smith via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 20 18:05:48 PDT 2021
Author: Brad Smith
Date: 2021-10-20T21:05:14-04:00
New Revision: 34188f237f2574dda2447d85fe2b1aa65b5321ce
URL: https://github.com/llvm/llvm-project/commit/34188f237f2574dda2447d85fe2b1aa65b5321ce
DIFF: https://github.com/llvm/llvm-project/commit/34188f237f2574dda2447d85fe2b1aa65b5321ce.diff
LOG: [Driver][OpenBSD] Some improvements to the external assembler handling
- Pass CPU variant for ARM
- Pass MIPS CPU in addition to the ABI
Added:
Modified:
clang/lib/Driver/ToolChains/OpenBSD.cpp
clang/test/Driver/openbsd.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp b/clang/lib/Driver/ToolChains/OpenBSD.cpp
index a2404e0d62067..96abac57764f7 100644
--- a/clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//
#include "OpenBSD.h"
+#include "Arch/ARM.h"
#include "Arch/Mips.h"
#include "Arch/Sparc.h"
#include "CommonArgs.h"
@@ -30,6 +31,8 @@ void openbsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
const char *LinkingOutput) const {
const toolchains::OpenBSD &ToolChain =
static_cast<const toolchains::OpenBSD &>(getToolChain());
+ const Driver &D = ToolChain.getDriver();
+ const llvm::Triple &Triple = ToolChain.getTriple();
claimNoWarnArgs(Args);
ArgStringList CmdArgs;
@@ -41,6 +44,15 @@ void openbsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("--32");
break;
+ case llvm::Triple::arm:
+ case llvm::Triple::armeb: {
+ StringRef MArch, MCPU;
+ arm::getARMArchCPUFromArgs(Args, MArch, MCPU, /*FromAs*/ true);
+ std::string Arch = arm::getARMTargetCPU(MCPU, MArch, Triple);
+ CmdArgs.push_back(Args.MakeArgString("-mcpu=" + Arch));
+ break;
+ }
+
case llvm::Triple::ppc:
CmdArgs.push_back("-mppc");
CmdArgs.push_back("-many");
@@ -48,10 +60,8 @@ void openbsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
case llvm::Triple::sparcv9: {
CmdArgs.push_back("-64");
- std::string CPU = getCPUName(ToolChain.getDriver(), Args,
- ToolChain.getTriple());
- CmdArgs.push_back(
- sparc::getSparcAsmModeForCPU(CPU, ToolChain.getTriple()));
+ std::string CPU = getCPUName(D, Args, Triple);
+ CmdArgs.push_back(sparc::getSparcAsmModeForCPU(CPU, Triple));
AddAssemblerKPIC(ToolChain, Args, CmdArgs);
break;
}
@@ -60,12 +70,15 @@ void openbsd::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
case llvm::Triple::mips64el: {
StringRef CPUName;
StringRef ABIName;
- mips::getMipsCPUAndABI(Args, ToolChain.getTriple(), CPUName, ABIName);
+ mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
+
+ CmdArgs.push_back("-march");
+ CmdArgs.push_back(CPUName.data());
CmdArgs.push_back("-mabi");
CmdArgs.push_back(mips::getGnuCompatibleMipsABIName(ABIName).data());
- if (ToolChain.getTriple().isLittleEndian())
+ if (Triple.isLittleEndian())
CmdArgs.push_back("-EL");
else
CmdArgs.push_back("-EB");
diff --git a/clang/test/Driver/openbsd.c b/clang/test/Driver/openbsd.c
index ae1aa64416907..c2ffe2a0397cd 100644
--- a/clang/test/Driver/openbsd.c
+++ b/clang/test/Driver/openbsd.c
@@ -56,6 +56,8 @@
// Check passing options to the assembler for various OpenBSD targets
// RUN: %clang -target amd64-pc-openbsd -m32 -### -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-AMD64-M32 %s
+// RUN: %clang -target arm-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-ARM %s
// RUN: %clang -target powerpc-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-POWERPC %s
// RUN: %clang -target sparc64-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \
@@ -69,10 +71,11 @@
// RUN: %clang -target mips64el-unknown-openbsd -fPIC -### -no-integrated-as -c %s 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-MIPS64EL-PIC %s
// CHECK-AMD64-M32: as{{.*}}" "--32"
+// CHECK-ARM: as{{.*}}" "-mcpu=cortex-a8"
// CHECK-POWERPC: as{{.*}}" "-mppc" "-many"
// CHECK-SPARC64: as{{.*}}" "-64" "-Av9a"
-// CHECK-MIPS64: as{{.*}}" "-mabi" "64" "-EB"
-// CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC"
+// CHECK-MIPS64: as{{.*}}" "-march" "mips3" "-mabi" "64" "-EB"
+// CHECK-MIPS64-PIC: as{{.*}}" "-march" "mips3" "-mabi" "64" "-EB" "-KPIC"
// CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL"
// CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC"
More information about the cfe-commits
mailing list