From 39e0c3053d08f69ad599f796a28fc81b07b5b7f3 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Fri, 3 Jun 2022 15:23:36 -0700 Subject: [PATCH 1/2] cleanup --- .gitignore | 1 + src/CodeGen_C.cpp | 4 ++-- src/CodeGen_C.h | 4 ++-- src/CodeGen_LLVM.cpp | 2 +- src/CodeGen_LLVM.h | 2 +- src/Generator.cpp | 2 +- src/Generator.h | 22 ++++--------------- src/Module.cpp | 4 ++-- src/Module.h | 4 +++- .../abstractgeneratortest_generator.cpp | 2 +- 10 files changed, 18 insertions(+), 29 deletions(-) diff --git a/.gitignore b/.gitignore index 747ad4353159..a3b089ad01dd 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ bin/* build/* share/* python_bindings/bin/* +build-32/* build-64/* build-ios/* build-osx/* diff --git a/src/CodeGen_C.cpp b/src/CodeGen_C.cpp index 9231c55fa705..d1e7b816ac81 100644 --- a/src/CodeGen_C.cpp +++ b/src/CodeGen_C.cpp @@ -1523,7 +1523,7 @@ void CodeGen_C::emit_argv_wrapper(const std::string &function_name, void CodeGen_C::emit_metadata_getter(const std::string &function_name, const std::vector &args, - const std::map &metadata_name_map) { + const MetadataNameMap &metadata_name_map) { if (is_header_or_extern_decl()) { stream << "\nHALIDE_FUNCTION_ATTRS\nconst struct halide_filter_metadata_t *" << function_name << "_metadata();\n"; return; @@ -1798,7 +1798,7 @@ void CodeGen_C::compile(const Module &input) { } } -void CodeGen_C::compile(const LoweredFunc &f, const std::map &metadata_name_map) { +void CodeGen_C::compile(const LoweredFunc &f, const MetadataNameMap &metadata_name_map) { // Don't put non-external function declarations in headers. if (is_header_or_extern_decl() && f.linkage == LinkageType::Internal) { return; diff --git a/src/CodeGen_C.h b/src/CodeGen_C.h index 7e3544b36d79..401c5e753f61 100644 --- a/src/CodeGen_C.h +++ b/src/CodeGen_C.h @@ -65,7 +65,7 @@ class CodeGen_C : public IRPrinter { /** Emit a declaration. */ // @{ - virtual void compile(const LoweredFunc &func, const std::map &metadata_name_map); + virtual void compile(const LoweredFunc &func, const MetadataNameMap &metadata_name_map); virtual void compile(const Buffer<> &buffer); // @} @@ -270,7 +270,7 @@ class CodeGen_C : public IRPrinter { const std::vector &args); void emit_metadata_getter(const std::string &function_name, const std::vector &args, - const std::map &metadata_name_map); + const MetadataNameMap &metadata_name_map); }; } // namespace Internal diff --git a/src/CodeGen_LLVM.cpp b/src/CodeGen_LLVM.cpp index 457473b4f1c1..ec0f326ec915 100644 --- a/src/CodeGen_LLVM.cpp +++ b/src/CodeGen_LLVM.cpp @@ -965,7 +965,7 @@ llvm::Function *CodeGen_LLVM::add_argv_wrapper(llvm::Function *fn, llvm::Function *CodeGen_LLVM::embed_metadata_getter(const std::string &metadata_name, const std::string &function_name, const std::vector &args, - const std::map &metadata_name_map) { + const MetadataNameMap &metadata_name_map) { Constant *zero = ConstantInt::get(i32_t, 0); const int num_args = (int)args.size(); diff --git a/src/CodeGen_LLVM.h b/src/CodeGen_LLVM.h index 606840a679ec..aaee800b4fed 100644 --- a/src/CodeGen_LLVM.h +++ b/src/CodeGen_LLVM.h @@ -532,7 +532,7 @@ class CodeGen_LLVM : public IRVisitor { */ llvm::Function *embed_metadata_getter(const std::string &metadata_getter_name, const std::string &function_name, const std::vector &args, - const std::map &metadata_name_map); + const MetadataNameMap &metadata_name_map); /** Embed a constant expression as a global variable. */ llvm::Constant *embed_constant_expr(Expr e, llvm::Type *t); diff --git a/src/Generator.cpp b/src/Generator.cpp index b17790ebf12f..7b82e9a958b9 100644 --- a/src/Generator.cpp +++ b/src/Generator.cpp @@ -849,7 +849,7 @@ gengen return g; }; - const auto build_target_strings = [](std::map *gp) { + const auto build_target_strings = [](GeneratorParamsMap *gp) { std::vector target_strings; if (gp->find("target") != gp->end()) { target_strings = split_string((*gp)["target"], ","); diff --git a/src/Generator.h b/src/Generator.h index 6078196bea71..ce17b433286b 100644 --- a/src/Generator.h +++ b/src/Generator.h @@ -3164,22 +3164,6 @@ struct NoRealizations { // if they cannot return a valid Generator, they must assert-fail. using GeneratorFactory = std::function; -struct StringOrLoopLevel { - std::string string_value; - LoopLevel loop_level; - - StringOrLoopLevel() = default; - /*not-explicit*/ StringOrLoopLevel(const char *s) - : string_value(s) { - } - /*not-explicit*/ StringOrLoopLevel(const std::string &s) - : string_value(s) { - } - /*not-explicit*/ StringOrLoopLevel(const LoopLevel &loop_level) - : loop_level(loop_level) { - } -}; - class GeneratorParamInfo { // names used across all params, inputs, and outputs. std::set names; @@ -3967,6 +3951,8 @@ class RegisterGenerator { // ----------------------------- +using GeneratorParamsMap = std::map; + /** ExecuteGeneratorArgs is the set of arguments to execute_generator(). */ struct ExecuteGeneratorArgs { @@ -4027,7 +4013,7 @@ struct ExecuteGeneratorArgs { // // If any of the generator param names specified in this map are unknown // to the Generator created, an error will occur. - std::map generator_params; + GeneratorParamsMap generator_params; // Compiler Logger to use, for diagnostic work. If null, don't do any logging. CompilerLoggerFactory compiler_logger_factory = nullptr; @@ -4124,7 +4110,7 @@ struct halide_global_ns; namespace GEN_REGISTRY_NAME##_ns { \ std::unique_ptr factory(const Halide::GeneratorContext &context) { \ auto g = ORIGINAL_REGISTRY_NAME##_ns::factory(context); \ - const std::map m = __VA_ARGS__; \ + const Halide::Internal::GeneratorParamsMap m = __VA_ARGS__; \ for (const auto &c : m) { \ g->set_generatorparam_value(c.first, c.second); \ } \ diff --git a/src/Module.cpp b/src/Module.cpp index bde384044eda..6c0c820f8876 100644 --- a/src/Module.cpp +++ b/src/Module.cpp @@ -330,7 +330,7 @@ struct ModuleContents { std::vector functions; std::vector submodules; std::vector external_code; - std::map metadata_name_map; + MetadataNameMap metadata_name_map; bool any_strict_float{false}; std::unique_ptr auto_scheduler_results; }; @@ -548,7 +548,7 @@ void Module::remap_metadata_name(const std::string &from, const std::string &to) contents->metadata_name_map[from] = to; } -std::map Module::get_metadata_name_map() const { +MetadataNameMap Module::get_metadata_name_map() const { return contents->metadata_name_map; } diff --git a/src/Module.h b/src/Module.h index 8c7fb16f95a8..38394811f3f7 100644 --- a/src/Module.h +++ b/src/Module.h @@ -131,6 +131,8 @@ class CompilerLogger; struct AutoSchedulerResults; +using MetadataNameMap = std::map; + /** A halide module. This represents IR containing lowered function * definitions and buffers. */ class Module { @@ -192,7 +194,7 @@ class Module { void remap_metadata_name(const std::string &from, const std::string &to) const; /** Retrieve the metadata name map. */ - std::map get_metadata_name_map() const; + MetadataNameMap get_metadata_name_map() const; /** Set the AutoSchedulerResults for the Module. It is an error to call this * multiple times for a given Module. */ diff --git a/test/generator/abstractgeneratortest_generator.cpp b/test/generator/abstractgeneratortest_generator.cpp index 28c15a893541..0c7da6fa985b 100644 --- a/test/generator/abstractgeneratortest_generator.cpp +++ b/test/generator/abstractgeneratortest_generator.cpp @@ -34,7 +34,7 @@ class AbstractGeneratorTest : public AbstractGenerator { const GeneratorContext context_; // Constants (aka GeneratorParams) - std::map constants_ = { + GeneratorParamsMap constants_ = { {"scaling", "2"}, }; From 0564fa9db1b38fa95acce9956a997b71b97675f2 Mon Sep 17 00:00:00 2001 From: Steven Johnson Date: Fri, 3 Jun 2022 15:48:27 -0700 Subject: [PATCH 2/2] format --- src/Generator.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generator.h b/src/Generator.h index ce17b433286b..6f59b1b00f80 100644 --- a/src/Generator.h +++ b/src/Generator.h @@ -4110,7 +4110,7 @@ struct halide_global_ns; namespace GEN_REGISTRY_NAME##_ns { \ std::unique_ptr factory(const Halide::GeneratorContext &context) { \ auto g = ORIGINAL_REGISTRY_NAME##_ns::factory(context); \ - const Halide::Internal::GeneratorParamsMap m = __VA_ARGS__; \ + const Halide::Internal::GeneratorParamsMap m = __VA_ARGS__; \ for (const auto &c : m) { \ g->set_generatorparam_value(c.first, c.second); \ } \