Skip to content

Commit ccbb04c

Browse files
MaskRayjrtc27
authored andcommitted
[ARM] Move MCStreamer::emitThumbFunc to ARMTargetStreamer
MCStreamer should not declare arch-specific functions. Such functions should go to MCTargetStreamer. Move MCMachOStreamer::emitThumbFunc to ARMTargetMachOStreamer, which is a new subclass of ARMTargetStreamer. (The new class is just placed in ARMMachObjectWriter.cpp. The conventional split like ARMELFObjectWriter.cpp/ARMELFObjectWriter.cpp is overkill.) `emitCFILabel`, called by ARMWinCOFFStreamer.cpp, has to be made public. Pull Request: llvm/llvm-project#126199 (cherry picked from commit ad61e53)
1 parent d41360b commit ccbb04c

18 files changed

+64
-57
lines changed

llvm/include/llvm/MC/MCELFStreamer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class MCELFStreamer : public MCObjectStreamer {
5252
void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F,
5353
uint64_t Offset) override;
5454
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
55-
void emitThumbFunc(MCSymbol *Func) override;
5655
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
5756
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
5857
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;

llvm/include/llvm/MC/MCObjectStreamer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class MCObjectStreamer : public MCStreamer {
6969
virtual void emitInstToData(const MCInst &Inst, const MCSubtargetInfo&) = 0;
7070
void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
7171
void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
72-
MCSymbol *emitCFILabel() override;
7372
void emitInstructionImpl(const MCInst &Inst, const MCSubtargetInfo &STI);
7473
void resolvePendingFixups();
7574

@@ -87,6 +86,7 @@ class MCObjectStreamer : public MCStreamer {
8786
bool isIntegratedAssemblerRequired() const override { return true; }
8887

8988
void emitFrames(MCAsmBackend *MAB);
89+
MCSymbol *emitCFILabel() override;
9090
void emitCFISections(bool EH, bool Debug) override;
9191

9292
MCFragment *getCurrentFragment() const;

llvm/include/llvm/MC/MCStreamer.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ class ARMTargetStreamer : public MCTargetStreamer {
168168

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

171+
// Note in the output that the specified \p Symbol is a Thumb mode function.
172+
virtual void emitThumbFunc(MCSymbol *Symbol);
171173
virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value);
172174

173175
void emitConstantPools() override;
@@ -529,10 +531,6 @@ class MCStreamer {
529531
const Triple *DarwinTargetVariantTriple,
530532
const VersionTuple &DarwinTargetVariantSDKVersion);
531533

532-
/// Note in the output that the specified \p Func is a Thumb mode
533-
/// function (ARM target only).
534-
virtual void emitThumbFunc(MCSymbol *Func);
535-
536534
/// Emit an assignment of \p Value to \p Symbol.
537535
///
538536
/// This corresponds to an assembler statement such as:

llvm/include/llvm/MC/MCWasmStreamer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ class MCWasmStreamer : public MCObjectStreamer {
4545
void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F,
4646
uint64_t Offset) override;
4747
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
48-
void emitThumbFunc(MCSymbol *Func) override;
4948
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
5049
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
5150
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;

llvm/include/llvm/MC/MCWinCOFFStreamer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class MCWinCOFFStreamer : public MCObjectStreamer {
4242
void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override;
4343
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
4444
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
45-
void emitThumbFunc(MCSymbol *Func) override;
4645
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
4746
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
4847
void beginCOFFSymbolDef(MCSymbol const *Symbol) override;

llvm/lib/MC/MCAsmStreamer.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ class MCAsmStreamer final : public MCStreamer {
170170
void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major,
171171
unsigned Minor, unsigned Update,
172172
VersionTuple SDKVersion) override;
173-
void emitThumbFunc(MCSymbol *Func) override;
174173

175174
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
176175
void emitConditionalAssignment(MCSymbol *Symbol,
@@ -670,18 +669,6 @@ void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
670669
emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
671670
}
672671

673-
void MCAsmStreamer::emitThumbFunc(MCSymbol *Func) {
674-
// This needs to emit to a temporary string to get properly quoted
675-
// MCSymbols when they have spaces in them.
676-
OS << "\t.thumb_func";
677-
// Only Mach-O hasSubsectionsViaSymbols()
678-
if (MAI->hasSubsectionsViaSymbols()) {
679-
OS << '\t';
680-
Func->print(OS, MAI);
681-
}
682-
EmitEOL();
683-
}
684-
685672
void MCAsmStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
686673
// Do not emit a .set on inlined target assignments.
687674
bool EmitSet = true;

llvm/lib/MC/MCELFStreamer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -723,10 +723,6 @@ void MCELFStreamer::finishImpl() {
723723
this->MCObjectStreamer::finishImpl();
724724
}
725725

726-
void MCELFStreamer::emitThumbFunc(MCSymbol *Func) {
727-
llvm_unreachable("Generic ELF doesn't support this directive");
728-
}
729-
730726
void MCELFStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
731727
llvm_unreachable("ELF doesn't support this directive");
732728
}

llvm/lib/MC/MCMachOStreamer.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class MCMachOStreamer : public MCObjectStreamer {
9999
void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major,
100100
unsigned Minor, unsigned Update,
101101
VersionTuple SDKVersion) override;
102-
void emitThumbFunc(MCSymbol *Func) override;
103102
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
104103
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
105104
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, Align ByteAlignment,
@@ -307,13 +306,6 @@ void MCMachOStreamer::emitDarwinTargetVariantBuildVersion(
307306
(MachO::PlatformType)Platform, Major, Minor, Update, SDKVersion);
308307
}
309308

310-
void MCMachOStreamer::emitThumbFunc(MCSymbol *Symbol) {
311-
// Remember that the function is a thumb function. Fixup and relocation
312-
// values will need adjusted.
313-
getAssembler().setIsThumbFunc(Symbol);
314-
cast<MCSymbolMachO>(Symbol)->setThumbFunc();
315-
}
316-
317309
bool MCMachOStreamer::emitSymbolAttribute(MCSymbol *Sym,
318310
MCSymbolAttr Attribute) {
319311
MCSymbolMachO *Symbol = cast<MCSymbolMachO>(Sym);

llvm/lib/MC/MCStreamer.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1259,7 +1259,6 @@ void MCStreamer::emitAbsoluteSymbolDiffAsULEB128(const MCSymbol *Hi,
12591259
}
12601260

12611261
void MCStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {}
1262-
void MCStreamer::emitThumbFunc(MCSymbol *Func) {}
12631262
void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
12641263
void MCStreamer::beginCOFFSymbolDef(const MCSymbol *Symbol) {
12651264
llvm_unreachable("this directive only supported on COFF targets");

llvm/lib/MC/MCWasmStreamer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,6 @@ void MCWasmStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
256256
}
257257
}
258258

259-
void MCWasmStreamer::emitThumbFunc(MCSymbol *Func) {
260-
llvm_unreachable("Generic Wasm doesn't support this directive");
261-
}
262-
263259
void MCWasmStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
264260
llvm_unreachable("Wasm doesn't support this directive");
265261
}

0 commit comments

Comments
 (0)