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

MegCC WebAssembly Support #57

Merged
merged 9 commits into from
Oct 23, 2024
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
3 changes: 2 additions & 1 deletion compiler/include/compiler/KernelGen/KernelGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ enum Arch {
AUTO_ARM64 = 5,
ARMV7_WITH_DOT = 6,
ARM64V7_WITH_DOT = 7,
ARM64_WITH_I8MM = 8
ARM64_WITH_I8MM = 8,
WEB_ASSEMBLY = 9
};

//! Flag the priority for Kernel selection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ llvm::cl::opt<megcc::KernelGen::Arch> target_arch(
"compiler for device arm64v7."),
clEnumValN(
megcc::KernelGen::ARM64V7_WITH_DOT, "arm64v7_with_dot",
"compiler for device arm64 and armv7 with dotprod feature.")),
"compiler for device arm64 and armv7 with dotprod feature."),
clEnumValN(
megcc::KernelGen::WEB_ASSEMBLY, "webassembly",
"compiler for device webassembly.")),
llvm::cl::init(megcc::KernelGen::BAREMETAL));

namespace mlir {
Expand Down
4 changes: 3 additions & 1 deletion compiler/lib/KernelGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ file(GLOB_RECURSE COMMON_SOURCES_FILE ./Common/*.cpp ./Common/*.h)
file(GLOB_RECURSE UTILS_SOURCES_FILE ./Utils/*.cpp ./Utils/*.h)
file(GLOB_RECURSE JIT_SOURCES_FILE ./Jit/*.cpp ./Jit/*.h)
file(GLOB_RECURSE AUTO_BARE_SOURCES_FILE ./AutoBareMetal/*.cpp ./AutoBareMetal/*.h)
file(GLOB_RECURSE WEBASM_SOURCES_FILE ./WebAssembly/*.cpp ./WebAssembly/*.h)
file(GLOB INTERFACE_SOURCE_FILE ./KernelGen.cpp)
file(GLOB_RECURSE GI_SOURCES_FILE ./GeneralIntrinsic/*.cpp ./GeneralIntrinsic/*.h)

Expand All @@ -32,7 +33,8 @@ list(
${COMMON_SOURCES_FILE}
${UTILS_SOURCES_FILE}
${JIT_SOURCES_FILE}
${GI_SOURCES_FILE})
${GI_SOURCES_FILE}
${WEBASM_SOURCES_FILE})
if(MEGCC_ENABLE_MLIR_KERN_GEN)
list(APPEND STATIC_KERNEL ${AUTO_BARE_SOURCES_FILE})
endif()
Expand Down
4 changes: 4 additions & 0 deletions compiler/lib/KernelGen/KernelGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Arm/Arm64/KernelPack.h"
#include "Arm/ArmCommon/KernelPack.h"
#include "Arm/Armv7/KernelPack.h"
#include "WebAssembly/KernelPack.h"
#if MEGCC_ENABLE_MLIR_KERN_GEN
#include "AutoBareMetal/KernelPack.h"
#endif
Expand Down Expand Up @@ -85,6 +86,9 @@ std::pair<std::vector<const KernelFunc*>, const DeduceFunc*> KernelPack::GetKern
a32_kerns.end(), armcommon_kerns.begin(), armcommon_kerns.end());
a32_kerns.insert(a32_kerns.end(), gi_kerns.begin(), gi_kerns.end());
return {a32_kerns, deduce_func};
} else if (arch == Arch::WEB_ASSEMBLY) {
auto web32_kerns = WebAssembly::ArchKernelPack::GetKernel(kernel_type);
return {web32_kerns, deduce_func};
}
#if MEGCC_ENABLE_MLIR_KERN_GEN
else if (arch == Arch::AUTO_BAREMETAL) {
Expand Down
Loading
Loading