From 2e5330791552cf20665c511730afb951d7bac622 Mon Sep 17 00:00:00 2001 From: Juneyoung Lee Date: Wed, 13 Nov 2024 06:05:08 +0000 Subject: [PATCH] Do not use magic_enum (remove external dependency) --- CMakeLists.txt | 11 ----------- src/abstractops.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/abstractops.h | 5 +++++ src/vcgen.cpp | 15 +++++---------- 4 files changed, 47 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5ad139a..ce64bef5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,17 +87,6 @@ if(USE_LIBC) target_compile_options(${PROJECT_OBJ} PUBLIC -stdlib=libc++) endif() -# Get magic_enum using CPM -include(cmake/CPM.cmake) -CPMAddPackage( - NAME magic_enum - GITHUB_REPOSITORY Neargye/magic_enum - GIT_TAG v0.7.3 -) -# Well, magic_enum does not copy the include directory into its build directory :( -# Manual registration is needed. -target_include_directories(${PROJECT_OBJ} PUBLIC ${magic_enum_SOURCE_DIR}/include) - # /============================================================/ # 2. Build libmlirtv # /============================================================/ diff --git a/src/abstractops.cpp b/src/abstractops.cpp index e4953321..f088d924 100644 --- a/src/abstractops.cpp +++ b/src/abstractops.cpp @@ -1581,3 +1581,40 @@ Expr intDot(const Expr &a, const Expr &b, } } + +llvm::raw_ostream &operator<<(llvm::raw_ostream& out, aop::AbsLevelIntDot x) { + switch (x) { + case aop::AbsLevelIntDot::FULLY_ABS: out << "FULLY_ABS"; break; + case aop::AbsLevelIntDot::SUM_MUL: out << "SUM_MUL"; break; + default: llvm_unreachable("AbsLevelIntDot"); + } + return out; +} + +llvm::raw_ostream &operator<<(llvm::raw_ostream& out, aop::AbsLevelFpCast x) { + switch (x) { + case aop::AbsLevelFpCast::FULLY_ABS: out << "FULLY_ABS"; break; + case aop::AbsLevelFpCast::PRECISE: out << "PRECISE"; break; + default: llvm_unreachable("AbsLevelFpCast"); + } + return out; +} + +llvm::raw_ostream &operator<<(llvm::raw_ostream& out, aop::AbsLevelFpDot x) { + switch (x) { + case aop::AbsLevelFpDot::FULLY_ABS: out << "FULLY_ABS"; break; + case aop::AbsLevelFpDot::SUM_MUL: out << "SUM_MUL"; break; + default: llvm_unreachable("AbsLevelFpDot"); + } + return out; +} + +llvm::raw_ostream &operator<<(llvm::raw_ostream& out, aop::AbsFpAddSumEncoding x) { + switch (x) { + case aop::AbsFpAddSumEncoding::USE_SUM_ONLY: out << "USE_SUM_ONLY"; break; + case aop::AbsFpAddSumEncoding::DEFAULT: out << "DEFAULT"; break; + case aop::AbsFpAddSumEncoding::UNROLL_TO_ADD: out << "UNROLL_TO_ADD"; break; + default: llvm_unreachable("AbsFpAddSumEncoding"); + } + return out; +} diff --git a/src/abstractops.h b/src/abstractops.h index 61f43177..0b390e51 100644 --- a/src/abstractops.h +++ b/src/abstractops.h @@ -270,3 +270,8 @@ AbsFpEncoding &getDoubleEncoding(); AbsFpEncoding &getFpEncoding(mlir::Type); }; + +llvm::raw_ostream &operator<<(llvm::raw_ostream&, aop::AbsLevelIntDot); +llvm::raw_ostream &operator<<(llvm::raw_ostream&, aop::AbsLevelFpCast); +llvm::raw_ostream &operator<<(llvm::raw_ostream&, aop::AbsLevelFpDot); +llvm::raw_ostream &operator<<(llvm::raw_ostream&, aop::AbsFpAddSumEncoding); diff --git a/src/vcgen.cpp b/src/vcgen.cpp index 5628ee52..01ed8853 100644 --- a/src/vcgen.cpp +++ b/src/vcgen.cpp @@ -11,7 +11,6 @@ #include "vcgen.h" #include "analysis.h" -#include "magic_enum.hpp" #include #include #include @@ -577,17 +576,13 @@ static Results validate(ValidationInput vinput) { }); auto printSematics = [](Abstraction &abs, Results &result) { - verbose("validate") << "** Verification Result: " - << magic_enum::enum_name(result.code) << "\n"; - llvm::outs() << "\n--------------------------------------------------------------\n" << " Abstractions used for the validation:\n" - << " - dot ops (fp): " << magic_enum::enum_name(abs.fpDot) << "\n" - << " - cast ops (fp): " << magic_enum::enum_name(abs.fpCast) << "\n" - << " - add/sum ops (fp): " - << magic_enum::enum_name(abs.fpAddSumEncoding) << "\n" - << " - dot ops (int): " << magic_enum::enum_name(abs.intDot) << "\n" + << " - dot ops (fp): " << abs.fpDot << "\n" + << " - cast ops (fp): " << abs.fpCast << "\n" + << " - add/sum ops (fp): " << abs.fpAddSumEncoding << "\n" + << " - dot ops (int): " << abs.intDot << "\n" << "--------------------------------------------------------------\n\n"; }; @@ -824,7 +819,7 @@ Results validate( } if (num_memblocks.getValue() != 0) { - for (auto &[ty, cnt]: vinput.numBlocksPerType) + for (auto &[_, cnt]: vinput.numBlocksPerType) cnt = num_memblocks.getValue(); }