Skip to content

Commit

Permalink
Do not use magic_enum (remove external dependency)
Browse files Browse the repository at this point in the history
  • Loading branch information
aqjune committed Nov 13, 2024
1 parent b591fa9 commit 2e53307
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 21 deletions.
11 changes: 0 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
# /============================================================/
Expand Down
37 changes: 37 additions & 0 deletions src/abstractops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
5 changes: 5 additions & 0 deletions src/abstractops.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
15 changes: 5 additions & 10 deletions src/vcgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "vcgen.h"
#include "analysis.h"

#include "magic_enum.hpp"
#include <chrono>
#include <fstream>
#include <functional>
Expand Down Expand Up @@ -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";
};

Expand Down Expand Up @@ -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();
}

Expand Down

0 comments on commit 2e53307

Please sign in to comment.