a.out.go 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  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. package arm
  31. import "github.com/twitchyliquid64/golang-asm/obj"
  32. //go:generate go run ../stringer.go -i $GOFILE -o anames.go -p arm
  33. const (
  34. NSNAME = 8
  35. NSYM = 50
  36. NREG = 16
  37. )
  38. /* -1 disables use of REGARG */
  39. const (
  40. REGARG = -1
  41. )
  42. const (
  43. REG_R0 = obj.RBaseARM + iota // must be 16-aligned
  44. REG_R1
  45. REG_R2
  46. REG_R3
  47. REG_R4
  48. REG_R5
  49. REG_R6
  50. REG_R7
  51. REG_R8
  52. REG_R9
  53. REG_R10
  54. REG_R11
  55. REG_R12
  56. REG_R13
  57. REG_R14
  58. REG_R15
  59. REG_F0 // must be 16-aligned
  60. REG_F1
  61. REG_F2
  62. REG_F3
  63. REG_F4
  64. REG_F5
  65. REG_F6
  66. REG_F7
  67. REG_F8
  68. REG_F9
  69. REG_F10
  70. REG_F11
  71. REG_F12
  72. REG_F13
  73. REG_F14
  74. REG_F15
  75. REG_FPSR // must be 2-aligned
  76. REG_FPCR
  77. REG_CPSR // must be 2-aligned
  78. REG_SPSR
  79. REGRET = REG_R0
  80. /* compiler allocates R1 up as temps */
  81. /* compiler allocates register variables R3 up */
  82. /* compiler allocates external registers R10 down */
  83. REGEXT = REG_R10
  84. /* these two registers are declared in runtime.h */
  85. REGG = REGEXT - 0
  86. REGM = REGEXT - 1
  87. REGCTXT = REG_R7
  88. REGTMP = REG_R11
  89. REGSP = REG_R13
  90. REGLINK = REG_R14
  91. REGPC = REG_R15
  92. NFREG = 16
  93. /* compiler allocates register variables F0 up */
  94. /* compiler allocates external registers F7 down */
  95. FREGRET = REG_F0
  96. FREGEXT = REG_F7
  97. FREGTMP = REG_F15
  98. )
  99. // http://infocenter.arm.com/help/topic/com.arm.doc.ihi0040b/IHI0040B_aadwarf.pdf
  100. var ARMDWARFRegisters = map[int16]int16{}
  101. func init() {
  102. // f assigns dwarfregisters[from:to] = (base):(step*(to-from)+base)
  103. f := func(from, to, base, step int16) {
  104. for r := int16(from); r <= to; r++ {
  105. ARMDWARFRegisters[r] = step*(r-from) + base
  106. }
  107. }
  108. f(REG_R0, REG_R15, 0, 1)
  109. f(REG_F0, REG_F15, 64, 2) // Use d0 through D15, aka S0, S2, ..., S30
  110. }
  111. // Special registers, after subtracting obj.RBaseARM, bit 9 indicates
  112. // a special register and the low bits select the register.
  113. const (
  114. REG_SPECIAL = obj.RBaseARM + 1<<9 + iota
  115. REG_MB_SY
  116. REG_MB_ST
  117. REG_MB_ISH
  118. REG_MB_ISHST
  119. REG_MB_NSH
  120. REG_MB_NSHST
  121. REG_MB_OSH
  122. REG_MB_OSHST
  123. MAXREG
  124. )
  125. const (
  126. C_NONE = iota
  127. C_REG
  128. C_REGREG
  129. C_REGREG2
  130. C_REGLIST
  131. C_SHIFT /* register shift R>>x */
  132. C_SHIFTADDR /* memory address with shifted offset R>>x(R) */
  133. C_FREG
  134. C_PSR
  135. C_FCR
  136. C_SPR /* REG_MB_SY */
  137. C_RCON /* 0xff rotated */
  138. C_NCON /* ~RCON */
  139. C_RCON2A /* OR of two disjoint C_RCON constants */
  140. C_RCON2S /* subtraction of two disjoint C_RCON constants */
  141. C_SCON /* 0xffff */
  142. C_LCON
  143. C_LCONADDR
  144. C_ZFCON
  145. C_SFCON
  146. C_LFCON
  147. C_RACON
  148. C_LACON
  149. C_SBRA
  150. C_LBRA
  151. C_HAUTO /* halfword insn offset (-0xff to 0xff) */
  152. C_FAUTO /* float insn offset (0 to 0x3fc, word aligned) */
  153. C_HFAUTO /* both H and F */
  154. C_SAUTO /* -0xfff to 0xfff */
  155. C_LAUTO
  156. C_HOREG
  157. C_FOREG
  158. C_HFOREG
  159. C_SOREG
  160. C_ROREG
  161. C_SROREG /* both nil and R */
  162. C_LOREG
  163. C_PC
  164. C_SP
  165. C_HREG
  166. C_ADDR /* reference to relocatable address */
  167. // TLS "var" in local exec mode: will become a constant offset from
  168. // thread local base that is ultimately chosen by the program linker.
  169. C_TLS_LE
  170. // TLS "var" in initial exec mode: will become a memory address (chosen
  171. // by the program linker) that the dynamic linker will fill with the
  172. // offset from the thread local base.
  173. C_TLS_IE
  174. C_TEXTSIZE
  175. C_GOK
  176. C_NCLASS /* must be the last */
  177. )
  178. const (
  179. AAND = obj.ABaseARM + obj.A_ARCHSPECIFIC + iota
  180. AEOR
  181. ASUB
  182. ARSB
  183. AADD
  184. AADC
  185. ASBC
  186. ARSC
  187. ATST
  188. ATEQ
  189. ACMP
  190. ACMN
  191. AORR
  192. ABIC
  193. AMVN
  194. /*
  195. * Do not reorder or fragment the conditional branch
  196. * opcodes, or the predication code will break
  197. */
  198. ABEQ
  199. ABNE
  200. ABCS
  201. ABHS
  202. ABCC
  203. ABLO
  204. ABMI
  205. ABPL
  206. ABVS
  207. ABVC
  208. ABHI
  209. ABLS
  210. ABGE
  211. ABLT
  212. ABGT
  213. ABLE
  214. AMOVWD
  215. AMOVWF
  216. AMOVDW
  217. AMOVFW
  218. AMOVFD
  219. AMOVDF
  220. AMOVF
  221. AMOVD
  222. ACMPF
  223. ACMPD
  224. AADDF
  225. AADDD
  226. ASUBF
  227. ASUBD
  228. AMULF
  229. AMULD
  230. ANMULF
  231. ANMULD
  232. AMULAF
  233. AMULAD
  234. ANMULAF
  235. ANMULAD
  236. AMULSF
  237. AMULSD
  238. ANMULSF
  239. ANMULSD
  240. AFMULAF
  241. AFMULAD
  242. AFNMULAF
  243. AFNMULAD
  244. AFMULSF
  245. AFMULSD
  246. AFNMULSF
  247. AFNMULSD
  248. ADIVF
  249. ADIVD
  250. ASQRTF
  251. ASQRTD
  252. AABSF
  253. AABSD
  254. ANEGF
  255. ANEGD
  256. ASRL
  257. ASRA
  258. ASLL
  259. AMULU
  260. ADIVU
  261. AMUL
  262. AMMUL
  263. ADIV
  264. AMOD
  265. AMODU
  266. ADIVHW
  267. ADIVUHW
  268. AMOVB
  269. AMOVBS
  270. AMOVBU
  271. AMOVH
  272. AMOVHS
  273. AMOVHU
  274. AMOVW
  275. AMOVM
  276. ASWPBU
  277. ASWPW
  278. ARFE
  279. ASWI
  280. AMULA
  281. AMULS
  282. AMMULA
  283. AMMULS
  284. AWORD
  285. AMULL
  286. AMULAL
  287. AMULLU
  288. AMULALU
  289. ABX
  290. ABXRET
  291. ADWORD
  292. ALDREX
  293. ASTREX
  294. ALDREXD
  295. ASTREXD
  296. ADMB
  297. APLD
  298. ACLZ
  299. AREV
  300. AREV16
  301. AREVSH
  302. ARBIT
  303. AXTAB
  304. AXTAH
  305. AXTABU
  306. AXTAHU
  307. ABFX
  308. ABFXU
  309. ABFC
  310. ABFI
  311. AMULWT
  312. AMULWB
  313. AMULBB
  314. AMULAWT
  315. AMULAWB
  316. AMULABB
  317. AMRC // MRC/MCR
  318. ALAST
  319. // aliases
  320. AB = obj.AJMP
  321. ABL = obj.ACALL
  322. )
  323. /* scond byte */
  324. const (
  325. C_SCOND = (1 << 4) - 1
  326. C_SBIT = 1 << 4
  327. C_PBIT = 1 << 5
  328. C_WBIT = 1 << 6
  329. C_FBIT = 1 << 7 /* psr flags-only */
  330. C_UBIT = 1 << 7 /* up bit, unsigned bit */
  331. // These constants are the ARM condition codes encodings,
  332. // XORed with 14 so that C_SCOND_NONE has value 0,
  333. // so that a zeroed Prog.scond means "always execute".
  334. C_SCOND_XOR = 14
  335. C_SCOND_EQ = 0 ^ C_SCOND_XOR
  336. C_SCOND_NE = 1 ^ C_SCOND_XOR
  337. C_SCOND_HS = 2 ^ C_SCOND_XOR
  338. C_SCOND_LO = 3 ^ C_SCOND_XOR
  339. C_SCOND_MI = 4 ^ C_SCOND_XOR
  340. C_SCOND_PL = 5 ^ C_SCOND_XOR
  341. C_SCOND_VS = 6 ^ C_SCOND_XOR
  342. C_SCOND_VC = 7 ^ C_SCOND_XOR
  343. C_SCOND_HI = 8 ^ C_SCOND_XOR
  344. C_SCOND_LS = 9 ^ C_SCOND_XOR
  345. C_SCOND_GE = 10 ^ C_SCOND_XOR
  346. C_SCOND_LT = 11 ^ C_SCOND_XOR
  347. C_SCOND_GT = 12 ^ C_SCOND_XOR
  348. C_SCOND_LE = 13 ^ C_SCOND_XOR
  349. C_SCOND_NONE = 14 ^ C_SCOND_XOR
  350. C_SCOND_NV = 15 ^ C_SCOND_XOR
  351. /* D_SHIFT type */
  352. SHIFT_LL = 0 << 5
  353. SHIFT_LR = 1 << 5
  354. SHIFT_AR = 2 << 5
  355. SHIFT_RR = 3 << 5
  356. )