rewrite the lunabuild toolchain with enhanced feature
[lunaix-os.git] / lunaix-os / arch / LConfig
1 from . import x86
2
3 @"Platform"
4 def architecture_support():
5     """
6         Config ISA related features
7     """
8
9     @flag
10     def arch_x86_32() -> bool:
11         return arch.val == "i386"
12     
13     @flag
14     def arch_x86_64() -> bool:
15         return arch.val == "x86_64"
16     
17     @flag
18     def arch_x86() -> bool:
19         return arch.val in ["x86_64", "i386"]
20
21     @"Architecture"
22     def arch() -> "i386" | "x86_64":
23         """ 
24             Config ISA support 
25         """
26         _arch = env("ARCH")
27         return _arch if _arch else "x86_64"
28
29     @"Base operand size"
30     @readonly
31     def arch_bits() -> 32 | 64:
32         """ 
33             Defines the base size of a general register of the 
34             current selected ISA.
35
36             This the 'bits' part when we are talking about a CPU
37         """
38
39         match arch.val:
40             case "i386": 
41                 return 32
42             case "aarch64": 
43                 return 64
44             case "rv64": 
45                 return 64
46             case "x86_64": 
47                 return 64
48             case _:
49                 return 32
50