Make code more readable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12305 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Misha Brukman
2004-03-12 00:58:41 +00:00
parent ec85af16a0
commit 56c0fa69a3
2 changed files with 62 additions and 70 deletions

View File

@ -131,7 +131,7 @@ class ModRefInfoBuilder : public InstVisitor<ModRefInfoBuilder> {
void operator=(const ModRefInfoBuilder&); // DO NOT IMPLEMENT void operator=(const ModRefInfoBuilder&); // DO NOT IMPLEMENT
public: public:
/*ctor*/ ModRefInfoBuilder(const DSGraph& _funcGraph, ModRefInfoBuilder(const DSGraph& _funcGraph,
const FunctionModRefInfo& _funcModRef, const FunctionModRefInfo& _funcModRef,
ModRefTable& _modRefTable) ModRefTable& _modRefTable)
: funcGraph(_funcGraph), funcModRef(_funcModRef), modRefTable(_modRefTable) : funcGraph(_funcGraph), funcModRef(_funcModRef), modRefTable(_modRefTable)
@ -142,11 +142,11 @@ public:
// Add the call to the defs list if it modifies any nodes and to the uses // Add the call to the defs list if it modifies any nodes and to the uses
// list if it refs any nodes. // list if it refs any nodes.
// //
void visitCallInst (CallInst& callInst) { void visitCallInst(CallInst& callInst) {
ModRefInfo safeModRef(funcGraph.getGraphSize()); ModRefInfo safeModRef(funcGraph.getGraphSize());
const ModRefInfo* callModRef = funcModRef.getModRefInfo(callInst); const ModRefInfo* callModRef = funcModRef.getModRefInfo(callInst);
if (callModRef == NULL) if (callModRef == NULL) {
{ // call to external/unknown function: mark all nodes as Mod and Ref // call to external/unknown function: mark all nodes as Mod and Ref
safeModRef.getModSet().set(); safeModRef.getModSet().set();
safeModRef.getRefSet().set(); safeModRef.getRefSet().set();
callModRef = &safeModRef; callModRef = &safeModRef;
@ -163,11 +163,10 @@ public:
// At a store instruction, add to the mod set the single node pointed to // At a store instruction, add to the mod set the single node pointed to
// by the pointer argument of the store. Interestingly, if there is no // by the pointer argument of the store. Interestingly, if there is no
// such node, that would be a null pointer reference! // such node, that would be a null pointer reference!
void visitStoreInst (StoreInst& storeInst) { void visitStoreInst(StoreInst& storeInst) {
const DSNodeHandle& ptrNode = const DSNodeHandle& ptrNode =
funcGraph.getNodeForValue(storeInst.getPointerOperand()); funcGraph.getNodeForValue(storeInst.getPointerOperand());
if (const DSNode* target = ptrNode.getNode()) if (const DSNode* target = ptrNode.getNode()) {
{
unsigned nodeId = funcModRef.getNodeId(target); unsigned nodeId = funcModRef.getNodeId(target);
ModRefInfo& minfo = ModRefInfo& minfo =
modRefTable.modRefMap.insert( modRefTable.modRefMap.insert(
@ -175,19 +174,17 @@ public:
ModRefInfo(funcGraph.getGraphSize()))).first->second; ModRefInfo(funcGraph.getGraphSize()))).first->second;
minfo.setNodeIsMod(nodeId); minfo.setNodeIsMod(nodeId);
modRefTable.AddDef(&storeInst); modRefTable.AddDef(&storeInst);
} } else
else
std::cerr << "Warning: Uninitialized pointer reference!\n"; std::cerr << "Warning: Uninitialized pointer reference!\n";
} }
// At a load instruction, add to the ref set the single node pointed to // At a load instruction, add to the ref set the single node pointed to
// by the pointer argument of the load. Interestingly, if there is no // by the pointer argument of the load. Interestingly, if there is no
// such node, that would be a null pointer reference! // such node, that would be a null pointer reference!
void visitLoadInst (LoadInst& loadInst) { void visitLoadInst(LoadInst& loadInst) {
const DSNodeHandle& ptrNode = const DSNodeHandle& ptrNode =
funcGraph.getNodeForValue(loadInst.getPointerOperand()); funcGraph.getNodeForValue(loadInst.getPointerOperand());
if (const DSNode* target = ptrNode.getNode()) if (const DSNode* target = ptrNode.getNode()) {
{
unsigned nodeId = funcModRef.getNodeId(target); unsigned nodeId = funcModRef.getNodeId(target);
ModRefInfo& minfo = ModRefInfo& minfo =
modRefTable.modRefMap.insert( modRefTable.modRefMap.insert(
@ -195,8 +192,7 @@ public:
ModRefInfo(funcGraph.getGraphSize()))).first->second; ModRefInfo(funcGraph.getGraphSize()))).first->second;
minfo.setNodeIsRef(nodeId); minfo.setNodeIsRef(nodeId);
modRefTable.AddUse(&loadInst); modRefTable.AddUse(&loadInst);
} } else
else
std::cerr << "Warning: Uninitialized pointer reference!\n"; std::cerr << "Warning: Uninitialized pointer reference!\n";
} }
}; };

View File

@ -131,7 +131,7 @@ class ModRefInfoBuilder : public InstVisitor<ModRefInfoBuilder> {
void operator=(const ModRefInfoBuilder&); // DO NOT IMPLEMENT void operator=(const ModRefInfoBuilder&); // DO NOT IMPLEMENT
public: public:
/*ctor*/ ModRefInfoBuilder(const DSGraph& _funcGraph, ModRefInfoBuilder(const DSGraph& _funcGraph,
const FunctionModRefInfo& _funcModRef, const FunctionModRefInfo& _funcModRef,
ModRefTable& _modRefTable) ModRefTable& _modRefTable)
: funcGraph(_funcGraph), funcModRef(_funcModRef), modRefTable(_modRefTable) : funcGraph(_funcGraph), funcModRef(_funcModRef), modRefTable(_modRefTable)
@ -142,11 +142,11 @@ public:
// Add the call to the defs list if it modifies any nodes and to the uses // Add the call to the defs list if it modifies any nodes and to the uses
// list if it refs any nodes. // list if it refs any nodes.
// //
void visitCallInst (CallInst& callInst) { void visitCallInst(CallInst& callInst) {
ModRefInfo safeModRef(funcGraph.getGraphSize()); ModRefInfo safeModRef(funcGraph.getGraphSize());
const ModRefInfo* callModRef = funcModRef.getModRefInfo(callInst); const ModRefInfo* callModRef = funcModRef.getModRefInfo(callInst);
if (callModRef == NULL) if (callModRef == NULL) {
{ // call to external/unknown function: mark all nodes as Mod and Ref // call to external/unknown function: mark all nodes as Mod and Ref
safeModRef.getModSet().set(); safeModRef.getModSet().set();
safeModRef.getRefSet().set(); safeModRef.getRefSet().set();
callModRef = &safeModRef; callModRef = &safeModRef;
@ -163,11 +163,10 @@ public:
// At a store instruction, add to the mod set the single node pointed to // At a store instruction, add to the mod set the single node pointed to
// by the pointer argument of the store. Interestingly, if there is no // by the pointer argument of the store. Interestingly, if there is no
// such node, that would be a null pointer reference! // such node, that would be a null pointer reference!
void visitStoreInst (StoreInst& storeInst) { void visitStoreInst(StoreInst& storeInst) {
const DSNodeHandle& ptrNode = const DSNodeHandle& ptrNode =
funcGraph.getNodeForValue(storeInst.getPointerOperand()); funcGraph.getNodeForValue(storeInst.getPointerOperand());
if (const DSNode* target = ptrNode.getNode()) if (const DSNode* target = ptrNode.getNode()) {
{
unsigned nodeId = funcModRef.getNodeId(target); unsigned nodeId = funcModRef.getNodeId(target);
ModRefInfo& minfo = ModRefInfo& minfo =
modRefTable.modRefMap.insert( modRefTable.modRefMap.insert(
@ -175,19 +174,17 @@ public:
ModRefInfo(funcGraph.getGraphSize()))).first->second; ModRefInfo(funcGraph.getGraphSize()))).first->second;
minfo.setNodeIsMod(nodeId); minfo.setNodeIsMod(nodeId);
modRefTable.AddDef(&storeInst); modRefTable.AddDef(&storeInst);
} } else
else
std::cerr << "Warning: Uninitialized pointer reference!\n"; std::cerr << "Warning: Uninitialized pointer reference!\n";
} }
// At a load instruction, add to the ref set the single node pointed to // At a load instruction, add to the ref set the single node pointed to
// by the pointer argument of the load. Interestingly, if there is no // by the pointer argument of the load. Interestingly, if there is no
// such node, that would be a null pointer reference! // such node, that would be a null pointer reference!
void visitLoadInst (LoadInst& loadInst) { void visitLoadInst(LoadInst& loadInst) {
const DSNodeHandle& ptrNode = const DSNodeHandle& ptrNode =
funcGraph.getNodeForValue(loadInst.getPointerOperand()); funcGraph.getNodeForValue(loadInst.getPointerOperand());
if (const DSNode* target = ptrNode.getNode()) if (const DSNode* target = ptrNode.getNode()) {
{
unsigned nodeId = funcModRef.getNodeId(target); unsigned nodeId = funcModRef.getNodeId(target);
ModRefInfo& minfo = ModRefInfo& minfo =
modRefTable.modRefMap.insert( modRefTable.modRefMap.insert(
@ -195,8 +192,7 @@ public:
ModRefInfo(funcGraph.getGraphSize()))).first->second; ModRefInfo(funcGraph.getGraphSize()))).first->second;
minfo.setNodeIsRef(nodeId); minfo.setNodeIsRef(nodeId);
modRefTable.AddUse(&loadInst); modRefTable.AddUse(&loadInst);
} } else
else
std::cerr << "Warning: Uninitialized pointer reference!\n"; std::cerr << "Warning: Uninitialized pointer reference!\n";
} }
}; };