2022-05-05 16:08:16 +02:00
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Compiler:
|
|
|
|
name: str
|
|
|
|
asm_function_macro: str = "glabel"
|
2022-12-11 08:43:29 +01:00
|
|
|
asm_jtbl_label_macro: str = "glabel"
|
2022-05-05 16:08:16 +02:00
|
|
|
asm_data_macro: str = "glabel"
|
|
|
|
asm_end_label: str = ""
|
|
|
|
c_newline: str = "\n"
|
|
|
|
asm_inc_header: str = ""
|
2022-10-15 00:21:50 +02:00
|
|
|
include_macro_inc: bool = True
|
2022-05-05 16:08:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
GCC = Compiler(
|
|
|
|
"GCC",
|
2022-09-24 17:21:54 +02:00
|
|
|
asm_inc_header=".set noat /* allow manual use of $at */\n.set noreorder /* don't insert nops after branches */\n\n",
|
2022-05-05 16:08:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
SN64 = Compiler(
|
|
|
|
"SN64",
|
|
|
|
asm_function_macro=".globl",
|
2022-12-11 08:43:29 +01:00
|
|
|
asm_jtbl_label_macro=".globl",
|
2022-05-05 16:08:16 +02:00
|
|
|
asm_data_macro=".globl",
|
|
|
|
asm_end_label=".end",
|
|
|
|
c_newline="\r\n",
|
2022-10-15 00:21:50 +02:00
|
|
|
include_macro_inc=False,
|
2022-05-05 16:08:16 +02:00
|
|
|
)
|
|
|
|
|
2022-06-12 17:33:32 +02:00
|
|
|
IDO = Compiler("IDO")
|
|
|
|
|
|
|
|
compiler_for_name = {"GCC": GCC, "SN64": SN64, "IDO": IDO}
|
2022-05-05 16:08:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
def for_name(name: str) -> Compiler:
|
|
|
|
name = name.upper()
|
|
|
|
if name in compiler_for_name:
|
|
|
|
return compiler_for_name[name]
|
|
|
|
return Compiler(name)
|