diff --git a/Makefile b/Makefile index e66e12127b68061169a0852483b4bbbafa964c50..b0dad73c298df8d754b668af575d8380a1c5e8bd 100644 --- a/Makefile +++ b/Makefile @@ -82,6 +82,10 @@ ast2mpl: mplfe: install_patch $(call build_gn, $(GN_OPTIONS), mplfe) +.PHONY: clang2mpl +clang2mpl: maple + (cd tools/clang2mpl; make setup; make; make install) + .PHONY: mplfeUT mplfeUT: $(call build_gn, $(GN_OPTIONS) COV_CHECK=1, mplfeUT) @@ -103,7 +107,7 @@ java-core-def: install $(MAKE) gen-def OPT=$(OPT) DEBUG=$(DEBUG) OPS_ANDROID=$(OPS_ANDROID) .PHONY: install -install: maple dex2mpl_install irbuild mplfe +install: maple dex2mpl_install irbuild mplfe clang2mpl $(shell mkdir -p $(INSTALL_DIR)/ops/linker/; \ rsync -a -L $(MRT_ROOT)/maplert/linker/maplelld.so.lds $(INSTALL_DIR)/ops/linker/; \ rsync -a -L $(MAPLE_ROOT)/build/java2d8 $(INSTALL_DIR)/bin; \ @@ -111,7 +115,7 @@ install: maple dex2mpl_install irbuild mplfe rsync -a -L $(MAPLE_BIN_DIR)/jbc2mpl $(INSTALL_DIR)/bin/;) .PHONY: all -all: install mplfe libcore +all: install libcore ifeq ($(OPS_ANDROID),0) .PHONY: dex2mpl_install @@ -129,7 +133,7 @@ setup: .PHONY: demo demo: - test/maple_aarch64_with_whirl2mpl.sh test/c_demo printHuawei 1 1 + test/maple_aarch64_with_clang2mpl.sh test/c_demo printHuawei 1 1 .PHONY: ctorture-ci ctorture-ci: diff --git a/build/jenkins/main.sh b/build/jenkins/main.sh index bede6475b8066020639a5a51f54fb62e967c69f0..87fe5a879a86f330785cd9dc5f13a78cdf62381c 100755 --- a/build/jenkins/main.sh +++ b/build/jenkins/main.sh @@ -13,6 +13,7 @@ function debug_test { make make irbuild make mplfe + make clang2mpl make irbuild_test make c_test } @@ -37,6 +38,7 @@ function release_test { make make irbuild make mplfe + make clang2mpl make libcore OPT=${opt} for dir in $sample_list diff --git a/src/mapleall/maple_driver/defs/phases.def b/src/mapleall/maple_driver/defs/phases.def index 80aa29bd5acdc406b4ffebb935f5ccc513c32649..cd56a454402a44ee8c7045306852af4689a7945b 100644 --- a/src/mapleall/maple_driver/defs/phases.def +++ b/src/mapleall/maple_driver/defs/phases.def @@ -24,31 +24,31 @@ ADD_PHASE("gencheckcast", JAVALANG) ADD_PHASE("javaintrnlowering", JAVALANG) ADD_PHASE("inline", Options::O2 && Options::useInline) // mephase begin -ADD_PHASE("mecfgbuild", MeOption::optLevel == 2 || JAVALANG) -ADD_PHASE("bypatheh", JAVALANG && MeOption::optLevel == 2) -ADD_PHASE("loopcanon", MeOption::optLevel == 2) -ADD_PHASE("splitcriticaledge", MeOption::optLevel == 2) -ADD_PHASE("ssatab", MeOption::optLevel == 2 || JAVALANG) -ADD_PHASE("aliasclass", MeOption::optLevel == 2 || JAVALANG) -ADD_PHASE("ssa", MeOption::optLevel == 2 || JAVALANG) -ADD_PHASE("dse", MeOption::optLevel == 2) +ADD_PHASE("mecfgbuild", MeOption::optLevel >= 2 || JAVALANG) +ADD_PHASE("bypatheh", JAVALANG && MeOption::optLevel >= 2) +ADD_PHASE("loopcanon", MeOption::optLevel >= 2) +ADD_PHASE("splitcriticaledge", MeOption::optLevel >= 2) +ADD_PHASE("ssatab", MeOption::optLevel >= 2 || JAVALANG) +ADD_PHASE("aliasclass", MeOption::optLevel >= 2 || JAVALANG) +ADD_PHASE("ssa", MeOption::optLevel >= 2 || JAVALANG) +ADD_PHASE("dse", MeOption::optLevel >= 2) ADD_PHASE("analyzector", JAVALANG) -ADD_PHASE("abcopt", JAVALANG && MeOption::optLevel == 2) -ADD_PHASE("ssadevirt", JAVALANG && MeOption::optLevel == 2) -ADD_PHASE("hprop", MeOption::optLevel == 2) -ADD_PHASE("hdse", MeOption::optLevel == 2) -ADD_PHASE("may2dassign", JAVALANG && MeOption::optLevel == 2) -ADD_PHASE("condbasednpc", JAVALANG && MeOption::optLevel == 2) -ADD_PHASE("epre", MeOption::optLevel == 2) -ADD_PHASE("stmtpre", JAVALANG && MeOption::optLevel == 2) -ADD_PHASE("analyzerc", JAVALANG && MeOption::optLevel == 2) +ADD_PHASE("abcopt", JAVALANG && MeOption::optLevel >= 2) +ADD_PHASE("ssadevirt", JAVALANG && MeOption::optLevel >= 2) +ADD_PHASE("hprop", MeOption::optLevel >= 2) +ADD_PHASE("hdse", MeOption::optLevel >= 2) +ADD_PHASE("may2dassign", JAVALANG && MeOption::optLevel >= 2) +ADD_PHASE("condbasednpc", JAVALANG && MeOption::optLevel >= 2) +ADD_PHASE("epre", MeOption::optLevel >= 2) +ADD_PHASE("stmtpre", JAVALANG && MeOption::optLevel >= 2) +ADD_PHASE("analyzerc", JAVALANG && MeOption::optLevel >= 2) ADD_PHASE("rclowering", JAVALANG) -ADD_PHASE("rename2preg", MeOption::optLevel == 2) -ADD_PHASE("lpre", MeOption::optLevel == 2) -ADD_PHASE("storepre", MeOption::optLevel == 2) -ADD_PHASE("pregrename", MeOption::optLevel == 2) -ADD_PHASE("bblayout", MeOption::optLevel == 2 || JAVALANG) -ADD_PHASE("emit", MeOption::optLevel == 2 || JAVALANG) +ADD_PHASE("rename2preg", MeOption::optLevel >= 2) +ADD_PHASE("lpre", MeOption::optLevel >= 2) +ADD_PHASE("storepre", MeOption::optLevel >= 2) +ADD_PHASE("pregrename", MeOption::optLevel >= 2) +ADD_PHASE("bblayout", MeOption::optLevel >= 2 || JAVALANG) +ADD_PHASE("emit", MeOption::optLevel >= 2 || JAVALANG) ADD_PHASE("meverify", JAVALANG && MeOption::meVerify) // mephase end ADD_PHASE("clinit", JAVALANG) diff --git a/src/mapleall/maple_driver/src/driver_runner.cpp b/src/mapleall/maple_driver/src/driver_runner.cpp index e37bebdea3415040ffd1f660bf0399d9edeb008c..749b71116779aabb9ae6e290f72a985e9e956637 100644 --- a/src/mapleall/maple_driver/src/driver_runner.cpp +++ b/src/mapleall/maple_driver/src/driver_runner.cpp @@ -38,6 +38,7 @@ using namespace maplebe; #define JAVALANG (theModule->IsJavaModule()) +#define CLANG (theModule->IsCModule()) #define CHECK_MODULE(errorCode...) \ do { \ diff --git a/src/mapleall/maple_me/src/me_option.cpp b/src/mapleall/maple_me/src/me_option.cpp index ceb474ab4a51ee295c810907411b56707f92d9b3..5a6ba6507d64b9bfba0b2b585c448fc60e8e0d4f 100644 --- a/src/mapleall/maple_me/src/me_option.cpp +++ b/src/mapleall/maple_me/src/me_option.cpp @@ -142,6 +142,7 @@ enum OptionIndex { kMeWarnLevel, kMeOptL1, kMeOptL2, + kMeOptL3, kRefUsedCheck, kMeRange, kEpreLimit, @@ -235,6 +236,15 @@ const Descriptor kUsage[] = { " -O2 \tDo some optimization.\n", "me", {} }, + { kMeOptL3, + 0, + "", + "O3", + kBuildTypeProduct, + kArgCheckPolicyOptional, + " -O3 \tDo aggressive optimizations.\n", + "me", + {} }, { kRefUsedCheck, 0, "", @@ -1040,6 +1050,8 @@ void MeOption::DecideMeRealLevel(const std::vector &inputOp case kMeOptL2: realLevel = kLevelTwo; break; + case kMeOptL3: + realLevel = kLevelThree; default: break; } @@ -1053,6 +1065,13 @@ void MeOption::DecideMeRealLevel(const std::vector &inputOp placementRC = true; subsumRC = true; epreIncludeRef = true; + } else if (realLevel == kLevelThree) { + optLevel = kLevelThree; + // turn on as O2 + optDirectCall = true; + placementRC = true; + subsumRC = true; + epreIncludeRef = true; } } @@ -1076,6 +1095,8 @@ bool MeOption::SolveOptions(const std::vector &opts, bool i case kMeOptL2: // Already handled above in DecideMeRealLevel break; + case kMeOptL3: + break; case kRefUsedCheck: SplitPhases(opt.Args(), checkRefUsedInFuncs); break; diff --git a/test/Makefile.in b/test/Makefile.in index 62aec71ce2f75caaab16f230b6d64d8801634581..2f99e3165f9efe05a3c48c7af33cd48855b73d15 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -13,7 +13,7 @@ # See the Mulan PSL v2 for more details. # -CCMD := $(MAPLE_ROOT)/test/maple_aarch64_with_whirl2mpl.sh +CCMD := $(MAPLE_ROOT)/test/maple_aarch64_with_clang2mpl.sh OPTIMIZE := 0 diff --git a/test/c_demo/Makefile b/test/c_demo/Makefile index 2d89b333af4133e641a372c651e781efce0b9748..82612b52eab37e91794147cdc707e03e68bf3723 100644 --- a/test/c_demo/Makefile +++ b/test/c_demo/Makefile @@ -15,4 +15,4 @@ .PHONY: default default: - ../maple_aarch64_with_whirl2mpl.sh . printHuawei 1 1 + ../maple_aarch64_with_clang2mpl.sh . printHuawei 1 1 diff --git a/test/maple_aarch64_with_whirl2mpl.sh b/test/maple_aarch64_with_clang2mpl.sh similarity index 66% rename from test/maple_aarch64_with_whirl2mpl.sh rename to test/maple_aarch64_with_clang2mpl.sh index 25efdcbb516ebd3bb73b8d95ffdb19b095b6c6db..e40915fbcd5c372bf5fb399114157f3c267a73da 100755 --- a/test/maple_aarch64_with_whirl2mpl.sh +++ b/test/maple_aarch64_with_clang2mpl.sh @@ -29,25 +29,19 @@ else verbose=$4 fi -WORKDIR=$MAPLE_BUILD_OUTPUT/$rel/$dir/aarch64_with_whirl2mpl +WORKDIR=$MAPLE_BUILD_OUTPUT/$rel/$dir/aarch64_with_clang2mpl mkdir -p $WORKDIR cp $dir/$src.c $WORKDIR cd $WORKDIR echo ======================================================================== > cmd.log -echo ============= Use clangfe/whirl2mpl as C Frontend ======================= >> cmd.log +echo ==================== use clang2mpl as C Frontend ======================= >> cmd.log echo ======================================================================== >> cmd.log echo cd $WORKDIR >> cmd.log -V=$(cd /usr/lib/gcc-cross/aarch64-linux-gnu/; ls | head -1) -FLAGS="-cc1 -emit-llvm -triple aarch64-linux-gnu -D__clang__ -D__BLOCKS__ -isystem /usr/aarch64-linux-gnu/include -isystem /usr/lib/gcc-cross/aarch64-linux-gnu/$V/include" -echo $MAPLE_ROOT/tools/open64_prebuilt/x86/aarch64/bin/clangfe $FLAGS $src.c >> cmd.log -$MAPLE_ROOT/tools/open64_prebuilt/x86/aarch64/bin/clangfe $FLAGS $src.c > doit.log 2>&1 - -echo $MAPLE_ROOT/tools/open64_prebuilt/x86/aarch64/bin/whirl2mpl -a $src.B >> cmd.log -$MAPLE_ROOT/tools/open64_prebuilt/x86/aarch64/bin/whirl2mpl -a $src.B >> doit.log 2>&1 - +echo $MAPLE_EXECUTE_BIN/clang2mpl --ascii $src.c -- --target=aarch64-linux-elf >> cmd.log +$MAPLE_EXECUTE_BIN/clang2mpl --ascii $src.c -- --target=aarch64-linux-elf >> doit.log 2>&1 if [ $opt -eq 0 ]; then echo $MAPLE_EXECUTE_BIN/maple --run=mplcg --option=\"-quiet\" $src.mpl >> cmd.log @@ -57,8 +51,8 @@ else $MAPLE_EXECUTE_BIN/maple --run=mplcg --option="-O2 -quiet" $src.mpl >> doit.log 2>&1 fi -echo /usr/bin/aarch64-linux-gnu-gcc-$V -o $src.out $src.s >> cmd.log -/usr/bin/aarch64-linux-gnu-gcc-$V -o $src.out $src.s +echo $MAPLE_ROOT/tools/gcc-linaro-7.5.0/bin/aarch64-linux-gnu-gcc -o $src.out $src.s >> cmd.log +$MAPLE_ROOT/tools/gcc-linaro-7.5.0/bin/aarch64-linux-gnu-gcc -o $src.out $src.s echo $MAPLE_ROOT/tools/bin/qemu-aarch64 -L /usr/aarch64-linux-gnu/ $src.out >> cmd.log $MAPLE_ROOT/tools/bin/qemu-aarch64 -L /usr/aarch64-linux-gnu/ $src.out > output.log diff --git a/testsuite/driver/src/api/c_linker.py b/testsuite/driver/src/api/c_linker.py index 0de13f875892a3a4abefbd5868fdaac142325d38..de319d2dc5376de646a6a8f09ed4dc771a93fdfd 100644 --- a/testsuite/driver/src/api/c_linker.py +++ b/testsuite/driver/src/api/c_linker.py @@ -23,5 +23,5 @@ class CLinker(ShellOperator): self.outfile = outfile def get_command(self, variables): - self.command = "/usr/bin/aarch64-linux-gnu-gcc -o " + self.outfile + " " + self.infile + self.command = "${MAPLE_ROOT}/tools/gcc-linaro-7.5.0/bin/aarch64-linux-gnu-gcc -o " + self.outfile + " " + self.infile return super().get_final_command(variables) diff --git a/testsuite/driver/src/api/clangfe.py b/testsuite/driver/src/api/clang2mpl.py similarity index 64% rename from testsuite/driver/src/api/clangfe.py rename to testsuite/driver/src/api/clang2mpl.py index 98f7e51dcfd91a42cf90ff7693a2e78e42f30228..dee77c273b4a7d70d836987637d9a805790502ec 100644 --- a/testsuite/driver/src/api/clangfe.py +++ b/testsuite/driver/src/api/clang2mpl.py @@ -12,19 +12,18 @@ # See the Mulan PSL v2 for more details. # -import os - from api.shell_operator import ShellOperator -class Clangfe(ShellOperator): - - aarch64_linux_gnu_version = os.listdir("/usr/lib/gcc-cross/aarch64-linux-gnu")[0] +class Clang2mpl(ShellOperator): def __init__(self, infile, return_value_list=None, redirection=None): super().__init__(return_value_list, redirection) self.infile = infile def get_command(self, variables): - self.command = "${TOOL_BIN_PATH}/clangfe -cc1 -emit-llvm -triple aarch64-linux-gnu -D__clang__ -D__BLOCKS__ -isystem /usr/aarch64-linux-gnu/include -isystem /usr/lib/gcc-cross/aarch64-linux-gnu/" + str(Clangfe.aarch64_linux_gnu_version) + "/include " + self.infile + linaroDir = "${MAPLE_ROOT}/tools/gcc-linaro-7.5.0" + isystemFlags = "-isystem " + linaroDir + "/aarch64-linux-gnu/libc/usr/include -isystem " + linaroDir + "/lib/gcc/aarch64-linux-gnu/7.5.0/include" + clangFlags = "--target=aarch64-linux-elf -Wno-return-type -U__SIZEOF_INT128__ " + isystemFlags + self.command = "${MAPLE_EXECUTE_BIN}/clang2mpl --ascii " + self.infile + " -- " + clangFlags return super().get_final_command(variables) diff --git a/testsuite/driver/src/api/whirl2mpl.py b/testsuite/driver/src/api/whirl2mpl.py deleted file mode 100644 index d7a84016e9b6398522e4dc8459bc2a0284cafc2a..0000000000000000000000000000000000000000 --- a/testsuite/driver/src/api/whirl2mpl.py +++ /dev/null @@ -1,26 +0,0 @@ -# -# Copyright (c) [2021] Huawei Technologies Co.,Ltd.All rights reserved. -# -# OpenArkCompiler is licensed under Mulan PSL v2. -# You can use this software according to the terms and conditions of the Mulan PSL v2. -# -# http://license.coscl.org.cn/MulanPSL2 -# -# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR -# FIT FOR A PARTICULAR PURPOSE. -# See the Mulan PSL v2 for more details. -# - -from api.shell_operator import ShellOperator - - -class Whirl2mpl(ShellOperator): - - def __init__(self, infile, return_value_list=None, redirection=None): - super().__init__(return_value_list, redirection) - self.infile = infile - - def get_command(self, variables): - self.command = "${MAPLE_ROOT}/tools/open64_prebuilt/x86/aarch64/bin/whirl2mpl -a " + self.infile - return super().get_final_command(variables) diff --git a/testsuite/driver/src/mode/CO0.py b/testsuite/driver/src/mode/CO0.py index f79ed7a4679be9e0d0d5e37170abfda766bf3c2e..ce77a51a0a39f64a1c75966927695edc77bd2939 100644 --- a/testsuite/driver/src/mode/CO0.py +++ b/testsuite/driver/src/mode/CO0.py @@ -21,12 +21,9 @@ CO0 = { ) ], "compile": [ - Clangfe( + Clang2mpl( infile="${APP}.c" ), - Whirl2mpl( - infile="${APP}.B" - ), Maple( maple="${OUT_ROOT}/${MAPLE_BUILD_TYPE}/bin/maple", run=["mplcg"], diff --git a/testsuite/driver/src/mode/CO2.py b/testsuite/driver/src/mode/CO2.py index 066467e765d156a43a0777411cbf93597cde8a3b..1336993828f930f51ca0858cd70106c1944ee762 100644 --- a/testsuite/driver/src/mode/CO2.py +++ b/testsuite/driver/src/mode/CO2.py @@ -21,12 +21,9 @@ CO2 = { ) ], "compile": [ - Clangfe( + Clang2mpl( infile="${APP}.c" ), - Whirl2mpl( - infile="${APP}.B" - ), Maple( maple="${OUT_ROOT}/${MAPLE_BUILD_TYPE}/bin/maple", run=["mplcg"], diff --git a/tools/setup_tools.sh b/tools/setup_tools.sh index 1f4f6a1b2f37a1f51644299a2117fde92db908ec..d72a7d8cab0b14ebdd1a12e71f1d652718817f18 100755 --- a/tools/setup_tools.sh +++ b/tools/setup_tools.sh @@ -147,7 +147,7 @@ version=c3b1120 if [ ! -f $TOOLS/open64_prebuilt/V_$version ]; then cd $TOOLS rm -rf open64_prebuilt - git clone --depth 2 https://gitee.com/open64ark/open64_prebuilt.git + git clone --depth 1 https://gitee.com/open64ark/open64_prebuilt.git fi if [ ! -f $TOOLS/open64_prebuilt/x86/riscv64/bin/clangfe ]; then cd $TOOLS/open64_prebuilt/x86 @@ -160,6 +160,18 @@ if [ ! -f $TOOLS/open64_prebuilt/x86/riscv64/bin/clangfe ]; then echo Downloaded open64_prebuilt. fi +# clang2mpl +if [ ! -d $TOOLS/clang2mpl ]; then + git clone --depth 1 https://gitee.com/openarkcompiler-incubator/clang2mpl.git + echo Installed qemu-aarch64 +fi +# routinly updated to be compatible with maple +cd $TOOLS/clang2mpl +git clean -df +git checkout . +git checkout master +git pull + mkdir -p ${TOOL_BIN_PATH} if [ "$OLD_OS" == "1" ]; then ln -s -f ${MAPLE_ROOT}/tools/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/clang++ ${TOOL_BIN_PATH}/clang++