Skip to content

Commit 31bf16a

Browse files
committed
[MC] Add MCTargetStreamer::getContext to simplify code
1 parent dcca3f4 commit 31bf16a

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

llvm/include/llvm/MC/MCStreamer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class MCTargetStreamer {
100100
virtual ~MCTargetStreamer();
101101

102102
MCStreamer &getStreamer() { return Streamer; }
103+
MCContext &getContext();
103104

104105
// Allow a target to add behavior to the EmitLabel of MCStreamer.
105106
virtual void emitLabel(MCSymbol *Symbol);
@@ -1157,6 +1158,10 @@ class MCStreamer {
11571158
unsigned PointerSize) {}
11581159
};
11591160

1161+
inline MCContext &MCTargetStreamer::getContext() {
1162+
return Streamer.getContext();
1163+
}
1164+
11601165
/// Create a dummy machine code streamer, which does nothing. This is useful for
11611166
/// timing the assembler front end.
11621167
MCStreamer *createNullStreamer(MCContext &Ctx);

llvm/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ void ARMTargetELFStreamer::finish() {
11381138
// section from making the whole .text section non-execute-only, we
11391139
// mark it execute-only if it is empty and there is at least one
11401140
// execute-only section in the object.
1141-
MCContext &Ctx = getStreamer().getContext();
1141+
MCContext &Ctx = getContext();
11421142
auto &Asm = getStreamer().getAssembler();
11431143
if (any_of(Asm, [](const MCSection &Sec) {
11441144
return cast<MCSectionELF>(Sec).getFlags() & ELF::SHF_ARM_PURECODE;

llvm/lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void ARMTargetStreamer::reset() {}
5252
void ARMTargetStreamer::emitInst(uint32_t Inst, char Suffix) {
5353
unsigned Size;
5454
char Buffer[4];
55-
const bool LittleEndian = getStreamer().getContext().getAsmInfo()->isLittleEndian();
55+
const bool LittleEndian = getContext().getAsmInfo()->isLittleEndian();
5656

5757
switch (Suffix) {
5858
case '\0':

llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4290,7 +4290,7 @@ bool MipsAsmParser::expandDivRem(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
42904290
}
42914291

42924292
// Temporary label for first branch traget
4293-
MCContext &Context = TOut.getStreamer().getContext();
4293+
MCContext &Context = TOut.getContext();
42944294
MCSymbol *BrTarget;
42954295
MCOperand LabelOp;
42964296

@@ -5222,7 +5222,7 @@ bool MipsAsmParser::expandMulO(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
52225222
if (useTraps()) {
52235223
TOut.emitRRI(Mips::TNE, DstReg, ATReg, 6, IDLoc, STI);
52245224
} else {
5225-
MCContext & Context = TOut.getStreamer().getContext();
5225+
MCContext &Context = TOut.getContext();
52265226
MCSymbol * BrTarget = Context.createTempSymbol();
52275227
MCOperand LabelOp =
52285228
MCOperand::createExpr(MCSymbolRefExpr::create(BrTarget, Context));
@@ -5259,7 +5259,7 @@ bool MipsAsmParser::expandMulOU(MCInst &Inst, SMLoc IDLoc, MCStreamer &Out,
52595259
if (useTraps()) {
52605260
TOut.emitRRI(Mips::TNE, ATReg, Mips::ZERO, 6, IDLoc, STI);
52615261
} else {
5262-
MCContext & Context = TOut.getStreamer().getContext();
5262+
MCContext &Context = TOut.getContext();
52635263
MCSymbol * BrTarget = Context.createTempSymbol();
52645264
MCOperand LabelOp =
52655265
MCOperand::createExpr(MCSymbolRefExpr::create(BrTarget, Context));

llvm/lib/Target/X86/MCTargetDesc/X86WinCOFFTargetStreamer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,6 @@ class X86WinCOFFTargetStreamer : public X86TargetStreamer {
8080

8181
MCSymbol *emitFPOLabel();
8282

83-
MCContext &getContext() { return getStreamer().getContext(); }
84-
8583
public:
8684
X86WinCOFFTargetStreamer(MCStreamer &S) : X86TargetStreamer(S) {}
8785

@@ -100,7 +98,7 @@ class X86WinCOFFTargetStreamer : public X86TargetStreamer {
10098
bool X86WinCOFFAsmTargetStreamer::emitFPOProc(const MCSymbol *ProcSym,
10199
unsigned ParamsSize, SMLoc L) {
102100
OS << "\t.cv_fpo_proc\t";
103-
ProcSym->print(OS, getStreamer().getContext().getAsmInfo());
101+
ProcSym->print(OS, getContext().getAsmInfo());
104102
OS << ' ' << ParamsSize << '\n';
105103
return false;
106104
}

0 commit comments

Comments
 (0)