mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
Make use of the new AssemblyAnnotationWriter interface
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9619 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
#include "llvm/Assembly/CachedWriter.h"
|
#include "llvm/Assembly/CachedWriter.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
#include "llvm/Assembly/PrintModulePass.h"
|
#include "llvm/Assembly/PrintModulePass.h"
|
||||||
|
#include "llvm/Assembly/AsmAnnotationWriter.h"
|
||||||
#include "llvm/SlotCalculator.h"
|
#include "llvm/SlotCalculator.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "llvm/Instruction.h"
|
#include "llvm/Instruction.h"
|
||||||
@@ -466,9 +467,11 @@ class AssemblyWriter {
|
|||||||
SlotCalculator &Table;
|
SlotCalculator &Table;
|
||||||
const Module *TheModule;
|
const Module *TheModule;
|
||||||
std::map<const Type *, std::string> TypeNames;
|
std::map<const Type *, std::string> TypeNames;
|
||||||
|
AssemblyAnnotationWriter *AnnotationWriter;
|
||||||
public:
|
public:
|
||||||
inline AssemblyWriter(std::ostream &o, SlotCalculator &Tab, const Module *M)
|
inline AssemblyWriter(std::ostream &o, SlotCalculator &Tab, const Module *M,
|
||||||
: Out(o), Table(Tab), TheModule(M) {
|
AssemblyAnnotationWriter *AAW)
|
||||||
|
: Out(o), Table(Tab), TheModule(M), AnnotationWriter(AAW) {
|
||||||
|
|
||||||
// If the module has a symbol table, take all global types and stuff their
|
// If the module has a symbol table, take all global types and stuff their
|
||||||
// names into the TypeNames map.
|
// names into the TypeNames map.
|
||||||
@@ -662,6 +665,8 @@ void AssemblyWriter::printFunction(const Function *F) {
|
|||||||
// Print out the return type and name...
|
// Print out the return type and name...
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
|
|
||||||
|
if (AnnotationWriter) AnnotationWriter->emitFunctionAnnot(F, Out);
|
||||||
|
|
||||||
if (F->isExternal())
|
if (F->isExternal())
|
||||||
Out << "declare ";
|
Out << "declare ";
|
||||||
else
|
else
|
||||||
@@ -757,6 +762,8 @@ void AssemblyWriter::printBasicBlock(const BasicBlock *BB) {
|
|||||||
|
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
|
|
||||||
|
if (AnnotationWriter) AnnotationWriter->emitBasicBlockAnnot(BB, Out);
|
||||||
|
|
||||||
// Output all of the instructions in the basic block...
|
// Output all of the instructions in the basic block...
|
||||||
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
|
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I)
|
||||||
printInstruction(*I);
|
printInstruction(*I);
|
||||||
@@ -783,6 +790,8 @@ void AssemblyWriter::printInfoComment(const Value &V) {
|
|||||||
// printInstruction - This member is called for each Instruction in a method.
|
// printInstruction - This member is called for each Instruction in a method.
|
||||||
//
|
//
|
||||||
void AssemblyWriter::printInstruction(const Instruction &I) {
|
void AssemblyWriter::printInstruction(const Instruction &I) {
|
||||||
|
if (AnnotationWriter) AnnotationWriter->emitInstructionAnnot(&I, Out);
|
||||||
|
|
||||||
Out << "\t";
|
Out << "\t";
|
||||||
|
|
||||||
// Print out name if it exists...
|
// Print out name if it exists...
|
||||||
@@ -947,37 +956,36 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
|
|||||||
// External Interface declarations
|
// External Interface declarations
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
void Module::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
|
||||||
void Module::print(std::ostream &o) const {
|
|
||||||
SlotCalculator SlotTable(this, true);
|
SlotCalculator SlotTable(this, true);
|
||||||
AssemblyWriter W(o, SlotTable, this);
|
AssemblyWriter W(o, SlotTable, this, AAW);
|
||||||
W.write(this);
|
W.write(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalVariable::print(std::ostream &o) const {
|
void GlobalVariable::print(std::ostream &o) const {
|
||||||
SlotCalculator SlotTable(getParent(), true);
|
SlotCalculator SlotTable(getParent(), true);
|
||||||
AssemblyWriter W(o, SlotTable, getParent());
|
AssemblyWriter W(o, SlotTable, getParent(), 0);
|
||||||
W.write(this);
|
W.write(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Function::print(std::ostream &o) const {
|
void Function::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
|
||||||
SlotCalculator SlotTable(getParent(), true);
|
SlotCalculator SlotTable(getParent(), true);
|
||||||
AssemblyWriter W(o, SlotTable, getParent());
|
AssemblyWriter W(o, SlotTable, getParent(), AAW);
|
||||||
|
|
||||||
W.write(this);
|
W.write(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BasicBlock::print(std::ostream &o) const {
|
void BasicBlock::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
|
||||||
SlotCalculator SlotTable(getParent(), true);
|
SlotCalculator SlotTable(getParent(), true);
|
||||||
AssemblyWriter W(o, SlotTable,
|
AssemblyWriter W(o, SlotTable,
|
||||||
getParent() ? getParent()->getParent() : 0);
|
getParent() ? getParent()->getParent() : 0, AAW);
|
||||||
W.write(this);
|
W.write(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instruction::print(std::ostream &o) const {
|
void Instruction::print(std::ostream &o, AssemblyAnnotationWriter *AAW) const {
|
||||||
const Function *F = getParent() ? getParent()->getParent() : 0;
|
const Function *F = getParent() ? getParent()->getParent() : 0;
|
||||||
SlotCalculator SlotTable(F, true);
|
SlotCalculator SlotTable(F, true);
|
||||||
AssemblyWriter W(o, SlotTable, F ? F->getParent() : 0);
|
AssemblyWriter W(o, SlotTable, F ? F->getParent() : 0, AAW);
|
||||||
|
|
||||||
W.write(this);
|
W.write(this);
|
||||||
}
|
}
|
||||||
@@ -1018,7 +1026,7 @@ void CachedWriter::setModule(const Module *M) {
|
|||||||
delete SC; delete AW;
|
delete SC; delete AW;
|
||||||
if (M) {
|
if (M) {
|
||||||
SC = new SlotCalculator(M, true);
|
SC = new SlotCalculator(M, true);
|
||||||
AW = new AssemblyWriter(Out, *SC, M);
|
AW = new AssemblyWriter(Out, *SC, M, 0);
|
||||||
} else {
|
} else {
|
||||||
SC = 0; AW = 0;
|
SC = 0; AW = 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user