mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 19:31:58 +00:00
Formatting, 80-col, trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195180 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
1357859c0d
commit
73a69d6e93
@ -44,7 +44,7 @@ typedef std::pair<const MachineInstr *, const MachineInstr *> InsnRange;
|
||||
///
|
||||
class LexicalScopes {
|
||||
public:
|
||||
LexicalScopes() : MF(NULL), CurrentFnLexicalScope(NULL) { }
|
||||
LexicalScopes() : MF(NULL), CurrentFnLexicalScope(NULL) {}
|
||||
virtual ~LexicalScopes();
|
||||
|
||||
/// initialize - Scan machine function and constuct lexical scope nest.
|
||||
@ -52,24 +52,26 @@ public:
|
||||
|
||||
/// releaseMemory - release memory.
|
||||
virtual void releaseMemory();
|
||||
|
||||
|
||||
/// empty - Return true if there is any lexical scope information available.
|
||||
bool empty() { return CurrentFnLexicalScope == NULL; }
|
||||
|
||||
/// isCurrentFunctionScope - Return true if given lexical scope represents
|
||||
/// isCurrentFunctionScope - Return true if given lexical scope represents
|
||||
/// current function.
|
||||
bool isCurrentFunctionScope(const LexicalScope *LS) {
|
||||
bool isCurrentFunctionScope(const LexicalScope *LS) {
|
||||
return LS == CurrentFnLexicalScope;
|
||||
}
|
||||
|
||||
/// getCurrentFunctionScope - Return lexical scope for the current function.
|
||||
LexicalScope *getCurrentFunctionScope() const { return CurrentFnLexicalScope;}
|
||||
LexicalScope *getCurrentFunctionScope() const {
|
||||
return CurrentFnLexicalScope;
|
||||
}
|
||||
|
||||
/// getMachineBasicBlocks - Populate given set using machine basic blocks
|
||||
/// which have machine instructions that belong to lexical scope identified by
|
||||
/// DebugLoc.
|
||||
void getMachineBasicBlocks(DebugLoc DL,
|
||||
SmallPtrSet<const MachineBasicBlock*, 4> &MBBs);
|
||||
SmallPtrSet<const MachineBasicBlock *, 4> &MBBs);
|
||||
|
||||
/// dominates - Return true if DebugLoc's lexical scope dominates at least one
|
||||
/// machine instruction's lexical scope in a given machine basic block.
|
||||
@ -104,7 +106,6 @@ public:
|
||||
void dump();
|
||||
|
||||
private:
|
||||
|
||||
/// getOrCreateLexicalScope - Find lexical scope for the given DebugLoc. If
|
||||
/// not available then create new lexical scope.
|
||||
LexicalScope *getOrCreateLexicalScope(DebugLoc DL);
|
||||
@ -123,8 +124,9 @@ private:
|
||||
void extractLexicalScopes(SmallVectorImpl<InsnRange> &MIRanges,
|
||||
DenseMap<const MachineInstr *, LexicalScope *> &M);
|
||||
void constructScopeNest(LexicalScope *Scope);
|
||||
void assignInstructionRanges(SmallVectorImpl<InsnRange> &MIRanges,
|
||||
DenseMap<const MachineInstr *, LexicalScope *> &M);
|
||||
void
|
||||
assignInstructionRanges(SmallVectorImpl<InsnRange> &MIRanges,
|
||||
DenseMap<const MachineInstr *, LexicalScope *> &M);
|
||||
|
||||
private:
|
||||
const MachineFunction *MF;
|
||||
@ -133,10 +135,11 @@ private:
|
||||
/// contained LexicalScope*s.
|
||||
DenseMap<const MDNode *, LexicalScope *> LexicalScopeMap;
|
||||
|
||||
/// InlinedLexicalScopeMap - Tracks inlined function scopes in current function.
|
||||
/// InlinedLexicalScopeMap - Tracks inlined function scopes in current
|
||||
/// function.
|
||||
DenseMap<DebugLoc, LexicalScope *> InlinedLexicalScopeMap;
|
||||
|
||||
/// AbstractScopeMap - These scopes are not included LexicalScopeMap.
|
||||
/// AbstractScopeMap - These scopes are not included LexicalScopeMap.
|
||||
/// AbstractScopes owns its LexicalScope*s.
|
||||
DenseMap<const MDNode *, LexicalScope *> AbstractScopeMap;
|
||||
|
||||
@ -157,8 +160,8 @@ class LexicalScope {
|
||||
|
||||
public:
|
||||
LexicalScope(LexicalScope *P, const MDNode *D, const MDNode *I, bool A)
|
||||
: Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A),
|
||||
LastInsn(0), FirstInsn(0), DFSIn(0), DFSOut(0) {
|
||||
: Parent(P), Desc(D), InlinedAtLocation(I), AbstractScope(A), LastInsn(0),
|
||||
FirstInsn(0), DFSIn(0), DFSOut(0) {
|
||||
if (Parent)
|
||||
Parent->addChild(this);
|
||||
}
|
||||
@ -166,13 +169,13 @@ public:
|
||||
virtual ~LexicalScope() {}
|
||||
|
||||
// Accessors.
|
||||
LexicalScope *getParent() const { return Parent; }
|
||||
const MDNode *getDesc() const { return Desc; }
|
||||
const MDNode *getInlinedAt() const { return InlinedAtLocation; }
|
||||
const MDNode *getScopeNode() const { return Desc; }
|
||||
bool isAbstractScope() const { return AbstractScope; }
|
||||
LexicalScope *getParent() const { return Parent; }
|
||||
const MDNode *getDesc() const { return Desc; }
|
||||
const MDNode *getInlinedAt() const { return InlinedAtLocation; }
|
||||
const MDNode *getScopeNode() const { return Desc; }
|
||||
bool isAbstractScope() const { return AbstractScope; }
|
||||
SmallVectorImpl<LexicalScope *> &getChildren() { return Children; }
|
||||
SmallVectorImpl<InsnRange> &getRanges() { return Ranges; }
|
||||
SmallVectorImpl<InsnRange> &getRanges() { return Ranges; }
|
||||
|
||||
/// addChild - Add a child scope.
|
||||
void addChild(LexicalScope *S) { Children.push_back(S); }
|
||||
@ -189,7 +192,7 @@ public:
|
||||
/// extendInsnRange - Extend the current instruction range covered by
|
||||
/// this scope.
|
||||
void extendInsnRange(const MachineInstr *MI) {
|
||||
assert (FirstInsn && "MI Range is not open!");
|
||||
assert(FirstInsn && "MI Range is not open!");
|
||||
LastInsn = MI;
|
||||
if (Parent)
|
||||
Parent->extendInsnRange(MI);
|
||||
@ -199,7 +202,7 @@ public:
|
||||
/// until now. This is used when a new scope is encountered while walking
|
||||
/// machine instructions.
|
||||
void closeInsnRange(LexicalScope *NewScope = NULL) {
|
||||
assert (LastInsn && "Last insn missing!");
|
||||
assert(LastInsn && "Last insn missing!");
|
||||
Ranges.push_back(InsnRange(FirstInsn, LastInsn));
|
||||
FirstInsn = NULL;
|
||||
LastInsn = NULL;
|
||||
@ -219,28 +222,28 @@ public:
|
||||
}
|
||||
|
||||
// Depth First Search support to walk and manipulate LexicalScope hierarchy.
|
||||
unsigned getDFSOut() const { return DFSOut; }
|
||||
void setDFSOut(unsigned O) { DFSOut = O; }
|
||||
unsigned getDFSIn() const { return DFSIn; }
|
||||
void setDFSIn(unsigned I) { DFSIn = I; }
|
||||
unsigned getDFSOut() const { return DFSOut; }
|
||||
void setDFSOut(unsigned O) { DFSOut = O; }
|
||||
unsigned getDFSIn() const { return DFSIn; }
|
||||
void setDFSIn(unsigned I) { DFSIn = I; }
|
||||
|
||||
/// dump - print lexical scope.
|
||||
void dump(unsigned Indent = 0) const;
|
||||
|
||||
private:
|
||||
LexicalScope *Parent; // Parent to this scope.
|
||||
AssertingVH<const MDNode> Desc; // Debug info descriptor.
|
||||
AssertingVH<const MDNode> InlinedAtLocation; // Location at which this
|
||||
// scope is inlined.
|
||||
bool AbstractScope; // Abstract Scope
|
||||
SmallVector<LexicalScope *, 4> Children; // Scopes defined in scope.
|
||||
// Contents not owned.
|
||||
LexicalScope *Parent; // Parent to this scope.
|
||||
AssertingVH<const MDNode> Desc; // Debug info descriptor.
|
||||
AssertingVH<const MDNode> InlinedAtLocation; // Location at which this
|
||||
// scope is inlined.
|
||||
bool AbstractScope; // Abstract Scope
|
||||
SmallVector<LexicalScope *, 4> Children; // Scopes defined in scope.
|
||||
// Contents not owned.
|
||||
SmallVector<InsnRange, 4> Ranges;
|
||||
|
||||
const MachineInstr *LastInsn; // Last instruction of this scope.
|
||||
const MachineInstr *FirstInsn; // First instruction of this scope.
|
||||
unsigned DFSIn, DFSOut; // In & Out Depth use to determine
|
||||
// scope nesting.
|
||||
const MachineInstr *LastInsn; // Last instruction of this scope.
|
||||
const MachineInstr *FirstInsn; // First instruction of this scope.
|
||||
unsigned DFSIn, DFSOut; // In & Out Depth use to determine
|
||||
// scope nesting.
|
||||
};
|
||||
|
||||
} // end llvm namespace
|
||||
|
@ -25,9 +25,7 @@
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
using namespace llvm;
|
||||
|
||||
LexicalScopes::~LexicalScopes() {
|
||||
releaseMemory();
|
||||
}
|
||||
LexicalScopes::~LexicalScopes() { releaseMemory(); }
|
||||
|
||||
/// releaseMemory - release memory.
|
||||
void LexicalScopes::releaseMemory() {
|
||||
@ -54,13 +52,13 @@ void LexicalScopes::initialize(const MachineFunction &Fn) {
|
||||
|
||||
/// extractLexicalScopes - Extract instruction ranges for each lexical scopes
|
||||
/// for the given machine function.
|
||||
void LexicalScopes::
|
||||
extractLexicalScopes(SmallVectorImpl<InsnRange> &MIRanges,
|
||||
DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap) {
|
||||
void LexicalScopes::extractLexicalScopes(
|
||||
SmallVectorImpl<InsnRange> &MIRanges,
|
||||
DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap) {
|
||||
|
||||
// Scan each instruction and create scopes. First build working set of scopes.
|
||||
for (MachineFunction::const_iterator I = MF->begin(), E = MF->end();
|
||||
I != E; ++I) {
|
||||
for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E;
|
||||
++I) {
|
||||
const MachineInstr *RangeBeginMI = NULL;
|
||||
const MachineInstr *PrevMI = NULL;
|
||||
DebugLoc PrevDL;
|
||||
@ -117,14 +115,15 @@ LexicalScope *LexicalScopes::findLexicalScope(DebugLoc DL) {
|
||||
MDNode *Scope = NULL;
|
||||
MDNode *IA = NULL;
|
||||
DL.getScopeAndInlinedAt(Scope, IA, MF->getFunction()->getContext());
|
||||
if (!Scope) return NULL;
|
||||
if (!Scope)
|
||||
return NULL;
|
||||
|
||||
// The scope that we were created with could have an extra file - which
|
||||
// isn't what we care about in this case.
|
||||
DIDescriptor D = DIDescriptor(Scope);
|
||||
if (D.isLexicalBlockFile())
|
||||
Scope = DILexicalBlockFile(Scope).getScope();
|
||||
|
||||
|
||||
if (IA)
|
||||
return InlinedLexicalScopeMap.lookup(DebugLoc::getFromDILocation(IA));
|
||||
return LexicalScopeMap.lookup(Scope);
|
||||
@ -143,7 +142,7 @@ LexicalScope *LexicalScopes::getOrCreateLexicalScope(DebugLoc DL) {
|
||||
// Create an inlined scope for inlined function.
|
||||
return getOrCreateInlinedScope(Scope, InlinedAt);
|
||||
}
|
||||
|
||||
|
||||
return getOrCreateRegularScope(Scope);
|
||||
}
|
||||
|
||||
@ -154,7 +153,7 @@ LexicalScope *LexicalScopes::getOrCreateRegularScope(MDNode *Scope) {
|
||||
Scope = DILexicalBlockFile(Scope).getScope();
|
||||
D = DIDescriptor(Scope);
|
||||
}
|
||||
|
||||
|
||||
LexicalScope *WScope = LexicalScopeMap.lookup(Scope);
|
||||
if (WScope)
|
||||
return WScope;
|
||||
@ -164,15 +163,15 @@ LexicalScope *LexicalScopes::getOrCreateRegularScope(MDNode *Scope) {
|
||||
Parent = getOrCreateLexicalScope(DebugLoc::getFromDILexicalBlock(Scope));
|
||||
WScope = new LexicalScope(Parent, DIDescriptor(Scope), NULL, false);
|
||||
LexicalScopeMap.insert(std::make_pair(Scope, WScope));
|
||||
if (!Parent && DIDescriptor(Scope).isSubprogram()
|
||||
&& DISubprogram(Scope).describes(MF->getFunction()))
|
||||
if (!Parent && DIDescriptor(Scope).isSubprogram() &&
|
||||
DISubprogram(Scope).describes(MF->getFunction()))
|
||||
CurrentFnLexicalScope = WScope;
|
||||
|
||||
|
||||
return WScope;
|
||||
}
|
||||
|
||||
/// getOrCreateInlinedScope - Find or create an inlined lexical scope.
|
||||
LexicalScope *LexicalScopes::getOrCreateInlinedScope(MDNode *Scope,
|
||||
LexicalScope *LexicalScopes::getOrCreateInlinedScope(MDNode *Scope,
|
||||
MDNode *InlinedAt) {
|
||||
LexicalScope *InlinedScope = LexicalScopeMap.lookup(InlinedAt);
|
||||
if (InlinedScope)
|
||||
@ -212,7 +211,7 @@ LexicalScope *LexicalScopes::getOrCreateAbstractScope(const MDNode *N) {
|
||||
|
||||
/// constructScopeNest
|
||||
void LexicalScopes::constructScopeNest(LexicalScope *Scope) {
|
||||
assert (Scope && "Unable to calculate scope dominance graph!");
|
||||
assert(Scope && "Unable to calculate scope dominance graph!");
|
||||
SmallVector<LexicalScope *, 4> WorkStack;
|
||||
WorkStack.push_back(Scope);
|
||||
unsigned Counter = 0;
|
||||
@ -221,7 +220,8 @@ void LexicalScopes::constructScopeNest(LexicalScope *Scope) {
|
||||
const SmallVectorImpl<LexicalScope *> &Children = WS->getChildren();
|
||||
bool visitedChildren = false;
|
||||
for (SmallVectorImpl<LexicalScope *>::const_iterator SI = Children.begin(),
|
||||
SE = Children.end(); SI != SE; ++SI) {
|
||||
SE = Children.end();
|
||||
SI != SE; ++SI) {
|
||||
LexicalScope *ChildScope = *SI;
|
||||
if (!ChildScope->getDFSOut()) {
|
||||
WorkStack.push_back(ChildScope);
|
||||
@ -239,17 +239,17 @@ void LexicalScopes::constructScopeNest(LexicalScope *Scope) {
|
||||
|
||||
/// assignInstructionRanges - Find ranges of instructions covered by each
|
||||
/// lexical scope.
|
||||
void LexicalScopes::
|
||||
assignInstructionRanges(SmallVectorImpl<InsnRange> &MIRanges,
|
||||
DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap)
|
||||
{
|
||||
|
||||
void LexicalScopes::assignInstructionRanges(
|
||||
SmallVectorImpl<InsnRange> &MIRanges,
|
||||
DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap) {
|
||||
|
||||
LexicalScope *PrevLexicalScope = NULL;
|
||||
for (SmallVectorImpl<InsnRange>::const_iterator RI = MIRanges.begin(),
|
||||
RE = MIRanges.end(); RI != RE; ++RI) {
|
||||
RE = MIRanges.end();
|
||||
RI != RE; ++RI) {
|
||||
const InsnRange &R = *RI;
|
||||
LexicalScope *S = MI2ScopeMap.lookup(R.first);
|
||||
assert (S && "Lost LexicalScope for a machine instruction!");
|
||||
assert(S && "Lost LexicalScope for a machine instruction!");
|
||||
if (PrevLexicalScope && !PrevLexicalScope->dominates(S))
|
||||
PrevLexicalScope->closeInsnRange(S);
|
||||
S->openInsnRange(R.first);
|
||||
@ -262,26 +262,26 @@ assignInstructionRanges(SmallVectorImpl<InsnRange> &MIRanges,
|
||||
}
|
||||
|
||||
/// getMachineBasicBlocks - Populate given set using machine basic blocks which
|
||||
/// have machine instructions that belong to lexical scope identified by
|
||||
/// have machine instructions that belong to lexical scope identified by
|
||||
/// DebugLoc.
|
||||
void LexicalScopes::
|
||||
getMachineBasicBlocks(DebugLoc DL,
|
||||
SmallPtrSet<const MachineBasicBlock*, 4> &MBBs) {
|
||||
void LexicalScopes::getMachineBasicBlocks(
|
||||
DebugLoc DL, SmallPtrSet<const MachineBasicBlock *, 4> &MBBs) {
|
||||
MBBs.clear();
|
||||
LexicalScope *Scope = getOrCreateLexicalScope(DL);
|
||||
if (!Scope)
|
||||
return;
|
||||
|
||||
|
||||
if (Scope == CurrentFnLexicalScope) {
|
||||
for (MachineFunction::const_iterator I = MF->begin(), E = MF->end();
|
||||
I != E; ++I)
|
||||
for (MachineFunction::const_iterator I = MF->begin(), E = MF->end(); I != E;
|
||||
++I)
|
||||
MBBs.insert(I);
|
||||
return;
|
||||
}
|
||||
|
||||
SmallVectorImpl<InsnRange> &InsnRanges = Scope->getRanges();
|
||||
for (SmallVectorImpl<InsnRange>::iterator I = InsnRanges.begin(),
|
||||
E = InsnRanges.end(); I != E; ++I) {
|
||||
E = InsnRanges.end();
|
||||
I != E; ++I) {
|
||||
InsnRange &R = *I;
|
||||
MBBs.insert(R.first->getParent());
|
||||
}
|
||||
@ -299,8 +299,8 @@ bool LexicalScopes::dominates(DebugLoc DL, MachineBasicBlock *MBB) {
|
||||
return true;
|
||||
|
||||
bool Result = false;
|
||||
for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
|
||||
I != E; ++I) {
|
||||
for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E;
|
||||
++I) {
|
||||
DebugLoc IDL = I->getDebugLoc();
|
||||
if (IDL.isUnknown())
|
||||
continue;
|
||||
@ -311,7 +311,7 @@ bool LexicalScopes::dominates(DebugLoc DL, MachineBasicBlock *MBB) {
|
||||
return Result;
|
||||
}
|
||||
|
||||
void LexicalScope::anchor() { }
|
||||
void LexicalScope::anchor() {}
|
||||
|
||||
/// dump - Print data structures.
|
||||
void LexicalScope::dump(unsigned Indent) const {
|
||||
@ -332,4 +332,3 @@ void LexicalScope::dump(unsigned Indent) const {
|
||||
Children[i]->dump(Indent + 2);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user