Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor typedef cleanup #6800

Merged
merged 2 commits into from
Jun 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ bin/*
build/*
share/*
python_bindings/bin/*
build-32/*
build-64/*
build-ios/*
build-osx/*
Expand Down
4 changes: 2 additions & 2 deletions src/CodeGen_C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LoweredArgument> &args,
const std::map<std::string, std::string> &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;
Expand Down Expand Up @@ -1798,7 +1798,7 @@ void CodeGen_C::compile(const Module &input) {
}
}

void CodeGen_C::compile(const LoweredFunc &f, const std::map<std::string, std::string> &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;
Expand Down
4 changes: 2 additions & 2 deletions src/CodeGen_C.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class CodeGen_C : public IRPrinter {

/** Emit a declaration. */
// @{
virtual void compile(const LoweredFunc &func, const std::map<std::string, std::string> &metadata_name_map);
virtual void compile(const LoweredFunc &func, const MetadataNameMap &metadata_name_map);
virtual void compile(const Buffer<> &buffer);
// @}

Expand Down Expand Up @@ -270,7 +270,7 @@ class CodeGen_C : public IRPrinter {
const std::vector<LoweredArgument> &args);
void emit_metadata_getter(const std::string &function_name,
const std::vector<LoweredArgument> &args,
const std::map<std::string, std::string> &metadata_name_map);
const MetadataNameMap &metadata_name_map);
};

} // namespace Internal
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<LoweredArgument> &args,
const std::map<std::string, std::string> &metadata_name_map) {
const MetadataNameMap &metadata_name_map) {
Constant *zero = ConstantInt::get(i32_t, 0);

const int num_args = (int)args.size();
Expand Down
2 changes: 1 addition & 1 deletion src/CodeGen_LLVM.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<LoweredArgument> &args,
const std::map<std::string, std::string> &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);
Expand Down
2 changes: 1 addition & 1 deletion src/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ gengen
return g;
};

const auto build_target_strings = [](std::map<std::string, std::string> *gp) {
const auto build_target_strings = [](GeneratorParamsMap *gp) {
std::vector<std::string> target_strings;
if (gp->find("target") != gp->end()) {
target_strings = split_string((*gp)["target"], ",");
Expand Down
22 changes: 4 additions & 18 deletions src/Generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -3164,22 +3164,6 @@ struct NoRealizations<T, Args...> {
// if they cannot return a valid Generator, they must assert-fail.
using GeneratorFactory = std::function<AbstractGeneratorPtr(const GeneratorContext &context)>;

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<std::string> names;
Expand Down Expand Up @@ -3967,6 +3951,8 @@ class RegisterGenerator {

// -----------------------------

using GeneratorParamsMap = std::map<std::string, std::string>;

/** ExecuteGeneratorArgs is the set of arguments to execute_generator().
*/
struct ExecuteGeneratorArgs {
Expand Down Expand Up @@ -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<std::string, std::string> generator_params;
GeneratorParamsMap generator_params;

// Compiler Logger to use, for diagnostic work. If null, don't do any logging.
CompilerLoggerFactory compiler_logger_factory = nullptr;
Expand Down Expand Up @@ -4124,7 +4110,7 @@ struct halide_global_ns;
namespace GEN_REGISTRY_NAME##_ns { \
std::unique_ptr<Halide::Internal::AbstractGenerator> factory(const Halide::GeneratorContext &context) { \
auto g = ORIGINAL_REGISTRY_NAME##_ns::factory(context); \
const std::map<std::string, std::string> m = __VA_ARGS__; \
const Halide::Internal::GeneratorParamsMap m = __VA_ARGS__; \
for (const auto &c : m) { \
g->set_generatorparam_value(c.first, c.second); \
} \
Expand Down
4 changes: 2 additions & 2 deletions src/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ struct ModuleContents {
std::vector<Internal::LoweredFunc> functions;
std::vector<Module> submodules;
std::vector<ExternalCode> external_code;
std::map<std::string, std::string> metadata_name_map;
MetadataNameMap metadata_name_map;
bool any_strict_float{false};
std::unique_ptr<AutoSchedulerResults> auto_scheduler_results;
};
Expand Down Expand Up @@ -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<std::string, std::string> Module::get_metadata_name_map() const {
MetadataNameMap Module::get_metadata_name_map() const {
return contents->metadata_name_map;
}

Expand Down
4 changes: 3 additions & 1 deletion src/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ class CompilerLogger;

struct AutoSchedulerResults;

using MetadataNameMap = std::map<std::string, std::string>;

/** A halide module. This represents IR containing lowered function
* definitions and buffers. */
class Module {
Expand Down Expand Up @@ -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<std::string, std::string> 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. */
Expand Down
2 changes: 1 addition & 1 deletion test/generator/abstractgeneratortest_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AbstractGeneratorTest : public AbstractGenerator {
const GeneratorContext context_;

// Constants (aka GeneratorParams)
std::map<std::string, std::string> constants_ = {
GeneratorParamsMap constants_ = {
{"scaling", "2"},
};

Expand Down