Commit 56537575 authored by Paul's avatar Paul
Browse files

Formatting

parent 375e4c15
......@@ -8,7 +8,7 @@ namespace migraph {
void dead_code_elimination::apply(program& p) const
{
for(auto i:iterator_for(p))
for(auto i : iterator_for(p))
{
// Skip over instructions that may have been removed
if(!p.has_instruction(i))
......@@ -23,7 +23,7 @@ void dead_code_elimination::apply(program& p) const
std::cout << p << std::endl;
auto args = ins->arguments;
p.remove_instruction(ins);
for(auto arg:args)
for(auto arg : args)
self(arg);
}
})(i);
......
......@@ -7,12 +7,12 @@ namespace migraph {
namespace detail {
template<class R, class F>
template <class R, class F>
struct fix_f
{
F f;
template<class... Ts>
template <class... Ts>
R operator()(Ts&&... xs) const
{
return f(*this, std::forward<Ts>(xs)...);
......@@ -22,13 +22,13 @@ struct fix_f
} // namespace detail
/// Implements a fix-point combinator
template<class R, class F>
template <class R, class F>
detail::fix_f<R, F> fix(F f)
{
return {f};
}
template<class F>
template <class F>
auto fix(F f)
{
return fix<void>(f);
......
......@@ -20,8 +20,16 @@ struct iterator_for_range
bool operator!=(const iterator& rhs) { return i != rhs.i; }
};
iterator begin() { assert(base != nullptr); return {base->begin()}; }
iterator end() { assert(base != nullptr); return {base->end()}; }
iterator begin()
{
assert(base != nullptr);
return {base->begin()};
}
iterator end()
{
assert(base != nullptr);
return {base->end()};
}
};
template <class T>
iterator_for_range<T> iterator_for(T& x)
......
......@@ -52,8 +52,7 @@ program::replace_instruction(instruction_ref ins, operation op, std::vector<inst
return ins;
}
instruction_ref
program::remove_instruction(instruction_ref ins)
instruction_ref program::remove_instruction(instruction_ref ins)
{
assert(has_instruction(ins));
assert(ins->output.empty());
......
......@@ -5,7 +5,10 @@
struct dce_target
{
std::string name() const { return "dce"; }
std::vector<migraph::pass> get_passes(migraph::context&) const { return { migraph::dead_code_elimination{} }; }
std::vector<migraph::pass> get_passes(migraph::context&) const
{
return {migraph::dead_code_elimination{}};
}
migraph::context get_context() const { return {}; }
};
......@@ -34,7 +37,7 @@ void duplicate_test()
p.add_instruction(sum_op{}, one, two);
auto count = std::distance(p.begin(), p.end());
p.compile(dce_target{});
EXPECT(std::distance(p.begin(), p.end()) == (count-1));
EXPECT(std::distance(p.begin(), p.end()) == (count - 1));
auto result = p.eval({});
EXPECT(result == migraph::literal{3});
EXPECT(result != migraph::literal{4});
......@@ -45,4 +48,3 @@ int main()
simple_test();
duplicate_test();
}
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