Simplified and HTML lowered statement dumps

Initial import, adaptation, and cleanup of statement simplification, HTML dump. Original code by @zingales. This needs a review.
Yep, it's safe. It's impossible to mutate a stmt with doing something evil
like casting it to a void *. All IRMutators return a new copy if they want
to change anything.


On Thu, Jul 24, 2014 at 9:40 AM, Giuseppe Zingales <notifications@github.com
> wrote:

> In src/Func.cpp:
>
> > @@ -1928,8 +1930,80 @@ void Func::compile_to_c(const string &filename, vector<Argument> args,
> >  void Func::compile_to_lowered_stmt(
> const string &filename, const Target &target) {
> >      lower(target);
> >
> > -    ofstream stmt_output(filename.c_str());
> > -    stmt_output << lowered;
> > +    if (filename.compare(filename.length()-5, 5, ".html") == 0) {
> > +        print_to_html(filename, lowered);
> > +    } else {
> > +        ofstream stmt_output(filename.c_str());
> > +        stmt_output << lowered;
> > +    }
> > +}
> > +
> > +
> > +void Func::compile_to_simplified_lowered_stmt(const std::string &filename, Realization dst, std::map<std::string, Expr> additional_replacements, const Target &t) {
> > +    _halide_user_assert(outputs() == 1) << "Handling multiple outputs is not yet supported by compile_to_simplified_lowered_stmt\n";
> > +    // i purposfully don't use f.lowered because i want a copy of the STMT since it will later get modified
>
> I didn't see any documentation that convinced me if it was immutable or
> not, and re-lowering was way safer. If, however, there are no side-effect
> to the original f.lowered, by running substitute then by all means we
> should use f.lowered.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/halide/Halide/pull/389/files#r15357443>.
>