Commit bf3789fa authored by Paul's avatar Paul
Browse files

Formatting

parent d2d5fd19
...@@ -75,8 +75,7 @@ struct instruction ...@@ -75,8 +75,7 @@ struct instruction
bool valid(instruction_ref start) const bool valid(instruction_ref start) const
{ {
return valid() && return valid() && std::all_of(arguments.begin(), arguments.end(), [&](instruction_ref i) {
std::all_of(arguments.begin(), arguments.end(), [&](instruction_ref i) {
auto self = std::find(i->output.begin(), i->output.end(), *this); auto self = std::find(i->output.begin(), i->output.end(), *this);
return self != i->output.end() && return self != i->output.end() &&
std::distance(start, i) < std::distance(start, *self); std::distance(start, i) < std::distance(start, *self);
...@@ -106,12 +105,10 @@ struct instruction ...@@ -106,12 +105,10 @@ struct instruction
} }
} }
return result == computed && return result == computed &&
std::all_of(output.begin(), std::all_of(output.begin(), output.end(), [&](instruction_ref i) {
output.end(), return std::find(i->arguments.begin(), i->arguments.end(), *this) !=
[&](instruction_ref i) { i->arguments.end();
return std::find(i->arguments.begin(), i->arguments.end(), *this) != });
i->arguments.end();
});
} }
friend bool operator==(instruction_ref ref, const instruction& i) { return i == ref; } friend bool operator==(instruction_ref ref, const instruction& i) { return i == ref; }
...@@ -126,7 +123,7 @@ struct instruction ...@@ -126,7 +123,7 @@ struct instruction
output.push_back(ins); output.push_back(ins);
} }
template<class T> template <class T>
void remove_output(const T& ins) void remove_output(const T& ins)
{ {
migraph::erase(output, ins); migraph::erase(output, ins);
......
...@@ -55,8 +55,7 @@ struct program ...@@ -55,8 +55,7 @@ struct program
instruction_ref instruction_ref
replace_instructions(instruction_ref ins, instruction_ref start, instruction_ref last); replace_instructions(instruction_ref ins, instruction_ref start, instruction_ref last);
instruction_ref instruction_ref replace_instruction(instruction_ref ins, instruction_ref start);
replace_instruction(instruction_ref ins, instruction_ref start);
instruction_ref remove_instruction(instruction_ref ins); instruction_ref remove_instruction(instruction_ref ins);
instruction_ref remove_instructions(instruction_ref first, instruction_ref last); instruction_ref remove_instructions(instruction_ref first, instruction_ref last);
......
...@@ -77,8 +77,7 @@ program::replace_instructions(instruction_ref ins, instruction_ref start, instru ...@@ -77,8 +77,7 @@ program::replace_instructions(instruction_ref ins, instruction_ref start, instru
return rep; return rep;
} }
instruction_ref instruction_ref program::replace_instruction(instruction_ref ins, instruction_ref start)
program::replace_instruction(instruction_ref ins, instruction_ref start)
{ {
assert(ins != start); assert(ins != start);
return replace_instructions(ins, start, std::next(start)); return replace_instructions(ins, start, std::next(start));
......
...@@ -122,9 +122,9 @@ void replace_ins_test() ...@@ -122,9 +122,9 @@ void replace_ins_test()
{ {
migraph::program p; migraph::program p;
auto one = p.add_literal(1); auto one = p.add_literal(1);
auto two = p.add_literal(2); auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two); auto sum = p.add_instruction(sum_op{}, one, two);
auto minus = p.add_instruction(minus_op{}, two, one); auto minus = p.add_instruction(minus_op{}, two, one);
p.replace_instruction(sum, minus); p.replace_instruction(sum, minus);
......
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