podman
410 строк · 6.9 Кб
1// Inferno utils/5c/5.out.h
2// https://bitbucket.org/inferno-os/inferno-os/src/master/utils/5c/5.out.h
3//
4// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
5// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
6// Portions Copyright © 1997-1999 Vita Nuova Limited
7// Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
8// Portions Copyright © 2004,2006 Bruce Ellis
9// Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
10// Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
11// Portions Copyright © 2009 The Go Authors. All rights reserved.
12//
13// Permission is hereby granted, free of charge, to any person obtaining a copy
14// of this software and associated documentation files (the "Software"), to deal
15// in the Software without restriction, including without limitation the rights
16// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17// copies of the Software, and to permit persons to whom the Software is
18// furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included in
21// all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29// THE SOFTWARE.
30
31package arm
32
33import "github.com/twitchyliquid64/golang-asm/obj"
34
35//go:generate go run ../stringer.go -i $GOFILE -o anames.go -p arm
36
37const (
38NSNAME = 8
39NSYM = 50
40NREG = 16
41)
42
43/* -1 disables use of REGARG */
44const (
45REGARG = -1
46)
47
48const (
49REG_R0 = obj.RBaseARM + iota // must be 16-aligned
50REG_R1
51REG_R2
52REG_R3
53REG_R4
54REG_R5
55REG_R6
56REG_R7
57REG_R8
58REG_R9
59REG_R10
60REG_R11
61REG_R12
62REG_R13
63REG_R14
64REG_R15
65
66REG_F0 // must be 16-aligned
67REG_F1
68REG_F2
69REG_F3
70REG_F4
71REG_F5
72REG_F6
73REG_F7
74REG_F8
75REG_F9
76REG_F10
77REG_F11
78REG_F12
79REG_F13
80REG_F14
81REG_F15
82
83REG_FPSR // must be 2-aligned
84REG_FPCR
85
86REG_CPSR // must be 2-aligned
87REG_SPSR
88
89REGRET = REG_R0
90/* compiler allocates R1 up as temps */
91/* compiler allocates register variables R3 up */
92/* compiler allocates external registers R10 down */
93REGEXT = REG_R10
94/* these two registers are declared in runtime.h */
95REGG = REGEXT - 0
96REGM = REGEXT - 1
97
98REGCTXT = REG_R7
99REGTMP = REG_R11
100REGSP = REG_R13
101REGLINK = REG_R14
102REGPC = REG_R15
103
104NFREG = 16
105/* compiler allocates register variables F0 up */
106/* compiler allocates external registers F7 down */
107FREGRET = REG_F0
108FREGEXT = REG_F7
109FREGTMP = REG_F15
110)
111
112// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0040b/IHI0040B_aadwarf.pdf
113var ARMDWARFRegisters = map[int16]int16{}
114
115func init() {
116// f assigns dwarfregisters[from:to] = (base):(step*(to-from)+base)
117f := func(from, to, base, step int16) {
118for r := int16(from); r <= to; r++ {
119ARMDWARFRegisters[r] = step*(r-from) + base
120}
121}
122f(REG_R0, REG_R15, 0, 1)
123f(REG_F0, REG_F15, 64, 2) // Use d0 through D15, aka S0, S2, ..., S30
124}
125
126// Special registers, after subtracting obj.RBaseARM, bit 9 indicates
127// a special register and the low bits select the register.
128const (
129REG_SPECIAL = obj.RBaseARM + 1<<9 + iota
130REG_MB_SY
131REG_MB_ST
132REG_MB_ISH
133REG_MB_ISHST
134REG_MB_NSH
135REG_MB_NSHST
136REG_MB_OSH
137REG_MB_OSHST
138
139MAXREG
140)
141
142const (
143C_NONE = iota
144C_REG
145C_REGREG
146C_REGREG2
147C_REGLIST
148C_SHIFT /* register shift R>>x */
149C_SHIFTADDR /* memory address with shifted offset R>>x(R) */
150C_FREG
151C_PSR
152C_FCR
153C_SPR /* REG_MB_SY */
154
155C_RCON /* 0xff rotated */
156C_NCON /* ~RCON */
157C_RCON2A /* OR of two disjoint C_RCON constants */
158C_RCON2S /* subtraction of two disjoint C_RCON constants */
159C_SCON /* 0xffff */
160C_LCON
161C_LCONADDR
162C_ZFCON
163C_SFCON
164C_LFCON
165
166C_RACON
167C_LACON
168
169C_SBRA
170C_LBRA
171
172C_HAUTO /* halfword insn offset (-0xff to 0xff) */
173C_FAUTO /* float insn offset (0 to 0x3fc, word aligned) */
174C_HFAUTO /* both H and F */
175C_SAUTO /* -0xfff to 0xfff */
176C_LAUTO
177
178C_HOREG
179C_FOREG
180C_HFOREG
181C_SOREG
182C_ROREG
183C_SROREG /* both nil and R */
184C_LOREG
185
186C_PC
187C_SP
188C_HREG
189
190C_ADDR /* reference to relocatable address */
191
192// TLS "var" in local exec mode: will become a constant offset from
193// thread local base that is ultimately chosen by the program linker.
194C_TLS_LE
195
196// TLS "var" in initial exec mode: will become a memory address (chosen
197// by the program linker) that the dynamic linker will fill with the
198// offset from the thread local base.
199C_TLS_IE
200
201C_TEXTSIZE
202
203C_GOK
204
205C_NCLASS /* must be the last */
206)
207
208const (
209AAND = obj.ABaseARM + obj.A_ARCHSPECIFIC + iota
210AEOR
211ASUB
212ARSB
213AADD
214AADC
215ASBC
216ARSC
217ATST
218ATEQ
219ACMP
220ACMN
221AORR
222ABIC
223
224AMVN
225
226/*
227* Do not reorder or fragment the conditional branch
228* opcodes, or the predication code will break
229*/
230ABEQ
231ABNE
232ABCS
233ABHS
234ABCC
235ABLO
236ABMI
237ABPL
238ABVS
239ABVC
240ABHI
241ABLS
242ABGE
243ABLT
244ABGT
245ABLE
246
247AMOVWD
248AMOVWF
249AMOVDW
250AMOVFW
251AMOVFD
252AMOVDF
253AMOVF
254AMOVD
255
256ACMPF
257ACMPD
258AADDF
259AADDD
260ASUBF
261ASUBD
262AMULF
263AMULD
264ANMULF
265ANMULD
266AMULAF
267AMULAD
268ANMULAF
269ANMULAD
270AMULSF
271AMULSD
272ANMULSF
273ANMULSD
274AFMULAF
275AFMULAD
276AFNMULAF
277AFNMULAD
278AFMULSF
279AFMULSD
280AFNMULSF
281AFNMULSD
282ADIVF
283ADIVD
284ASQRTF
285ASQRTD
286AABSF
287AABSD
288ANEGF
289ANEGD
290
291ASRL
292ASRA
293ASLL
294AMULU
295ADIVU
296AMUL
297AMMUL
298ADIV
299AMOD
300AMODU
301ADIVHW
302ADIVUHW
303
304AMOVB
305AMOVBS
306AMOVBU
307AMOVH
308AMOVHS
309AMOVHU
310AMOVW
311AMOVM
312ASWPBU
313ASWPW
314
315ARFE
316ASWI
317AMULA
318AMULS
319AMMULA
320AMMULS
321
322AWORD
323
324AMULL
325AMULAL
326AMULLU
327AMULALU
328
329ABX
330ABXRET
331ADWORD
332
333ALDREX
334ASTREX
335ALDREXD
336ASTREXD
337
338ADMB
339
340APLD
341
342ACLZ
343AREV
344AREV16
345AREVSH
346ARBIT
347
348AXTAB
349AXTAH
350AXTABU
351AXTAHU
352
353ABFX
354ABFXU
355ABFC
356ABFI
357
358AMULWT
359AMULWB
360AMULBB
361AMULAWT
362AMULAWB
363AMULABB
364
365AMRC // MRC/MCR
366
367ALAST
368
369// aliases
370AB = obj.AJMP
371ABL = obj.ACALL
372)
373
374/* scond byte */
375const (
376C_SCOND = (1 << 4) - 1
377C_SBIT = 1 << 4
378C_PBIT = 1 << 5
379C_WBIT = 1 << 6
380C_FBIT = 1 << 7 /* psr flags-only */
381C_UBIT = 1 << 7 /* up bit, unsigned bit */
382
383// These constants are the ARM condition codes encodings,
384// XORed with 14 so that C_SCOND_NONE has value 0,
385// so that a zeroed Prog.scond means "always execute".
386C_SCOND_XOR = 14
387
388C_SCOND_EQ = 0 ^ C_SCOND_XOR
389C_SCOND_NE = 1 ^ C_SCOND_XOR
390C_SCOND_HS = 2 ^ C_SCOND_XOR
391C_SCOND_LO = 3 ^ C_SCOND_XOR
392C_SCOND_MI = 4 ^ C_SCOND_XOR
393C_SCOND_PL = 5 ^ C_SCOND_XOR
394C_SCOND_VS = 6 ^ C_SCOND_XOR
395C_SCOND_VC = 7 ^ C_SCOND_XOR
396C_SCOND_HI = 8 ^ C_SCOND_XOR
397C_SCOND_LS = 9 ^ C_SCOND_XOR
398C_SCOND_GE = 10 ^ C_SCOND_XOR
399C_SCOND_LT = 11 ^ C_SCOND_XOR
400C_SCOND_GT = 12 ^ C_SCOND_XOR
401C_SCOND_LE = 13 ^ C_SCOND_XOR
402C_SCOND_NONE = 14 ^ C_SCOND_XOR
403C_SCOND_NV = 15 ^ C_SCOND_XOR
404
405/* D_SHIFT type */
406SHIFT_LL = 0 << 5
407SHIFT_LR = 1 << 5
408SHIFT_AR = 2 << 5
409SHIFT_RR = 3 << 5
410)
411