mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-21 06:30:16 +00:00
Make various changes suggested by Chris.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79358 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
fc13d1c4d3
commit
fe37ab335b
@ -17,6 +17,7 @@
|
|||||||
#define LLVM_CODEGEN_ASMPRINTER_H
|
#define LLVM_CODEGEN_ASMPRINTER_H
|
||||||
|
|
||||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||||
|
#include "llvm/Support/DebugLoc.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
|
|
||||||
@ -24,15 +25,22 @@ namespace llvm {
|
|||||||
class GCStrategy;
|
class GCStrategy;
|
||||||
class Constant;
|
class Constant;
|
||||||
class ConstantArray;
|
class ConstantArray;
|
||||||
|
class ConstantFP;
|
||||||
class ConstantInt;
|
class ConstantInt;
|
||||||
class ConstantStruct;
|
class ConstantStruct;
|
||||||
class ConstantVector;
|
class ConstantVector;
|
||||||
class GCMetadataPrinter;
|
class GCMetadataPrinter;
|
||||||
|
class GlobalValue;
|
||||||
class GlobalVariable;
|
class GlobalVariable;
|
||||||
|
class MachineBasicBlock;
|
||||||
|
class MachineFunction;
|
||||||
|
class MachineInstr;
|
||||||
class MachineLoopInfo;
|
class MachineLoopInfo;
|
||||||
class MachineLoop;
|
class MachineLoop;
|
||||||
|
class MachineConstantPool;
|
||||||
class MachineConstantPoolEntry;
|
class MachineConstantPoolEntry;
|
||||||
class MachineConstantPoolValue;
|
class MachineConstantPoolValue;
|
||||||
|
class MachineJumpTableInfo;
|
||||||
class MachineModuleInfo;
|
class MachineModuleInfo;
|
||||||
class MCInst;
|
class MCInst;
|
||||||
class MCContext;
|
class MCContext;
|
||||||
@ -67,11 +75,6 @@ namespace llvm {
|
|||||||
///
|
///
|
||||||
MachineLoopInfo *LI;
|
MachineLoopInfo *LI;
|
||||||
|
|
||||||
/// PrintChildLoopComment - Print comments about child loops
|
|
||||||
/// within the loop for this basic block, with nesting.
|
|
||||||
///
|
|
||||||
void PrintChildLoopComment(const MachineLoop *loop) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// MMI - If available, this is a pointer to the current MachineModuleInfo.
|
/// MMI - If available, this is a pointer to the current MachineModuleInfo.
|
||||||
MachineModuleInfo *MMI;
|
MachineModuleInfo *MMI;
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
//===----------------- IOManip.h - iostream manipulators ---------*- C++ -*===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// This file is distributed under the University of Illinois Open Source
|
|
||||||
// License. See LICENSE.TXT for details.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// Manipulators to do special-purpose formatting.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
namespace llvm {
|
|
||||||
/// Indent - Insert spaces into the character output stream. The
|
|
||||||
/// "level" is multiplied by the "scale" to calculate the number of
|
|
||||||
/// spaces to insert. "level" can represent something like loop
|
|
||||||
/// nesting level, for example.
|
|
||||||
///
|
|
||||||
class Indent {
|
|
||||||
public:
|
|
||||||
explicit Indent(int lvl, int amt = 2)
|
|
||||||
: level(lvl), scale(amt) {}
|
|
||||||
|
|
||||||
template<typename OStream>
|
|
||||||
OStream &operator()(OStream &out) const {
|
|
||||||
for(int i = 0; i < level*scale; ++i) {
|
|
||||||
out << " ";
|
|
||||||
}
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
int level;
|
|
||||||
int scale;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename OStream>
|
|
||||||
OStream &operator<<(OStream &out, const Indent &indent)
|
|
||||||
{
|
|
||||||
return(indent(out));
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,6 +18,7 @@
|
|||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/CodeGen/GCMetadataPrinter.h"
|
#include "llvm/CodeGen/GCMetadataPrinter.h"
|
||||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
#include "llvm/CodeGen/MachineJumpTableInfo.h"
|
||||||
#include "llvm/CodeGen/MachineLoopInfo.h"
|
#include "llvm/CodeGen/MachineLoopInfo.h"
|
||||||
#include "llvm/CodeGen/MachineModuleInfo.h"
|
#include "llvm/CodeGen/MachineModuleInfo.h"
|
||||||
@ -30,7 +31,6 @@
|
|||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/FormattedStream.h"
|
||||||
#include "llvm/Support/IOManip.h"
|
|
||||||
#include "llvm/Support/Mangler.h"
|
#include "llvm/Support/Mangler.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
@ -48,10 +48,6 @@ static cl::opt<cl::boolOrDefault>
|
|||||||
AsmVerbose("asm-verbose", cl::desc("Add comments to directives."),
|
AsmVerbose("asm-verbose", cl::desc("Add comments to directives."),
|
||||||
cl::init(cl::BOU_UNSET));
|
cl::init(cl::BOU_UNSET));
|
||||||
|
|
||||||
static cl::opt<cl::boolOrDefault>
|
|
||||||
AsmExuberant("asm-exuberant", cl::desc("Add many comments."),
|
|
||||||
cl::init(cl::BOU_FALSE));
|
|
||||||
|
|
||||||
char AsmPrinter::ID = 0;
|
char AsmPrinter::ID = 0;
|
||||||
AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
|
AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
|
||||||
const TargetAsmInfo *T, bool VDef)
|
const TargetAsmInfo *T, bool VDef)
|
||||||
@ -69,11 +65,6 @@ AsmPrinter::AsmPrinter(formatted_raw_ostream &o, TargetMachine &tm,
|
|||||||
case cl::BOU_TRUE: VerboseAsm = true; break;
|
case cl::BOU_TRUE: VerboseAsm = true; break;
|
||||||
case cl::BOU_FALSE: VerboseAsm = false; break;
|
case cl::BOU_FALSE: VerboseAsm = false; break;
|
||||||
}
|
}
|
||||||
switch (AsmExuberant) {
|
|
||||||
case cl::BOU_UNSET: ExuberantAsm = false; break;
|
|
||||||
case cl::BOU_TRUE: ExuberantAsm = true; break;
|
|
||||||
case cl::BOU_FALSE: ExuberantAsm = false; break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AsmPrinter::~AsmPrinter() {
|
AsmPrinter::~AsmPrinter() {
|
||||||
@ -106,7 +97,7 @@ void AsmPrinter::getAnalysisUsage(AnalysisUsage &AU) const {
|
|||||||
AU.setPreservesAll();
|
AU.setPreservesAll();
|
||||||
MachineFunctionPass::getAnalysisUsage(AU);
|
MachineFunctionPass::getAnalysisUsage(AU);
|
||||||
AU.addRequired<GCModuleInfo>();
|
AU.addRequired<GCModuleInfo>();
|
||||||
if (ExuberantAsm)
|
if (VerboseAsm)
|
||||||
AU.addRequired<MachineLoopInfo>();
|
AU.addRequired<MachineLoopInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,7 +229,7 @@ void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
|
|||||||
CurrentFnName = Mang->getMangledName(MF.getFunction());
|
CurrentFnName = Mang->getMangledName(MF.getFunction());
|
||||||
IncrementFunctionNumber();
|
IncrementFunctionNumber();
|
||||||
|
|
||||||
if (ExuberantAsm) {
|
if (VerboseAsm) {
|
||||||
LI = &getAnalysis<MachineLoopInfo>();
|
LI = &getAnalysis<MachineLoopInfo>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1802,10 +1793,50 @@ void AsmPrinter::EmitComments(const MCInst &MI) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Indent - Insert spaces into the character output stream. The
|
||||||
|
/// "level" is multiplied by the "scale" to calculate the number of
|
||||||
|
/// spaces to insert. "level" can represent something like loop
|
||||||
|
/// nesting level, for example.
|
||||||
|
///
|
||||||
|
static formatted_raw_ostream &
|
||||||
|
Indent(formatted_raw_ostream &out, int level, int scale = 2) {
|
||||||
|
for(int i = 0; i < level*scale; ++i) {
|
||||||
|
out << " ";
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// PrintChildLoopComment - Print comments about child loops within
|
||||||
|
/// the loop for this basic block, with nesting.
|
||||||
|
///
|
||||||
|
static void PrintChildLoopComment(formatted_raw_ostream &O,
|
||||||
|
const MachineLoop *loop,
|
||||||
|
const TargetAsmInfo *TAI,
|
||||||
|
int FunctionNumber) {
|
||||||
|
// Add child loop information
|
||||||
|
for(MachineLoop::iterator cl = loop->begin(),
|
||||||
|
clend = loop->end();
|
||||||
|
cl != clend;
|
||||||
|
++cl) {
|
||||||
|
MachineBasicBlock *Header = (*cl)->getHeader();
|
||||||
|
assert(Header && "No header for loop");
|
||||||
|
|
||||||
|
O << '\n';
|
||||||
|
O.PadToColumn(TAI->getCommentColumn());
|
||||||
|
|
||||||
|
O << TAI->getCommentString();
|
||||||
|
Indent(O, (*cl)->getLoopDepth()-1)
|
||||||
|
<< " Child Loop BB" << FunctionNumber << "_"
|
||||||
|
<< Header->getNumber() << " Depth " << (*cl)->getLoopDepth();
|
||||||
|
|
||||||
|
PrintChildLoopComment(O, *cl, TAI, FunctionNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// EmitComments - Pretty-print comments for basic blocks
|
/// EmitComments - Pretty-print comments for basic blocks
|
||||||
void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const
|
void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const
|
||||||
{
|
{
|
||||||
if (ExuberantAsm) {
|
if (VerboseAsm) {
|
||||||
// Add loop depth information
|
// Add loop depth information
|
||||||
const MachineLoop *loop = LI->getLoopFor(&MBB);
|
const MachineLoop *loop = LI->getLoopFor(&MBB);
|
||||||
|
|
||||||
@ -1823,7 +1854,7 @@ void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const
|
|||||||
|
|
||||||
if (Header == &MBB) {
|
if (Header == &MBB) {
|
||||||
O << TAI->getCommentString() << " Loop Header";
|
O << TAI->getCommentString() << " Loop Header";
|
||||||
PrintChildLoopComment(loop);
|
PrintChildLoopComment(O, loop, TAI, getFunctionNumber());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
O << TAI->getCommentString() << " Loop Header is BB"
|
O << TAI->getCommentString() << " Loop Header is BB"
|
||||||
@ -1845,30 +1876,11 @@ void AsmPrinter::EmitComments(const MachineBasicBlock &MBB) const
|
|||||||
|
|
||||||
O << '\n';
|
O << '\n';
|
||||||
O.PadToColumn(TAI->getCommentColumn());
|
O.PadToColumn(TAI->getCommentColumn());
|
||||||
O << TAI->getCommentString() << Indent(CurLoop->getLoopDepth()-1)
|
O << TAI->getCommentString();
|
||||||
<< " Inside Loop BB" << getFunctionNumber() << "_"
|
Indent(O, CurLoop->getLoopDepth()-1)
|
||||||
|
<< " Inside Loop BB" << getFunctionNumber() << "_"
|
||||||
<< Header->getNumber() << " Depth " << CurLoop->getLoopDepth();
|
<< Header->getNumber() << " Depth " << CurLoop->getLoopDepth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsmPrinter::PrintChildLoopComment(const MachineLoop *loop) const {
|
|
||||||
// Add child loop information
|
|
||||||
for(MachineLoop::iterator cl = loop->begin(),
|
|
||||||
clend = loop->end();
|
|
||||||
cl != clend;
|
|
||||||
++cl) {
|
|
||||||
MachineBasicBlock *Header = (*cl)->getHeader();
|
|
||||||
assert(Header && "No header for loop");
|
|
||||||
|
|
||||||
O << '\n';
|
|
||||||
O.PadToColumn(TAI->getCommentColumn());
|
|
||||||
|
|
||||||
O << TAI->getCommentString() << Indent((*cl)->getLoopDepth()-1)
|
|
||||||
<< " Child Loop BB" << getFunctionNumber() << "_"
|
|
||||||
<< Header->getNumber() << " Depth " << (*cl)->getLoopDepth();
|
|
||||||
|
|
||||||
PrintChildLoopComment(*cl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user