-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Linear ASM compiler #13989
base: master
Are you sure you want to change the base?
Add Linear ASM compiler #13989
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Add new language Linear Asm | ||
|
||
TI C6000 compiler supports a dialect of TI asm, so we add a new language for it. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
from ..options import OptionKey | ||
from .compilers import Compiler | ||
from .mixins.metrowerks import MetrowerksCompiler, mwasmarm_instruction_set_args, mwasmeppc_instruction_set_args | ||
from .mixins.ti import TICompiler | ||
|
||
if T.TYPE_CHECKING: | ||
from ..environment import Environment | ||
|
@@ -259,6 +260,34 @@ def depfile_for_object(self, objfile: str) -> T.Optional[str]: | |
return None | ||
|
||
|
||
# https://downloads.ti.com/docs/esd/SPRUI04/ | ||
class TILinearAsmCompiler(TICompiler, Compiler): | ||
language = 'linearasm' | ||
|
||
def __init__(self, ccache: T.List[str], exelist: T.List[str], version: str, | ||
for_machine: 'MachineChoice', info: 'MachineInfo', | ||
linker: T.Optional['DynamicLinker'] = None, | ||
full_version: T.Optional[str] = None, is_cross: bool = False): | ||
Compiler.__init__(self, ccache, exelist, version, for_machine, info, linker, full_version, is_cross) | ||
TICompiler.__init__(self) | ||
|
||
def needs_static_linker(self) -> bool: | ||
return True | ||
|
||
def get_always_args(self) -> T.List[str]: | ||
return [] | ||
|
||
def get_crt_compile_args(self, crt_val: str, buildtype: str) -> T.List[str]: | ||
return [] | ||
|
||
def sanity_check(self, work_dir: str, environment: 'Environment') -> None: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
if self.info.cpu_family not in {'c6000'}: | ||
raise EnvironmentException(f'TI Linear ASM compiler {self.id!r} does not support {self.info.cpu_family} CPU family') | ||
|
||
def get_depfile_suffix(self) -> str: | ||
return 'd' | ||
|
||
|
||
class MetrowerksAsmCompiler(MetrowerksCompiler, Compiler): | ||
language = 'nasm' | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -98,6 +98,7 @@ def compiler_from_language(env: 'Environment', lang: str, for_machine: MachineCh | |
'cython': detect_cython_compiler, | ||
'nasm': detect_nasm_compiler, | ||
'masm': detect_masm_compiler, | ||
'linearasm': detect_linearasm_compiler, | ||
} | ||
return lang_map[lang](env, for_machine) if lang in lang_map else None | ||
|
||
|
@@ -1353,6 +1354,26 @@ def detect_masm_compiler(env: 'Environment', for_machine: MachineChoice) -> Comp | |
_handle_exceptions(popen_exceptions, [comp]) | ||
raise EnvironmentException('Unreachable code (exception to make mypy happy)') | ||
|
||
def detect_linearasm_compiler(env: 'Environment', for_machine: MachineChoice) -> Compiler: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
from .asm import TILinearAsmCompiler | ||
comp = ['cl6x'] | ||
comp_class: T.Type[Compiler] = TILinearAsmCompiler | ||
arg = '-h' | ||
info = env.machines[for_machine] | ||
cc = detect_c_compiler(env, for_machine) | ||
is_cross = env.is_cross_build(for_machine) | ||
|
||
popen_exceptions: T.Dict[str, Exception] = {} | ||
try: | ||
output = Popen_safe(comp + [arg])[2] | ||
Comment on lines
+1359
to
+1368
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are hardcoding the compiler as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On the other hand, it looks like masm handling already does that too. @dcbaker what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sigh... We need to fix that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How to fix that? |
||
version = search_version(output) | ||
env.coredata.add_lang_args(comp_class.language, comp_class, for_machine, env) | ||
return comp_class([], comp, version, for_machine, info, cc.linker, is_cross=is_cross) | ||
except OSError as e: | ||
popen_exceptions[' '.join(comp + [arg])] = e | ||
_handle_exceptions(popen_exceptions, [comp]) | ||
raise EnvironmentException('Unreachable code (exception to make mypy happy)') | ||
|
||
# GNU/Clang defines and version | ||
# ============================= | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid quoting type annotations in newly introduced code. It is an older style and unnecessary since we now require a minimum python >=3.7 and started using
from __future__ import annotations
.