forked from OSchip/llvm-project
parent
962c5bd803
commit
a61e93d4b5
|
@ -25,6 +25,7 @@ namespace llvm {
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
class StringRef;
|
class StringRef;
|
||||||
class raw_ostream;
|
class raw_ostream;
|
||||||
|
class TargetAsmInfo;
|
||||||
|
|
||||||
/// MCStreamer - Streaming machine code generation interface. This interface
|
/// MCStreamer - Streaming machine code generation interface. This interface
|
||||||
/// is intended to provide a programatic interface that is very similar to the
|
/// is intended to provide a programatic interface that is very similar to the
|
||||||
|
@ -232,7 +233,7 @@ namespace llvm {
|
||||||
///
|
///
|
||||||
/// \arg AP - If given, an AsmPrinter to use for printing instructions.
|
/// \arg AP - If given, an AsmPrinter to use for printing instructions.
|
||||||
MCStreamer *createAsmStreamer(MCContext &Ctx, raw_ostream &OS,
|
MCStreamer *createAsmStreamer(MCContext &Ctx, raw_ostream &OS,
|
||||||
AsmPrinter *AP = 0);
|
const TargetAsmInfo &TAI, AsmPrinter *AP = 0);
|
||||||
|
|
||||||
// FIXME: These two may end up getting rolled into a single
|
// FIXME: These two may end up getting rolled into a single
|
||||||
// createObjectStreamer interface, which implements the assembler backend, and
|
// createObjectStreamer interface, which implements the assembler backend, and
|
||||||
|
|
|
@ -59,7 +59,7 @@ AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
|
||||||
TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
|
TM(tm), TAI(T), TRI(tm.getRegisterInfo()),
|
||||||
|
|
||||||
OutContext(*new MCContext()),
|
OutContext(*new MCContext()),
|
||||||
OutStreamer(*createAsmStreamer(OutContext, O)),
|
OutStreamer(*createAsmStreamer(OutContext, O, *T, this)),
|
||||||
|
|
||||||
LastMI(0), LastFn(0), Counter(~0U),
|
LastMI(0), LastFn(0), Counter(~0U),
|
||||||
PrevDLT(0, ~0U, ~0U) {
|
PrevDLT(0, ~0U, ~0U) {
|
||||||
|
|
|
@ -22,11 +22,14 @@ namespace {
|
||||||
|
|
||||||
class MCAsmStreamer : public MCStreamer {
|
class MCAsmStreamer : public MCStreamer {
|
||||||
raw_ostream &OS;
|
raw_ostream &OS;
|
||||||
|
const TargetAsmInfo &TAI;
|
||||||
AsmPrinter *Printer;
|
AsmPrinter *Printer;
|
||||||
MCSection *CurSection;
|
MCSection *CurSection;
|
||||||
public:
|
public:
|
||||||
MCAsmStreamer(MCContext &Context, raw_ostream &_OS, AsmPrinter *_AsmPrinter)
|
MCAsmStreamer(MCContext &Context, raw_ostream &_OS, const TargetAsmInfo &tai,
|
||||||
: MCStreamer(Context), OS(_OS), Printer(_AsmPrinter), CurSection(0) {}
|
AsmPrinter *_AsmPrinter)
|
||||||
|
: MCStreamer(Context), OS(_OS), TAI(tai), Printer(_AsmPrinter),
|
||||||
|
CurSection(0) {}
|
||||||
~MCAsmStreamer() {}
|
~MCAsmStreamer() {}
|
||||||
|
|
||||||
/// @name MCStreamer Interface
|
/// @name MCStreamer Interface
|
||||||
|
@ -293,6 +296,6 @@ void MCAsmStreamer::Finish() {
|
||||||
}
|
}
|
||||||
|
|
||||||
MCStreamer *llvm::createAsmStreamer(MCContext &Context, raw_ostream &OS,
|
MCStreamer *llvm::createAsmStreamer(MCContext &Context, raw_ostream &OS,
|
||||||
AsmPrinter *AP) {
|
const TargetAsmInfo &TAI, AsmPrinter *AP) {
|
||||||
return new MCAsmStreamer(Context, OS, AP);
|
return new MCAsmStreamer(Context, OS, TAI, AP);
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,21 +211,21 @@ static int AssembleInput(const char *ProgName) {
|
||||||
if (!Out)
|
if (!Out)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
// See if we can get an asm printer.
|
|
||||||
OwningPtr<AsmPrinter> AP(0);
|
|
||||||
|
|
||||||
// FIXME: We shouldn't need to do this (and link in codegen).
|
// FIXME: We shouldn't need to do this (and link in codegen).
|
||||||
OwningPtr<TargetMachine> TM(TheTarget->createTargetMachine(TripleName, ""));
|
OwningPtr<TargetMachine> TM(TheTarget->createTargetMachine(TripleName, ""));
|
||||||
const TargetAsmInfo *TAI = 0;
|
|
||||||
|
|
||||||
if (TM) {
|
if (!TM) {
|
||||||
TAI = TheTarget->createAsmInfo(TripleName);
|
errs() << ProgName << ": error: could not create target for triple '"
|
||||||
assert(TAI && "Unable to create target asm info!");
|
<< TripleName << "'.\n";
|
||||||
|
return 1;
|
||||||
AP.reset(TheTarget->createAsmPrinter(*Out, *TM, TAI, true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OwningPtr<MCStreamer> Str(createAsmStreamer(Ctx, *Out, AP.get()));
|
const TargetAsmInfo *TAI = TheTarget->createAsmInfo(TripleName);
|
||||||
|
assert(TAI && "Unable to create target asm info!");
|
||||||
|
|
||||||
|
OwningPtr<AsmPrinter> AP(TheTarget->createAsmPrinter(*Out, *TM, TAI, true));
|
||||||
|
OwningPtr<MCStreamer> Str(createAsmStreamer(Ctx, *Out, *TAI, AP.get()));
|
||||||
|
|
||||||
// FIXME: Target hook & command line option for initial section.
|
// FIXME: Target hook & command line option for initial section.
|
||||||
Str.get()->SwitchSection(MCSectionMachO::Create("__TEXT","__text",
|
Str.get()->SwitchSection(MCSectionMachO::Create("__TEXT","__text",
|
||||||
|
|
Loading…
Reference in New Issue