c-alpha.texi 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. @c Copyright (C) 2002-2022 Free Software Foundation, Inc.
  2. @c This is part of the GAS manual.
  3. @c For copying conditions, see the file as.texinfo.
  4. @c man end
  5. @ifset GENERIC
  6. @page
  7. @node Alpha-Dependent
  8. @chapter Alpha Dependent Features
  9. @end ifset
  10. @ifclear GENERIC
  11. @node Machine Dependencies
  12. @chapter Alpha Dependent Features
  13. @end ifclear
  14. @cindex Alpha support
  15. @menu
  16. * Alpha Notes:: Notes
  17. * Alpha Options:: Options
  18. * Alpha Syntax:: Syntax
  19. * Alpha Floating Point:: Floating Point
  20. * Alpha Directives:: Alpha Machine Directives
  21. * Alpha Opcodes:: Opcodes
  22. @end menu
  23. @node Alpha Notes
  24. @section Notes
  25. @cindex Alpha notes
  26. @cindex notes for Alpha
  27. The documentation here is primarily for the ELF object format.
  28. @code{@value{AS}} also supports the ECOFF and EVAX formats, but
  29. features specific to these formats are not yet documented.
  30. @node Alpha Options
  31. @section Options
  32. @cindex Alpha options
  33. @cindex options for Alpha
  34. @c man begin OPTIONS
  35. @table @gcctabopt
  36. @cindex @code{-m@var{cpu}} command-line option, Alpha
  37. @item -m@var{cpu}
  38. This option specifies the target processor. If an attempt is made to
  39. assemble an instruction which will not execute on the target processor,
  40. the assembler may either expand the instruction as a macro or issue an
  41. error message. This option is equivalent to the @code{.arch} directive.
  42. The following processor names are recognized:
  43. @code{21064},
  44. @code{21064a},
  45. @code{21066},
  46. @code{21068},
  47. @code{21164},
  48. @code{21164a},
  49. @code{21164pc},
  50. @code{21264},
  51. @code{21264a},
  52. @code{21264b},
  53. @code{ev4},
  54. @code{ev5},
  55. @code{lca45},
  56. @code{ev5},
  57. @code{ev56},
  58. @code{pca56},
  59. @code{ev6},
  60. @code{ev67},
  61. @code{ev68}.
  62. The special name @code{all} may be used to allow the assembler to accept
  63. instructions valid for any Alpha processor.
  64. In order to support existing practice in OSF/1 with respect to @code{.arch},
  65. and existing practice within @command{MILO} (the Linux ARC bootloader), the
  66. numbered processor names (e.g.@: 21064) enable the processor-specific PALcode
  67. instructions, while the ``electro-vlasic'' names (e.g.@: @code{ev4}) do not.
  68. @cindex @code{-mdebug} command-line option, Alpha
  69. @cindex @code{-no-mdebug} command-line option, Alpha
  70. @item -mdebug
  71. @itemx -no-mdebug
  72. Enables or disables the generation of @code{.mdebug} encapsulation for
  73. stabs directives and procedure descriptors. The default is to automatically
  74. enable @code{.mdebug} when the first stabs directive is seen.
  75. @cindex @code{-relax} command-line option, Alpha
  76. @item -relax
  77. This option forces all relocations to be put into the object file, instead
  78. of saving space and resolving some relocations at assembly time. Note that
  79. this option does not propagate all symbol arithmetic into the object file,
  80. because not all symbol arithmetic can be represented. However, the option
  81. can still be useful in specific applications.
  82. @cindex @code{-replace} command-line option, Alpha
  83. @cindex @code{-noreplace} command-line option, Alpha
  84. @item -replace
  85. @itemx -noreplace
  86. Enables or disables the optimization of procedure calls, both at assemblage
  87. and at link time. These options are only available for VMS targets and
  88. @code{-replace} is the default. See section 1.4.1 of the OpenVMS Linker
  89. Utility Manual.
  90. @cindex @code{-g} command-line option, Alpha
  91. @item -g
  92. This option is used when the compiler generates debug information. When
  93. @command{gcc} is using @command{mips-tfile} to generate debug
  94. information for ECOFF, local labels must be passed through to the object
  95. file. Otherwise this option has no effect.
  96. @cindex @code{-G} command-line option, Alpha
  97. @item -G@var{size}
  98. A local common symbol larger than @var{size} is placed in @code{.bss},
  99. while smaller symbols are placed in @code{.sbss}.
  100. @cindex @code{-F} command-line option, Alpha
  101. @cindex @code{-32addr} command-line option, Alpha
  102. @item -F
  103. @itemx -32addr
  104. These options are ignored for backward compatibility.
  105. @end table
  106. @c man end
  107. @cindex Alpha Syntax
  108. @node Alpha Syntax
  109. @section Syntax
  110. The assembler syntax closely follow the Alpha Reference Manual;
  111. assembler directives and general syntax closely follow the OSF/1 and
  112. OpenVMS syntax, with a few differences for ELF.
  113. @menu
  114. * Alpha-Chars:: Special Characters
  115. * Alpha-Regs:: Register Names
  116. * Alpha-Relocs:: Relocations
  117. @end menu
  118. @node Alpha-Chars
  119. @subsection Special Characters
  120. @cindex line comment character, Alpha
  121. @cindex Alpha line comment character
  122. @samp{#} is the line comment character. Note that if @samp{#} is the
  123. first character on a line then it can also be a logical line number
  124. directive (@pxref{Comments}) or a preprocessor control
  125. command (@pxref{Preprocessing}).
  126. @cindex line separator, Alpha
  127. @cindex statement separator, Alpha
  128. @cindex Alpha line separator
  129. @samp{;} can be used instead of a newline to separate statements.
  130. @node Alpha-Regs
  131. @subsection Register Names
  132. @cindex Alpha registers
  133. @cindex register names, Alpha
  134. The 32 integer registers are referred to as @samp{$@var{n}} or
  135. @samp{$r@var{n}}. In addition, registers 15, 28, 29, and 30 may
  136. be referred to by the symbols @samp{$fp}, @samp{$at}, @samp{$gp},
  137. and @samp{$sp} respectively.
  138. The 32 floating-point registers are referred to as @samp{$f@var{n}}.
  139. @node Alpha-Relocs
  140. @subsection Relocations
  141. @cindex Alpha relocations
  142. @cindex relocations, Alpha
  143. Some of these relocations are available for ECOFF, but mostly
  144. only for ELF. They are modeled after the relocation format
  145. introduced in Digital Unix 4.0, but there are additions.
  146. The format is @samp{!@var{tag}} or @samp{!@var{tag}!@var{number}}
  147. where @var{tag} is the name of the relocation. In some cases
  148. @var{number} is used to relate specific instructions.
  149. The relocation is placed at the end of the instruction like so:
  150. @example
  151. ldah $0,a($29) !gprelhigh
  152. lda $0,a($0) !gprellow
  153. ldq $1,b($29) !literal!100
  154. ldl $2,0($1) !lituse_base!100
  155. @end example
  156. @table @code
  157. @item !literal
  158. @itemx !literal!@var{N}
  159. Used with an @code{ldq} instruction to load the address of a symbol
  160. from the GOT.
  161. A sequence number @var{N} is optional, and if present is used to pair
  162. @code{lituse} relocations with this @code{literal} relocation. The
  163. @code{lituse} relocations are used by the linker to optimize the code
  164. based on the final location of the symbol.
  165. Note that these optimizations are dependent on the data flow of the
  166. program. Therefore, if @emph{any} @code{lituse} is paired with a
  167. @code{literal} relocation, then @emph{all} uses of the register set by
  168. the @code{literal} instruction must also be marked with @code{lituse}
  169. relocations. This is because the original @code{literal} instruction
  170. may be deleted or transformed into another instruction.
  171. Also note that there may be a one-to-many relationship between
  172. @code{literal} and @code{lituse}, but not a many-to-one. That is, if
  173. there are two code paths that load up the same address and feed the
  174. value to a single use, then the use may not use a @code{lituse}
  175. relocation.
  176. @item !lituse_base!@var{N}
  177. Used with any memory format instruction (e.g.@: @code{ldl}) to indicate
  178. that the literal is used for an address load. The offset field of the
  179. instruction must be zero. During relaxation, the code may be altered
  180. to use a gp-relative load.
  181. @item !lituse_jsr!@var{N}
  182. Used with a register branch format instruction (e.g.@: @code{jsr}) to
  183. indicate that the literal is used for a call. During relaxation, the
  184. code may be altered to use a direct branch (e.g.@: @code{bsr}).
  185. @item !lituse_jsrdirect!@var{N}
  186. Similar to @code{lituse_jsr}, but also that this call cannot be vectored
  187. through a PLT entry. This is useful for functions with special calling
  188. conventions which do not allow the normal call-clobbered registers to be
  189. clobbered.
  190. @item !lituse_bytoff!@var{N}
  191. Used with a byte mask instruction (e.g.@: @code{extbl}) to indicate
  192. that only the low 3 bits of the address are relevant. During relaxation,
  193. the code may be altered to use an immediate instead of a register shift.
  194. @item !lituse_addr!@var{N}
  195. Used with any other instruction to indicate that the original address
  196. is in fact used, and the original @code{ldq} instruction may not be
  197. altered or deleted. This is useful in conjunction with @code{lituse_jsr}
  198. to test whether a weak symbol is defined.
  199. @example
  200. ldq $27,foo($29) !literal!1
  201. beq $27,is_undef !lituse_addr!1
  202. jsr $26,($27),foo !lituse_jsr!1
  203. @end example
  204. @item !lituse_tlsgd!@var{N}
  205. Used with a register branch format instruction to indicate that the
  206. literal is the call to @code{__tls_get_addr} used to compute the
  207. address of the thread-local storage variable whose descriptor was
  208. loaded with @code{!tlsgd!@var{N}}.
  209. @item !lituse_tlsldm!@var{N}
  210. Used with a register branch format instruction to indicate that the
  211. literal is the call to @code{__tls_get_addr} used to compute the
  212. address of the base of the thread-local storage block for the current
  213. module. The descriptor for the module must have been loaded with
  214. @code{!tlsldm!@var{N}}.
  215. @item !gpdisp!@var{N}
  216. Used with @code{ldah} and @code{lda} to load the GP from the current
  217. address, a-la the @code{ldgp} macro. The source register for the
  218. @code{ldah} instruction must contain the address of the @code{ldah}
  219. instruction. There must be exactly one @code{lda} instruction paired
  220. with the @code{ldah} instruction, though it may appear anywhere in
  221. the instruction stream. The immediate operands must be zero.
  222. @example
  223. bsr $26,foo
  224. ldah $29,0($26) !gpdisp!1
  225. lda $29,0($29) !gpdisp!1
  226. @end example
  227. @item !gprelhigh
  228. Used with an @code{ldah} instruction to add the high 16 bits of a
  229. 32-bit displacement from the GP.
  230. @item !gprellow
  231. Used with any memory format instruction to add the low 16 bits of a
  232. 32-bit displacement from the GP.
  233. @item !gprel
  234. Used with any memory format instruction to add a 16-bit displacement
  235. from the GP.
  236. @item !samegp
  237. Used with any branch format instruction to skip the GP load at the
  238. target address. The referenced symbol must have the same GP as the
  239. source object file, and it must be declared to either not use @code{$27}
  240. or perform a standard GP load in the first two instructions via the
  241. @code{.prologue} directive.
  242. @item !tlsgd
  243. @itemx !tlsgd!@var{N}
  244. Used with an @code{lda} instruction to load the address of a TLS
  245. descriptor for a symbol in the GOT.
  246. The sequence number @var{N} is optional, and if present it used to
  247. pair the descriptor load with both the @code{literal} loading the
  248. address of the @code{__tls_get_addr} function and the @code{lituse_tlsgd}
  249. marking the call to that function.
  250. For proper relaxation, both the @code{tlsgd}, @code{literal} and
  251. @code{lituse} relocations must be in the same extended basic block.
  252. That is, the relocation with the lowest address must be executed
  253. first at runtime.
  254. @item !tlsldm
  255. @itemx !tlsldm!@var{N}
  256. Used with an @code{lda} instruction to load the address of a TLS
  257. descriptor for the current module in the GOT.
  258. Similar in other respects to @code{tlsgd}.
  259. @item !gotdtprel
  260. Used with an @code{ldq} instruction to load the offset of the TLS
  261. symbol within its module's thread-local storage block. Also known
  262. as the dynamic thread pointer offset or dtp-relative offset.
  263. @item !dtprelhi
  264. @itemx !dtprello
  265. @itemx !dtprel
  266. Like @code{gprel} relocations except they compute dtp-relative offsets.
  267. @item !gottprel
  268. Used with an @code{ldq} instruction to load the offset of the TLS
  269. symbol from the thread pointer. Also known as the tp-relative offset.
  270. @item !tprelhi
  271. @itemx !tprello
  272. @itemx !tprel
  273. Like @code{gprel} relocations except they compute tp-relative offsets.
  274. @end table
  275. @node Alpha Floating Point
  276. @section Floating Point
  277. @cindex floating point, Alpha (@sc{ieee})
  278. @cindex Alpha floating point (@sc{ieee})
  279. The Alpha family uses both @sc{ieee} and VAX floating-point numbers.
  280. @node Alpha Directives
  281. @section Alpha Assembler Directives
  282. @command{@value{AS}} for the Alpha supports many additional directives for
  283. compatibility with the native assembler. This section describes them only
  284. briefly.
  285. @cindex Alpha-only directives
  286. These are the additional directives in @code{@value{AS}} for the Alpha:
  287. @table @code
  288. @item .arch @var{cpu}
  289. Specifies the target processor. This is equivalent to the
  290. @option{-m@var{cpu}} command-line option. @xref{Alpha Options, Options},
  291. for a list of values for @var{cpu}.
  292. @item .ent @var{function}[, @var{n}]
  293. Mark the beginning of @var{function}. An optional number may follow for
  294. compatibility with the OSF/1 assembler, but is ignored. When generating
  295. @code{.mdebug} information, this will create a procedure descriptor for
  296. the function. In ELF, it will mark the symbol as a function a-la the
  297. generic @code{.type} directive.
  298. @item .end @var{function}
  299. Mark the end of @var{function}. In ELF, it will set the size of the symbol
  300. a-la the generic @code{.size} directive.
  301. @item .mask @var{mask}, @var{offset}
  302. Indicate which of the integer registers are saved in the current
  303. function's stack frame. @var{mask} is interpreted a bit mask in which
  304. bit @var{n} set indicates that register @var{n} is saved. The registers
  305. are saved in a block located @var{offset} bytes from the @dfn{canonical
  306. frame address} (CFA) which is the value of the stack pointer on entry to
  307. the function. The registers are saved sequentially, except that the
  308. return address register (normally @code{$26}) is saved first.
  309. This and the other directives that describe the stack frame are
  310. currently only used when generating @code{.mdebug} information. They
  311. may in the future be used to generate DWARF2 @code{.debug_frame} unwind
  312. information for hand written assembly.
  313. @item .fmask @var{mask}, @var{offset}
  314. Indicate which of the floating-point registers are saved in the current
  315. stack frame. The @var{mask} and @var{offset} parameters are interpreted
  316. as with @code{.mask}.
  317. @item .frame @var{framereg}, @var{frameoffset}, @var{retreg}[, @var{argoffset}]
  318. Describes the shape of the stack frame. The frame pointer in use is
  319. @var{framereg}; normally this is either @code{$fp} or @code{$sp}. The
  320. frame pointer is @var{frameoffset} bytes below the CFA. The return
  321. address is initially located in @var{retreg} until it is saved as
  322. indicated in @code{.mask}. For compatibility with OSF/1 an optional
  323. @var{argoffset} parameter is accepted and ignored. It is believed to
  324. indicate the offset from the CFA to the saved argument registers.
  325. @item .prologue @var{n}
  326. Indicate that the stack frame is set up and all registers have been
  327. spilled. The argument @var{n} indicates whether and how the function
  328. uses the incoming @dfn{procedure vector} (the address of the called
  329. function) in @code{$27}. 0 indicates that @code{$27} is not used; 1
  330. indicates that the first two instructions of the function use @code{$27}
  331. to perform a load of the GP register; 2 indicates that @code{$27} is
  332. used in some non-standard way and so the linker cannot elide the load of
  333. the procedure vector during relaxation.
  334. @item .usepv @var{function}, @var{which}
  335. Used to indicate the use of the @code{$27} register, similar to
  336. @code{.prologue}, but without the other semantics of needing to
  337. be inside an open @code{.ent}/@code{.end} block.
  338. The @var{which} argument should be either @code{no}, indicating that
  339. @code{$27} is not used, or @code{std}, indicating that the first two
  340. instructions of the function perform a GP load.
  341. One might use this directive instead of @code{.prologue} if you are
  342. also using dwarf2 CFI directives.
  343. @item .gprel32 @var{expression}
  344. Computes the difference between the address in @var{expression} and the
  345. GP for the current object file, and stores it in 4 bytes. In addition
  346. to being smaller than a full 8 byte address, this also does not require
  347. a dynamic relocation when used in a shared library.
  348. @item .t_floating @var{expression}
  349. Stores @var{expression} as an @sc{ieee} double precision value.
  350. @item .s_floating @var{expression}
  351. Stores @var{expression} as an @sc{ieee} single precision value.
  352. @item .f_floating @var{expression}
  353. Stores @var{expression} as a VAX F format value.
  354. @item .g_floating @var{expression}
  355. Stores @var{expression} as a VAX G format value.
  356. @item .d_floating @var{expression}
  357. Stores @var{expression} as a VAX D format value.
  358. @item .set @var{feature}
  359. Enables or disables various assembler features. Using the positive
  360. name of the feature enables while using @samp{no@var{feature}} disables.
  361. @table @code
  362. @item at
  363. Indicates that macro expansions may clobber the @dfn{assembler
  364. temporary} (@code{$at} or @code{$28}) register. Some macros may not be
  365. expanded without this and will generate an error message if @code{noat}
  366. is in effect. When @code{at} is in effect, a warning will be generated
  367. if @code{$at} is used by the programmer.
  368. @item macro
  369. Enables the expansion of macro instructions. Note that variants of real
  370. instructions, such as @code{br label} vs @code{br $31,label} are
  371. considered alternate forms and not macros.
  372. @item move
  373. @itemx reorder
  374. @itemx volatile
  375. These control whether and how the assembler may re-order instructions.
  376. Accepted for compatibility with the OSF/1 assembler, but @command{@value{AS}}
  377. does not do instruction scheduling, so these features are ignored.
  378. @end table
  379. @end table
  380. The following directives are recognized for compatibility with the OSF/1
  381. assembler but are ignored.
  382. @example
  383. .proc .aproc
  384. .reguse .livereg
  385. .option .aent
  386. .ugen .eflag
  387. .alias .noalias
  388. @end example
  389. @node Alpha Opcodes
  390. @section Opcodes
  391. For detailed information on the Alpha machine instruction set, see the
  392. @c Attempt to work around a very overfull hbox.
  393. @iftex
  394. Alpha Architecture Handbook located at
  395. @smallfonts
  396. @example
  397. ftp://ftp.digital.com/pub/Digital/info/semiconductor/literature/alphaahb.pdf
  398. @end example
  399. @textfonts
  400. @end iftex
  401. @ifnottex
  402. @uref{ftp://ftp.digital.com/pub/Digital/info/semiconductor/literature/alphaahb.pdf,Alpha Architecture Handbook}.
  403. @end ifnottex