Esempio n. 1
0
Module GeneratorBase::build_module(const std::string &function_name,
                                   const LoweredFunc::LinkageType linkage_type) {
    build_params();
    Pipeline pipeline = build_pipeline();
    // Building the pipeline may mutate the params and imageparams.
    rebuild_params();
    return pipeline.compile_to_module(get_filter_arguments(), function_name, target, linkage_type);
}
Esempio n. 2
0
void GeneratorBase::emit_filter(const std::string &output_dir,
                                const std::string &function_name,
                                const std::string &file_base_name,
                                const EmitOptions &options) {
    build_params();

    Pipeline pipeline = build_pipeline();

    std::vector<Halide::Argument> inputs = get_filter_arguments();
    std::string base_path = output_dir + "/" + (file_base_name.empty() ? function_name : file_base_name);
    if (options.emit_o || options.emit_assembly || options.emit_bitcode) {
        Outputs output_files;
        if (options.emit_o) {
            // If the target arch is pnacl, then the output "object" file is
            // actually a pnacl bitcode file.
            if (Target(target).arch == Target::PNaCl) {
                output_files.object_name = base_path + ".bc";
            } else if (Target(target).os == Target::Windows &&
                       !Target(target).has_feature(Target::MinGW)) {
                // If it's windows, then we're emitting a COFF file
                output_files.object_name = base_path + ".obj";
            } else {
                // Otherwise it is an ELF or Mach-o
                output_files.object_name = base_path + ".o";
            }
        }
        if (options.emit_assembly) {
            output_files.assembly_name = base_path + ".s";
        }
        if (options.emit_bitcode) {
            // In this case, bitcode refers to the LLVM IR generated by Halide
            // and passed to LLVM, for both the pnacl and ordinary archs
            output_files.bitcode_name = base_path + ".bc";
        }
        pipeline.compile_to(output_files, inputs, function_name, target);
    }
    if (options.emit_h) {
        pipeline.compile_to_header(base_path + ".h", inputs, function_name, target);
    }
    if (options.emit_cpp) {
        pipeline.compile_to_c(base_path + ".cpp", inputs, function_name, target);
    }
    if (options.emit_stmt) {
        pipeline.compile_to_lowered_stmt(base_path + ".stmt", inputs, Halide::Text, target);
    }
    if (options.emit_stmt_html) {
        pipeline.compile_to_lowered_stmt(base_path + ".html", inputs, Halide::HTML, target);
    }
}