mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-13 22:58:50 +00:00
MC: Sink code emitter into MCAssembler.
llvm-svn: 98953
This commit is contained in:
parent
74330a6389
commit
c47468760e
@ -24,6 +24,7 @@ class raw_ostream;
|
||||
class MCAsmLayout;
|
||||
class MCAssembler;
|
||||
class MCContext;
|
||||
class MCCodeEmitter;
|
||||
class MCExpr;
|
||||
class MCFragment;
|
||||
class MCObjectWriter;
|
||||
@ -598,6 +599,8 @@ private:
|
||||
|
||||
TargetAsmBackend &Backend;
|
||||
|
||||
MCCodeEmitter &Emitter;
|
||||
|
||||
raw_ostream &OS;
|
||||
|
||||
iplist<MCSectionData> Sections;
|
||||
@ -683,13 +686,16 @@ public:
|
||||
// concrete and require clients to pass in a target like object. The other
|
||||
// option is to make this abstract, and have targets provide concrete
|
||||
// implementations as we do with AsmParser.
|
||||
MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend, raw_ostream &OS);
|
||||
MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend,
|
||||
MCCodeEmitter &_Emitter, raw_ostream &OS);
|
||||
~MCAssembler();
|
||||
|
||||
MCContext &getContext() const { return Context; }
|
||||
|
||||
TargetAsmBackend &getBackend() const { return Backend; }
|
||||
|
||||
MCCodeEmitter &getEmitter() const { return Emitter; }
|
||||
|
||||
/// Finish - Do final processing and write the object to the output stream.
|
||||
void Finish();
|
||||
|
||||
|
@ -103,8 +103,9 @@ MCSymbolData::MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment,
|
||||
/* *** */
|
||||
|
||||
MCAssembler::MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend,
|
||||
raw_ostream &_OS)
|
||||
: Context(_Context), Backend(_Backend), OS(_OS), SubsectionsViaSymbols(false)
|
||||
MCCodeEmitter &_Emitter, raw_ostream &_OS)
|
||||
: Context(_Context), Backend(_Backend), Emitter(_Emitter),
|
||||
OS(_OS), SubsectionsViaSymbols(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,6 @@ class MCMachOStreamer : public MCStreamer {
|
||||
|
||||
private:
|
||||
MCAssembler Assembler;
|
||||
MCCodeEmitter *Emitter;
|
||||
MCSectionData *CurSectionData;
|
||||
|
||||
private:
|
||||
@ -61,7 +60,7 @@ private:
|
||||
public:
|
||||
MCMachOStreamer(MCContext &Context, TargetAsmBackend &TAB,
|
||||
raw_ostream &_OS, MCCodeEmitter *_Emitter)
|
||||
: MCStreamer(Context), Assembler(Context, TAB, _OS), Emitter(_Emitter),
|
||||
: MCStreamer(Context), Assembler(Context, TAB, *_Emitter, _OS),
|
||||
CurSectionData(0) {}
|
||||
~MCMachOStreamer() {}
|
||||
|
||||
@ -370,15 +369,12 @@ void MCMachOStreamer::EmitInstruction(const MCInst &Inst) {
|
||||
if (Inst.getOperand(i).isExpr())
|
||||
AddValueSymbols(Inst.getOperand(i).getExpr());
|
||||
|
||||
if (!Emitter)
|
||||
llvm_unreachable("no code emitter available!");
|
||||
|
||||
CurSectionData->setHasInstructions(true);
|
||||
|
||||
SmallVector<MCFixup, 4> Fixups;
|
||||
SmallString<256> Code;
|
||||
raw_svector_ostream VecOS(Code);
|
||||
Emitter->EncodeInstruction(Inst, VecOS, Fixups);
|
||||
Assembler.getEmitter().EncodeInstruction(Inst, VecOS, Fixups);
|
||||
VecOS.flush();
|
||||
|
||||
// Add the fixups and data.
|
||||
|
Loading…
Reference in New Issue
Block a user