[PATCH] D148490: [AIX] use system assembler for assembly files
ChenZheng via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 16 20:38:07 PDT 2023
shchenz created this revision.
shchenz added reviewers: hubert.reinterpretcast, nemanjai, PowerPC.
shchenz added a project: LLVM.
Herald added a project: All.
shchenz requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.
Change to system assembler to compile assembly files even `-fintegrated-as` is specified.
We don't have a good Clang as for now for assembly files on AIX.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D148490
Files:
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/AIX.cpp
clang/lib/Driver/ToolChains/AIX.h
clang/test/Driver/aix-assembler.s
Index: clang/test/Driver/aix-assembler.s
===================================================================
--- /dev/null
+++ clang/test/Driver/aix-assembler.s
@@ -0,0 +1,31 @@
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang %s -### -c -fintegrated-as 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN: | FileCheck --check-prefixes=AS64,CHECK %s
+
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN: | FileCheck --check-prefixes=AS64,CHECK %s
+
+// RUN: %clang %s -### -c -fno-integrated-as 2>&1 \
+// RUN: --target=powerpc64-ibm-aix7.1.0.0 \
+// RUN: | FileCheck --check-prefixes=AS64,CHECK %s
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang %s -### -c -fintegrated-as 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN: | FileCheck --check-prefixes=AS32,CHECK %s
+
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN: | FileCheck --check-prefixes=AS32,CHECK %s
+
+// RUN: %clang %s -### -c 2>&1 -fno-integrated-as \
+// RUN: --target=powerpc-ibm-aix7.1.0.0 \
+// RUN: | FileCheck --check-prefixes=AS32,CHECK %s
+
+// CHECK: "{{.*}}as{{(.exe)?}}"
+// AS32: "-a32"
+// AS64: "-a64"
+// CHECK: "-many"
Index: clang/lib/Driver/ToolChains/AIX.h
===================================================================
--- clang/lib/Driver/ToolChains/AIX.h
+++ clang/lib/Driver/ToolChains/AIX.h
@@ -97,8 +97,10 @@
protected:
Tool *buildAssembler() const override;
Tool *buildLinker() const override;
+ Tool *getTool(Action::ActionClass AC) const override;
private:
+ mutable std::unique_ptr<Tool> Assembler;
llvm::StringRef GetHeaderSysroot(const llvm::opt::ArgList &DriverArgs) const;
bool ParseInlineAsmUsingAsmParser;
};
Index: clang/lib/Driver/ToolChains/AIX.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -416,6 +416,19 @@
return ToolChain::RLT_CompilerRT;
}
+Tool *AIX::getTool(Action::ActionClass AC) const {
+ switch (AC) {
+ default:
+ break;
+ // AIX always uses system assembler to compile assembly files.
+ case Action::AssembleJobClass:
+ if (!Assembler)
+ Assembler.reset(buildAssembler());
+ return Assembler.get();
+ }
+ return ToolChain::getTool(AC);
+}
+
auto AIX::buildAssembler() const -> Tool * { return new aix::Assembler(*this); }
auto AIX::buildLinker() const -> Tool * { return new aix::Linker(*this); }
Index: clang/lib/Driver/ToolChain.cpp
===================================================================
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -662,7 +662,8 @@
if (D.IsFlangMode() && getDriver().ShouldUseFlangCompiler(JA)) return getFlang();
if (getDriver().ShouldUseClangCompiler(JA)) return getClang();
Action::ActionClass AC = JA.getKind();
- if (AC == Action::AssembleJobClass && useIntegratedAs())
+ if (AC == Action::AssembleJobClass && useIntegratedAs() &&
+ !getTriple().isOSAIX())
return getClangAs();
return getTool(AC);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148490.514083.patch
Type: text/x-patch
Size: 3144 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230417/32a39b74/attachment-0001.bin>
More information about the cfe-commits
mailing list