Skip to content

Commit

Permalink
Move makeValueBinaryOpFromLocal to ValueExpr.*
Browse files Browse the repository at this point in the history
  • Loading branch information
long-long-float committed Aug 23, 2020
1 parent cc9087c commit c1a1378
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/optimization/Combiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1127,12 +1127,6 @@ InstructionWalker optimizations::combineArithmeticOperations(
return it;
}

std::shared_ptr<ValueExpr> makeValueBinaryOpFromLocal(Value& left, ValueBinaryOp::BinaryOp binOp, Value& right)
{
return std::make_shared<ValueBinaryOp>(
std::make_shared<ValueTerm>(left), binOp, std::make_shared<ValueTerm>(right));
}

// try to convert shl to mul and return it as ValueExpr
std::shared_ptr<ValueExpr> shlToMul(Value& value, const intermediate::Operation* op)
{
Expand Down
6 changes: 6 additions & 0 deletions src/optimization/ValueExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,12 @@ std::string ValueBinaryOp::to_string() const
return "(" + left->to_string() + " " + opStr + " " + right->to_string() + ")";
}

std::shared_ptr<ValueExpr> optimizations::makeValueBinaryOpFromLocal(Value& left, ValueBinaryOp::BinaryOp binOp, Value& right)
{
return std::make_shared<ValueBinaryOp>(
std::make_shared<ValueTerm>(left), binOp, std::make_shared<ValueTerm>(right));
}

bool ValueTerm::operator==(const ValueExpr& other) const
{
if(auto otherTerm = dynamic_cast<const ValueTerm*>(&other))
Expand Down
2 changes: 2 additions & 0 deletions src/optimization/ValueExpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ namespace vc4c
std::shared_ptr<ValueExpr> right;
};

std::shared_ptr<ValueExpr> makeValueBinaryOpFromLocal(Value& left, ValueBinaryOp::BinaryOp binOp, Value& right);

class ValueTerm : public ValueExpr
{
public:
Expand Down

0 comments on commit c1a1378

Please sign in to comment.