Skip to content

Commit 1b41599

Browse files
authored
[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.
1 parent 5fa985e commit 1b41599

38 files changed

+136
-195
lines changed

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,6 @@ class MCAsmBackend {
213213
/// Give backend an opportunity to finish layout after relaxation
214214
virtual void finishLayout(MCAssembler const &Asm) const {}
215215

216-
/// Handle any target-specific assembler flags. By default, do nothing.
217-
virtual void handleAssemblerFlag(MCAssemblerFlag Flag) {}
218-
219216
/// Generate the compact unwind encoding for the CFI instructions.
220217
virtual uint64_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
221218
const MCContext *Ctxt) const {

llvm/include/llvm/MC/MCAsmInfo.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,6 @@ class MCAsmInfo {
166166
const char *InlineAsmStart;
167167
const char *InlineAsmEnd;
168168

169-
/// These are assembly directives that tells the assembler to interpret the
170-
/// following instructions differently. Defaults to ".code16", ".code32",
171-
/// ".code64".
172-
const char *Code16Directive;
173-
const char *Code32Directive;
174-
const char *Code64Directive;
175-
176169
/// Which dialect of an assembler variant to use. Defaults to 0
177170
unsigned AssemblerDialect = 0;
178171

@@ -544,9 +537,6 @@ class MCAsmInfo {
544537

545538
const char *getInlineAsmStart() const { return InlineAsmStart; }
546539
const char *getInlineAsmEnd() const { return InlineAsmEnd; }
547-
const char *getCode16Directive() const { return Code16Directive; }
548-
const char *getCode32Directive() const { return Code32Directive; }
549-
const char *getCode64Directive() const { return Code64Directive; }
550540
unsigned getAssemblerDialect() const { return AssemblerDialect; }
551541
bool doesAllowAtInName() const { return AllowAtInName; }
552542
void setAllowAtInName(bool V) { AllowAtInName = V; }

llvm/include/llvm/MC/MCDirectives.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ enum MCSymbolAttr {
5050
MCSA_Memtag, ///< .memtag (ELF)
5151
};
5252

53-
enum MCAssemblerFlag {
54-
MCAF_SyntaxUnified, ///< .syntax (ARM/ELF)
55-
MCAF_SubsectionsViaSymbols, ///< .subsections_via_symbols (MachO)
56-
MCAF_Code16, ///< .code16 (X86) / .code 16 (ARM)
57-
MCAF_Code32, ///< .code32 (X86) / .code 32 (ARM)
58-
MCAF_Code64 ///< .code64 (X86)
59-
};
60-
6153
enum MCDataRegionType {
6254
MCDR_DataRegion, ///< .data_region
6355
MCDR_DataRegionJT8, ///< .data_region jt8

llvm/include/llvm/MC/MCELFStreamer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class MCELFStreamer : public MCObjectStreamer {
5353
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
5454
void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
5555
uint64_t Offset) override;
56-
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
5756
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
5857
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
5958
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,

llvm/include/llvm/MC/MCStreamer.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@ class ARMTargetStreamer : public MCTargetStreamer {
169169

170170
virtual void annotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE);
171171

172+
virtual void emitSyntaxUnified();
173+
174+
virtual void emitCode16();
175+
virtual void emitCode32();
176+
172177
// Note in the output that the specified \p Symbol is a Thumb mode function.
173178
virtual void emitThumbFunc(MCSymbol *Symbol);
174179
virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value);
@@ -471,8 +476,8 @@ class MCStreamer {
471476

472477
virtual void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol);
473478

474-
/// Note in the output the specified \p Flag.
475-
virtual void emitAssemblerFlag(MCAssemblerFlag Flag);
479+
/// Emit a .subsection_via_symbols directive.
480+
virtual void emitSubsectionsViaSymbols();
476481

477482
/// Emit the given list \p Options of strings as linker
478483
/// options into the output.

llvm/include/llvm/MC/MCWasmStreamer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class MCWasmStreamer : public MCObjectStreamer {
4444
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
4545
void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
4646
uint64_t Offset) override;
47-
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
4847
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
4948
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
5049
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,

llvm/include/llvm/MC/MCWinCOFFStreamer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class MCWinCOFFStreamer : public MCObjectStreamer {
4545
void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override;
4646
void changeSection(MCSection *Section, uint32_t Subsection = 0) override;
4747
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
48-
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
4948
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
5049
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
5150
void beginCOFFSymbolDef(MCSymbol const *Symbol) override;

llvm/lib/MC/MCAsmInfo.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ MCAsmInfo::MCAsmInfo() {
4848
LinkerPrivateGlobalPrefix = "";
4949
InlineAsmStart = "APP";
5050
InlineAsmEnd = "NO_APP";
51-
Code16Directive = ".code16";
52-
Code32Directive = ".code32";
53-
Code64Directive = ".code64";
5451
ZeroDirective = "\t.zero\t";
5552
AsciiDirective = "\t.ascii\t";
5653
AscizDirective = "\t.asciz\t";

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class MCAsmStreamer final : public MCStreamer {
182182

183183
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
184184

185-
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
185+
void emitSubsectionsViaSymbols() override;
186186
void emitLinkerOptions(ArrayRef<std::string> Options) override;
187187
void emitDataRegion(MCDataRegionType Kind) override;
188188
void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
@@ -597,15 +597,8 @@ void MCAsmStreamer::emitGNUAttribute(unsigned Tag, unsigned Value) {
597597
OS << "\t.gnu_attribute " << Tag << ", " << Value << "\n";
598598
}
599599

600-
void MCAsmStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
601-
switch (Flag) {
602-
case MCAF_SyntaxUnified: OS << "\t.syntax unified"; break;
603-
case MCAF_SubsectionsViaSymbols: OS << ".subsections_via_symbols"; break;
604-
case MCAF_Code16: OS << '\t'<< MAI->getCode16Directive();break;
605-
case MCAF_Code32: OS << '\t'<< MAI->getCode32Directive();break;
606-
case MCAF_Code64: OS << '\t'<< MAI->getCode64Directive();break;
607-
}
608-
EmitEOL();
600+
void MCAsmStreamer::emitSubsectionsViaSymbols() {
601+
OS << ".subsections_via_symbols\n";
609602
}
610603

611604
void MCAsmStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {

llvm/lib/MC/MCELFStreamer.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,6 @@ void MCELFStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCDataFragment &F,
8484
Symbol->setType(ELF::STT_TLS);
8585
}
8686

87-
void MCELFStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
88-
// Let the target do whatever target specific stuff it needs to do.
89-
getAssembler().getBackend().handleAssemblerFlag(Flag);
90-
}
91-
9287
// If bundle alignment is used and there are any instructions in the section, it
9388
// needs to be aligned to at least the bundle size.
9489
static void setSectionAlignmentForBundling(const MCAssembler &Assembler,

llvm/lib/MC/MCMachOStreamer.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class MCMachOStreamer : public MCObjectStreamer {
8989
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
9090
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
9191
void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override;
92-
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
92+
void emitSubsectionsViaSymbols() override;
9393
void emitLinkerOptions(ArrayRef<std::string> Options) override;
9494
void emitDataRegion(MCDataRegionType Kind) override;
9595
void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
@@ -209,19 +209,8 @@ void MCMachOStreamer::emitDataRegionEnd() {
209209
emitLabel(Data.End);
210210
}
211211

212-
void MCMachOStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
213-
// Let the target do whatever target specific stuff it needs to do.
214-
getAssembler().getBackend().handleAssemblerFlag(Flag);
215-
// Do any generic stuff we need to do.
216-
switch (Flag) {
217-
case MCAF_SyntaxUnified: return; // no-op here.
218-
case MCAF_Code16: return; // Change parsing mode; no-op here.
219-
case MCAF_Code32: return; // Change parsing mode; no-op here.
220-
case MCAF_Code64: return; // Change parsing mode; no-op here.
221-
case MCAF_SubsectionsViaSymbols:
222-
getWriter().setSubsectionsViaSymbols(true);
223-
return;
224-
}
212+
void MCMachOStreamer::emitSubsectionsViaSymbols() {
213+
getWriter().setSubsectionsViaSymbols(true);
225214
}
226215

227216
void MCMachOStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {

llvm/lib/MC/MCNullStreamer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ namespace {
3838

3939
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
4040
Align ByteAlignment) override {}
41+
void emitSubsectionsViaSymbols() override {};
4142
void beginCOFFSymbolDef(const MCSymbol *Symbol) override {}
4243
void emitCOFFSymbolStorageClass(int StorageClass) override {}
4344
void emitCOFFSymbolType(int Type) override {}

llvm/lib/MC/MCParser/DarwinAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ bool DarwinAsmParser::parseDirectiveSubsectionsViaSymbols(StringRef, SMLoc) {
817817

818818
Lex();
819819

820-
getStreamer().emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
820+
getStreamer().emitSubsectionsViaSymbols();
821821

822822
return false;
823823
}

llvm/lib/MC/MCStreamer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,10 @@ void MCStreamer::emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi,
12451245
emitULEB128Value(Diff);
12461246
}
12471247

1248-
void MCStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {}
1248+
void MCStreamer::emitSubsectionsViaSymbols() {
1249+
llvm_unreachable(
1250+
"emitSubsectionsViaSymbols only supported on Mach-O targets");
1251+
}
12491252
void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
12501253
void MCStreamer::beginCOFFSymbolDef(const MCSymbol *Symbol) {
12511254
llvm_unreachable("this directive only supported on COFF targets");

llvm/lib/MC/MCWasmStreamer.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ void MCWasmStreamer::emitLabelAtPos(MCSymbol *S, SMLoc Loc, MCDataFragment &F,
5959
Symbol->setTLS();
6060
}
6161

62-
void MCWasmStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
63-
// Let the target do whatever target specific stuff it needs to do.
64-
getAssembler().getBackend().handleAssemblerFlag(Flag);
65-
66-
// Do any generic stuff we need to do.
67-
llvm_unreachable("invalid assembler flag!");
68-
}
69-
7062
void MCWasmStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
7163
MCAssembler &Asm = getAssembler();
7264
auto *SectionWasm = cast<MCSectionWasm>(Section);

llvm/lib/MC/MCWinCOFFStreamer.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -184,22 +184,6 @@ void MCWinCOFFStreamer::emitLabel(MCSymbol *S, SMLoc Loc) {
184184
MCObjectStreamer::emitLabel(Symbol, Loc);
185185
}
186186

187-
void MCWinCOFFStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
188-
// Let the target do whatever target specific stuff it needs to do.
189-
getAssembler().getBackend().handleAssemblerFlag(Flag);
190-
191-
switch (Flag) {
192-
// None of these require COFF specific handling.
193-
case MCAF_SyntaxUnified:
194-
case MCAF_Code16:
195-
case MCAF_Code32:
196-
case MCAF_Code64:
197-
break;
198-
case MCAF_SubsectionsViaSymbols:
199-
llvm_unreachable("COFF doesn't support .subsections_via_symbols");
200-
}
201-
}
202-
203187
bool MCWinCOFFStreamer::emitSymbolAttribute(MCSymbol *S,
204188
MCSymbolAttr Attribute) {
205189
auto *Symbol = cast<MCSymbolCOFF>(S);

llvm/lib/Object/RecordStreamer.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ class RecordStreamer : public MCStreamer {
5454
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
5555
Align ByteAlignment) override;
5656

57-
// Ignore COFF-specific directives; we do not need any information from them,
58-
// but the default implementation of these methods crashes, so we override
59-
// them with versions that do nothing.
57+
// Ignore format-specific directives; we do not need any information from
58+
// them, but the default implementation of these methods crashes, so we
59+
// override them with versions that do nothing.
60+
void emitSubsectionsViaSymbols() override {};
6061
void beginCOFFSymbolDef(const MCSymbol *Symbol) override {}
6162
void emitCOFFSymbolStorageClass(int StorageClass) override {}
6263
void emitCOFFSymbolType(int Type) override {}

llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ void AArch64AsmPrinter::emitEndOfAsmFile(Module &M) {
961961
// implementation of multiple entry points). If this doesn't occur, the
962962
// linker can safely perform dead code stripping. Since LLVM never
963963
// generates code that does this, it is always safe to set.
964-
OutStreamer->emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
964+
OutStreamer->emitSubsectionsViaSymbols();
965965
}
966966

967967
if (TT.isOSBinFormatELF()) {

llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ AArch64MCAsmInfoELF::AArch64MCAsmInfoELF(const Triple &T) {
108108
CommentString = "//";
109109
PrivateGlobalPrefix = ".L";
110110
PrivateLabelPrefix = ".L";
111-
Code32Directive = ".code\t32";
112111

113112
Data16bitsDirective = "\t.hword\t";
114113
Data32bitsDirective = "\t.word\t";

llvm/lib/Target/ARM/ARMAsmPrinter.cpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ void ARMAsmPrinter::emitFunctionEntryLabel() {
6666
auto &TS =
6767
static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
6868
if (AFI->isThumbFunction()) {
69-
OutStreamer->emitAssemblerFlag(MCAF_Code16);
69+
TS.emitCode16();
7070
TS.emitThumbFunc(CurrentFnSym);
7171
} else {
72-
OutStreamer->emitAssemblerFlag(MCAF_Code32);
72+
TS.emitCode32();
7373
}
7474

7575
// Emit symbol for CMSE non-secure entry point
@@ -171,7 +171,9 @@ bool ARMAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
171171
// These are created per function, rather than per TU, since it's
172172
// relatively easy to exceed the thumb branch range within a TU.
173173
if (! ThumbIndirectPads.empty()) {
174-
OutStreamer->emitAssemblerFlag(MCAF_Code16);
174+
auto &TS =
175+
static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
176+
TS.emitCode16();
175177
emitAlignment(Align(2));
176178
for (std::pair<unsigned, MCSymbol *> &TIP : ThumbIndirectPads) {
177179
OutStreamer->emitLabel(TIP.second);
@@ -489,24 +491,30 @@ void ARMAsmPrinter::emitInlineAsmEnd(const MCSubtargetInfo &StartInfo,
489491
// the start mode, then restore the start mode.
490492
const bool WasThumb = isThumb(StartInfo);
491493
if (!EndInfo || WasThumb != isThumb(*EndInfo)) {
492-
OutStreamer->emitAssemblerFlag(WasThumb ? MCAF_Code16 : MCAF_Code32);
494+
auto &TS =
495+
static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
496+
if (WasThumb)
497+
TS.emitCode16();
498+
else
499+
TS.emitCode32();
493500
}
494501
}
495502

496503
void ARMAsmPrinter::emitStartOfAsmFile(Module &M) {
497504
const Triple &TT = TM.getTargetTriple();
505+
auto &TS =
506+
static_cast<ARMTargetStreamer &>(*OutStreamer->getTargetStreamer());
498507
// Use unified assembler syntax.
499-
OutStreamer->emitAssemblerFlag(MCAF_SyntaxUnified);
508+
TS.emitSyntaxUnified();
500509

501510
// Emit ARM Build Attributes
502511
if (TT.isOSBinFormatELF())
503512
emitAttributes();
504513

505514
// Use the triple's architecture and subarchitecture to determine
506-
// if we're thumb for the purposes of the top level code16 assembler
507-
// flag.
515+
// if we're thumb for the purposes of the top level code16 state.
508516
if (!M.getModuleInlineAsm().empty() && TT.isThumb())
509-
OutStreamer->emitAssemblerFlag(MCAF_Code16);
517+
TS.emitCode16();
510518
}
511519

512520
static void
@@ -575,7 +583,7 @@ void ARMAsmPrinter::emitEndOfAsmFile(Module &M) {
575583
// implementation of multiple entry points). If this doesn't occur, the
576584
// linker can safely perform dead code stripping. Since LLVM never
577585
// generates code that does this, it is always safe to set.
578-
OutStreamer->emitAssemblerFlag(MCAF_SubsectionsViaSymbols);
586+
OutStreamer->emitSubsectionsViaSymbols();
579587
}
580588

581589
// The last attribute to be emitted is ABI_optimization_goals

llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11654,7 +11654,7 @@ bool ARMAsmParser::parseDirectiveThumb(SMLoc L) {
1165411654
if (!isThumb())
1165511655
SwitchMode();
1165611656

11657-
getParser().getStreamer().emitAssemblerFlag(MCAF_Code16);
11657+
getTargetStreamer().emitCode16();
1165811658
getParser().getStreamer().emitCodeAlignment(Align(2), &getSTI(), 0);
1165911659
return false;
1166011660
}
@@ -11667,7 +11667,7 @@ bool ARMAsmParser::parseDirectiveARM(SMLoc L) {
1166711667

1166811668
if (isThumb())
1166911669
SwitchMode();
11670-
getParser().getStreamer().emitAssemblerFlag(MCAF_Code32);
11670+
getTargetStreamer().emitCode32();
1167111671
getParser().getStreamer().emitCodeAlignment(Align(4), &getSTI(), 0);
1167211672
return false;
1167311673
}
@@ -11715,7 +11715,7 @@ bool ARMAsmParser::parseDirectiveThumbFunc(SMLoc L) {
1171511715
if (!isThumb())
1171611716
SwitchMode();
1171711717

11718-
getParser().getStreamer().emitAssemblerFlag(MCAF_Code16);
11718+
getTargetStreamer().emitCode16();
1171911719

1172011720
NextSymbolIsThumb = true;
1172111721
return false;
@@ -11768,14 +11768,14 @@ bool ARMAsmParser::parseDirectiveCode(SMLoc L) {
1176811768

1176911769
if (!isThumb())
1177011770
SwitchMode();
11771-
getParser().getStreamer().emitAssemblerFlag(MCAF_Code16);
11771+
getTargetStreamer().emitCode16();
1177211772
} else {
1177311773
if (!hasARM())
1177411774
return Error(L, "target does not support ARM mode");
1177511775

1177611776
if (isThumb())
1177711777
SwitchMode();
11778-
getParser().getStreamer().emitAssemblerFlag(MCAF_Code32);
11778+
getTargetStreamer().emitCode32();
1177911779
}
1178011780

1178111781
return false;
@@ -11824,8 +11824,10 @@ void ARMAsmParser::FixModeAfterArchChange(bool WasThumb, SMLoc Loc) {
1182411824
SwitchMode();
1182511825
} else {
1182611826
// Mode switch forced, because the new arch doesn't support the old mode.
11827-
getParser().getStreamer().emitAssemblerFlag(isThumb() ? MCAF_Code16
11828-
: MCAF_Code32);
11827+
if (isThumb())
11828+
getTargetStreamer().emitCode16();
11829+
else
11830+
getTargetStreamer().emitCode32();
1182911831
// Warn about the implcit mode switch. GAS does not switch modes here,
1183011832
// but instead stays in the old mode, reporting an error on any following
1183111833
// instructions as the mode does not exist on the target.

0 commit comments

Comments
 (0)