PowerPC: add EmitTCEntry class for TOC creation

This patch replaces the EmitRawText by a EmitTCEntry class (specialized for
each Streamer) in PowerPC64 TOC entry creation.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165940 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Adhemerval Zanella 2012-10-15 15:43:14 +00:00
parent 2611eeda98
commit f35c62bf02
5 changed files with 28 additions and 2 deletions

View File

@ -554,6 +554,11 @@ namespace llvm {
virtual void EmitRegSave(const SmallVectorImpl<unsigned> &RegList,
bool isVector);
/// PPC-related methods.
/// FIXME: Eventually replace it with some "target MC streamer" and move
/// these methods there.
virtual void EmitTCEntry(const MCSymbol &S);
/// FinishImpl - Streamer specific finalization.
virtual void FinishImpl() = 0;
/// Finish - Finish emission of machine code.

View File

@ -251,6 +251,7 @@ public:
virtual void EmitPad(int64_t Offset);
virtual void EmitRegSave(const SmallVectorImpl<unsigned> &RegList, bool);
virtual void EmitTCEntry(const MCSymbol &S);
virtual void EmitInstruction(const MCInst &Inst);
@ -1299,6 +1300,14 @@ void MCAsmStreamer::EmitRegSave(const SmallVectorImpl<unsigned> &RegList,
EmitEOL();
}
void MCAsmStreamer::EmitTCEntry(const MCSymbol &S) {
OS << "\t.tc ";
OS << S.getName();
OS << "[TC],";
OS << S.getName();
EmitEOL();
}
void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
assert(getCurrentSection() && "Cannot emit contents before setting section!");

View File

@ -103,6 +103,8 @@ public:
virtual void EmitFileDirective(StringRef Filename);
virtual void EmitTCEntry(const MCSymbol &S);
virtual void FinishImpl();
private:
@ -469,6 +471,12 @@ void MCELFStreamer::FinishImpl() {
this->MCObjectStreamer::FinishImpl();
}
void MCELFStreamer::EmitTCEntry(const MCSymbol &S)
{
// Creates a R_PPC64_TOC relocation
MCObjectStreamer::EmitSymbolValue(&S, 8, 0);
}
MCStreamer *llvm::createELFStreamer(MCContext &Context, MCAsmBackend &MAB,
raw_ostream &OS, MCCodeEmitter *CE,
bool RelaxAll, bool NoExecStack) {

View File

@ -561,6 +561,10 @@ void MCStreamer::EmitRegSave(const SmallVectorImpl<unsigned> &RegList, bool) {
abort();
}
void MCStreamer::EmitTCEntry(const MCSymbol &S) {
llvm_unreachable("Unsupported method");
}
/// EmitRawText - If this file is backed by an assembly streamer, this dumps
/// the specified string in the output .s file. This capability is
/// indicated by the hasRawTextSupport() predicate.

View File

@ -451,8 +451,8 @@ bool PPCLinuxAsmPrinter::doFinalization(Module &M) {
for (DenseMap<MCSymbol*, MCSymbol*>::iterator I = TOC.begin(),
E = TOC.end(); I != E; ++I) {
OutStreamer.EmitLabel(I->second);
OutStreamer.EmitRawText("\t.tc " + Twine(I->first->getName()) +
"[TC]," + I->first->getName());
MCSymbol *S = OutContext.GetOrCreateSymbol(I->first->getName());
OutStreamer.EmitTCEntry(*S);
}
}