li
pseudolyszt.net covers li and other RISC-V instructions in more detail.
Description
Writes a constant into a register. In li rd, imm, the constant goes to rd regardless of its width. addi covers constants up to 12 bits; li takes any 32-bit value and expands into whatever instruction sequence that value needs.
Expands to
addi rd, zero, imm # small constants lui rd, hi + addi rd, rd, lo # large constants
The assembler replaces this pseudo-instruction with the real instruction or instructions listed above.
Official definition
ADDI adds the sign-extended 12-bit immediate to register rs1. Arithmetic overflow is ignored and the result is simply the low XLEN bits of the result. ADDI rd, rs1, 0 is used to implement the MV rd, rs1 assembler pseudoinstruction.