Skip to content

Commit ad61e53

Browse files
authored
[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: #126199
1 parent 5d2e284 commit ad61e53

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
@@ -54,7 +54,6 @@ class MCELFStreamer : public MCObjectStreamer {
5454
void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCDataFragment &F,
5555
uint64_t Offset) override;
5656
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
57-
void emitThumbFunc(MCSymbol *Func) override;
5857
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override;
5958
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
6059
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
@@ -63,7 +63,6 @@ class MCObjectStreamer : public MCStreamer {
6363
virtual void emitInstToData(const MCInst &Inst, const MCSubtargetInfo&) = 0;
6464
void emitCFIStartProcImpl(MCDwarfFrameInfo &Frame) override;
6565
void emitCFIEndProcImpl(MCDwarfFrameInfo &Frame) override;
66-
MCSymbol *emitCFILabel() override;
6766
void emitInstructionImpl(const MCInst &Inst, const MCSubtargetInfo &STI);
6867
void resolvePendingFixups();
6968

@@ -81,6 +80,7 @@ class MCObjectStreamer : public MCStreamer {
8180
bool isIntegratedAssemblerRequired() const override { return true; }
8281

8382
void emitFrames(MCAsmBackend *MAB);
83+
MCSymbol *emitCFILabel() override;
8484
void emitCFISections(bool EH, bool Debug) override;
8585

8686
void insert(MCFragment *F) {

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;
@@ -501,10 +503,6 @@ class MCStreamer {
501503
const Triple *DarwinTargetVariantTriple,
502504
const VersionTuple &DarwinTargetVariantSDKVersion);
503505

504-
/// Note in the output that the specified \p Func is a Thumb mode
505-
/// function (ARM target only).
506-
virtual void emitThumbFunc(MCSymbol *Func);
507-
508506
/// Emit an assignment of \p Value to \p Symbol.
509507
///
510508
/// 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, MCDataFragment &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
@@ -46,7 +46,6 @@ class MCWinCOFFStreamer : public MCObjectStreamer {
4646
void changeSection(MCSection *Section, uint32_t Subsection = 0) override;
4747
void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
4848
void emitAssemblerFlag(MCAssemblerFlag Flag) override;
49-
void emitThumbFunc(MCSymbol *Func) override;
5049
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
5150
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
5251
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
@@ -191,7 +191,6 @@ class MCAsmStreamer final : public MCStreamer {
191191
void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major,
192192
unsigned Minor, unsigned Update,
193193
VersionTuple SDKVersion) override;
194-
void emitThumbFunc(MCSymbol *Func) override;
195194

196195
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
197196
void emitConditionalAssignment(MCSymbol *Symbol,
@@ -697,18 +696,6 @@ void MCAsmStreamer::emitDarwinTargetVariantBuildVersion(
697696
emitBuildVersion(Platform, Major, Minor, Update, SDKVersion);
698697
}
699698

700-
void MCAsmStreamer::emitThumbFunc(MCSymbol *Func) {
701-
// This needs to emit to a temporary string to get properly quoted
702-
// MCSymbols when they have spaces in them.
703-
OS << "\t.thumb_func";
704-
// Only Mach-O hasSubsectionsViaSymbols()
705-
if (MAI->hasSubsectionsViaSymbols()) {
706-
OS << '\t';
707-
Func->print(OS, MAI);
708-
}
709-
EmitEOL();
710-
}
711-
712699
void MCAsmStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
713700
// Do not emit a .set on inlined target assignments.
714701
bool EmitSet = true;

llvm/lib/MC/MCELFStreamer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -616,10 +616,6 @@ void MCELFStreamer::finishImpl() {
616616
this->MCObjectStreamer::finishImpl();
617617
}
618618

619-
void MCELFStreamer::emitThumbFunc(MCSymbol *Func) {
620-
llvm_unreachable("Generic ELF doesn't support this directive");
621-
}
622-
623619
void MCELFStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
624620
llvm_unreachable("ELF doesn't support this directive");
625621
}

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,
@@ -269,13 +268,6 @@ void MCMachOStreamer::emitDarwinTargetVariantBuildVersion(
269268
Minor, Update, SDKVersion);
270269
}
271270

272-
void MCMachOStreamer::emitThumbFunc(MCSymbol *Symbol) {
273-
// Remember that the function is a thumb function. Fixup and relocation
274-
// values will need adjusted.
275-
getAssembler().setIsThumbFunc(Symbol);
276-
cast<MCSymbolMachO>(Symbol)->setThumbFunc();
277-
}
278-
279271
bool MCMachOStreamer::emitSymbolAttribute(MCSymbol *Sym,
280272
MCSymbolAttr Attribute) {
281273
MCSymbolMachO *Symbol = cast<MCSymbolMachO>(Sym);

llvm/lib/MC/MCStreamer.cpp

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

12311231
void MCStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {}
1232-
void MCStreamer::emitThumbFunc(MCSymbol *Func) {}
12331232
void MCStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {}
12341233
void MCStreamer::beginCOFFSymbolDef(const MCSymbol *Symbol) {
12351234
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
@@ -238,10 +238,6 @@ void MCWasmStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
238238
}
239239
}
240240

241-
void MCWasmStreamer::emitThumbFunc(MCSymbol *Func) {
242-
llvm_unreachable("Generic Wasm doesn't support this directive");
243-
}
244-
245241
void MCWasmStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
246242
llvm_unreachable("Wasm doesn't support this directive");
247243
}

0 commit comments

Comments
 (0)