codestyle issues

This commit is contained in:
2024-04-04 20:15:56 +03:00
parent 1ac7fcca2a
commit e2ac45f48d
3 changed files with 23 additions and 17 deletions

View File

@@ -10,7 +10,8 @@
#include "../IR.h" #include "../IR.h"
template <class NodeType> template <class NodeType>
class BackwardDataFlowAnalysis : public DataFlowAnalysis<NodeType> { class BackwardDataFlowAnalysis : public DataFlowAnalysis<NodeType>
{
std::vector<SAPFOR::BasicBlock*> reorderSequence(const std::vector<SAPFOR::BasicBlock*>& blocks, std::vector<SAPFOR::BasicBlock*> reorderSequence(const std::vector<SAPFOR::BasicBlock*>& blocks,
const std::set<SAPFOR::BasicBlock*> back_edge_sources); const std::set<SAPFOR::BasicBlock*> back_edge_sources);
public: public:

View File

@@ -70,7 +70,8 @@ void DataFlowAnalysisNode<DataType>::doStep()
/* definitions for DataFlowAnalysis class */ /* definitions for DataFlowAnalysis class */
template <class NodeType> template <class NodeType>
void DataFlowAnalysis<NodeType>::analyze() { void DataFlowAnalysis<NodeType>::analyze()
{
auto curr = 0; auto curr = 0;
auto stop = nodes.size(); auto stop = nodes.size();

View File

@@ -135,7 +135,8 @@ static void buildUseDef(SAPFOR::BasicBlock* block, set<SAPFOR::Argument*>& use,
} }
class DeadCodeAnalysisNode : public DataFlowAnalysisNode<map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>> { class DeadCodeAnalysisNode : public DataFlowAnalysisNode<map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>>
{
private: private:
vector<bool> useful; vector<bool> useful;
bool useful_block = false; bool useful_block = false;
@@ -198,28 +199,28 @@ public:
return updated; return updated;
} }
map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>> getIn() { map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>> getIn()
{
return getBlock()->getLiveOut(); return getBlock()->getLiveOut();
} }
map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>> getOut() { map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>> getOut()
{
return getBlock()->getLiveIn(); return getBlock()->getLiveIn();
} }
bool addIn(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data) { bool addIn(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data)
bool inserted = getBlock()->addLiveOut(data); {
return getBlock()->addLiveOut(data);
return inserted;
} }
bool addOut(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data) { bool addOut(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data)
{
return getBlock()->addLiveIn(data); return getBlock()->addLiveIn(data);
} }
bool updateState() { bool updateState()
if(getBlock()->getInstructions()[0]->getInstruction()->getOperator()->lineNumber() == 58) {
int b = 51;
bool updated = false; bool updated = false;
if (!useful_block) if (!useful_block)
@@ -231,7 +232,8 @@ public:
return updated; return updated;
} }
bool forwardData(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data) { bool forwardData(const map<SAPFOR::Argument*, vector<SAPFOR::BasicBlock*>>& data)
{
bool inserted = false; bool inserted = false;
SAPFOR::BasicBlock* bb= getBlock(); SAPFOR::BasicBlock* bb= getBlock();
@@ -315,12 +317,14 @@ public:
const vector<bool>& getResult() { return useful; } const vector<bool>& getResult() { return useful; }
}; };
class DeadCodeAnalysis : public BackwardDataFlowAnalysis<DeadCodeAnalysisNode> { class DeadCodeAnalysis : public BackwardDataFlowAnalysis<DeadCodeAnalysisNode>
{
protected: protected:
vector<SAPFOR::Argument*>& formal_parameters; vector<SAPFOR::Argument*>& formal_parameters;
const map<string, FuncInfo*>& funcByName; const map<string, FuncInfo*>& funcByName;
DeadCodeAnalysisNode* createNode(SAPFOR::BasicBlock* block) override { DeadCodeAnalysisNode* createNode(SAPFOR::BasicBlock* block) override
{
return new DeadCodeAnalysisNode(block, formal_parameters, funcByName); return new DeadCodeAnalysisNode(block, formal_parameters, funcByName);
} }
public: public: