-
Notifications
You must be signed in to change notification settings - Fork 2
/
lit.cfg.py
31 lines (22 loc) · 1.97 KB
/
lit.cfg.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import lit.formats
import os
config.name = "MoNaCo: MLIR to Native Compiler"
config.test_format = lit.formats.ShTest(True)
config.suffixes = ['.mlir', '.c']
config.excludes = ['samples']
config.test_source_root = os.path.dirname(__file__)
config.test_exec_root = os.path.join(config.test_source_root, 'tests')
monacoExe = os.getenv("MONACO_EXE")
if monacoExe is None:
monacoExe = os.path.join(config.test_source_root, "monaco")
monacoExe = os.path.abspath(monacoExe)
config.substitutions.append(("%monaco", monacoExe))
config.substitutions.append(("%FileCheckAsm", r"%monaco -p asm %s | FileCheck"))
# doesn't work anymore with the mmapping stuff, but we don't need it, just use the jit execution engine
# config.substitutions.append(("%FileCheckExecReturnStatus", r"""outfileName=$(basename -z %basename_t .mlir); %monaco %s $outfileName && objcopy --input-target=binary --output-target=elf64-x86-64 --rename-section '.data=.text' $outfileName %t_2 && gcc -c -x c <(echo "int main(int argc, char** argv){ return _binary_"$outfileName"_start(argc, argv); } ") -o %t_3 && gcc %t_2 %t_3 -o %t_4 && %t_4; echo $? | FileCheck"""))
config.substitutions.append(("%FileCheckExecReturnStatus", r"""%monaco --jit "main" %s; echo $? | FileCheck"""))
# would be nice to be able to do this on all optimization levels
config.substitutions.append(("%CRun", r"""clang -S -emit-llvm %s -o - 2>/dev/null | mlir-translate --import-llvm 2>/dev/null | %monaco /dev/stdin --jit """))
config.substitutions.append(("%CCheckLLVM", r"""clang -S -emit-llvm %s -o - 2>/dev/null | mlir-translate --import-llvm 2>/dev/null > %t.mlir && diff <(ASAN_OPTS=detect_leaks=0 %monaco %t.mlir --jit main -F) <(%monaco %t.mlir --jit main)"""))
config.substitutions.append(("%MLIRCheckLLVM", r"""%monaco %s --jit main -F; TMP1=$(echo Exit code $?); %monaco %s --jit main; TMP2=$(echo Exit code $?); diff <(echo $TMP1) <(echo $TMP2) && diff <(%monaco %s --jit main -F) <(%monaco %s --jit main)"""))
config.recursiveExpansionLimit = 3