Remove an easy use of EmitRawText from PPC.

This makes lib/Target/PowerPC EmitRawText free.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200065 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2014-01-25 02:35:56 +00:00
parent 8fe060da52
commit f961273b79
4 changed files with 19 additions and 7 deletions

View File

@ -9,6 +9,7 @@
#include "MCTargetDesc/PPCMCTargetDesc.h" #include "MCTargetDesc/PPCMCTargetDesc.h"
#include "MCTargetDesc/PPCMCExpr.h" #include "MCTargetDesc/PPCMCExpr.h"
#include "PPCTargetStreamer.h"
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h" #include "llvm/ADT/SmallVector.h"
@ -1436,6 +1437,10 @@ bool PPCAsmParser::ParseDirectiveMachine(SMLoc L) {
Error(L, "unexpected token in directive"); Error(L, "unexpected token in directive");
return false; return false;
} }
PPCTargetStreamer &TStreamer =
*static_cast<PPCTargetStreamer *>(
getParser().getStreamer().getTargetStreamer());
TStreamer.emitMachine(CPU);
return false; return false;
} }

View File

@ -120,6 +120,9 @@ public:
OS << S.getName(); OS << S.getName();
OS << '\n'; OS << '\n';
} }
virtual void emitMachine(StringRef CPU) {
OS << "\t.machine " << CPU << '\n';
}
}; };
class PPCTargetELFStreamer : public PPCTargetStreamer { class PPCTargetELFStreamer : public PPCTargetStreamer {
@ -127,6 +130,10 @@ class PPCTargetELFStreamer : public PPCTargetStreamer {
// Creates a R_PPC64_TOC relocation // Creates a R_PPC64_TOC relocation
Streamer->EmitSymbolValue(&S, 8); Streamer->EmitSymbolValue(&S, 8);
} }
virtual void emitMachine(StringRef CPU) {
// FIXME: Is there anything to do in here or does this directive only
// limit the parser?
}
}; };
} }

View File

@ -850,13 +850,12 @@ void PPCDarwinAsmPrinter::EmitStartOfAsmFile(Module &M) {
if (Subtarget.isPPC64() && Directive < PPC::DIR_64) if (Subtarget.isPPC64() && Directive < PPC::DIR_64)
Directive = PPC::DIR_64; Directive = PPC::DIR_64;
assert(Directive <= PPC::DIR_64 && "Directive out of range."); assert(Directive <= PPC::DIR_64 && "Directive out of range.");
// FIXME: This is a total hack, finish mc'izing the PPC backend. assert(Directive < array_lengthof(CPUDirectives) &&
if (OutStreamer.hasRawTextSupport()) { "CPUDirectives[] might not be up-to-date!");
assert(Directive < array_lengthof(CPUDirectives) && PPCTargetStreamer &TStreamer =
"CPUDirectives[] might not be up-to-date!"); *static_cast<PPCTargetStreamer *>(OutStreamer.getTargetStreamer());
OutStreamer.EmitRawText("\t.machine " + Twine(CPUDirectives[Directive])); TStreamer.emitMachine(CPUDirectives[Directive]);
}
// Prime text sections so they are adjacent. This reduces the likelihood a // Prime text sections so they are adjacent. This reduces the likelihood a
// large data or debug section causes a branch to exceed 16M limit. // large data or debug section causes a branch to exceed 16M limit.

View File

@ -17,6 +17,7 @@ class PPCTargetStreamer : public MCTargetStreamer {
public: public:
virtual ~PPCTargetStreamer(); virtual ~PPCTargetStreamer();
virtual void emitTCEntry(const MCSymbol &S) = 0; virtual void emitTCEntry(const MCSymbol &S) = 0;
virtual void emitMachine(StringRef CPU) = 0;
}; };
} }