aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCMachOStreamer.cpp
diff options
context:
space:
mode:
authorJessica Clarke <jrtc27@jrtc27.com>2025-05-18 20:09:43 +0100
committerGitHub <noreply@github.com>2025-05-18 20:09:43 +0100
commit1b41599cf8972abbf0d2ee7595dba78a4b158af0 (patch)
treedc73a47a91632a5cd504ee4b9e8781753cb59675 /llvm/lib/MC/MCMachOStreamer.cpp
parent5fa985e751c8f890fff31e190473aeeb6f7a9fc5 (diff)
downloadllvm-1b41599cf8972abbf0d2ee7595dba78a4b158af0.zip
llvm-1b41599cf8972abbf0d2ee7595dba78a4b158af0.tar.gz
llvm-1b41599cf8972abbf0d2ee7595dba78a4b158af0.tar.bz2
[MC][AArch64][ARM][X86] Push target-dependent assembler flags into targets (#139844)
The .syntax unified directive and .codeX/.code X directives are, other than some simple common printing code, exclusively implemented in the targets themselves. Thus, remove the corresponding MCAF_* flags and reimplement the directives solely within the targets. This avoids exposing all targets to all other targets' flags. Since MCAF_SubsectionsViaSymbols is all that remains, convert it to its own function like other directives, simplifying its implementation. Note that, on X86, we now always need a target streamer when parsing assembly, as it's now used for directives that aren't COFF-specific. It still does not however need to do anything when producing a non-COFF object file, so this commit does not introduce any new target streamers. There is some churn in test output, and corresponding UTC regex changes, due to comments no longer being flushed by these various directives (and EmitEOL is not exposed outside MCAsmStreamer.cpp so we couldn't do so even if we wanted to), but that was a bit odd to be doing anyway. This is motivated by Morello LLVM, which adds yet another assembler flag to distinguish A64 and C64 instruction sets, but did not update every switch and so emits warnings during the build. Rather than fix those warnings it seems better to instead make the problem not exist in the first place via this change.
Diffstat (limited to 'llvm/lib/MC/MCMachOStreamer.cpp')
-rw-r--r--llvm/lib/MC/MCMachOStreamer.cpp17
1 files changed, 3 insertions, 14 deletions
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp
index 9b7152f..4cf602b 100644
--- a/llvm/lib/MC/MCMachOStreamer.cpp
+++ b/llvm/lib/MC/MCMachOStreamer.cpp
@@ -89,7 +89,7 @@ public:
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override;
- void emitAssemblerFlag(MCAssemblerFlag Flag) override;
+ void emitSubsectionsViaSymbols() override;
void emitLinkerOptions(ArrayRef<std::string> Options) override;
void emitDataRegion(MCDataRegionType Kind) override;
void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
@@ -209,19 +209,8 @@ void MCMachOStreamer::emitDataRegionEnd() {
emitLabel(Data.End);
}
-void MCMachOStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
- // Let the target do whatever target specific stuff it needs to do.
- getAssembler().getBackend().handleAssemblerFlag(Flag);
- // Do any generic stuff we need to do.
- switch (Flag) {
- case MCAF_SyntaxUnified: return; // no-op here.
- case MCAF_Code16: return; // Change parsing mode; no-op here.
- case MCAF_Code32: return; // Change parsing mode; no-op here.
- case MCAF_Code64: return; // Change parsing mode; no-op here.
- case MCAF_SubsectionsViaSymbols:
- getWriter().setSubsectionsViaSymbols(true);
- return;
- }
+void MCMachOStreamer::emitSubsectionsViaSymbols() {
+ getWriter().setSubsectionsViaSymbols(true);
}
void MCMachOStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {