1
2
3
4
5 package sys
6
7 import "encoding/binary"
8
9
10
11 type ArchFamily byte
12
13 const (
14 NoArch ArchFamily = iota
15 AMD64
16 ARM
17 ARM64
18 I386
19 Loong64
20 MIPS
21 MIPS64
22 PPC64
23 RISCV64
24 S390X
25 Wasm
26 )
27
28
29 type Arch struct {
30 Name string
31 Family ArchFamily
32
33 ByteOrder binary.ByteOrder
34
35
36
37 PtrSize int
38
39
40 RegSize int
41
42
43 MinLC int
44
45
46
47
48
49 Alignment int8
50
51
52
53
54 CanMergeLoads bool
55 }
56
57
58
59 func (a *Arch) InFamily(xs ...ArchFamily) bool {
60 for _, x := range xs {
61 if a.Family == x {
62 return true
63 }
64 }
65 return false
66 }
67
68 var Arch386 = &Arch{
69 Name: "386",
70 Family: I386,
71 ByteOrder: binary.LittleEndian,
72 PtrSize: 4,
73 RegSize: 4,
74 MinLC: 1,
75 Alignment: 1,
76 CanMergeLoads: true,
77 }
78
79 var ArchAMD64 = &Arch{
80 Name: "amd64",
81 Family: AMD64,
82 ByteOrder: binary.LittleEndian,
83 PtrSize: 8,
84 RegSize: 8,
85 MinLC: 1,
86 Alignment: 1,
87 CanMergeLoads: true,
88 }
89
90 var ArchARM = &Arch{
91 Name: "arm",
92 Family: ARM,
93 ByteOrder: binary.LittleEndian,
94 PtrSize: 4,
95 RegSize: 4,
96 MinLC: 4,
97 Alignment: 4,
98 CanMergeLoads: false,
99 }
100
101 var ArchARM64 = &Arch{
102 Name: "arm64",
103 Family: ARM64,
104 ByteOrder: binary.LittleEndian,
105 PtrSize: 8,
106 RegSize: 8,
107 MinLC: 4,
108 Alignment: 1,
109 CanMergeLoads: true,
110 }
111
112 var ArchLoong64 = &Arch{
113 Name: "loong64",
114 Family: Loong64,
115 ByteOrder: binary.LittleEndian,
116 PtrSize: 8,
117 RegSize: 8,
118 MinLC: 4,
119 Alignment: 8,
120 CanMergeLoads: false,
121 }
122
123 var ArchMIPS = &Arch{
124 Name: "mips",
125 Family: MIPS,
126 ByteOrder: binary.BigEndian,
127 PtrSize: 4,
128 RegSize: 4,
129 MinLC: 4,
130 Alignment: 4,
131 CanMergeLoads: false,
132 }
133
134 var ArchMIPSLE = &Arch{
135 Name: "mipsle",
136 Family: MIPS,
137 ByteOrder: binary.LittleEndian,
138 PtrSize: 4,
139 RegSize: 4,
140 MinLC: 4,
141 Alignment: 4,
142 CanMergeLoads: false,
143 }
144
145 var ArchMIPS64 = &Arch{
146 Name: "mips64",
147 Family: MIPS64,
148 ByteOrder: binary.BigEndian,
149 PtrSize: 8,
150 RegSize: 8,
151 MinLC: 4,
152 Alignment: 8,
153 CanMergeLoads: false,
154 }
155
156 var ArchMIPS64LE = &Arch{
157 Name: "mips64le",
158 Family: MIPS64,
159 ByteOrder: binary.LittleEndian,
160 PtrSize: 8,
161 RegSize: 8,
162 MinLC: 4,
163 Alignment: 8,
164 CanMergeLoads: false,
165 }
166
167 var ArchPPC64 = &Arch{
168 Name: "ppc64",
169 Family: PPC64,
170 ByteOrder: binary.BigEndian,
171 PtrSize: 8,
172 RegSize: 8,
173 MinLC: 4,
174 Alignment: 1,
175 CanMergeLoads: false,
176 }
177
178 var ArchPPC64LE = &Arch{
179 Name: "ppc64le",
180 Family: PPC64,
181 ByteOrder: binary.LittleEndian,
182 PtrSize: 8,
183 RegSize: 8,
184 MinLC: 4,
185 Alignment: 1,
186 CanMergeLoads: true,
187 }
188
189 var ArchRISCV64 = &Arch{
190 Name: "riscv64",
191 Family: RISCV64,
192 ByteOrder: binary.LittleEndian,
193 PtrSize: 8,
194 RegSize: 8,
195 MinLC: 4,
196 Alignment: 8,
197 CanMergeLoads: false,
198 }
199
200 var ArchS390X = &Arch{
201 Name: "s390x",
202 Family: S390X,
203 ByteOrder: binary.BigEndian,
204 PtrSize: 8,
205 RegSize: 8,
206 MinLC: 2,
207 Alignment: 1,
208 CanMergeLoads: true,
209 }
210
211 var ArchWasm = &Arch{
212 Name: "wasm",
213 Family: Wasm,
214 ByteOrder: binary.LittleEndian,
215 PtrSize: 8,
216 RegSize: 8,
217 MinLC: 1,
218 Alignment: 1,
219 CanMergeLoads: false,
220 }
221
222 var Archs = [...]*Arch{
223 Arch386,
224 ArchAMD64,
225 ArchARM,
226 ArchARM64,
227 ArchLoong64,
228 ArchMIPS,
229 ArchMIPSLE,
230 ArchMIPS64,
231 ArchMIPS64LE,
232 ArchPPC64,
233 ArchPPC64LE,
234 ArchRISCV64,
235 ArchS390X,
236 ArchWasm,
237 }
238
View as plain text