RISC-V: PR27158, fixed UJ/SB types and added CSS/CL/CS types for .insn.
[deliverable/binutils-gdb.git] / gas / doc / c-riscv.texi
CommitLineData
250d07de 1@c Copyright (C) 2016-2021 Free Software Foundation, Inc.
e23eba97
NC
2@c This is part of the GAS anual.
3@c For copying conditions, see the file as.texinfo
4@c man end
5
6@ifset GENERIC
7@page
8@node RISC-V-Dependent
9@chapter RISC-V Dependent Features
10@end ifset
11@ifclear GENERIC
12@node Machine Dependencies
13@chapter RISC-V Dependent Features
14@end ifclear
15
16@cindex RISC-V support
17@menu
b57e49f7
JW
18* RISC-V-Options:: RISC-V Options
19* RISC-V-Directives:: RISC-V Directives
de48783e 20* RISC-V-Modifiers:: RISC-V Assembler Modifiers
0e35537d 21* RISC-V-Formats:: RISC-V Instruction Formats
2dc8dd17 22* RISC-V-ATTRIBUTE:: RISC-V Object Attribute
e23eba97
NC
23@end menu
24
b57e49f7
JW
25@node RISC-V-Options
26@section RISC-V Options
e23eba97 27
b57e49f7 28The following table lists all available RISC-V specific options.
e23eba97
NC
29
30@c man begin OPTIONS
31@table @gcctabopt
e23eba97 32
19683c04
PD
33@cindex @samp{-fpic} option, RISC-V
34@item -fpic
b57e49f7 35@itemx -fPIC
19683c04
PD
36Generate position-independent code
37
38@cindex @samp{-fno-pic} option, RISC-V
39@item -fno-pic
40Don't generate position-independent code (default)
41
4f7eddc4
PD
42@cindex @samp{-march=ISA} option, RISC-V
43@item -march=ISA
2922d21d 44Select the base isa, as specified by ISA. For example -march=rv32ima.
338d56a8 45If this option and the architecture attributes aren't set, then assembler
8f595e9b
NC
46will check the default configure setting --with-arch=ISA.
47
48@cindex @samp{-misa-spec=ISAspec} option, RISC-V
49@item -misa-spec=ISAspec
50Select the default isa spec version. If the version of ISA isn't set
51by -march, then assembler helps to set the version according to
52the default chosen spec. If this option isn't set, then assembler will
53check the default configure setting --with-isa-spec=ISAspec.
54
55@cindex @samp{-mpriv-spec=PRIVspec} option, RISC-V
56@item -mpriv-spec=PRIVspec
57Select the privileged spec version. We can decide whether the CSR is valid or
58not according to the chosen spec. If this option and the privilege attributes
59aren't set, then assembler will check the default configure setting
60--with-priv-spec=PRIVspec.
2922d21d
AW
61
62@cindex @samp{-mabi=ABI} option, RISC-V
63@item -mabi=ABI
64Selects the ABI, which is either "ilp32" or "lp64", optionally followed
65by "f", "d", or "q" to indicate single-precision, double-precision, or
66quad-precision floating-point calling convention, or none to indicate
7f999549
JW
67the soft-float calling convention. Also, "ilp32" can optionally be followed
68by "e" to indicate the RVE ABI, which is always soft-float.
e23eba97 69
71060565
JW
70@cindex @samp{-mrelax} option, RISC-V
71@item -mrelax
72Take advantage of linker relaxations to reduce the number of instructions
73required to materialize symbol addresses. (default)
74
75@cindex @samp{-mno-relax} option, RISC-V
76@item -mno-relax
77Don't do linker relaxations.
78
bd3380bc
NC
79@cindex @samp{-march-attr} option, RISC-V
80@item -march-attr
81Generate the default contents for the riscv elf attribute section if the
82.attribute directives are not set. This section is used to record the
83information that a linker or runtime loader needs to check compatibility.
84This information includes ISA string, stack alignment requirement, unaligned
85memory accesses, and the major, minor and revision version of privileged
86specification.
87
88@cindex @samp{-mno-arch-attr} option, RISC-V
89@item -mno-arch-attr
90Don't generate the default riscv elf attribute section if the .attribute
91directives are not set.
92
2ca89224
NC
93@cindex @samp{-mcsr-check} option, RISC-V
94@item -mcsr-check
95Enable the CSR checking for the ISA-dependent CRS and the read-only CSR.
96The ISA-dependent CSR are only valid when the specific ISA is set. The
97read-only CSR can not be written by the CSR instructions.
98
99@cindex @samp{-mno-csr-check} option, RISC-V
100@item -mno-csr-check
369afd50 101Don't do CSR checking.
286d2f2c
MC
102
103@cindex @samp{-mlittle-endian} option, RISC-V
104@item -mlittle-endian
105Generate code for a little endian machine.
106
107@cindex @samp{-mbig-endian} option, RISC-V
108@item -mbig-endian
109Generate code for a big endian machine.
e23eba97
NC
110@end table
111@c man end
b57e49f7
JW
112
113@node RISC-V-Directives
fed44c60 114@section RISC-V Directives
b57e49f7
JW
115@cindex machine directives, RISC-V
116@cindex RISC-V machine directives
117
b57e49f7
JW
118The following table lists all available RISC-V specific directives.
119
120@table @code
121
122@cindex @code{align} directive
123@item .align @var{size-log-2}
124Align to the given boundary, with the size given as log2 the number of bytes to
125align to.
126
127@cindex Data directives
128@item .half @var{value}
129@itemx .word @var{value}
130@itemx .dword @var{value}
131Emits a half-word, word, or double-word value at the current position.
132
133@cindex DTP-relative data directives
134@item .dtprelword @var{value}
135@itemx .dtpreldword @var{value}
136Emits a DTP-relative word (or double-word) at the current position. This is
137meant to be used by the compiler in shared libraries for DWARF debug info for
138thread local variables.
139
140@cindex BSS directive
141@item .bss
142Sets the current section to the BSS section.
143
144@cindex LEB128 directives
145@item .uleb128 @var{value}
146@itemx .sleb128 @var{value}
147Emits a signed or unsigned LEB128 value at the current position. This only
148accepts constant expressions, because symbol addresses can change with
149relaxation, and we don't support relocations to modify LEB128 values at link
150time.
151
152@cindex Option directive
153@cindex @code{option} directive
154@item .option @var{argument}
155Modifies RISC-V specific assembler options inline with the assembly code.
156This is used when particular instruction sequences must be assembled with a
157specific set of options. For example, since we relax addressing sequences to
158shorter GP-relative sequences when possible the initial load of GP must not be
159relaxed and should be emitted as something like
160
161@smallexample
162 .option push
163 .option norelax
164 la gp, __global_pointer$
165 .option pop
166@end smallexample
167
168in order to produce after linker relaxation the expected
169
170@smallexample
171 auipc gp, %pcrel_hi(__global_pointer$)
172 addi gp, gp, %pcrel_lo(__global_pointer$)
173@end smallexample
174
175instead of just
176
177@smallexample
178 addi gp, gp, 0
179@end smallexample
180
181It's not expected that options are changed in this manner during regular use,
182but there are a handful of esoteric cases like the one above where users need
183to disable particular features of the assembler for particular code sequences.
184The complete list of option arguments is shown below:
185
186@table @code
187@item push
188@itemx pop
189Pushes or pops the current option stack. These should be used whenever
190changing an option in line with assembly code in order to ensure the user's
191command-line options are respected for the bulk of the file being assembled.
192
193@item rvc
194@itemx norvc
195Enables or disables the generation of compressed instructions. Instructions
196are opportunistically compressed by the RISC-V assembler when possible, but
197sometimes this behavior is not desirable.
198
199@item pic
200@itemx nopic
201Enables or disables position-independent code generation. Unless you really
202know what you're doing, this should only be at the top of a file.
203
204@item relax
205@itemx norelax
206Enables or disables relaxation. The RISC-V assembler and linker
207opportunistically relax some code sequences, but sometimes this behavior is not
208desirable.
209@end table
210
2ca89224
NC
211@item csr-check
212@itemx no-csr-check
213Enables or disables the CSR checking.
214
0e35537d
JW
215@cindex INSN directives
216@item .insn @var{value}
217@itemx .insn @var{value}
218This directive permits the numeric representation of an instructions
219and makes the assembler insert the operands according to one of the
220instruction formats for @samp{.insn} (@ref{RISC-V-Formats}).
221For example, the instruction @samp{add a0, a1, a2} could be written as
222@samp{.insn r 0x33, 0, 0, a0, a1, a2}.
223
2dc8dd17
JW
224@cindex @code{.attribute} directive, RISC-V
225@item .attribute @var{tag}, @var{value}
226Set the object attribute @var{tag} to @var{value}.
227
228The @var{tag} is either an attribute number, or one of the following:
229@code{Tag_RISCV_arch}, @code{Tag_RISCV_stack_align},
230@code{Tag_RISCV_unaligned_access}, @code{Tag_RISCV_priv_spec},
231@code{Tag_RISCV_priv_spec_minor}, @code{Tag_RISCV_priv_spec_revision}.
232
b57e49f7 233@end table
0e35537d 234
de48783e
NC
235@node RISC-V-Modifiers
236@section RISC-V Assembler Modifiers
237
238The RISC-V assembler supports following modifiers for relocatable addresses
239used in RISC-V instruction operands. However, we also support some pseudo
240instructions that are easier to use than these modifiers.
241
242@table @code
243@item %lo(@var{symbol})
244The low 12 bits of absolute address for @var{symbol}.
245
246@item %hi(@var{symbol})
247The high 20 bits of absolute address for @var{symbol}. This is usually
248used with the %lo modifier to represent a 32-bit absolute address.
249
250@smallexample
251 lui a0, %hi(@var{symbol}) // R_RISCV_HI20
252 addi a0, a0, %lo(@var{symbol}) // R_RISCV_LO12_I
253
254 lui a0, %hi(@var{symbol}) // R_RISCV_HI20
255 load/store a0, %lo(@var{symbol})(a0) // R_RISCV_LO12_I/S
256@end smallexample
257
258@item %pcrel_lo(@var{label})
259The low 12 bits of relative address between pc and @var{symbol}.
260The @var{symbol} is related to the high part instruction which is marked
261by @var{label}.
262
263@item %pcrel_hi(@var{symbol})
264The high 20 bits of relative address between pc and @var{symbol}.
265This is usually used with the %pcrel_lo modifier to represent a +/-2GB
266pc-relative range.
267
268@smallexample
269@var{label}:
270 auipc a0, %pcrel_hi(@var{symbol}) // R_RISCV_PCREL_HI20
271 addi a0, a0, %pcrel_lo(@var{label}) // R_RISCV_PCREL_LO12_I
272
273@var{label}:
274 auipc a0, %pcrel_hi(@var{symbol}) // R_RISCV_PCREL_HI20
275 load/store a0, %pcrel_lo(@var{label})(a0) // R_RISCV_PCREL_LO12_I/S
276@end smallexample
277
278Or you can use the pseudo lla/lw/sw/... instruction to do this.
279
280@smallexample
281 lla a0, @var{symbol}
282@end smallexample
283
dee35d02
NC
284@item %got_pcrel_hi(@var{symbol})
285The high 20 bits of relative address between pc and the GOT entry of
286@var{symbol}. This is usually used with the %pcrel_lo modifier to access
287the GOT entry.
288
289@smallexample
290@var{label}:
291 auipc a0, %got_pcrel_hi(@var{symbol}) // R_RISCV_GOT_HI20
292 addi a0, a0, %pcrel_lo(@var{label}) // R_RISCV_PCREL_LO12_I
293
294@var{label}:
295 auipc a0, %got_pcrel_hi(@var{symbol}) // R_RISCV_GOT_HI20
296 load/store a0, %pcrel_lo(@var{label})(a0) // R_RISCV_PCREL_LO12_I/S
297@end smallexample
298
299Also, the pseudo la instruction with PIC has similar behavior.
300
de48783e
NC
301@item %tprel_add(@var{symbol})
302This is used purely to associate the R_RISCV_TPREL_ADD relocation for
303TLS relaxation. This one is only valid as the fourth operand to the normally
3043 operand add instruction.
305
306@item %tprel_lo(@var{symbol})
307The low 12 bits of relative address between tp and @var{symbol}.
308
309@item %tprel_hi(@var{symbol})
310The high 20 bits of relative address between tp and @var{symbol}. This is
311usually used with the %tprel_lo and %tprel_add modifiers to access the thread
312local variable @var{symbol} in TLS Local Exec.
313
314@smallexample
315 lui a5, %tprel_hi(@var{symbol}) // R_RISCV_TPREL_HI20
316 add a5, a5, tp, %tprel_add(@var{symbol}) // R_RISCV_TPREL_ADD
317 load/store t0, %tprel_lo(@var{symbol})(a5) // R_RISCV_TPREL_LO12_I/S
318@end smallexample
319
320@item %tls_ie_pcrel_hi(@var{symbol})
321The high 20 bits of relative address between pc and GOT entry. It is
322usually used with the %pcrel_lo modifier to access the thread local
323variable @var{symbol} in TLS Initial Exec.
324
325@smallexample
326 la.tls.ie a5, @var{symbol}
327 add a5, a5, tp
328 load/store t0, 0(a5)
329@end smallexample
330
331The pseudo la.tls.ie instruction can be expended to
332
333@smallexample
334@var{label}:
335 auipc a5, %tls_ie_pcrel_hi(@var{symbol}) // R_RISCV_TLS_GOT_HI20
336 load a5, %pcrel_lo(@var{label})(a5) // R_RISCV_PCREL_LO12_I
337@end smallexample
338
339@item %tls_gd_pcrel_hi(@var{symbol})
340The high 20 bits of relative address between pc and GOT entry. It is
341usually used with the %pcrel_lo modifier to access the thread local variable
342@var{symbol} in TLS Global Dynamic.
343
344@smallexample
345 la.tls.gd a0, @var{symbol}
346 call __tls_get_addr@@plt
347 mv a5, a0
348 load/store t0, 0(a5)
349@end smallexample
350
351The pseudo la.tls.gd instruction can be expended to
352
353@smallexample
354@var{label}:
355 auipc a0, %tls_gd_pcrel_hi(@var{symbol}) // R_RISCV_TLS_GD_HI20
356 addi a0, a0, %pcrel_lo(@var{label}) // R_RISCV_PCREL_LO12_I
357@end smallexample
358
359@end table
360
0e35537d 361@node RISC-V-Formats
de48783e 362@section RISC-V Instruction Formats
0e35537d
JW
363@cindex instruction formats, risc-v
364@cindex RISC-V instruction formats
365
5a9f5403 366The RISC-V Instruction Set Manual Volume I: User-Level ISA lists 15
0e35537d
JW
367instruction formats where some of the formats have multiple variants.
368For the @samp{.insn} pseudo directive the assembler recognizes some
369of the formats.
370Typically, the most general variant of the instruction format is used
371by the @samp{.insn} directive.
372
373The following table lists the abbreviations used in the table of
374instruction formats:
375
376@display
377@multitable @columnfractions .15 .40
378@item opcode @tab Unsigned immediate or opcode name for 7-bits opcode.
379@item opcode2 @tab Unsigned immediate or opcode name for 2-bits opcode.
380@item func7 @tab Unsigned immediate for 7-bits function code.
4765cd61 381@item func6 @tab Unsigned immediate for 6-bits function code.
0e35537d
JW
382@item func4 @tab Unsigned immediate for 4-bits function code.
383@item func3 @tab Unsigned immediate for 3-bits function code.
384@item func2 @tab Unsigned immediate for 2-bits function code.
385@item rd @tab Destination register number for operand x, can be GPR or FPR.
386@item rd' @tab Destination register number for operand x,
387only accept s0-s1, a0-a5, fs0-fs1 and fa0-fa5.
388@item rs1 @tab First source register number for operand x, can be GPR or FPR.
389@item rs1' @tab First source register number for operand x,
390only accept s0-s1, a0-a5, fs0-fs1 and fa0-fa5.
391@item rs2 @tab Second source register number for operand x, can be GPR or FPR.
392@item rs2' @tab Second source register number for operand x,
393only accept s0-s1, a0-a5, fs0-fs1 and fa0-fa5.
394@item simm12 @tab Sign-extended 12-bit immediate for operand x.
395@item simm20 @tab Sign-extended 20-bit immediate for operand x.
396@item simm6 @tab Sign-extended 6-bit immediate for operand x.
5a9f5403
NC
397@item uimm5 @tab Unsigned 5-bit immediate for operand x.
398@item uimm6 @tab Unsigned 6-bit immediate for operand x.
0e35537d
JW
399@item uimm8 @tab Unsigned 8-bit immediate for operand x.
400@item symbol @tab Symbol or lable reference for operand x.
401@end multitable
402@end display
403
404The following table lists all available opcode name:
405
406@table @code
407@item C0
408@item C1
409@item C2
410Opcode space for compressed instructions.
411
412@item LOAD
413Opcode space for load instructions.
414
415@item LOAD_FP
416Opcode space for floating-point load instructions.
417
418@item STORE
419Opcode space for store instructions.
420
421@item STORE_FP
422Opcode space for floating-point store instructions.
423
424@item AUIPC
425Opcode space for auipc instruction.
426
427@item LUI
428Opcode space for lui instruction.
429
430@item BRANCH
431Opcode space for branch instructions.
432
433@item JAL
434Opcode space for jal instruction.
435
436@item JALR
437Opcode space for jalr instruction.
438
439@item OP
440Opcode space for ALU instructions.
441
442@item OP_32
443Opcode space for 32-bits ALU instructions.
444
445@item OP_IMM
446Opcode space for ALU with immediate instructions.
447
448@item OP_IMM_32
449Opcode space for 32-bits ALU with immediate instructions.
450
451@item OP_FP
452Opcode space for floating-point operation instructions.
453
454@item MADD
455Opcode space for madd instruction.
456
457@item MSUB
458Opcode space for msub instruction.
459
460@item NMADD
461Opcode space for nmadd instruction.
462
463@item NMSUB
464Opcode space for msub instruction.
465
466@item AMO
467Opcode space for atomic memory operation instructions.
468
98602811 469@item MISC_MEM
0e35537d
JW
470Opcode space for misc instructions.
471
472@item SYSTEM
473Opcode space for system instructions.
474
475@item CUSTOM_0
476@item CUSTOM_1
477@item CUSTOM_2
478@item CUSTOM_3
479Opcode space for customize instructions.
480
481@end table
482
483An instruction is two or four bytes in length and must be aligned
484on a 2 byte boundary. The first two bits of the instruction specify the
485length of the instruction, 00, 01 and 10 indicates a two byte instruction,
48611 indicates a four byte instruction.
487
488The following table lists the RISC-V instruction formats that are available
489with the @samp{.insn} pseudo directive:
490
491@table @code
5a9f5403 492@item R type: .insn r opcode6, func3, func7, rd, rs1, rs2
0e35537d 493@verbatim
5a9f5403
NC
494+-------+-----+-----+-------+----+---------+
495| func7 | rs2 | rs1 | func3 | rd | opcode6 |
496+-------+-----+-----+-------+----+---------+
49731 25 20 15 12 7 0
0e35537d
JW
498@end verbatim
499
5a9f5403
NC
500@item R type with 4 register operands: .insn r opcode6, func3, func2, rd, rs1, rs2, rs3
501@itemx R4 type: .insn r4 opcode6, func3, func2, rd, rs1, rs2, rs3
0e35537d 502@verbatim
5a9f5403
NC
503+-----+-------+-----+-----+-------+----+---------+
504| rs3 | func2 | rs2 | rs1 | func3 | rd | opcode6 |
505+-----+-------+-----+-----+-------+----+---------+
50631 27 25 20 15 12 7 0
0e35537d
JW
507@end verbatim
508
5a9f5403
NC
509@item I type: .insn i opcode6, func3, rd, rs1, simm12
510@itemx I type: .insn i opcode6, func3, rd, simm12(rs1)
0e35537d 511@verbatim
5a9f5403
NC
512+--------------+-----+-------+----+---------+
513| simm12[11:0] | rs1 | func3 | rd | opcode6 |
514+--------------+-----+-------+----+---------+
51531 20 15 12 7 0
0e35537d
JW
516@end verbatim
517
5a9f5403 518@item S type: .insn s opcode6, func3, rs2, simm12(rs1)
0e35537d 519@verbatim
5a9f5403
NC
520+--------------+-----+-----+-------+-------------+---------+
521| simm12[11:5] | rs2 | rs1 | func3 | simm12[4:0] | opcode6 |
522+--------------+-----+-----+-------+-------------+---------+
52331 25 20 15 12 7 0
0e35537d
JW
524@end verbatim
525
5a9f5403
NC
526@item B type: .insn s opcode6, func3, rs1, rs2, symbol
527@itemx SB type: .insn sb opcode6, func3, rs1, rs2, symbol
0e35537d 528@verbatim
5a9f5403
NC
529+-----------------+-----+-----+-------+----------------+---------+
530| simm12[12|10:5] | rs2 | rs1 | func3 | simm12[4:1|11] | opcode6 |
531+-----------------+-----+-----+-------+----------------+---------+
53231 25 20 15 12 7 0
0e35537d
JW
533@end verbatim
534
5a9f5403 535@item U type: .insn u opcode6, rd, simm20
0e35537d 536@verbatim
5a9f5403
NC
537+--------------------------+----+---------+
538| simm20[20|10:1|11|19:12] | rd | opcode6 |
539+--------------------------+----+---------+
54031 12 7 0
0e35537d
JW
541@end verbatim
542
5a9f5403
NC
543@item J type: .insn j opcode6, rd, symbol
544@itemx UJ type: .insn uj opcode6, rd, symbol
0e35537d 545@verbatim
5a9f5403
NC
546+------------+--------------+------------+---------------+----+---------+
547| simm20[20] | simm20[10:1] | simm20[11] | simm20[19:12] | rd | opcode6 |
548+------------+--------------+------------+---------------+----+---------+
54931 30 21 20 12 7 0
0e35537d
JW
550@end verbatim
551
4765cd61 552@item CR type: .insn cr opcode2, func4, rd, rs2
0e35537d 553@verbatim
5a9f5403
NC
554+-------+--------+-----+---------+
555| func4 | rd/rs1 | rs2 | opcode2 |
556+-------+--------+-----+---------+
55715 12 7 2 0
0e35537d
JW
558@end verbatim
559
560@item CI type: .insn ci opcode2, func3, rd, simm6
561@verbatim
5a9f5403
NC
562+-------+----------+--------+------------+---------+
563| func3 | simm6[5] | rd/rs1 | simm6[4:0] | opcode2 |
564+-------+----------+--------+------------+---------+
56515 13 12 7 2 0
0e35537d
JW
566@end verbatim
567
5a9f5403 568@item CIW type: .insn ciw opcode2, func3, rd', uimm8
0e35537d 569@verbatim
5a9f5403
NC
570+-------+------------+-----+---------+
571| func3 | uimm8[7:0] | rd' | opcode2 |
572+-------+-------- ---+-----+---------+
57315 13 5 2 0
0e35537d
JW
574@end verbatim
575
5a9f5403 576@item CSS type: .insn css opcode2, func3, rd, uimm6
4765cd61 577@verbatim
5a9f5403
NC
578+-------+------------+----+---------+
579| func3 | uimm6[5:0] | rd | opcode2 |
580+-------+------------+----+---------+
58115 13 7 2 0
4765cd61
JW
582@end verbatim
583
5a9f5403 584@item CL type: .insn cl opcode2, func3, rd', uimm5(rs1')
0e35537d 585@verbatim
5a9f5403
NC
586+-------+------------+------+------------+------+---------+
587| func3 | uimm5[4:2] | rs1' | uimm5[1:0] | rd' | opcode2 |
588+-------+------------+------+------------+------+---------+
58915 13 10 7 5 2 0
590@end verbatim
591
592@item CS type: .insn cs opcode2, func3, rs2', uimm5(rs1')
593@verbatim
594+-------+------------+------+------------+------+---------+
595| func3 | uimm5[4:2] | rs1' | uimm5[1:0] | rs2' | opcode2 |
596+-------+------------+------+------------+------+---------+
59715 13 10 7 5 2 0
598@end verbatim
599
600@item CA type: .insn ca opcode2, func6, func2, rd', rs2'
601@verbatim
602+-- ----+----------+-------+------+---------+
603| func6 | rd'/rs1' | func2 | rs2' | opcode2 |
604+-------+----------+-------+------+---------+
60515 10 7 5 2 0
606@end verbatim
607
608@item CB type: .insn cb opcode2, func3, rs1', symbol
609@verbatim
610+-------+--------------+------+------------------+---------+
611| func3 | simm8[8|4:3] | rs1' | simm8[7:6|2:1|5] | opcode2 |
612+-------+--------------+------+------------------+---------+
61315 13 10 7 2 0
0e35537d
JW
614@end verbatim
615
616@item CJ type: .insn cj opcode2, symbol
617@verbatim
5a9f5403
NC
618+-------+-------------------------------+---------+
619| func3 | simm11[11|4|9:8|10|6|7|3:1|5] | opcode2 |
620+-------+-------------------------------+---------+
62115 13 2 0
0e35537d
JW
622@end verbatim
623
624
625@end table
626
627For the complete list of all instruction format variants see
628The RISC-V Instruction Set Manual Volume I: User-Level ISA.
2dc8dd17
JW
629
630@node RISC-V-ATTRIBUTE
631@section RISC-V Object Attribute
632@cindex Object Attribute, RISC-V
633
634RISC-V attributes have a string value if the tag number is odd and an integer
635value if the tag number is even.
636
637@table @r
638@item Tag_RISCV_stack_align (4)
639Tag_RISCV_strict_align records the N-byte stack alignment for this object. The
640default value is 16 for RV32I or RV64I, and 4 for RV32E.
641
642The smallest value will be used if object files with different
643Tag_RISCV_stack_align values are merged.
644
645@item Tag_RISCV_arch (5)
646Tag_RISCV_arch contains a string for the target architecture taken from the
647option @option{-march}. Different architectures will be integrated into a
648superset when object files are merged.
649
650Note that the version information of the target architecture must be presented
651explicitly in the attribute and abbreviations must be expanded. The version
652information, if not given by @option{-march}, must be in accordance with the
653default specified by the tool. For example, the architecture @code{RV32I} has
654to be recorded in the attribute as @code{RV32I2P0} in which @code{2P0} stands
655for the default version of its base ISA. On the other hand, the architecture
656@code{RV32G} has to be presented as @code{RV32I2P0_M2P0_A2P0_F2P0_D2P0} in
657which the abbreviation @code{G} is expanded to the @code{IMAFD} combination
658with default versions of the standard extensions.
659
660@item Tag_RISCV_unaligned_access (6)
661Tag_RISCV_unaligned_access is 0 for files that do not allow any unaligned
662memory accesses, and 1 for files that do allow unaligned memory accesses.
663
664@item Tag_RISCV_priv_spec (8)
665@item Tag_RISCV_priv_spec_minor (10)
666@item Tag_RISCV_priv_spec_revision (12)
667Tag_RISCV_priv_spec contains the major/minor/revision version information of
668the privileged specification. It will report errors if object files of
669different privileged specification versions are merged.
670
671@end table
This page took 0.256845 seconds and 4 git commands to generate.