diff --git a/qpkg/src/bench/ansi.cc b/qpkg/src/core/ANSI.cc similarity index 99% rename from qpkg/src/bench/ansi.cc rename to qpkg/src/core/ANSI.cc index 76f8432a..1b901ac3 100644 --- a/qpkg/src/bench/ansi.cc +++ b/qpkg/src/core/ANSI.cc @@ -29,7 +29,7 @@ /// /// //////////////////////////////////////////////////////////////////////////////// -#include +#include #include thread_local qpkg::ansi::AnsiCout qpkg::ansi::acout; diff --git a/qpkg/src/bench/bench.hh b/qpkg/src/core/ANSI.hh similarity index 83% rename from qpkg/src/bench/bench.hh rename to qpkg/src/core/ANSI.hh index 96b6c9c6..5b2b1988 100644 --- a/qpkg/src/bench/bench.hh +++ b/qpkg/src/core/ANSI.hh @@ -29,8 +29,8 @@ /// /// //////////////////////////////////////////////////////////////////////////////// -#ifndef __QPKG_BENCH_HH__ -#define __QPKG_BENCH_HH__ +#ifndef __QPKG_CORE_ANSI_HH__ +#define __QPKG_CORE_ANSI_HH__ #include #include @@ -41,7 +41,6 @@ #include namespace qpkg { - namespace ansi { enum class Style { /*==== Text Color ====*/ @@ -137,46 +136,6 @@ static inline void operator|=(AnsiCout &out, Style style) { extern thread_local AnsiCout acout; } // namespace ansi -namespace bench { -int run_benchmark_lexer(); -int run_benchmark_parser(); -int run_benchmark_quix_ir(); -int run_benchmark_delta_ir(); -int run_benchmark_llvm_ir(); -int run_benchmark_llvm_codegen(); -int run_benchmark_c11_codegen(); -int run_benchmark_pipeline(); - -extern const std::string_view test_source_code; - -class Progress { - std::string m_title; - std::string m_last_msg; - std::queue> m_queue; - std::chrono::high_resolution_clock::time_point m_last_print; - constexpr static std::chrono::milliseconds m_print_interval = - std::chrono::milliseconds(1000); - - void print(double percent, const std::string &msg); - - public: - Progress(const std::string &title); - - void update(double percent, const std::string &msg = ""); - void done(const std::string &outfile_name = ""); - - enum class Result { - THROUGHPUT, - MEMORY, - TIME, - }; - - void begin_result(Result type); - void result(const std::string &msg); - void end_result(); -}; -} // namespace bench - } // namespace qpkg -#endif // __QPKG_BENCH_HH__ \ No newline at end of file +#endif // __QPKG_CORE_ANSI_HH__ \ No newline at end of file diff --git a/qpkg/src/core/Config.hh b/qpkg/src/core/Config.hh new file mode 100644 index 00000000..ed01e01f --- /dev/null +++ b/qpkg/src/core/Config.hh @@ -0,0 +1,37 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#ifndef __QPKG_CORE_CONFIG_HH__ +#define __QPKG_CORE_CONFIG_HH__ + +#define QPKG_DEV_TOOLS 1 + +#endif // __QPKG_CORE_CONFIG_HH__ diff --git a/qpkg/src/dev/bench/bench.hh b/qpkg/src/dev/bench/bench.hh new file mode 100644 index 00000000..f14130f0 --- /dev/null +++ b/qpkg/src/dev/bench/bench.hh @@ -0,0 +1,86 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#ifndef __QPKG_BENCH_HH__ +#define __QPKG_BENCH_HH__ + +#include +#include +#include +#include +#include +#include +#include + +namespace qpkg { +namespace dev::bench { +int run_benchmark_lexer(); +int run_benchmark_parser(); +int run_benchmark_quix_ir(); +int run_benchmark_delta_ir(); +int run_benchmark_llvm_ir(); +int run_benchmark_llvm_codegen(); +int run_benchmark_c11_codegen(); +int run_benchmark_pipeline(); + +extern const std::string_view test_source_code; + +class Progress { + std::string m_title; + std::string m_last_msg; + std::queue> m_queue; + std::chrono::high_resolution_clock::time_point m_last_print; + constexpr static std::chrono::milliseconds m_print_interval = + std::chrono::milliseconds(1000); + + void print(double percent, const std::string &msg); + + public: + Progress(const std::string &title); + + void update(double percent, const std::string &msg = ""); + void done(const std::string &outfile_name = ""); + + enum class Result { + THROUGHPUT, + MEMORY, + TIME, + }; + + void begin_result(Result type); + void result(const std::string &msg); + void end_result(); +}; +} // namespace dev::bench + +} // namespace qpkg + +#endif // __QPKG_BENCH_HH__ \ No newline at end of file diff --git a/qpkg/src/bench/c11-codegen.cc b/qpkg/src/dev/bench/c11-codegen.cc similarity index 95% rename from qpkg/src/bench/c11-codegen.cc rename to qpkg/src/dev/bench/c11-codegen.cc index c1c579cd..41654073 100644 --- a/qpkg/src/bench/c11-codegen.cc +++ b/qpkg/src/dev/bench/c11-codegen.cc @@ -31,7 +31,7 @@ #include -#include +#include #include #include #include @@ -52,8 +52,8 @@ bool do_bench_c11(std::chrono::system_clock::time_point &start, return false; } - code = fmemopen((void *)qpkg::bench::test_source_code.data(), - qpkg::bench::test_source_code.size(), "r"); + code = fmemopen((void *)qpkg::dev::bench::test_source_code.data(), + qpkg::dev::bench::test_source_code.size(), "r"); if (!code) { std::cerr << "do_bench (internal error): Failed to open code stream." << std::endl; @@ -99,7 +99,7 @@ static void write_c11_result_csv(const std::vector &throughput) { file.close(); } -int qpkg::bench::run_benchmark_c11_codegen() { +int qpkg::dev::bench::run_benchmark_c11_codegen() { Progress progress("C11 Codegen"); std::vector times; @@ -127,7 +127,7 @@ int qpkg::bench::run_benchmark_c11_codegen() { std::vector throughput; // Kbit/s for (size_t i = 0; i < ROUNDS; i++) { - size_t total_kbit = qpkg::bench::test_source_code.size() / 1024 * 8; + size_t total_kbit = qpkg::dev::bench::test_source_code.size() / 1024 * 8; double kbit_per_ns = total_kbit / times[i]; double kbit_per_s = kbit_per_ns * 1e9; throughput.push_back(kbit_per_s); diff --git a/qpkg/src/bench/delta-ir.cc b/qpkg/src/dev/bench/delta-ir.cc similarity index 95% rename from qpkg/src/bench/delta-ir.cc rename to qpkg/src/dev/bench/delta-ir.cc index 5c82e37c..a1ee4cb8 100644 --- a/qpkg/src/bench/delta-ir.cc +++ b/qpkg/src/dev/bench/delta-ir.cc @@ -31,7 +31,7 @@ #include -#include +#include #include #include #include @@ -52,8 +52,8 @@ bool do_bench_delta_ir(std::chrono::system_clock::time_point &start, return false; } - code = fmemopen((void *)qpkg::bench::test_source_code.data(), - qpkg::bench::test_source_code.size(), "r"); + code = fmemopen((void *)qpkg::dev::bench::test_source_code.data(), + qpkg::dev::bench::test_source_code.size(), "r"); if (!code) { std::cerr << "do_bench (internal error): Failed to open code stream." << std::endl; @@ -99,7 +99,7 @@ static void write_delta_ir_result_csv(const std::vector &throughput) { file.close(); } -int qpkg::bench::run_benchmark_delta_ir() { +int qpkg::dev::bench::run_benchmark_delta_ir() { Progress progress("DeltaIR Codegen"); std::vector times; @@ -127,7 +127,7 @@ int qpkg::bench::run_benchmark_delta_ir() { std::vector throughput; // Kbit/s for (size_t i = 0; i < ROUNDS; i++) { - size_t total_kbit = qpkg::bench::test_source_code.size() / 1024 * 8; + size_t total_kbit = qpkg::dev::bench::test_source_code.size() / 1024 * 8; double kbit_per_ns = total_kbit / times[i]; double kbit_per_s = kbit_per_ns * 1e9; throughput.push_back(kbit_per_s); diff --git a/qpkg/src/bench/lexer.cc b/qpkg/src/dev/bench/lexer.cc similarity index 96% rename from qpkg/src/bench/lexer.cc rename to qpkg/src/dev/bench/lexer.cc index 19745e16..12aff27b 100644 --- a/qpkg/src/bench/lexer.cc +++ b/qpkg/src/dev/bench/lexer.cc @@ -31,7 +31,7 @@ #include -#include +#include #include #include #include @@ -54,8 +54,8 @@ bool do_bench_lexer(std::chrono::system_clock::time_point &start, return false; } - code = fmemopen((void *)qpkg::bench::test_source_code.data(), - qpkg::bench::test_source_code.size(), "r"); + code = fmemopen((void *)qpkg::dev::bench::test_source_code.data(), + qpkg::dev::bench::test_source_code.size(), "r"); if (!code) { std::cerr << "do_bench (internal error): Failed to open code stream." << std::endl; @@ -115,7 +115,7 @@ static void write_lexer_result_csv(const std::vector &throughput) { file.close(); } -int qpkg::bench::run_benchmark_lexer() { +int qpkg::dev::bench::run_benchmark_lexer() { Progress progress("Lexer"); std::vector times; @@ -143,7 +143,7 @@ int qpkg::bench::run_benchmark_lexer() { std::vector throughput; // Kbit/s for (size_t i = 0; i < ROUNDS; i++) { - size_t total_kbit = qpkg::bench::test_source_code.size() / 1024 * 8; + size_t total_kbit = qpkg::dev::bench::test_source_code.size() / 1024 * 8; double kbit_per_ns = total_kbit / times[i]; double kbit_per_s = kbit_per_ns * 1e9; throughput.push_back(kbit_per_s); diff --git a/qpkg/src/bench/llvm-codegen.cc b/qpkg/src/dev/bench/llvm-codegen.cc similarity index 95% rename from qpkg/src/bench/llvm-codegen.cc rename to qpkg/src/dev/bench/llvm-codegen.cc index b08a1cb7..5d6a8343 100644 --- a/qpkg/src/bench/llvm-codegen.cc +++ b/qpkg/src/dev/bench/llvm-codegen.cc @@ -31,7 +31,7 @@ #include -#include +#include #include #include #include @@ -52,8 +52,8 @@ bool do_bench_llvm_codegen(std::chrono::system_clock::time_point &start, return false; } - code = fmemopen((void *)qpkg::bench::test_source_code.data(), - qpkg::bench::test_source_code.size(), "r"); + code = fmemopen((void *)qpkg::dev::bench::test_source_code.data(), + qpkg::dev::bench::test_source_code.size(), "r"); if (!code) { std::cerr << "do_bench (internal error): Failed to open code stream." << std::endl; @@ -99,7 +99,7 @@ static void write_llvm_obj_result_csv(const std::vector &throughput) { file.close(); } -int qpkg::bench::run_benchmark_llvm_codegen() { +int qpkg::dev::bench::run_benchmark_llvm_codegen() { Progress progress("LLVM OBJECT CODEGEN"); std::vector times; @@ -127,7 +127,7 @@ int qpkg::bench::run_benchmark_llvm_codegen() { std::vector throughput; // Kbit/s for (size_t i = 0; i < ROUNDS; i++) { - size_t total_kbit = qpkg::bench::test_source_code.size() / 1024 * 8; + size_t total_kbit = qpkg::dev::bench::test_source_code.size() / 1024 * 8; double kbit_per_ns = total_kbit / times[i]; double kbit_per_s = kbit_per_ns * 1e9; throughput.push_back(kbit_per_s); diff --git a/qpkg/src/bench/llvm-ir.cc b/qpkg/src/dev/bench/llvm-ir.cc similarity index 95% rename from qpkg/src/bench/llvm-ir.cc rename to qpkg/src/dev/bench/llvm-ir.cc index 1981f9c0..07cf45c6 100644 --- a/qpkg/src/bench/llvm-ir.cc +++ b/qpkg/src/dev/bench/llvm-ir.cc @@ -31,7 +31,7 @@ #include -#include +#include #include #include #include @@ -52,8 +52,8 @@ bool do_bench_llvm_ir(std::chrono::system_clock::time_point &start, return false; } - code = fmemopen((void *)qpkg::bench::test_source_code.data(), - qpkg::bench::test_source_code.size(), "r"); + code = fmemopen((void *)qpkg::dev::bench::test_source_code.data(), + qpkg::dev::bench::test_source_code.size(), "r"); if (!code) { std::cerr << "do_bench (internal error): Failed to open code stream." << std::endl; @@ -99,7 +99,7 @@ static void write_llvm_ir_result_csv(const std::vector &throughput) { file.close(); } -int qpkg::bench::run_benchmark_llvm_ir() { +int qpkg::dev::bench::run_benchmark_llvm_ir() { Progress progress("LLVM IR"); std::vector times; @@ -127,7 +127,7 @@ int qpkg::bench::run_benchmark_llvm_ir() { std::vector throughput; // Kbit/s for (size_t i = 0; i < ROUNDS; i++) { - size_t total_kbit = qpkg::bench::test_source_code.size() / 1024 * 8; + size_t total_kbit = qpkg::dev::bench::test_source_code.size() / 1024 * 8; double kbit_per_ns = total_kbit / times[i]; double kbit_per_s = kbit_per_ns * 1e9; throughput.push_back(kbit_per_s); diff --git a/qpkg/src/bench/parser.cc b/qpkg/src/dev/bench/parser.cc similarity index 95% rename from qpkg/src/bench/parser.cc rename to qpkg/src/dev/bench/parser.cc index 59acd1e4..fa6db173 100644 --- a/qpkg/src/bench/parser.cc +++ b/qpkg/src/dev/bench/parser.cc @@ -31,7 +31,7 @@ #include -#include +#include #include #include #include @@ -52,8 +52,8 @@ bool do_bench_parser(std::chrono::system_clock::time_point &start, return false; } - code = fmemopen((void *)qpkg::bench::test_source_code.data(), - qpkg::bench::test_source_code.size(), "r"); + code = fmemopen((void *)qpkg::dev::bench::test_source_code.data(), + qpkg::dev::bench::test_source_code.size(), "r"); if (!code) { std::cerr << "do_bench (internal error): Failed to open code stream." << std::endl; @@ -99,7 +99,7 @@ static void write_parser_result_csv(const std::vector &throughput) { file.close(); } -int qpkg::bench::run_benchmark_parser() { +int qpkg::dev::bench::run_benchmark_parser() { Progress progress("Parser"); std::vector times; @@ -127,7 +127,7 @@ int qpkg::bench::run_benchmark_parser() { std::vector throughput; // Kbit/s for (size_t i = 0; i < ROUNDS; i++) { - size_t total_kbit = qpkg::bench::test_source_code.size() / 1024 * 8; + size_t total_kbit = qpkg::dev::bench::test_source_code.size() / 1024 * 8; double kbit_per_ns = total_kbit / times[i]; double kbit_per_s = kbit_per_ns * 1e9; throughput.push_back(kbit_per_s); diff --git a/qpkg/src/bench/pipeline.cc b/qpkg/src/dev/bench/pipeline.cc similarity index 97% rename from qpkg/src/bench/pipeline.cc rename to qpkg/src/dev/bench/pipeline.cc index ddf90f6b..2a894f76 100644 --- a/qpkg/src/bench/pipeline.cc +++ b/qpkg/src/dev/bench/pipeline.cc @@ -33,7 +33,7 @@ #include #include -#include +#include #include bool do_bench_lexer(std::chrono::system_clock::time_point &start, @@ -51,7 +51,7 @@ bool do_bench_c11(std::chrono::system_clock::time_point &start, bool do_bench_llvm_codegen(std::chrono::system_clock::time_point &start, std::chrono::system_clock::time_point &end); -int qpkg::bench::run_benchmark_pipeline() { +int qpkg::dev::bench::run_benchmark_pipeline() { struct SuitePerf { double lexer; double parser; @@ -74,7 +74,7 @@ int qpkg::bench::run_benchmark_pipeline() { double time_ns = \ std::chrono::duration_cast(end - start) \ .count(); \ - size_t total_kbit = qpkg::bench::test_source_code.size() / 1024 * 8; \ + size_t total_kbit = qpkg::dev::bench::test_source_code.size() / 1024 * 8; \ double kbit_per_ns = total_kbit / time_ns; \ double kbit_per_s = kbit_per_ns * 1e9; \ suite_perf.name = kbit_per_s; \ diff --git a/qpkg/src/bench/programdata.cc b/qpkg/src/dev/bench/programdata.cc similarity index 99% rename from qpkg/src/bench/programdata.cc rename to qpkg/src/dev/bench/programdata.cc index e2a5c707..ddb59db0 100644 --- a/qpkg/src/bench/programdata.cc +++ b/qpkg/src/dev/bench/programdata.cc @@ -29,9 +29,9 @@ /// /// //////////////////////////////////////////////////////////////////////////////// -#include +#include -const std::string_view qpkg::bench::test_source_code = R"QUIX_BENCH_CODE( +const std::string_view qpkg::dev::bench::test_source_code = R"QUIX_BENCH_CODE( @use "v1.0"; # And he said, "Let there be performance!" diff --git a/qpkg/src/bench/progress.cc b/qpkg/src/dev/bench/progress.cc similarity index 93% rename from qpkg/src/bench/progress.cc rename to qpkg/src/dev/bench/progress.cc index 92f4fd09..f34bdb03 100644 --- a/qpkg/src/bench/progress.cc +++ b/qpkg/src/dev/bench/progress.cc @@ -29,8 +29,9 @@ /// /// //////////////////////////////////////////////////////////////////////////////// -#include #include +#include +#include #include #include @@ -42,7 +43,7 @@ using namespace qpkg::ansi; -qpkg::bench::Progress::Progress(const std::string &title) { +qpkg::dev::bench::Progress::Progress(const std::string &title) { m_title = title; acout |= Style::BOLD | Style::FG_WHITE | Style::BG_DEFAULT; @@ -76,7 +77,7 @@ qpkg::bench::Progress::Progress(const std::string &title) { << std::endl; } -void qpkg::bench::Progress::print(double percent, const std::string &msg) { +void qpkg::dev::bench::Progress::print(double percent, const std::string &msg) { std::stringstream ss; ss << std::fixed << std::setprecision(2) << percent * 100.0; std::string percent_str = ss.str(); @@ -95,7 +96,8 @@ void qpkg::bench::Progress::print(double percent, const std::string &msg) { acout << std::endl; } -void qpkg::bench::Progress::update(double percent, const std::string &msg) { +void qpkg::dev::bench::Progress::update(double percent, + const std::string &msg) { auto now = std::chrono::high_resolution_clock::now(); if (now - m_last_print < m_print_interval) { m_queue.emplace(msg, percent); @@ -116,7 +118,8 @@ void qpkg::bench::Progress::update(double percent, const std::string &msg) { print(percent, msg); } -void qpkg::bench::Progress::begin_result(qpkg::bench::Progress::Result type) { +void qpkg::dev::bench::Progress::begin_result( + qpkg::dev::bench::Progress::Result type) { switch (type) { case Result::THROUGHPUT: acout << "\n┏━━━━━┫ "; @@ -142,7 +145,7 @@ void qpkg::bench::Progress::begin_result(qpkg::bench::Progress::Result type) { } } -void qpkg::bench::Progress::result(const std::string &msg) { +void qpkg::dev::bench::Progress::result(const std::string &msg) { acout << "┃ "; acout |= Style::BOLD | Style::FG_PURPLE | Style::BG_DEFAULT; acout << "*"; @@ -150,12 +153,12 @@ void qpkg::bench::Progress::result(const std::string &msg) { acout << " " << msg << std::endl; } -void qpkg::bench::Progress::end_result() { +void qpkg::dev::bench::Progress::end_result() { acout << "┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n" << std::endl; } -void qpkg::bench::Progress::done(const std::string &outfile_name) { +void qpkg::dev::bench::Progress::done(const std::string &outfile_name) { bool do_last = false; #define F_CMP(a, b) (fabs((a) - (b)) < 1e-6) diff --git a/qpkg/src/bench/quix_ir.cc b/qpkg/src/dev/bench/quix_ir.cc similarity index 95% rename from qpkg/src/bench/quix_ir.cc rename to qpkg/src/dev/bench/quix_ir.cc index 4d6222a4..568885af 100644 --- a/qpkg/src/bench/quix_ir.cc +++ b/qpkg/src/dev/bench/quix_ir.cc @@ -31,7 +31,7 @@ #include -#include +#include #include #include #include @@ -52,8 +52,8 @@ bool do_bench_quix_ir(std::chrono::system_clock::time_point &start, return false; } - code = fmemopen((void *)qpkg::bench::test_source_code.data(), - qpkg::bench::test_source_code.size(), "r"); + code = fmemopen((void *)qpkg::dev::bench::test_source_code.data(), + qpkg::dev::bench::test_source_code.size(), "r"); if (!code) { std::cerr << "do_bench (internal error): Failed to open code stream." << std::endl; @@ -99,7 +99,7 @@ static void write_quix_ir_result_csv(const std::vector &throughput) { file.close(); } -int qpkg::bench::run_benchmark_quix_ir() { +int qpkg::dev::bench::run_benchmark_quix_ir() { Progress progress("QIR Codegen"); std::vector times; @@ -127,7 +127,7 @@ int qpkg::bench::run_benchmark_quix_ir() { std::vector throughput; // Kbit/s for (size_t i = 0; i < ROUNDS; i++) { - size_t total_kbit = qpkg::bench::test_source_code.size() / 1024 * 8; + size_t total_kbit = qpkg::dev::bench::test_source_code.size() / 1024 * 8; double kbit_per_ns = total_kbit / times[i]; double kbit_per_s = kbit_per_ns * 1e9; throughput.push_back(kbit_per_s); diff --git a/qpkg/src/dev/test/c11-codegen-vectors.cc b/qpkg/src/dev/test/c11-codegen-vectors.cc new file mode 100644 index 00000000..a3157bd0 --- /dev/null +++ b/qpkg/src/dev/test/c11-codegen-vectors.cc @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#if QPKG_DEV_TOOLS + +#endif diff --git a/qpkg/src/dev/test/delta-ir-vectors.cc b/qpkg/src/dev/test/delta-ir-vectors.cc new file mode 100644 index 00000000..a3157bd0 --- /dev/null +++ b/qpkg/src/dev/test/delta-ir-vectors.cc @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#if QPKG_DEV_TOOLS + +#endif diff --git a/qpkg/src/dev/test/lexer-vectors.cc b/qpkg/src/dev/test/lexer-vectors.cc new file mode 100644 index 00000000..a3157bd0 --- /dev/null +++ b/qpkg/src/dev/test/lexer-vectors.cc @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#if QPKG_DEV_TOOLS + +#endif diff --git a/qpkg/src/dev/test/llvm-codegen-vectors.cc b/qpkg/src/dev/test/llvm-codegen-vectors.cc new file mode 100644 index 00000000..a3157bd0 --- /dev/null +++ b/qpkg/src/dev/test/llvm-codegen-vectors.cc @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#if QPKG_DEV_TOOLS + +#endif diff --git a/qpkg/src/dev/test/llvm-ir-vectors.cc b/qpkg/src/dev/test/llvm-ir-vectors.cc new file mode 100644 index 00000000..a3157bd0 --- /dev/null +++ b/qpkg/src/dev/test/llvm-ir-vectors.cc @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#if QPKG_DEV_TOOLS + +#endif diff --git a/qpkg/src/dev/test/parser-vectors.cc b/qpkg/src/dev/test/parser-vectors.cc new file mode 100644 index 00000000..a3157bd0 --- /dev/null +++ b/qpkg/src/dev/test/parser-vectors.cc @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#if QPKG_DEV_TOOLS + +#endif diff --git a/qpkg/src/dev/test/progress.cc b/qpkg/src/dev/test/progress.cc new file mode 100644 index 00000000..8a32e0b4 --- /dev/null +++ b/qpkg/src/dev/test/progress.cc @@ -0,0 +1,152 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#if QPKG_DEV_TOOLS + +#include +#include +#include +#include +#include + +/// TODO: write CMake code to generate commit number define +#define QPKG_COMMIT_NUMBER "0" + +#define PROGRAM_STRING "Quix Compiler Suite (qpkg) - v" QPKG_COMMIT_NUMBER +#define COPYRIGHT_STRING "Copyright (C) 2024 Wesley C. Jones" + +using namespace qpkg::ansi; + +qpkg::dev::test::Progress::Progress(const std::string &title) { + m_title = title; + m_all_okay = true; + + acout |= Style::BOLD | Style::FG_WHITE | Style::BG_DEFAULT; + acout << "*"; + acout |= Style::RESET; + acout << " " PROGRAM_STRING << std::endl; + + acout |= Style::BOLD | Style::FG_WHITE | Style::BG_DEFAULT; + acout << "*"; + acout |= Style::RESET; + acout << " " COPYRIGHT_STRING << std::endl; + + acout << std::endl; + + acout |= Style::BOLD | Style::FG_CYAN | Style::BG_DEFAULT; + acout << "*"; + acout |= Style::RESET; + acout << " Running tests for "; + acout |= Style::BOLD | Style::FG_CYAN | Style::BG_DEFAULT; + acout << title; + acout |= Style::RESET; + acout << "..." << std::endl; + acout |= Style::BOLD | Style::FG_CYAN | Style::BG_DEFAULT; + acout << "*"; + acout |= Style::RESET; + acout << " This may take a while. Status updates will be printed" + << std::endl; + acout << " periodically.\n" << std::endl; +} + +void qpkg::dev::test::Progress::begin_result() { + acout << "┏━━━━━━━━━━━━━━━━━━━━━━━━━━" << std::endl; +} + +void qpkg::dev::test::Progress::result(const std::string &msg, Result type) { + if (type == Result::FAIL) { + m_all_okay = false; + } + + acout << "┃ "; + switch (type) { + case Result::PASS: + acout |= Style::BOLD | Style::FG_GREEN | Style::BG_DEFAULT; + acout << "PASS"; + acout |= Style::RESET; + break; + case Result::FAIL: + acout |= Style::BOLD | Style::FG_RED | Style::BG_DEFAULT; + acout << "FAIL"; + acout |= Style::RESET; + break; + } + + acout << " " << msg << std::endl; +} + +void qpkg::dev::test::Progress::end_result() { + if (m_all_okay) { + acout << "┃\n┃ "; + acout |= Style::BOLD | Style::FG_GREEN | Style::BG_DEFAULT; + acout << "* "; + acout |= Style::RESET; + acout |= Style::BOLD; + acout << "All tests passed!" << std::endl; + acout |= Style::RESET; + } else { + acout << "┃\n┃ "; + acout |= Style::BOLD | Style::FG_RED | Style::BG_DEFAULT; + acout << "* "; + acout |= Style::RESET; + acout |= Style::BOLD | Style::FG_RED; + acout << "Some tests failed" << std::endl; + acout |= Style::RESET; + } + + acout << "┗━━━━━━━━━━━━━━━━━━━━━━━━━━\n" << std::endl; +} + +void qpkg::dev::test::Progress::done(const std::string &outfile_name) { + acout |= Style::BOLD | Style::FG_CYAN | Style::BG_DEFAULT; + acout << "*"; + acout |= Style::RESET; + acout << " Done running tests for "; + acout |= Style::BOLD | Style::FG_CYAN | Style::BG_DEFAULT; + acout << m_title; + acout |= Style::RESET; + acout << "." << std::endl; + + if (!outfile_name.empty()) { + acout |= Style::BOLD | Style::FG_GREEN | Style::BG_DEFAULT; + acout << "*"; + acout |= Style::RESET; + acout << " Results saved to "; + acout |= Style::BOLD | Style::FG_GREEN | Style::BG_DEFAULT; + acout << outfile_name; + acout |= Style::RESET; + acout << "." << std::endl; + } +} + +#endif // QPKG_DEV_TOOLS diff --git a/qpkg/src/dev/test/quit-ir-vectors.cc b/qpkg/src/dev/test/quit-ir-vectors.cc new file mode 100644 index 00000000..a3157bd0 --- /dev/null +++ b/qpkg/src/dev/test/quit-ir-vectors.cc @@ -0,0 +1,36 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#if QPKG_DEV_TOOLS + +#endif diff --git a/qpkg/src/dev/test/test.cc b/qpkg/src/dev/test/test.cc new file mode 100644 index 00000000..540f03f9 --- /dev/null +++ b/qpkg/src/dev/test/test.cc @@ -0,0 +1,108 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#if QPKG_DEV_TOOLS + +#include +#include + +int qpkg::dev::test::run_lexer_test(Progress &p) { + p.result("Lexer", Progress::Result::PASS); + + /// TODO: Implement lexer test + return 0; +} + +int qpkg::dev::test::run_parser_test(Progress &p) { + p.result("Parser", Progress::Result::PASS); + + /// TODO: Implement parser test + return 0; +} + +int qpkg::dev::test::run_quix_ir_test(Progress &p) { + p.result("Quix IR", Progress::Result::FAIL); + + /// TODO: Implement Quix IR test + return 0; +} + +int qpkg::dev::test::run_delta_ir_test(Progress &p) { + p.result("Delta IR", Progress::Result::PASS); + + /// TODO: Implement Delta IR test + return 0; +} + +int qpkg::dev::test::run_llvm_ir_test(Progress &p) { + p.result("LLVM IR", Progress::Result::PASS); + + /// TODO: Implement LLVM IR test + return 0; +} + +int qpkg::dev::test::run_llvm_codegen_test(Progress &p) { + p.result("LLVM Codegen", Progress::Result::PASS); + + /// TODO: Implement LLVM codegen test + return 0; +} + +int qpkg::dev::test::run_c11_codegen_test(Progress &p) { + p.result("C11 Codegen", Progress::Result::PASS); + + /// TODO: Implement C11 codegen test + return 0; +} + +int qpkg::dev::test::run_tests() { + int ret = 0; + + Progress progress("Quix"); + + progress.begin_result(); + ret += run_lexer_test(progress); + ret += run_parser_test(progress); + ret += run_quix_ir_test(progress); + ret += run_delta_ir_test(progress); + ret += run_llvm_ir_test(progress); + ret += run_llvm_codegen_test(progress); + ret += run_c11_codegen_test(progress); + progress.end_result(); + + progress.done(); + + return ret; +} + +#endif // QPKG_DEV_TOOLS diff --git a/qpkg/src/dev/test/test.hh b/qpkg/src/dev/test/test.hh new file mode 100644 index 00000000..8ab07f81 --- /dev/null +++ b/qpkg/src/dev/test/test.hh @@ -0,0 +1,81 @@ +//////////////////////////////////////////////////////////////////////////////// +/// /// +/// ░▒▓██████▓▒░░▒▓███████▓▒░░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓███████▓▒░░▒▓███████▓▒░░▒▓█▓▒▒▓███▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░▒▓█▓▒░░▒▓█▓▒░ /// +/// ░▒▓██████▓▒░░▒▓█▓▒░ ░▒▓█▓▒░░▒▓█▓▒░░▒▓██████▓▒░ /// +/// ░▒▓█▓▒░ /// +/// ░▒▓██▓▒░ /// +/// /// +/// * QUIX PACKAGE MANAGER - The official tool for the Quix language. /// +/// * Copyright (C) 2024 Wesley C. Jones /// +/// /// +/// The QUIX Compiler Suite is free software; you can redistribute it or /// +/// modify it under the terms of the GNU Lesser General Public /// +/// License as published by the Free Software Foundation; either /// +/// version 2.1 of the License, or (at your option) any later version. /// +/// /// +/// The QUIX Compiler Suite is distributed in the hope that it will be /// +/// useful, but WITHOUT ANY WARRANTY; without even the implied warranty of /// +/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU /// +/// Lesser General Public License for more details. /// +/// /// +/// You should have received a copy of the GNU Lesser General Public /// +/// License along with the QUIX Compiler Suite; if not, see /// +/// . /// +/// /// +//////////////////////////////////////////////////////////////////////////////// + +#include + +#if QPKG_DEV_TOOLS + +#ifndef __QPKG_DEV_TEST_HH__ +#define __QPKG_DEV_TEST_HH__ + +#include +#include +#include +#include +#include +#include +#include + +namespace qpkg::dev::test { +class Progress { + std::string m_title; + bool m_all_okay; + + public: + Progress(const std::string &title); + + enum class Result { + PASS, + FAIL, + }; + + void begin_result(); + void result(const std::string &msg, Result type); + void end_result(); + + void done(const std::string &outfile_name = ""); +}; + +int run_tests(); + +int run_lexer_test(Progress &progress); +int run_parser_test(Progress &progress); +int run_quix_ir_test(Progress &progress); +int run_delta_ir_test(Progress &progress); +int run_llvm_ir_test(Progress &progress); +int run_llvm_codegen_test(Progress &progress); +int run_c11_codegen_test(Progress &progress); + +} // namespace qpkg::dev::test + +#endif + +#endif // QPKG_DEV_TOOLS diff --git a/qpkg/src/qpkg.cc b/qpkg/src/qpkg.cc index 29001969..9bbb9d30 100644 --- a/qpkg/src/qpkg.cc +++ b/qpkg/src/qpkg.cc @@ -31,10 +31,16 @@ #include -#include #include #include +#include #include + +#if QPKG_DEV_TOOLS +#include +#include +#endif + #include #include #include @@ -506,6 +512,7 @@ void setup_argparse_test(ArgumentParser &parser) { .nargs(1); } +#if QPKG_DEV_TOOLS void setup_argparse_dev( ArgumentParser &parser, std::unordered_map> @@ -517,8 +524,7 @@ void setup_argparse_dev( .implicit_value(true); /*================= BENCH SUBPARSER =================*/ - auto bench = - std::make_unique("bench", "run internal benchmarks"); + auto bench = std::make_unique("bench"); bench->add_argument("-n", "--name") .choices("lexer", "parser", "quix-ir", "delta-ir", "llvm-ir", @@ -532,18 +538,31 @@ void setup_argparse_dev( subparsers["bench"] = std::move(bench); + /*================= TEST SUBPARSER =================*/ + auto test = std::make_unique("test"); + + subparsers["test"] = std::move(test); + parser.add_subparser(*subparsers["bench"]); + parser.add_subparser(*subparsers["test"]); } +#endif + void setup_argparse( ArgumentParser &parser, ArgumentParser &init_parser, ArgumentParser &build_parser, ArgumentParser &clean_parser, ArgumentParser &update_parser, ArgumentParser &install_parser, ArgumentParser &doc_parser, ArgumentParser &env_parser, ArgumentParser &fmt_parser, ArgumentParser &list_parser, - ArgumentParser &test_parser, ArgumentParser &dev_parser, + ArgumentParser &test_parser +#if QPKG_DEV_TOOLS + , + ArgumentParser &dev_parser, std::unordered_map> - &dev_subparsers) { + &dev_subparsers +#endif +) { using namespace argparse; setup_argparse_init(init_parser); @@ -556,7 +575,9 @@ void setup_argparse( setup_argparse_fmt(fmt_parser); setup_argparse_list(list_parser); setup_argparse_test(test_parser); +#if QPKG_DEV_TOOLS setup_argparse_dev(dev_parser, dev_subparsers); +#endif parser.add_subparser(init_parser); parser.add_subparser(build_parser); @@ -568,7 +589,9 @@ void setup_argparse( parser.add_subparser(fmt_parser); parser.add_subparser(list_parser); parser.add_subparser(test_parser); +#if QPKG_DEV_TOOLS parser.add_subparser(dev_parser); +#endif parser.add_argument("--license") .help("show license information") @@ -726,6 +749,7 @@ int run_test_mode(const ArgumentParser &parser) { return 1; } +#if QPKG_DEV_TOOLS int run_dev_mode( const ArgumentParser &parser, const std::unordered_map> @@ -793,34 +817,36 @@ int run_dev_mode( switch (bench_type) { case Benchmark::LEXER: - return qpkg::bench::run_benchmark_lexer(); + return qpkg::dev::bench::run_benchmark_lexer(); case Benchmark::PARSER: - return qpkg::bench::run_benchmark_parser(); + return qpkg::dev::bench::run_benchmark_parser(); case Benchmark::Q_IR: - return qpkg::bench::run_benchmark_quix_ir(); + return qpkg::dev::bench::run_benchmark_quix_ir(); case Benchmark::DELTA_IR: - return qpkg::bench::run_benchmark_delta_ir(); + return qpkg::dev::bench::run_benchmark_delta_ir(); case Benchmark::LLVM_IR: - return qpkg::bench::run_benchmark_llvm_ir(); + return qpkg::dev::bench::run_benchmark_llvm_ir(); case Benchmark::LLVM_CODEGEN: - return qpkg::bench::run_benchmark_llvm_codegen(); + return qpkg::dev::bench::run_benchmark_llvm_codegen(); case Benchmark::C11_CODEGEN: - return qpkg::bench::run_benchmark_c11_codegen(); + return qpkg::dev::bench::run_benchmark_c11_codegen(); case Benchmark::PIPELINE: - return qpkg::bench::run_benchmark_pipeline(); + return qpkg::dev::bench::run_benchmark_pipeline(); default: std::cerr << "Unknown benchmark name: " << bench_name << std::endl; return 1; } return 0; + } else if (parser.is_subcommand_used("test")) { + return qpkg::dev::test::run_tests(); } - std::cerr << "Unknown subcommand for dev" << std::endl; std::cerr << parser; return 1; } +#endif int qpkg_main(std::vector args) { if (args.size() >= 2 && args[1] == "run") { @@ -828,27 +854,32 @@ int qpkg_main(std::vector args) { return run_run_mode(run_args); } - ArgumentParser init_parser("init", "initialize a new package"); - ArgumentParser build_parser("build", "compile packages and dependencies"); - ArgumentParser clean_parser("clean", "remove object files and cached files"); - ArgumentParser update_parser("update", "update package dependencies"); - ArgumentParser install_parser("install", - "download and compile remote source"); - ArgumentParser doc_parser("doc", "show documentation for package or symbol"); - ArgumentParser env_parser("env", "print QUIX environment information"); - ArgumentParser fmt_parser("fmt", "reformat package sources"); - ArgumentParser list_parser("list", "list packages or modules"); - ArgumentParser test_parser("test", "test packages"); - ArgumentParser dev_parser("dev", "run internal development"); + ArgumentParser init_parser("init"); + ArgumentParser build_parser("build"); + ArgumentParser clean_parser("clean"); + ArgumentParser update_parser("update"); + ArgumentParser install_parser("install"); + ArgumentParser doc_parser("doc"); + ArgumentParser env_parser("env"); + ArgumentParser fmt_parser("fmt"); + ArgumentParser list_parser("list"); + ArgumentParser test_parser("test"); +#if QPKG_DEV_TOOLS + ArgumentParser dev_parser("dev"); std::unordered_map> dev_subparsers; +#endif ArgumentParser program("qpkg", VERSION_STR); setup_argparse(program, init_parser, build_parser, clean_parser, update_parser, install_parser, doc_parser, env_parser, - fmt_parser, list_parser, test_parser, dev_parser, - dev_subparsers); + fmt_parser, list_parser, test_parser +#if QPKG_DEV_TOOLS + , + dev_parser, dev_subparsers +#endif + ); try { program.parse_args(args); @@ -883,8 +914,10 @@ int qpkg_main(std::vector args) { return run_list_mode(list_parser); else if (program.is_subcommand_used("test")) return run_test_mode(test_parser); +#if QPKG_DEV_TOOLS else if (program.is_subcommand_used("dev")) return run_dev_mode(dev_parser, dev_subparsers); +#endif else { std::cerr << "No command specified" << std::endl; std::cerr << program;