RISC-V Dependent Features
*************************

RISC-V Options
==============

The following table lists all available RISC-V specific options.

-fpic
-fPIC
     Generate position-independent code

-fno-pic
     Don't generate position-independent code (default)

-march=ISA
     Select the base isa, as specified by ISA.  For example -march=rv32ima.

-mabi=ABI
     Selects the ABI, which is either "ilp32" or "lp64", optionally followed by "f", "d", or "q" to indicate single-precision, double-precision, or quad-precision floating-point calling convention, or none to indicate the soft-float calling convention.

RISC-V Directives
=================

The following table lists all available RISC-V specific directives.

.align SIZE-LOG-2
     Align to the given boundary, with the size given as log2 the number of bytes to align to.

.half VALUE
.word VALUE
.dword VALUE
     Emits a half-word, word, or double-word value at the current position.

.dtprelword VALUE
.dtpreldword VALUE
     Emits a DTP-relative word (or double-word) at the current position.  This is meant to be used by the compiler in shared libraries for DWARF debug info for thread local variables.

.bss
     Sets the current section to the BSS section.

.uleb128 VALUE
.sleb128 VALUE
     Emits a signed or unsigned LEB128 value at the current position.  This only accepts constant expressions, because symbol addresses can change with relaxation, and we don't support relocations to modify LEB128 values at link time.

.option ARGUMENT
     Modifies RISC-V specific assembler options inline with the assembly code. This is used when particular instruction sequences must be assembled with a specific set of options.  For example, since we relax addressing sequences to shorter GP-relative sequences when possible the initial load of GP must not be relaxed and should be emitted as something like

          	.option push
          	.option norelax
          	la gp, __global_pointer$
          	.option pop

     in order to produce after linker relaxation the expected

          	auipc gp, %pcrel_hi(__global_pointer$)
          	addi gp, gp, %pcrel_lo(__global_pointer$)

     instead of just

          	addi gp, gp, 0

     It's not expected that options are changed in this manner during regular use, but there are a handful of esoteric cases like the one above where users need to disable particular features of the assembler for particular code sequences. The complete list of option arguments is shown below:

     push
     pop
          Pushes or pops the current option stack.  These should be used whenever changing an option in line with assembly code in order to ensure the user's command-line options are respected for the bulk of the file being assembled.

     rvc
     norvc
          Enables or disables the generation of compressed instructions.  Instructions are opportunistically compressed by the RISC-V assembler when possible, but sometimes this behavior is not desirable.

     pic
     nopic
          Enables or disables position-independent code generation.  Unless you really know what you're doing, this should only be at the top of a file.

     relax
     norelax
          Enables or disables relaxation.  The RISC-V assembler and linker opportunistically relax some code sequences, but sometimes this behavior is not desirable.