Home | History | Annotate | Line # | Download | only in doc
c-xtensa.texi revision 1.1.1.2
      1 @c Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
      2 @c Free Software Foundation, Inc.
      3 @c This is part of the GAS manual.
      4 @c For copying conditions, see the file as.texinfo.
      5 @c
      6 @ifset GENERIC
      7 @page
      8 @node Xtensa-Dependent
      9 @chapter Xtensa Dependent Features
     10 @end ifset
     11 @ifclear GENERIC
     12 @node Machine Dependencies
     13 @chapter Xtensa Dependent Features
     14 @end ifclear
     15 
     16 @cindex Xtensa architecture
     17 This chapter covers features of the @sc{gnu} assembler that are specific
     18 to the Xtensa architecture.  For details about the Xtensa instruction
     19 set, please consult the @cite{Xtensa Instruction Set Architecture (ISA)
     20 Reference Manual}.
     21 
     22 @menu
     23 * Xtensa Options::              Command-line Options.
     24 * Xtensa Syntax::               Assembler Syntax for Xtensa Processors.
     25 * Xtensa Optimizations::        Assembler Optimizations.
     26 * Xtensa Relaxation::           Other Automatic Transformations.
     27 * Xtensa Directives::           Directives for Xtensa Processors.
     28 @end menu
     29 
     30 @node Xtensa Options
     31 @section Command Line Options
     32 
     33 The Xtensa version of the @sc{gnu} assembler supports these
     34 special options:
     35 
     36 @table @code
     37 @item --text-section-literals | --no-text-section-literals
     38 @kindex --text-section-literals
     39 @kindex --no-text-section-literals
     40 Control the treatment of literal pools.  The default is
     41 @samp{--no-@-text-@-section-@-literals}, which places literals in
     42 separate sections in the output file.  This allows the literal pool to be
     43 placed in a data RAM/ROM.  With @samp{--text-@-section-@-literals}, the
     44 literals are interspersed in the text section in order to keep them as
     45 close as possible to their references.  This may be necessary for large
     46 assembly files, where the literals would otherwise be out of range of the
     47 @code{L32R} instructions in the text section.  These options only affect
     48 literals referenced via PC-relative @code{L32R} instructions; literals
     49 for absolute mode @code{L32R} instructions are handled separately.
     50 @xref{Literal Directive, ,literal}.
     51 
     52 @item --absolute-literals | --no-absolute-literals
     53 @kindex --absolute-literals
     54 @kindex --no-absolute-literals
     55 Indicate to the assembler whether @code{L32R} instructions use absolute
     56 or PC-relative addressing.  If the processor includes the absolute
     57 addressing option, the default is to use absolute @code{L32R}
     58 relocations.  Otherwise, only the PC-relative @code{L32R} relocations
     59 can be used.
     60 
     61 @item --target-align | --no-target-align
     62 @kindex --target-align
     63 @kindex --no-target-align
     64 Enable or disable automatic alignment to reduce branch penalties at some
     65 expense in code size.  @xref{Xtensa Automatic Alignment, ,Automatic
     66 Instruction Alignment}.  This optimization is enabled by default.  Note
     67 that the assembler will always align instructions like @code{LOOP} that
     68 have fixed alignment requirements.
     69 
     70 @item --longcalls | --no-longcalls
     71 @kindex --longcalls
     72 @kindex --no-longcalls
     73 Enable or disable transformation of call instructions to allow calls
     74 across a greater range of addresses.  @xref{Xtensa Call Relaxation,
     75 ,Function Call Relaxation}.  This option should be used when call
     76 targets can potentially be out of range.  It may degrade both code size
     77 and performance, but the linker can generally optimize away the
     78 unnecessary overhead when a call ends up within range.  The default is
     79 @samp{--no-@-longcalls}.
     80 
     81 @item --transform | --no-transform
     82 @kindex --transform
     83 @kindex --no-transform
     84 Enable or disable all assembler transformations of Xtensa instructions,
     85 including both relaxation and optimization.  The default is
     86 @samp{--transform}; @samp{--no-transform} should only be used in the
     87 rare cases when the instructions must be exactly as specified in the
     88 assembly source.  Using @samp{--no-transform} causes out of range
     89 instruction operands to be errors.
     90 
     91 @item --rename-section @var{oldname}=@var{newname}
     92 @kindex --rename-section
     93 Rename the @var{oldname} section to @var{newname}.  This option can be used
     94 multiple times to rename multiple sections.
     95 @end table
     96 
     97 @node Xtensa Syntax
     98 @section Assembler Syntax
     99 @cindex syntax, Xtensa assembler
    100 @cindex Xtensa assembler syntax
    101 @cindex FLIX syntax
    102 
    103 Block comments are delimited by @samp{/*} and @samp{*/}.  End of line
    104 comments may be introduced with either @samp{#} or @samp{//}.
    105 
    106 Instructions consist of a leading opcode or macro name followed by
    107 whitespace and an optional comma-separated list of operands:
    108 
    109 @smallexample
    110 @var{opcode} [@var{operand}, @dots{}]
    111 @end smallexample
    112 
    113 Instructions must be separated by a newline or semicolon.
    114 
    115 FLIX instructions, which bundle multiple opcodes together in a single
    116 instruction, are specified by enclosing the bundled opcodes inside
    117 braces:
    118 
    119 @smallexample
    120 @group
    121 @{
    122 [@var{format}]
    123 @var{opcode0} [@var{operands}]
    124 @end group
    125 @var{opcode1} [@var{operands}]
    126 @group
    127 @var{opcode2} [@var{operands}]
    128 @dots{}
    129 @}
    130 @end group
    131 @end smallexample
    132 
    133 The opcodes in a FLIX instruction are listed in the same order as the
    134 corresponding instruction slots in the TIE format declaration.
    135 Directives and labels are not allowed inside the braces of a FLIX
    136 instruction.  A particular TIE format name can optionally be specified
    137 immediately after the opening brace, but this is usually unnecessary.
    138 The assembler will automatically search for a format that can encode the
    139 specified opcodes, so the format name need only be specified in rare
    140 cases where there is more than one applicable format and where it
    141 matters which of those formats is used.  A FLIX instruction can also be
    142 specified on a single line by separating the opcodes with semicolons:
    143 
    144 @smallexample
    145 @{ [@var{format};] @var{opcode0} [@var{operands}]; @var{opcode1} [@var{operands}]; @var{opcode2} [@var{operands}]; @dots{} @}
    146 @end smallexample
    147 
    148 If an opcode can only be encoded in a FLIX instruction but is not
    149 specified as part of a FLIX bundle, the assembler will choose the
    150 smallest format where the opcode can be encoded and
    151 will fill unused instruction slots with no-ops.
    152 
    153 @menu
    154 * Xtensa Opcodes::              Opcode Naming Conventions.
    155 * Xtensa Registers::            Register Naming.
    156 @end menu
    157 
    158 @node Xtensa Opcodes
    159 @subsection Opcode Names
    160 @cindex Xtensa opcode names
    161 @cindex opcode names, Xtensa
    162 
    163 See the @cite{Xtensa Instruction Set Architecture (ISA) Reference
    164 Manual} for a complete list of opcodes and descriptions of their
    165 semantics.
    166 
    167 @cindex _ opcode prefix
    168 If an opcode name is prefixed with an underscore character (@samp{_}),
    169 @command{@value{AS}} will not transform that instruction in any way.  The
    170 underscore prefix disables both optimization (@pxref{Xtensa
    171 Optimizations, ,Xtensa Optimizations}) and relaxation (@pxref{Xtensa
    172 Relaxation, ,Xtensa Relaxation}) for that particular instruction.  Only
    173 use the underscore prefix when it is essential to select the exact
    174 opcode produced by the assembler.  Using this feature unnecessarily
    175 makes the code less efficient by disabling assembler optimization and
    176 less flexible by disabling relaxation.
    177 
    178 Note that this special handling of underscore prefixes only applies to
    179 Xtensa opcodes, not to either built-in macros or user-defined macros.
    180 When an underscore prefix is used with a macro (e.g., @code{_MOV}), it
    181 refers to a different macro.  The assembler generally provides built-in
    182 macros both with and without the underscore prefix, where the underscore
    183 versions behave as if the underscore carries through to the instructions
    184 in the macros.  For example, @code{_MOV} may expand to @code{_MOV.N}@.
    185 
    186 The underscore prefix only applies to individual instructions, not to
    187 series of instructions.  For example, if a series of instructions have
    188 underscore prefixes, the assembler will not transform the individual
    189 instructions, but it may insert other instructions between them (e.g.,
    190 to align a @code{LOOP} instruction).  To prevent the assembler from
    191 modifying a series of instructions as a whole, use the
    192 @code{no-transform} directive.  @xref{Transform Directive, ,transform}.
    193 
    194 @node Xtensa Registers
    195 @subsection Register Names
    196 @cindex Xtensa register names
    197 @cindex register names, Xtensa
    198 @cindex sp register
    199 
    200 The assembly syntax for a register file entry is the ``short'' name for
    201 a TIE register file followed by the index into that register file.  For
    202 example, the general-purpose @code{AR} register file has a short name of
    203 @code{a}, so these registers are named @code{a0}@dots{}@code{a15}.
    204 As a special feature, @code{sp} is also supported as a synonym for
    205 @code{a1}.  Additional registers may be added by processor configuration
    206 options and by designer-defined TIE extensions.  An initial @samp{$}
    207 character is optional in all register names.
    208 
    209 @node Xtensa Optimizations
    210 @section Xtensa Optimizations
    211 @cindex optimizations
    212 
    213 The optimizations currently supported by @command{@value{AS}} are
    214 generation of density instructions where appropriate and automatic
    215 branch target alignment.
    216 
    217 @menu
    218 * Density Instructions::        Using Density Instructions.
    219 * Xtensa Automatic Alignment::  Automatic Instruction Alignment.
    220 @end menu
    221 
    222 @node Density Instructions
    223 @subsection Using Density Instructions
    224 @cindex density instructions
    225 
    226 The Xtensa instruction set has a code density option that provides
    227 16-bit versions of some of the most commonly used opcodes.  Use of these
    228 opcodes can significantly reduce code size.  When possible, the
    229 assembler automatically translates instructions from the core
    230 Xtensa instruction set into equivalent instructions from the Xtensa code
    231 density option.  This translation can be disabled by using underscore
    232 prefixes (@pxref{Xtensa Opcodes, ,Opcode Names}), by using the
    233 @samp{--no-transform} command-line option (@pxref{Xtensa Options, ,Command
    234 Line Options}), or by using the @code{no-transform} directive
    235 (@pxref{Transform Directive, ,transform}).
    236 
    237 It is a good idea @emph{not} to use the density instructions directly.
    238 The assembler will automatically select dense instructions where
    239 possible.  If you later need to use an Xtensa processor without the code
    240 density option, the same assembly code will then work without modification.
    241 
    242 @node Xtensa Automatic Alignment
    243 @subsection Automatic Instruction Alignment
    244 @cindex alignment of @code{LOOP} instructions
    245 @cindex alignment of branch targets
    246 @cindex @code{LOOP} instructions, alignment
    247 @cindex branch target alignment
    248 
    249 The Xtensa assembler will automatically align certain instructions, both
    250 to optimize performance and to satisfy architectural requirements.
    251 
    252 As an optimization to improve performance, the assembler attempts to
    253 align branch targets so they do not cross instruction fetch boundaries.
    254 (Xtensa processors can be configured with either 32-bit or 64-bit
    255 instruction fetch widths.)  An
    256 instruction immediately following a call is treated as a branch target
    257 in this context, because it will be the target of a return from the
    258 call.  This alignment has the potential to reduce branch penalties at
    259 some expense in code size.
    260 This optimization is enabled by default.  You can disable it with the
    261 @samp{--no-target-@-align} command-line option (@pxref{Xtensa Options,
    262 ,Command Line Options}).
    263 
    264 The target alignment optimization is done without adding instructions
    265 that could increase the execution time of the program.  If there are
    266 density instructions in the code preceding a target, the assembler can
    267 change the target alignment by widening some of those instructions to
    268 the equivalent 24-bit instructions.  Extra bytes of padding can be
    269 inserted immediately following unconditional jump and return
    270 instructions.
    271 This approach is usually successful in aligning many, but not all,
    272 branch targets.
    273 
    274 The @code{LOOP} family of instructions must be aligned such that the
    275 first instruction in the loop body does not cross an instruction fetch
    276 boundary (e.g., with a 32-bit fetch width, a @code{LOOP} instruction
    277 must be on either a 1 or 2 mod 4 byte boundary).  The assembler knows
    278 about this restriction and inserts the minimal number of 2 or 3 byte
    279 no-op instructions to satisfy it.  When no-op instructions are added,
    280 any label immediately preceding the original loop will be moved in order
    281 to refer to the loop instruction, not the newly generated no-op
    282 instruction.  To preserve binary compatibility across processors with
    283 different fetch widths, the assembler conservatively assumes a 32-bit
    284 fetch width when aligning @code{LOOP} instructions (except if the first
    285 instruction in the loop is a 64-bit instruction).
    286 
    287 Previous versions of the assembler automatically aligned @code{ENTRY}
    288 instructions to 4-byte boundaries, but that alignment is now the
    289 programmer's responsibility.
    290 
    291 @node Xtensa Relaxation
    292 @section Xtensa Relaxation
    293 @cindex relaxation
    294 
    295 When an instruction operand is outside the range allowed for that
    296 particular instruction field, @command{@value{AS}} can transform the code
    297 to use a functionally-equivalent instruction or sequence of
    298 instructions.  This process is known as @dfn{relaxation}.  This is
    299 typically done for branch instructions because the distance of the
    300 branch targets is not known until assembly-time.  The Xtensa assembler
    301 offers branch relaxation and also extends this concept to function
    302 calls, @code{MOVI} instructions and other instructions with immediate
    303 fields.
    304 
    305 @menu
    306 * Xtensa Branch Relaxation::        Relaxation of Branches.
    307 * Xtensa Call Relaxation::          Relaxation of Function Calls.
    308 * Xtensa Immediate Relaxation::     Relaxation of other Immediate Fields.
    309 @end menu
    310 
    311 @node Xtensa Branch Relaxation
    312 @subsection Conditional Branch Relaxation
    313 @cindex relaxation of branch instructions
    314 @cindex branch instructions, relaxation
    315 
    316 When the target of a branch is too far away from the branch itself,
    317 i.e., when the offset from the branch to the target is too large to fit
    318 in the immediate field of the branch instruction, it may be necessary to
    319 replace the branch with a branch around a jump.  For example,
    320 
    321 @smallexample
    322     beqz    a2, L
    323 @end smallexample
    324 
    325 may result in:
    326 
    327 @smallexample
    328 @group
    329     bnez.n  a2, M
    330     j L
    331 M:
    332 @end group
    333 @end smallexample
    334 
    335 (The @code{BNEZ.N} instruction would be used in this example only if the
    336 density option is available.  Otherwise, @code{BNEZ} would be used.)
    337 
    338 This relaxation works well because the unconditional jump instruction
    339 has a much larger offset range than the various conditional branches.
    340 However, an error will occur if a branch target is beyond the range of a
    341 jump instruction.  @command{@value{AS}} cannot relax unconditional jumps.
    342 Similarly, an error will occur if the original input contains an
    343 unconditional jump to a target that is out of range.
    344 
    345 Branch relaxation is enabled by default.  It can be disabled by using
    346 underscore prefixes (@pxref{Xtensa Opcodes, ,Opcode Names}), the
    347 @samp{--no-transform} command-line option (@pxref{Xtensa Options,
    348 ,Command Line Options}), or the @code{no-transform} directive
    349 (@pxref{Transform Directive, ,transform}).
    350 
    351 @node Xtensa Call Relaxation
    352 @subsection Function Call Relaxation
    353 @cindex relaxation of call instructions
    354 @cindex call instructions, relaxation
    355 
    356 Function calls may require relaxation because the Xtensa immediate call
    357 instructions (@code{CALL0}, @code{CALL4}, @code{CALL8} and
    358 @code{CALL12}) provide a PC-relative offset of only 512 Kbytes in either
    359 direction.  For larger programs, it may be necessary to use indirect
    360 calls (@code{CALLX0}, @code{CALLX4}, @code{CALLX8} and @code{CALLX12})
    361 where the target address is specified in a register.  The Xtensa
    362 assembler can automatically relax immediate call instructions into
    363 indirect call instructions.  This relaxation is done by loading the
    364 address of the called function into the callee's return address register
    365 and then using a @code{CALLX} instruction.  So, for example:
    366 
    367 @smallexample
    368     call8 func
    369 @end smallexample
    370 
    371 might be relaxed to:
    372 
    373 @smallexample
    374 @group
    375     .literal .L1, func
    376     l32r    a8, .L1
    377     callx8  a8
    378 @end group
    379 @end smallexample
    380 
    381 Because the addresses of targets of function calls are not generally
    382 known until link-time, the assembler must assume the worst and relax all
    383 the calls to functions in other source files, not just those that really
    384 will be out of range.  The linker can recognize calls that were
    385 unnecessarily relaxed, and it will remove the overhead introduced by the
    386 assembler for those cases where direct calls are sufficient.
    387 
    388 Call relaxation is disabled by default because it can have a negative
    389 effect on both code size and performance, although the linker can
    390 usually eliminate the unnecessary overhead.  If a program is too large
    391 and some of the calls are out of range, function call relaxation can be
    392 enabled using the @samp{--longcalls} command-line option or the
    393 @code{longcalls} directive (@pxref{Longcalls Directive, ,longcalls}).
    394 
    395 @node Xtensa Immediate Relaxation
    396 @subsection Other Immediate Field Relaxation
    397 @cindex immediate fields, relaxation
    398 @cindex relaxation of immediate fields
    399 
    400 The assembler normally performs the following other relaxations.  They
    401 can be disabled by using underscore prefixes (@pxref{Xtensa Opcodes,
    402 ,Opcode Names}), the @samp{--no-transform} command-line option
    403 (@pxref{Xtensa Options, ,Command Line Options}), or the
    404 @code{no-transform} directive (@pxref{Transform Directive, ,transform}).
    405 
    406 @cindex @code{MOVI} instructions, relaxation
    407 @cindex relaxation of @code{MOVI} instructions
    408 The @code{MOVI} machine instruction can only materialize values in the
    409 range from -2048 to 2047.  Values outside this range are best
    410 materialized with @code{L32R} instructions.  Thus:
    411 
    412 @smallexample
    413     movi a0, 100000
    414 @end smallexample
    415 
    416 is assembled into the following machine code:
    417 
    418 @smallexample
    419 @group
    420     .literal .L1, 100000
    421     l32r a0, .L1
    422 @end group
    423 @end smallexample
    424 
    425 @cindex @code{L8UI} instructions, relaxation
    426 @cindex @code{L16SI} instructions, relaxation
    427 @cindex @code{L16UI} instructions, relaxation
    428 @cindex @code{L32I} instructions, relaxation
    429 @cindex relaxation of @code{L8UI} instructions
    430 @cindex relaxation of @code{L16SI} instructions
    431 @cindex relaxation of @code{L16UI} instructions
    432 @cindex relaxation of @code{L32I} instructions
    433 The @code{L8UI} machine instruction can only be used with immediate
    434 offsets in the range from 0 to 255. The @code{L16SI} and @code{L16UI}
    435 machine instructions can only be used with offsets from 0 to 510.  The
    436 @code{L32I} machine instruction can only be used with offsets from 0 to
    437 1020.  A load offset outside these ranges can be materialized with
    438 an @code{L32R} instruction if the destination register of the load
    439 is different than the source address register.  For example:
    440 
    441 @smallexample
    442     l32i a1, a0, 2040
    443 @end smallexample
    444 
    445 is translated to:
    446 
    447 @smallexample
    448 @group
    449     .literal .L1, 2040
    450     l32r a1, .L1
    451 @end group
    452 @group
    453     add a1, a0, a1
    454     l32i a1, a1, 0
    455 @end group
    456 @end smallexample
    457 
    458 @noindent
    459 If the load destination and source address register are the same, an
    460 out-of-range offset causes an error.
    461 
    462 @cindex @code{ADDI} instructions, relaxation
    463 @cindex relaxation of @code{ADDI} instructions
    464 The Xtensa @code{ADDI} instruction only allows immediate operands in the
    465 range from -128 to 127.  There are a number of alternate instruction
    466 sequences for the @code{ADDI} operation.  First, if the
    467 immediate is 0, the @code{ADDI} will be turned into a @code{MOV.N}
    468 instruction (or the equivalent @code{OR} instruction if the code density
    469 option is not available).  If the @code{ADDI} immediate is outside of
    470 the range -128 to 127, but inside the range -32896 to 32639, an
    471 @code{ADDMI} instruction or @code{ADDMI}/@code{ADDI} sequence will be
    472 used.  Finally, if the immediate is outside of this range and a free
    473 register is available, an @code{L32R}/@code{ADD} sequence will be used
    474 with a literal allocated from the literal pool.
    475 
    476 For example:
    477 
    478 @smallexample
    479 @group
    480     addi    a5, a6, 0
    481     addi    a5, a6, 512
    482 @end group
    483 @group
    484     addi    a5, a6, 513
    485     addi    a5, a6, 50000
    486 @end group
    487 @end smallexample
    488 
    489 is assembled into the following:
    490 
    491 @smallexample
    492 @group
    493     .literal .L1, 50000
    494     mov.n   a5, a6
    495 @end group
    496     addmi   a5, a6, 0x200
    497     addmi   a5, a6, 0x200
    498     addi    a5, a5, 1
    499 @group
    500     l32r    a5, .L1
    501     add     a5, a6, a5
    502 @end group
    503 @end smallexample
    504 
    505 @node Xtensa Directives
    506 @section Directives
    507 @cindex Xtensa directives
    508 @cindex directives, Xtensa
    509 
    510 The Xtensa assembler supports a region-based directive syntax:
    511 
    512 @smallexample
    513 @group
    514     .begin @var{directive} [@var{options}]
    515     @dots{}
    516     .end @var{directive}
    517 @end group
    518 @end smallexample
    519 
    520 All the Xtensa-specific directives that apply to a region of code use
    521 this syntax.
    522 
    523 The directive applies to code between the @code{.begin} and the
    524 @code{.end}.  The state of the option after the @code{.end} reverts to
    525 what it was before the @code{.begin}.
    526 A nested @code{.begin}/@code{.end} region can further
    527 change the state of the directive without having to be aware of its
    528 outer state.  For example, consider:
    529 
    530 @smallexample
    531 @group
    532     .begin no-transform
    533 L:  add a0, a1, a2
    534 @end group
    535     .begin transform
    536 M:  add a0, a1, a2
    537     .end transform
    538 @group
    539 N:  add a0, a1, a2
    540     .end no-transform
    541 @end group
    542 @end smallexample
    543 
    544 The @code{ADD} opcodes at @code{L} and @code{N} in the outer
    545 @code{no-transform} region both result in @code{ADD} machine instructions,
    546 but the assembler selects an @code{ADD.N} instruction for the
    547 @code{ADD} at @code{M} in the inner @code{transform} region.
    548 
    549 The advantage of this style is that it works well inside macros which can
    550 preserve the context of their callers.
    551 
    552 The following directives are available:
    553 @menu
    554 * Schedule Directive::         Enable instruction scheduling.
    555 * Longcalls Directive::        Use Indirect Calls for Greater Range.
    556 * Transform Directive::        Disable All Assembler Transformations.
    557 * Literal Directive::          Intermix Literals with Instructions.
    558 * Literal Position Directive:: Specify Inline Literal Pool Locations.
    559 * Literal Prefix Directive::   Specify Literal Section Name Prefix.
    560 * Absolute Literals Directive:: Control PC-Relative vs. Absolute Literals.
    561 @end menu
    562 
    563 @node Schedule Directive
    564 @subsection schedule
    565 @cindex @code{schedule} directive
    566 @cindex @code{no-schedule} directive
    567 
    568 The @code{schedule} directive is recognized only for compatibility with
    569 Tensilica's assembler.
    570 
    571 @smallexample
    572 @group
    573     .begin [no-]schedule
    574     .end [no-]schedule
    575 @end group
    576 @end smallexample
    577 
    578 This directive is ignored and has no effect on @command{@value{AS}}.
    579 
    580 @node Longcalls Directive
    581 @subsection longcalls
    582 @cindex @code{longcalls} directive
    583 @cindex @code{no-longcalls} directive
    584 
    585 The @code{longcalls} directive enables or disables function call
    586 relaxation.  @xref{Xtensa Call Relaxation, ,Function Call Relaxation}.
    587 
    588 @smallexample
    589 @group
    590     .begin [no-]longcalls
    591     .end [no-]longcalls
    592 @end group
    593 @end smallexample
    594 
    595 Call relaxation is disabled by default unless the @samp{--longcalls}
    596 command-line option is specified.  The @code{longcalls} directive
    597 overrides the default determined by the command-line options.
    598 
    599 @node Transform Directive
    600 @subsection transform
    601 @cindex @code{transform} directive
    602 @cindex @code{no-transform} directive
    603 
    604 This directive enables or disables all assembler transformation,
    605 including relaxation (@pxref{Xtensa Relaxation, ,Xtensa Relaxation}) and
    606 optimization (@pxref{Xtensa Optimizations, ,Xtensa Optimizations}).
    607 
    608 @smallexample
    609 @group
    610     .begin [no-]transform
    611     .end [no-]transform
    612 @end group
    613 @end smallexample
    614 
    615 Transformations are enabled by default unless the @samp{--no-transform}
    616 option is used.  The @code{transform} directive overrides the default
    617 determined by the command-line options.  An underscore opcode prefix,
    618 disabling transformation of that opcode, always takes precedence over
    619 both directives and command-line flags.
    620 
    621 @node Literal Directive
    622 @subsection literal
    623 @cindex @code{literal} directive
    624 
    625 The @code{.literal} directive is used to define literal pool data, i.e., 
    626 read-only 32-bit data accessed via @code{L32R} instructions.
    627 
    628 @smallexample
    629     .literal @var{label}, @var{value}[, @var{value}@dots{}]
    630 @end smallexample
    631 
    632 This directive is similar to the standard @code{.word} directive, except
    633 that the actual location of the literal data is determined by the
    634 assembler and linker, not by the position of the @code{.literal}
    635 directive.  Using this directive gives the assembler freedom to locate
    636 the literal data in the most appropriate place and possibly to combine
    637 identical literals.  For example, the code:
    638 
    639 @smallexample
    640 @group
    641     entry sp, 40
    642     .literal .L1, sym
    643     l32r    a4, .L1
    644 @end group
    645 @end smallexample
    646 
    647 can be used to load a pointer to the symbol @code{sym} into register
    648 @code{a4}.  The value of @code{sym} will not be placed between the
    649 @code{ENTRY} and @code{L32R} instructions; instead, the assembler puts
    650 the data in a literal pool.
    651 
    652 Literal pools are placed by default in separate literal sections;
    653 however, when using the @samp{--text-@-section-@-literals}
    654 option (@pxref{Xtensa Options, ,Command Line Options}), the literal
    655 pools for PC-relative mode @code{L32R} instructions
    656 are placed in the current section.@footnote{Literals for the
    657 @code{.init} and @code{.fini} sections are always placed in separate
    658 sections, even when @samp{--text-@-section-@-literals} is enabled.}
    659 These text section literal
    660 pools are created automatically before @code{ENTRY} instructions and
    661 manually after @samp{.literal_position} directives (@pxref{Literal
    662 Position Directive, ,literal_position}).  If there are no preceding
    663 @code{ENTRY} instructions, explicit @code{.literal_position} directives
    664 must be used to place the text section literal pools; otherwise,
    665 @command{@value{AS}} will report an error.
    666 
    667 When literals are placed in separate sections, the literal section names
    668 are derived from the names of the sections where the literals are
    669 defined.  The base literal section names are @code{.literal} for
    670 PC-relative mode @code{L32R} instructions and @code{.lit4} for absolute
    671 mode @code{L32R} instructions (@pxref{Absolute Literals Directive,
    672 ,absolute-literals}).  These base names are used for literals defined in
    673 the default @code{.text} section.  For literals defined in other
    674 sections or within the scope of a @code{literal_prefix} directive
    675 (@pxref{Literal Prefix Directive, ,literal_prefix}), the following rules
    676 determine the literal section name:
    677 
    678 @enumerate
    679 @item
    680 If the current section is a member of a section group, the literal
    681 section name includes the group name as a suffix to the base
    682 @code{.literal} or @code{.lit4} name, with a period to separate the base
    683 name and group name.  The literal section is also made a member of the
    684 group.
    685 
    686 @item
    687 If the current section name (or @code{literal_prefix} value) begins with
    688 ``@code{.gnu.linkonce.@var{kind}.}'', the literal section name is formed
    689 by replacing ``@code{.@var{kind}}'' with the base @code{.literal} or
    690 @code{.lit4} name.  For example, for literals defined in a section named
    691 @code{.gnu.linkonce.t.func}, the literal section will be
    692 @code{.gnu.linkonce.literal.func} or @code{.gnu.linkonce.lit4.func}.
    693 
    694 @item
    695 If the current section name (or @code{literal_prefix} value) ends with
    696 @code{.text}, the literal section name is formed by replacing that
    697 suffix with the base @code{.literal} or @code{.lit4} name.  For example,
    698 for literals defined in a section named @code{.iram0.text}, the literal
    699 section will be @code{.iram0.literal} or @code{.iram0.lit4}.
    700 
    701 @item
    702 If none of the preceding conditions apply, the literal section name is
    703 formed by adding the base @code{.literal} or @code{.lit4} name as a
    704 suffix to the current section name (or @code{literal_prefix} value).
    705 @end enumerate
    706 
    707 @node Literal Position Directive
    708 @subsection literal_position
    709 @cindex @code{literal_position} directive
    710 
    711 When using @samp{--text-@-section-@-literals} to place literals inline
    712 in the section being assembled, the @code{.literal_position} directive
    713 can be used to mark a potential location for a literal pool.
    714 
    715 @smallexample
    716     .literal_position
    717 @end smallexample
    718 
    719 The @code{.literal_position} directive is ignored when the
    720 @samp{--text-@-section-@-literals} option is not used or when
    721 @code{L32R} instructions use the absolute addressing mode.
    722 
    723 The assembler will automatically place text section literal pools 
    724 before @code{ENTRY} instructions, so the @code{.literal_position}
    725 directive is only needed to specify some other location for a literal
    726 pool.  You may need to add an explicit jump instruction to skip over an
    727 inline literal pool.
    728 
    729 For example, an interrupt vector does not begin with an @code{ENTRY}
    730 instruction so the assembler will be unable to automatically find a good
    731 place to put a literal pool.  Moreover, the code for the interrupt
    732 vector must be at a specific starting address, so the literal pool
    733 cannot come before the start of the code.  The literal pool for the
    734 vector must be explicitly positioned in the middle of the vector (before
    735 any uses of the literals, due to the negative offsets used by
    736 PC-relative @code{L32R} instructions).  The @code{.literal_position}
    737 directive can be used to do this.  In the following code, the literal
    738 for @samp{M} will automatically be aligned correctly and is placed after
    739 the unconditional jump.
    740 
    741 @smallexample
    742 @group
    743     .global M
    744 code_start:
    745 @end group
    746     j continue
    747     .literal_position
    748     .align 4
    749 @group
    750 continue:
    751     movi    a4, M
    752 @end group
    753 @end smallexample
    754 
    755 @node Literal Prefix Directive
    756 @subsection literal_prefix
    757 @cindex @code{literal_prefix} directive
    758 
    759 The @code{literal_prefix} directive allows you to override the default
    760 literal section names, which are derived from the names of the sections
    761 where the literals are defined.
    762 
    763 @smallexample
    764 @group
    765     .begin literal_prefix [@var{name}]
    766     .end literal_prefix
    767 @end group
    768 @end smallexample
    769 
    770 For literals defined within the delimited region, the literal section
    771 names are derived from the @var{name} argument instead of the name of
    772 the current section.  The rules used to derive the literal section names
    773 do not change.  @xref{Literal Directive, ,literal}.  If the @var{name}
    774 argument is omitted, the literal sections revert to the defaults.  This
    775 directive has no effect when using the
    776 @samp{--text-@-section-@-literals} option (@pxref{Xtensa Options,
    777 ,Command Line Options}).
    778 
    779 @node Absolute Literals Directive
    780 @subsection absolute-literals
    781 @cindex @code{absolute-literals} directive
    782 @cindex @code{no-absolute-literals} directive
    783 
    784 The @code{absolute-@-literals} and @code{no-@-absolute-@-literals}
    785 directives control the absolute vs.@: PC-relative mode for @code{L32R}
    786 instructions.  These are relevant only for Xtensa configurations that
    787 include the absolute addressing option for @code{L32R} instructions.
    788 
    789 @smallexample
    790 @group
    791     .begin [no-]absolute-literals
    792     .end [no-]absolute-literals
    793 @end group
    794 @end smallexample
    795 
    796 These directives do not change the @code{L32R} mode---they only cause
    797 the assembler to emit the appropriate kind of relocation for @code{L32R}
    798 instructions and to place the literal values in the appropriate section.
    799 To change the @code{L32R} mode, the program must write the
    800 @code{LITBASE} special register.  It is the programmer's responsibility
    801 to keep track of the mode and indicate to the assembler which mode is
    802 used in each region of code.
    803 
    804 If the Xtensa configuration includes the absolute @code{L32R} addressing
    805 option, the default is to assume absolute @code{L32R} addressing unless
    806 the @samp{--no-@-absolute-@-literals} command-line option is specified.
    807 Otherwise, the default is to assume PC-relative @code{L32R} addressing.
    808 The @code{absolute-@-literals} directive can then be used to override
    809 the default determined by the command-line options.
    810 
    811 @c Local Variables:
    812 @c fill-column: 72
    813 @c End:
    814