启用后为每个函数定义生成 internal i64 计数器并在入口递增;各模块 Ctrl+C 处理器以追加方式写最终文件(含 main 的模块启动时清空一次),经 llvm.global_ctors 自注册;未传参数时零影响。
46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
# 常量定义
|
||
from __future__ import annotations
|
||
|
||
DEFAULT_INPUT_FILE: str = 'test.vp'
|
||
DEFAULT_OUTPUT_FILE: str = 'test.ll'
|
||
|
||
SLICE_THRESHOLD: int = 50
|
||
SLICE_LEVEL_DEFAULT: int = 3
|
||
SLICE_LEVELS: dict[int | str, str] = {
|
||
0: 'no_optimize',
|
||
1: 'conservative',
|
||
2: 'moderate',
|
||
3: 'aggressive',
|
||
's': 'size',
|
||
}
|
||
|
||
DEFAULT_COMPILE_COMMAND: str = 'gcc'
|
||
DEFAULT_COMPILE_FLAGS: str = ''
|
||
|
||
DEFAULT_METADATA: dict[str, str] = {
|
||
'PROJECT_NAME': 'TransPyC Project',
|
||
'AUTHOR': 'TransPyC Team',
|
||
'VERSION': '1.0.0',
|
||
'DESCRIPTION': 'Auto-generated LLVM IR file',
|
||
'COPYRIGHT_YEAR': '2026',
|
||
'COPYRIGHT_HOLDER': 'Galactic Vorpal Software Development Studio (e.g. GVSDS Inc.)'
|
||
}
|
||
|
||
ERROR_MESSAGES: dict[str, str] = {
|
||
'MISSING_ARGS': 'Missing required arguments -f and/or -o',
|
||
'UNKNOWN_ARG': 'Unknown argument',
|
||
'UNSUPPORTED_TYPE': 'Unsupported file type',
|
||
'FAILED_PARSE': 'Failed to parse file',
|
||
'COMPILE_FAILED': 'Compilation or execution failed'
|
||
}
|
||
|
||
HELP_MESSAGE: str = '''
|
||
Usage: python TransPyC.py -f InputFile -o OutputFile [-wh header_files] [-debug DebugFile]
|
||
[-cc compile_command] [-cflags CompileFlags] [-run] [-args RunArgs] [-h HelperFiles]
|
||
[-func-hotspot HotFile]
|
||
-h: Specify helper files (C or Python) to help identify structs, functions, variables, and ptrs
|
||
-func-hotspot: 统计各函数调用次数,Ctrl+C 退出时写入 HotFile(每行 "函数名 计数")
|
||
'''
|
||
|
||
mode: str = "strict"
|