diff --git a/Makefile b/Makefile index 3be57cb4fd571d33fa46ed885af897ff2db5aa52..00e78acfd298b9cf6e3b82c8cadc82b66f65e646 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,8 @@ GN_OPTIONS := \ HOST_ARCH=$(HOST_ARCH) \ MIR_JAVA=$(MIR_JAVA) \ OPT="$(OPT)" \ - OPS_ANDROID=$(OPS_ANDROID) + OPS_ANDROID=$(OPS_ANDROID) \ + TARGET="$(TARGET_PROCESSOR)" \ .PHONY: default default: install diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index dc545010fd47d4165fcec1e923de7e1fe0447de0..06e1a56959bc455b4f457a6827a07ca15a0bcfd4 100755 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -24,6 +24,7 @@ declare_args() { COV_CHECK = 0 OPS_ANDROID = 0 OPT = "O2" + TARGET = "" } # Define global args @@ -173,7 +174,6 @@ if (MARK_CYCLE_ROOTS) { cflags_cc += [ "-DMIR_FEATURE_FULL=1" ] if (MIR_JAVA == 1) { - TARGET = "aarch64" cflags_cc += [ "-DMIR_JAVA=1" ] } else { TARGET = "vm" diff --git a/build/envsetup.sh b/build/envsetup.sh index 5e6a761b92b3c01ccfbb264650058df9a77ec740..8f5f788b7f4dd85a16f6b9030b26e88583bcf4f0 100644 --- a/build/envsetup.sh +++ b/build/envsetup.sh @@ -61,18 +61,15 @@ export QEMU_PATH=${QEMU_PATH} if [ $1 = "arm" ]; then PLATFORM=aarch64 USEOJ=0 +elif [ $1 = "riscv" ]; then + PLATFORM=riscv64 + USEOJ=0 elif [ $1 = "engine" ]; then PLATFORM=ark USEOJ=1 elif [ $1 = "ark" ]; then PLATFORM=ark USEOJ=1 -elif [ $1 = "ark2" ]; then - PLATFORM=ark - USEOJ=2 -elif [ $1 = "riscv" ]; then - PLATFORM=riscv64 - USEOJ=0 else print_usage return diff --git a/src/mapleall/BUILD.gn b/src/mapleall/BUILD.gn index 1e6969ef370471ecb33bc665bbcb0b7f6974d32d..85f1a5ef5ac1d929c7641af09fb20f52a28f4018 100644 --- a/src/mapleall/BUILD.gn +++ b/src/mapleall/BUILD.gn @@ -17,9 +17,29 @@ config("mapleallcompilecfg") { cflags_cc += [ "-std=c++17", "-fno-common", - "-DTARGAARCH64", ] + if(TARGET == "aarch64"){ + cflags_cc += [ + "-DTARGAARCH64", + "-DMAPLE_ROOT=\"${MAPLE_ROOT}\"", + ] + } + + if(TARGET == "riscv64"){ + cflags_cc += [ + "-DTARGRISCV64", + "-DMAPLE_ROOT=\"${MAPLE_ROOT}\"", + ] + } + + if(TARGET == "ark"){ + cflags_cc += [ + "-DTARGARK", + "-DMAPLE_ROOT=\"${MAPLE_ROOT}\"", + ] + } + if (GN_BUILD_TYPE == "DEBUG") { cflags_c += [ "-DDEBUG" ] cflags_cc += [ "-DDEBUG" ] diff --git a/src/mapleall/maple_be/BUILD.gn b/src/mapleall/maple_be/BUILD.gn index f6cf043be431d565347e7c04e989edb737221c65..e399e2b24f42c1f9e93e4b8580ce1dd7e87aca55 100644 --- a/src/mapleall/maple_be/BUILD.gn +++ b/src/mapleall/maple_be/BUILD.gn @@ -14,11 +14,9 @@ # include_directories = [ "${MAPLEALL_ROOT}/maple_be/include/cg", - "${MAPLEALL_ROOT}/maple_be/include/cg/aarch64", "${MAPLEALL_ROOT}/maple_be/include/ad", "${MAPLE_BUILD_OUTPUT}/common/target", "${MAPLEALL_ROOT}/maple_be/include/ad/target", - "${MAPLEALL_ROOT}/maple_be/include/be/aarch64", "${MAPLEALL_ROOT}/maple_be/include/be", "${MAPLEALL_ROOT}/maple_driver/include", "${MAPLEALL_ROOT}/maple_util/include", @@ -30,6 +28,36 @@ include_directories = [ "${MAPLE_ROOT}/third_party/bounds_checking_function/include", ] +deps_libcg = [] + +deps_libmplbe = [ + ":libcglowerer", +] + +if(TARGET == "aarch64"){ + include_directories += [ + "${MAPLEALL_ROOT}/maple_be/include/cg/aarch64", + "${MAPLEALL_ROOT}/maple_be/include/be/aarch64", + ] + deps_libcg += [ ":libcgaarch64", ] +} + +if(TARGET == "riscv64"){ + include_directories += [ + "${MAPLEALL_ROOT}/maple_be/include/cg/riscv64", + "${MAPLEALL_ROOT}/maple_be/include/be/riscv64", + ] + deps_libcg += [ ":libcgriscv64", ] +} + +if(TARGET == "ark"){ + include_directories += [ + "${MAPLEALL_ROOT}/maple_be/include/cg/ark", + "${MAPLEALL_ROOT}/maple_be/include/be/ark", + ] + deps_libcg += [ ":libcgark", ] +} + src_libmplad = [ "src/ad/mad.cpp" ] src_libcglowerer = [ @@ -44,11 +72,6 @@ src_libmplbe = [ "src/be/rt.cpp", ] -deps_libmplbe = [ - ":libcglowerer", - ":libbeaarch64", -] - src_libcgaarch64 = [ "src/cg/aarch64/aarch64_abi.cpp", "src/cg/aarch64/mpl_atomic.cpp", @@ -80,6 +103,14 @@ src_libcgaarch64 = [ "src/cg/aarch64/aarch64_lsra.cpp", ] +src_libcgriscv64 = [ + "src/cg/riscv64/foo.cpp", +] + +src_libcgark = [ + "src/cg/ark/foo.cpp", +] + src_libcg = [ "src/cg/args.cpp", "src/cg/cfgo.cpp", @@ -110,9 +141,6 @@ src_libcg = [ "src/cg/yieldpoint.cpp", ] -deps_libcg = [] -deps_libcg += [ ":libcgaarch64" ] - cflags_cc -= [ "-DRC_NO_MMAP" ] cflags_cc -= [ "-DMIR_JAVA=1" ] @@ -126,10 +154,6 @@ static_library("libmplad") { cflags_cc += [ "-DRC_NO_MMAP" ] } -source_set("libbeaarch64") { - include_dirs = include_directories -} - source_set("libcglowerer") { sources = src_libcglowerer include_dirs = include_directories @@ -147,6 +171,16 @@ source_set("libcgaarch64") { include_dirs = include_directories } +source_set("libcgriscv64") { + sources = src_libcgriscv64 + include_dirs = include_directories +} + +source_set("libcgark") { + sources = src_libcgark + include_dirs = include_directories +} + static_library("libcg") { sources = src_libcg include_dirs = include_directories diff --git a/src/mapleall/maple_driver/BUILD.gn b/src/mapleall/maple_driver/BUILD.gn index 0a163a5b70c24615e28306ed5aa93e3df47ef7bf..35ed290dfdacff0f311dd38a4c1318ef9fc143f1 100644 --- a/src/mapleall/maple_driver/BUILD.gn +++ b/src/mapleall/maple_driver/BUILD.gn @@ -14,8 +14,6 @@ # configs = [ "${MAPLEALL_ROOT}:mapleallcompilecfg" ] -cflags_cc += [ "-DMAPLE_ROOT=\"${MAPLE_ROOT}\"" ] - include_directories = [ "${MAPLEALL_ROOT}", "${MAPLEALL_ROOT}/maple_be/include",