diff --git a/testsuite/driver/config/ci_testall.conf b/testsuite/driver/config/ci_testall.conf index 1035305802c4273536e7e7ab29b301a29e18ef73..a963f69dec8e2245f40985f17b72096e985b2d1f 100755 --- a/testsuite/driver/config/ci_testall.conf +++ b/testsuite/driver/config/ci_testall.conf @@ -26,6 +26,7 @@ java_test/unsafe_test: java_common_mode_set java_test/gconly_test: GC_O0, GC_O2 irbuild_test: IR + mplir_test: MPLIR [BAN_TEST_SUITE] java_test/compact_test/RT0194-rt-compact-AnnotationStaticFieldSetTest: GC_O0, GC_O2 diff --git a/testsuite/driver/config/testall.conf b/testsuite/driver/config/testall.conf index 73a2ddd0608fca76ad51e08bda4a14a6437da842..d66cecaa538996d0a9fdfee030501e1eabbff77f 100644 --- a/testsuite/driver/config/testall.conf +++ b/testsuite/driver/config/testall.conf @@ -20,6 +20,7 @@ java_test/thread_test: java_common_mode_set java_test/unsafe_test: java_common_mode_set irbuild_test: IR + mplir_test: MPLIR c_test/sanity_test: c_common_mode_set c_test/driver_test: c_driver_mode_set diff --git a/testsuite/driver/src/api/c_linker.py b/testsuite/driver/src/api/c_linker.py index 039b8da44989dd8d6802724100f94a367253cff1..ca29b1e72e9215a37c9ee1f6c8b4736fe1805936 100644 --- a/testsuite/driver/src/api/c_linker.py +++ b/testsuite/driver/src/api/c_linker.py @@ -17,14 +17,14 @@ from api.shell_operator import ShellOperator class CLinker(ShellOperator): - def __init__(self, infile, front_option, outfile, back_option, mid_opt="",return_value_list=None, redirection=None): + def __init__(self, infiles, front_option, outfile, back_option, mid_opt="",return_value_list=None, redirection=None): super().__init__(return_value_list, redirection) - self.infile = infile + self.infiles = infiles self.front_option = front_option self.outfile = outfile self.back_option = back_option self.mid_opt = mid_opt def get_command(self, variables): - self.command = "${OUT_ROOT}/tools/bin/aarch64-linux-gnu-gcc " + self.front_option + " -o " + self.outfile + " " + self.mid_opt + " " + self.infile + " " + self.back_option + self.command = "${OUT_ROOT}/tools/bin/aarch64-linux-gnu-gcc " + self.front_option + " -o " + self.outfile + " " + self.mid_opt + " " + " ".join(self.infiles) + " " + self.back_option return super().get_final_command(variables) diff --git a/testsuite/driver/src/api/maple.py b/testsuite/driver/src/api/maple.py index 6417addd2d0e0e6cf97d12717e6e0eb5f2fb6996..2bff3d44f8dcc03358af479340dc624c05707796 100644 --- a/testsuite/driver/src/api/maple.py +++ b/testsuite/driver/src/api/maple.py @@ -17,20 +17,22 @@ from api.shell_operator import ShellOperator class Maple(ShellOperator): - def __init__(self, maple, run, option, global_option, infile, return_value_list=None, redirection=None): + def __init__(self, maple, run, option, global_option, infiles, return_value_list=None, redirection=None): super().__init__(return_value_list, redirection) self.maple = maple self.run = run self.option_dict = option self.global_option = global_option - self.infile = infile + self.infiles = infiles def get_command(self, variables): - self.command = self.maple + " --run=" + ":".join(self.run) + " " - option = [] - for cmd in self.run: - option.append(self.option_dict[cmd]) - self.command += "--option=\"" + ":".join(option) + "\" " - self.command += self.global_option + " " - self.command += "--infile " + self.infile + self.command = self.maple + " " + self.command += "--infile " + " ".join(self.infiles) + if self.run: + self.command += " --run=" + ":".join(self.run) + " " + option = [] + for cmd in self.run: + option.append(self.option_dict[cmd]) + self.command += "--option=\"" + ":".join(option) + "\" " + self.command += self.global_option + " " return super().get_final_command(variables) diff --git a/testsuite/driver/src/mode/ASTO2.py b/testsuite/driver/src/mode/ASTO2.py index 094e8b48715672ad01f8ea26a73608fa40685f83..d0918270c3b8ef93720e592420b8d2840a870456 100644 --- a/testsuite/driver/src/mode/ASTO2.py +++ b/testsuite/driver/src/mode/ASTO2.py @@ -40,7 +40,7 @@ ASTO2 = { "mplcg": "-O2 --fpic --quiet" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), GenBin( infile="${APP}.s", diff --git a/testsuite/driver/src/mode/CO0.py b/testsuite/driver/src/mode/CO0.py index faa45a1f5a0b3c51ab16e90027940197ca3b5420..51e139388e6f38d1633ba3673225432d0e61a750 100644 --- a/testsuite/driver/src/mode/CO0.py +++ b/testsuite/driver/src/mode/CO0.py @@ -40,10 +40,10 @@ CO0 = { "mplcg": "--quiet" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="", outfile="${APP}.out", back_option="-lm" diff --git a/testsuite/driver/src/mode/CO2.py b/testsuite/driver/src/mode/CO2.py index d90abd9ad80334e04f3174d4b602129bfc2981e9..929ee74e150f9e9b79c4a935f3da731b09c6dc02 100644 --- a/testsuite/driver/src/mode/CO2.py +++ b/testsuite/driver/src/mode/CO2.py @@ -42,10 +42,10 @@ CO2 = { "mplcg": "-O2 --fpic --quiet" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="", outfile="${APP}.out", back_option="-lm" diff --git a/testsuite/driver/src/mode/GC_O0.py b/testsuite/driver/src/mode/GC_O0.py index e4c3ee6a8ccf68126140cafc230423a7c6dee309..062b6212ddd8fc8619290b9fbd164815eb5b95c1 100644 --- a/testsuite/driver/src/mode/GC_O0.py +++ b/testsuite/driver/src/mode/GC_O0.py @@ -39,7 +39,7 @@ GC_O0 = { "mplcg": "--O2 --quiet --no-pie --fpic --verbose-asm --maplelinker --gconly" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), Linker( lib="host-x86_64-GC_O0", diff --git a/testsuite/driver/src/mode/GC_O2.py b/testsuite/driver/src/mode/GC_O2.py index a5d01f05d05812f8b8c80a499b943018f764be64..6d8453025b1b504a0140e6dc2b6da950c9f6061b 100644 --- a/testsuite/driver/src/mode/GC_O2.py +++ b/testsuite/driver/src/mode/GC_O2.py @@ -39,7 +39,7 @@ GC_O2 = { "mplcg": "--O2 --quiet --no-pie --fpic --verbose-asm --maplelinker --gconly" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), Linker( lib="host-x86_64-GC_O2", diff --git a/testsuite/driver/src/mode/MPLIR.py b/testsuite/driver/src/mode/MPLIR.py new file mode 100644 index 0000000000000000000000000000000000000000..bd3d429b71c9a3564d8fb061c3753f12ec6370a5 --- /dev/null +++ b/testsuite/driver/src/mode/MPLIR.py @@ -0,0 +1,42 @@ +# +# Copyright (c) [2022] 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 import * + +MPLIR = { + "compile" : [ + Maple( + maple="${OUT_ROOT}/${MAPLE_BUILD_TYPE}/bin/maple", + run=[], + option={}, + global_option="", + infiles=["${DRIVER}.c", "${APP}.mpl" ] + ), + CLinker( + infiles=["${DRIVER}.s" "${APP}.s"], + front_option="", + outfile="${APP}.out", + back_option="-lm" + ) + ], + "run": [ + Shell( + "${OUT_ROOT}/tools/bin/qemu-aarch64 -L ${OUT_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc ${APP}.out > output.log 2>&1" + ), + CheckFileEqual( + file1="output.log", + file2="expected.txt" + ) + ] +} diff --git a/testsuite/driver/src/mode/O0.py b/testsuite/driver/src/mode/O0.py index 220b48c05dec58aed674a61a196728485b25135e..1c6b642e813380b517d581aae9dca43a54793b66 100644 --- a/testsuite/driver/src/mode/O0.py +++ b/testsuite/driver/src/mode/O0.py @@ -39,7 +39,7 @@ O0 = { "mplcg": "--quiet --no-pie --fpic --verbose-asm --maplelinker" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), Linker( lib="host-x86_64-O0", diff --git a/testsuite/driver/src/mode/O2.py b/testsuite/driver/src/mode/O2.py index 9cad688be4b818537b10c2c340a809ecf9b01f6f..c5526ec2e64affafa098dba520865d2758a756d4 100644 --- a/testsuite/driver/src/mode/O2.py +++ b/testsuite/driver/src/mode/O2.py @@ -39,7 +39,7 @@ O2 = { "mplcg": "--O2 --quiet --no-pie --fpic --verbose-asm --maplelinker" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), Linker( lib="host-x86_64-O2", diff --git a/testsuite/driver/src/mode/SCO0_TEST.py b/testsuite/driver/src/mode/SCO0_TEST.py index 65cd3a4d5cb930cd2f2415fa5d9cb7a377940769..f1305c1b7c2cca0cd864dfe52437e6e319cb0c47 100644 --- a/testsuite/driver/src/mode/SCO0_TEST.py +++ b/testsuite/driver/src/mode/SCO0_TEST.py @@ -41,10 +41,10 @@ SCO0_TEST = { "mplcg": "--O0 --patch-long-branch --quiet --no-pie --fpic --verbose-asm" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="-O2 -std=c99", outfile="${APP}.o", back_option="", @@ -53,7 +53,7 @@ SCO0_TEST = { ], "link": [ CLinker( - infile="${APP}", + infiles=["${APP}"], front_option="-std=gnu99 -no-pie", outfile="${EXE}", back_option="-lm -L${OUT_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/lib/", diff --git a/testsuite/driver/src/mode/SCO0_TRAIN.py b/testsuite/driver/src/mode/SCO0_TRAIN.py index d1fb051bc888b8052bc5673f5076cd730d217862..fa72d00f4599b361977a5ec24ac498e7c46154a2 100644 --- a/testsuite/driver/src/mode/SCO0_TRAIN.py +++ b/testsuite/driver/src/mode/SCO0_TRAIN.py @@ -41,10 +41,10 @@ SCO0_TRAIN = { "mplcg": "--O0 --patch-long-branch --quiet --no-pie --fpic --verbose-asm" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="-O2 -std=c99", outfile="${APP}.o", back_option="", @@ -53,7 +53,7 @@ SCO0_TRAIN = { ], "link": [ CLinker( - infile="${APP}", + infiles=["${APP}"], front_option="-std=gnu99 -no-pie", outfile="${EXE}", back_option="-lm -L${OUT_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/lib/" diff --git a/testsuite/driver/src/mode/SCO2_TEST.py b/testsuite/driver/src/mode/SCO2_TEST.py index eabf287dbb75a70ee3e23c0d6155e3ec221e4aee..17229e794f49dfc26489f98fe5a5818867939501 100644 --- a/testsuite/driver/src/mode/SCO2_TEST.py +++ b/testsuite/driver/src/mode/SCO2_TEST.py @@ -43,10 +43,10 @@ SCO2_TEST = { "mplcg": "--O2 --fpic --quiet --no-pie --verbose-asm" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="-O2 -std=c99", outfile="${APP}.o", back_option="", @@ -55,7 +55,7 @@ SCO2_TEST = { ], "link": [ CLinker( - infile="${APP}", + infiles=["${APP}"], front_option="-std=gnu99 -no-pie", outfile="${EXE}", back_option="-lm -L${OUT_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/lib/" diff --git a/testsuite/driver/src/mode/SCO2_TRAIN.py b/testsuite/driver/src/mode/SCO2_TRAIN.py index 5bc1519f3439dda591a8278205d90d2956fe1d1e..5776bbbc35eaa3c34c938e09bded6841e7703007 100644 --- a/testsuite/driver/src/mode/SCO2_TRAIN.py +++ b/testsuite/driver/src/mode/SCO2_TRAIN.py @@ -43,10 +43,10 @@ SCO2_TRAIN = { "mplcg": "--O2 --fpic --quiet --no-pie --verbose-asm" }, global_option="", - infile="${APP}.mpl" + infiles=["${APP}.mpl"] ), CLinker( - infile="${APP}.s", + infiles=["${APP}.s"], front_option="-O2 -std=c99", outfile="${APP}.o", back_option="", @@ -55,7 +55,7 @@ SCO2_TRAIN = { ], "link": [ CLinker( - infile="${APP}", + infiles=["${APP}"], front_option="-std=gnu99 -no-pie", outfile="${EXE}", back_option="-lm -L${OUT_ROOT}/tools/gcc-linaro-7.5.0/aarch64-linux-gnu/libc/lib/" diff --git a/testsuite/mplir_test/MPLIR0001-helloworld/driver.c b/testsuite/mplir_test/MPLIR0001-helloworld/driver.c new file mode 100644 index 0000000000000000000000000000000000000000..373e18700bddda2db4b5dce36083107ab78a9bb4 --- /dev/null +++ b/testsuite/mplir_test/MPLIR0001-helloworld/driver.c @@ -0,0 +1,8 @@ +#include + +extern void print_hello(); + +int main() { + print_hello(); + return 0; +} diff --git a/testsuite/mplir_test/MPLIR0001-helloworld/expected.txt b/testsuite/mplir_test/MPLIR0001-helloworld/expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..af5626b4a114abcb82d63db7c8082c3c4756e51b --- /dev/null +++ b/testsuite/mplir_test/MPLIR0001-helloworld/expected.txt @@ -0,0 +1 @@ +Hello, world! diff --git a/testsuite/mplir_test/MPLIR0001-helloworld/hello.mpl b/testsuite/mplir_test/MPLIR0001-helloworld/hello.mpl new file mode 100644 index 0000000000000000000000000000000000000000..cbcd4b10fb437e707089f08814edfba8a4bd71f9 --- /dev/null +++ b/testsuite/mplir_test/MPLIR0001-helloworld/hello.mpl @@ -0,0 +1,8 @@ +srclang 1 +func &printf public used varargs extern (var %format <* i8>, ...) i32 + +func &print_hello public () void { + var %ret i32 + callassigned &printf (conststr ptr "Hello, world!\x0a") { dassign %ret 0 } + return () +} diff --git a/testsuite/mplir_test/MPLIR0001-helloworld/test.cfg b/testsuite/mplir_test/MPLIR0001-helloworld/test.cfg new file mode 100644 index 0000000000000000000000000000000000000000..b8ca0dc52ed0b439777fd7bbc58b32c85f26a1bc --- /dev/null +++ b/testsuite/mplir_test/MPLIR0001-helloworld/test.cfg @@ -0,0 +1,2 @@ +compile(DRIVER=driver, hello) +run(hello)