Commit b1f2b21d authored by 李晓奇's avatar 李晓奇

finish part

parent f26d91aa
...@@ -2,6 +2,7 @@ build ...@@ -2,6 +2,7 @@ build
Documentations/1-parser/*.pdf Documentations/1-parser/*.pdf
compile_commands.json compile_commands.json
.cache .cache
.vscode
todo.txt todo.txt
tmp.cminus tmp.cminus
...@@ -204,13 +204,15 @@ class UniqueExpression : public Expression { ...@@ -204,13 +204,15 @@ class UniqueExpression : public Expression {
} }
virtual std::string print() { return "(UNIQUE " + instr_->print() + ")"; } virtual std::string print() { return "(UNIQUE " + instr_->print() + ")"; }
bool equiv(const UniqueExpression *other) const { return false; } bool equiv(const UniqueExpression *other) const {
return instr_ == other->instr_;
}
UniqueExpression(Instruction *instr) UniqueExpression(Instruction *instr)
: Expression(e_unique), instr_(instr) {} : Expression(e_unique), instr_(instr) {}
private: private:
std::shared_ptr<Instruction> instr_; Instruction *instr_;
}; };
} // namespace GVNExpression } // namespace GVNExpression
...@@ -277,7 +279,7 @@ class GVN : public Pass { ...@@ -277,7 +279,7 @@ class GVN : public Pass {
BasicBlock *bb); BasicBlock *bb);
std::shared_ptr<GVNExpression::Expression> valueExpr( std::shared_ptr<GVNExpression::Expression> valueExpr(
Instruction *instr, Instruction *instr,
partitions *part = nullptr); const partitions &part);
std::shared_ptr<GVNExpression::Expression> getVN( std::shared_ptr<GVNExpression::Expression> getVN(
const partitions &pout, const partitions &pout,
std::shared_ptr<GVNExpression::Expression> ve); std::shared_ptr<GVNExpression::Expression> ve);
...@@ -293,11 +295,6 @@ class GVN : public Pass { ...@@ -293,11 +295,6 @@ class GVN : public Pass {
return std::make_shared<CongruenceClass>(index); return std::make_shared<CongruenceClass>(index);
} }
// self add
//
std::uint64_t new_number() { return next_value_number_++; }
static int pretend_copy_stmt(Instruction *inst, BasicBlock *bb);
private: private:
bool dump_json_; bool dump_json_;
std::uint64_t next_value_number_ = 1; std::uint64_t next_value_number_ = 1;
...@@ -307,10 +304,24 @@ class GVN : public Pass { ...@@ -307,10 +304,24 @@ class GVN : public Pass {
std::unique_ptr<GVNExpression::ConstFolder> folder_; std::unique_ptr<GVNExpression::ConstFolder> folder_;
std::unique_ptr<DeadCode> dce_; std::unique_ptr<DeadCode> dce_;
// self add // self add member
std::map<BasicBlock *, bool> _TOP; std::map<BasicBlock *, bool> _TOP;
partitions join_helper(BasicBlock *pre1, BasicBlock *pre2); partitions join_helper(BasicBlock *pre1, BasicBlock *pre2);
BasicBlock* curr_bb; BasicBlock *curr_bb;
//
// self add function
//
std::uint64_t new_number() { return next_value_number_++; }
static int pretend_copy_stmt(Instruction *inst, BasicBlock *bb);
std::shared_ptr<GVNExpression::Expression> search_ve(
Value *v,
const partitions &part);
std::vector<std::shared_ptr<GVNExpression::Expression>> core_(
Instruction *instr,
const partitions &part,
size_t count,
bool fold_ = true);
}; };
bool operator==(const GVN::partitions &p1, const GVN::partitions &p2); bool operator==(const GVN::partitions &p1, const GVN::partitions &p2);
This diff is collapsed.
rm -rf *.ll
rm -rf gvn.json
rm -rf `ls | grep -v "\."`
rm -rf const-prop
rm -rf transpose
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment