|
7 | 7 | //===----------------------------------------------------------------------===// |
8 | 8 |
|
9 | 9 | #include "MCTargetDesc/X86BaseInfo.h" |
10 | | -#include "MCTargetDesc/X86FixupKinds.h" |
11 | 10 | #include "MCTargetDesc/X86EncodingOptimization.h" |
| 11 | +#include "MCTargetDesc/X86FixupKinds.h" |
12 | 12 | #include "llvm/ADT/StringSwitch.h" |
13 | 13 | #include "llvm/BinaryFormat/ELF.h" |
14 | 14 | #include "llvm/BinaryFormat/MachO.h" |
|
19 | 19 | #include "llvm/MC/MCContext.h" |
20 | 20 | #include "llvm/MC/MCDwarf.h" |
21 | 21 | #include "llvm/MC/MCELFObjectWriter.h" |
| 22 | +#include "llvm/MC/MCELFStreamer.h" |
22 | 23 | #include "llvm/MC/MCExpr.h" |
23 | 24 | #include "llvm/MC/MCFixupKindInfo.h" |
24 | 25 | #include "llvm/MC/MCInst.h" |
@@ -162,8 +163,8 @@ class X86AsmBackend : public MCAsmBackend { |
162 | 163 | bool allowAutoPadding() const override; |
163 | 164 | bool allowEnhancedRelaxation() const override; |
164 | 165 | void emitInstructionBegin(MCObjectStreamer &OS, const MCInst &Inst, |
165 | | - const MCSubtargetInfo &STI) override; |
166 | | - void emitInstructionEnd(MCObjectStreamer &OS, const MCInst &Inst) override; |
| 166 | + const MCSubtargetInfo &STI); |
| 167 | + void emitInstructionEnd(MCObjectStreamer &OS, const MCInst &Inst); |
167 | 168 |
|
168 | 169 | unsigned getNumFixupKinds() const override { |
169 | 170 | return X86::NumTargetFixupKinds; |
@@ -1546,3 +1547,37 @@ MCAsmBackend *llvm::createX86_64AsmBackend(const Target &T, |
1546 | 1547 | return new ELFX86_X32AsmBackend(T, OSABI, STI); |
1547 | 1548 | return new ELFX86_64AsmBackend(T, OSABI, STI); |
1548 | 1549 | } |
| 1550 | + |
| 1551 | +namespace { |
| 1552 | +class X86ELFStreamer : public MCELFStreamer { |
| 1553 | +public: |
| 1554 | + X86ELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB, |
| 1555 | + std::unique_ptr<MCObjectWriter> OW, |
| 1556 | + std::unique_ptr<MCCodeEmitter> Emitter) |
| 1557 | + : MCELFStreamer(Context, std::move(TAB), std::move(OW), |
| 1558 | + std::move(Emitter)) {} |
| 1559 | + |
| 1560 | + void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override; |
| 1561 | +}; |
| 1562 | +} // end anonymous namespace |
| 1563 | + |
| 1564 | +void X86_MC::emitInstruction(MCObjectStreamer &S, const MCInst &Inst, |
| 1565 | + const MCSubtargetInfo &STI) { |
| 1566 | + auto &Backend = static_cast<X86AsmBackend &>(S.getAssembler().getBackend()); |
| 1567 | + Backend.emitInstructionBegin(S, Inst, STI); |
| 1568 | + S.MCObjectStreamer::emitInstruction(Inst, STI); |
| 1569 | + Backend.emitInstructionEnd(S, Inst); |
| 1570 | +} |
| 1571 | + |
| 1572 | +void X86ELFStreamer::emitInstruction(const MCInst &Inst, |
| 1573 | + const MCSubtargetInfo &STI) { |
| 1574 | + X86_MC::emitInstruction(*this, Inst, STI); |
| 1575 | +} |
| 1576 | + |
| 1577 | +MCStreamer *llvm::createX86ELFStreamer(const Triple &T, MCContext &Context, |
| 1578 | + std::unique_ptr<MCAsmBackend> &&MAB, |
| 1579 | + std::unique_ptr<MCObjectWriter> &&MOW, |
| 1580 | + std::unique_ptr<MCCodeEmitter> &&MCE) { |
| 1581 | + return new X86ELFStreamer(Context, std::move(MAB), std::move(MOW), |
| 1582 | + std::move(MCE)); |
| 1583 | +} |
0 commit comments