mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
MC: Provide MCAssembler with a TargetAsmBackend.
llvm-svn: 98222
This commit is contained in:
parent
f7f88fba2d
commit
687d99cfa8
@ -28,6 +28,7 @@ class MCFragment;
|
||||
class MCSection;
|
||||
class MCSectionData;
|
||||
class MCSymbol;
|
||||
class TargetAsmBackend;
|
||||
|
||||
/// MCAsmFixup - Represent a fixed size region of bytes inside some fragment
|
||||
/// which needs to be rewritten. This region will either be rewritten by the
|
||||
@ -582,6 +583,8 @@ private:
|
||||
|
||||
MCContext &Context;
|
||||
|
||||
TargetAsmBackend &Backend;
|
||||
|
||||
raw_ostream &OS;
|
||||
|
||||
iplist<MCSectionData> Sections;
|
||||
@ -617,7 +620,7 @@ 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, raw_ostream &OS);
|
||||
MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend, raw_ostream &OS);
|
||||
~MCAssembler();
|
||||
|
||||
MCContext &getContext() const { return Context; }
|
||||
|
@ -27,6 +27,7 @@ namespace llvm {
|
||||
class MCSection;
|
||||
class MCSymbol;
|
||||
class StringRef;
|
||||
class TargetAsmBackend;
|
||||
class Twine;
|
||||
class raw_ostream;
|
||||
class formatted_raw_ostream;
|
||||
@ -304,18 +305,10 @@ namespace llvm {
|
||||
MCCodeEmitter *CE = 0,
|
||||
bool ShowInst = false);
|
||||
|
||||
// FIXME: These two may end up getting rolled into a single
|
||||
// createObjectStreamer interface, which implements the assembler backend, and
|
||||
// is parameterized on an output object file writer.
|
||||
|
||||
/// createMachOStream - Create a machine code streamer which will generative
|
||||
/// Mach-O format object files.
|
||||
MCStreamer *createMachOStreamer(MCContext &Ctx, raw_ostream &OS,
|
||||
MCCodeEmitter *CE);
|
||||
|
||||
/// createELFStreamer - Create a machine code streamer which will generative
|
||||
/// ELF format object files.
|
||||
MCStreamer *createELFStreamer(MCContext &Ctx, raw_ostream &OS);
|
||||
MCStreamer *createMachOStreamer(MCContext &Ctx, TargetAsmBackend &TAB,
|
||||
raw_ostream &OS, MCCodeEmitter *CE);
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
|
@ -224,6 +224,8 @@ public:
|
||||
/// implemented with the LLVM target-independent code generator.
|
||||
///
|
||||
class LLVMTargetMachine : public TargetMachine {
|
||||
std::string TargetTriple;
|
||||
|
||||
protected: // Can only create subclasses.
|
||||
LLVMTargetMachine(const Target &T, const std::string &TargetTriple);
|
||||
|
||||
|
@ -94,8 +94,8 @@ static cl::opt<bool> EnableSplitGEPGVN("split-gep-gvn", cl::Hidden,
|
||||
cl::desc("Split GEPs and run no-load GVN"));
|
||||
|
||||
LLVMTargetMachine::LLVMTargetMachine(const Target &T,
|
||||
const std::string &TargetTriple)
|
||||
: TargetMachine(T) {
|
||||
const std::string &Triple)
|
||||
: TargetMachine(T), TargetTriple(Triple) {
|
||||
AsmInfo = T.createAsmInfo(TargetTriple);
|
||||
}
|
||||
|
||||
@ -143,10 +143,11 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
|
||||
// Create the code emitter for the target if it exists. If not, .o file
|
||||
// emission fails.
|
||||
MCCodeEmitter *MCE = getTarget().createCodeEmitter(*this, *Context);
|
||||
if (MCE == 0)
|
||||
TargetAsmBackend *TAB = getTarget().createAsmBackend(TargetTriple);
|
||||
if (MCE == 0 || TAB == 0)
|
||||
return true;
|
||||
|
||||
AsmStreamer.reset(createMachOStreamer(*Context, Out, MCE));
|
||||
AsmStreamer.reset(createMachOStreamer(*Context, *TAB, Out, MCE));
|
||||
|
||||
// Any output to the asmprinter's "O" stream is bad and needs to be fixed,
|
||||
// force it to come out stderr.
|
||||
|
@ -991,8 +991,9 @@ MCSymbolData::MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment,
|
||||
|
||||
/* *** */
|
||||
|
||||
MCAssembler::MCAssembler(MCContext &_Context, raw_ostream &_OS)
|
||||
: Context(_Context), OS(_OS), SubsectionsViaSymbols(false)
|
||||
MCAssembler::MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend,
|
||||
raw_ostream &_OS)
|
||||
: Context(_Context), Backend(_Backend), OS(_OS), SubsectionsViaSymbols(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -59,8 +59,9 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
MCMachOStreamer(MCContext &Context, raw_ostream &_OS, MCCodeEmitter *_Emitter)
|
||||
: MCStreamer(Context), Assembler(Context, _OS), Emitter(_Emitter),
|
||||
MCMachOStreamer(MCContext &Context, TargetAsmBackend &TAB,
|
||||
raw_ostream &_OS, MCCodeEmitter *_Emitter)
|
||||
: MCStreamer(Context), Assembler(Context, TAB, _OS), Emitter(_Emitter),
|
||||
CurSectionData(0) {}
|
||||
~MCMachOStreamer() {}
|
||||
|
||||
@ -398,7 +399,7 @@ void MCMachOStreamer::Finish() {
|
||||
Assembler.Finish();
|
||||
}
|
||||
|
||||
MCStreamer *llvm::createMachOStreamer(MCContext &Context, raw_ostream &OS,
|
||||
MCCodeEmitter *CE) {
|
||||
return new MCMachOStreamer(Context, OS, CE);
|
||||
MCStreamer *llvm::createMachOStreamer(MCContext &Context, TargetAsmBackend &TAB,
|
||||
raw_ostream &OS, MCCodeEmitter *CE) {
|
||||
return new MCMachOStreamer(Context, TAB, OS, CE);
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "llvm/Support/SourceMgr.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
#include "llvm/System/Signals.h"
|
||||
#include "llvm/Target/TargetAsmBackend.h"
|
||||
#include "llvm/Target/TargetAsmParser.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
@ -259,6 +260,7 @@ static int AssembleInput(const char *ProgName) {
|
||||
OwningPtr<MCInstPrinter> IP;
|
||||
OwningPtr<MCCodeEmitter> CE;
|
||||
OwningPtr<MCStreamer> Str;
|
||||
OwningPtr<TargetAsmBackend> TAB;
|
||||
|
||||
const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName);
|
||||
assert(MAI && "Unable to create target asm info!");
|
||||
@ -274,7 +276,8 @@ static int AssembleInput(const char *ProgName) {
|
||||
} else {
|
||||
assert(FileType == OFT_ObjectFile && "Invalid file type!");
|
||||
CE.reset(TheTarget->createCodeEmitter(*TM, Ctx));
|
||||
Str.reset(createMachOStreamer(Ctx, *Out, CE.get()));
|
||||
TAB.reset(TheTarget->createAsmBackend(TripleName));
|
||||
Str.reset(createMachOStreamer(Ctx, *TAB, *Out, CE.get()));
|
||||
}
|
||||
|
||||
AsmParser Parser(SrcMgr, Ctx, *Str.get(), *MAI);
|
||||
|
Loading…
Reference in New Issue
Block a user