diff options
author | John Hodge <tpg@mutabah.net> | 2019-11-24 19:28:53 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2019-11-24 20:11:41 +0800 |
commit | 80fc5138c0d8e8755b61ad37a4107a02b5a074e3 (patch) | |
tree | 7de575ac780242332229cc4ce3e86b82c726a0ad /tools/mir_opt_test/main.cpp | |
parent | 0c09aba4b978d5886f67d8745742aa2c8b545313 (diff) | |
download | mrust-80fc5138c0d8e8755b61ad37a4107a02b5a074e3.tar.gz |
mir_opt_test - All terminators implemented, more simple test cases
Diffstat (limited to 'tools/mir_opt_test/main.cpp')
-rw-r--r-- | tools/mir_opt_test/main.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/tools/mir_opt_test/main.cpp b/tools/mir_opt_test/main.cpp index 80a627f3..daa6afe5 100644 --- a/tools/mir_opt_test/main.cpp +++ b/tools/mir_opt_test/main.cpp @@ -24,6 +24,8 @@ struct Options { helpers::path test_dir; + // TODO: List of test globs + bool parse(int argc, char* argv[]); void print_usage() const; void print_help() const; @@ -96,6 +98,7 @@ int main(int argc, char* argv[]) #endif } + // Run HIR bind on the loaded code (makes sure that it's ready for use) { auto ph = DebugTimedPhase("Cleanup"); for(auto& f : test_files) @@ -104,6 +107,7 @@ int main(int argc, char* argv[]) } } + // Run MIR validation BEFORE attempting optimisaion { auto ph = DebugTimedPhase("Validate"); for(auto& f : test_files) @@ -112,21 +116,27 @@ int main(int argc, char* argv[]) } } - for(auto& f : test_files) + // Funally run the tests { auto ph = DebugTimedPhase("Run Tests"); - for(const auto& test : f.m_tests) + for(auto& f : test_files) { - const auto& in_fcn = f.m_crate->get_function_by_path(Span(), test.input_function); - const auto& exp_mir = *f.m_crate->get_function_by_path(Span(), test.output_template_function).m_code.m_mir; + for(const auto& test : f.m_tests) + { + const auto& in_fcn = f.m_crate->get_function_by_path(Span(), test.input_function); + const auto& exp_mir = *f.m_crate->get_function_by_path(Span(), test.output_template_function).m_code.m_mir; - StaticTraitResolve resolve(*f.m_crate); - // TODO: Generics? - auto cloned_mir = clone_mir(resolve, in_fcn.m_code.m_mir); + StaticTraitResolve resolve(*f.m_crate); + // TODO: Generics? + auto cloned_mir = clone_mir(resolve, in_fcn.m_code.m_mir); - MIR_Optimise(resolve, test.input_function, *cloned_mir, in_fcn.m_args, in_fcn.m_return); + MIR_Optimise(resolve, test.input_function, *cloned_mir, in_fcn.m_args, in_fcn.m_return); - compare_mir(exp_mir, *cloned_mir, test.input_function); + if( !compare_mir(exp_mir, *cloned_mir, test.input_function) ) + { + MIR_Dump_Fcn(std::cout, *cloned_mir); + } + } } } |