forked from DMOJ/judge-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLLC.py
46 lines (34 loc) · 1.22 KB
/
LLC.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from typing import Dict, List, Optional, Set
from dmoj.executors.asm_executor import ASMExecutor, NativeMixin
class Executor(NativeMixin, ASMExecutor):
as_name = 'llc'
optimize = 2
test_program = """
declare i32 @getchar() nounwind
declare i32 @putchar(i32) nounwind
define i32 @main() {
br label %start
start:
%ch = call i32 @getchar()
%cond = icmp ne i32 %ch, -1
br i1 %cond, label %write, label %end
write:
call i32 @putchar(i32 %ch)
br label %start
end:
ret i32 0
}
"""
def find_features(self, source_code: bytes) -> Set[str]:
return super().find_features(source_code) | {'libc'}
def get_as_args(self, obj_file: str) -> List[str]:
assert self._code is not None
return [self.get_as_path(), '-filetype=obj', f'-O{self.optimize}', self._code, '-o', obj_file]
@classmethod
def get_version_flags(cls, command: str) -> List[str]:
return ['-version'] if command == cls.as_name else super().get_version_flags(command)
@classmethod
def get_find_first_mapping(cls) -> Optional[Dict[str, List[str]]]:
if cls.platform_prefixes is None:
return None
return {cls.ld_name: [f'{i}-ld' for i in cls.platform_prefixes] + ['ld'], 'llc': ['llc']}