2 # RISC-V translation routines for the RVXI Base Integer Instruction Set.
4 # Copyright (c) 2018 Peer Adelt, peer.adelt@hni.uni-paderborn.de
5 # Bastian Koppelmann, kbastian@mail.uni-paderborn.de
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms and conditions of the GNU General Public License,
9 # version 2 or later, as published by the Free Software Foundation.
11 # This program is distributed in the hope it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 # You should have received a copy of the GNU General Public License along with
17 # this program. If not, see <http://www.gnu.org/licenses/>.
32 %imm_b 31:s1 7:1 25:6 8:4 !function=ex_shift_1
33 %imm_j 31:s1 12:8 20:1 21:10 !function=ex_shift_1
34 %imm_u 12:s20 !function=ex_shift_12
41 &atomic aq rl rs2 rs1 rd
44 @r ....... ..... ..... ... ..... ....... &r %rs2 %rs1 %rd
45 @i ............ ..... ... ..... ....... &i imm=%imm_i %rs1 %rd
46 @b ....... ..... ..... ... ..... ....... &b imm=%imm_b %rs2 %rs1
47 @s ....... ..... ..... ... ..... ....... imm=%imm_s %rs2 %rs1
48 @u .................... ..... ....... imm=%imm_u %rd
49 @j .................... ..... ....... imm=%imm_j %rd
51 @sh ...... ...... ..... ... ..... ....... &shift shamt=%sh10 %rs1 %rd
52 @csr ............ ..... ... ..... ....... %csr %rs1 %rd
54 @atom_ld ..... aq:1 rl:1 ..... ........ ..... ....... &atomic rs2=0 %rs1 %rd
55 @atom_st ..... aq:1 rl:1 ..... ........ ..... ....... &atomic %rs2 %rs1 %rd
57 @r4_rm ..... .. ..... ..... ... ..... ....... %rs3 %rs2 %rs1 %rm %rd
58 @r_rm ....... ..... ..... ... ..... ....... %rs2 %rs1 %rm %rd
59 @r2_rm ....... ..... ..... ... ..... ....... %rs1 %rm %rd
60 @r2 ....... ..... ..... ... ..... ....... %rs1 %rd
62 @sfence_vma ....... ..... ..... ... ..... ....... %rs2 %rs1
63 @sfence_vm ....... ..... ..... ... ..... ....... %rs1
66 # *** Privileged Instructions ***
67 ecall 000000000000 00000 000 00000 1110011
68 ebreak 000000000001 00000 000 00000 1110011
69 uret 0000000 00010 00000 000 00000 1110011
70 sret 0001000 00010 00000 000 00000 1110011
71 hret 0010000 00010 00000 000 00000 1110011
72 mret 0011000 00010 00000 000 00000 1110011
73 wfi 0001000 00101 00000 000 00000 1110011
74 sfence_vma 0001001 ..... ..... 000 00000 1110011 @sfence_vma
75 sfence_vm 0001000 00100 ..... 000 00000 1110011 @sfence_vm
77 # *** RV32I Base Instruction Set ***
78 lui .................... ..... 0110111 @u
79 auipc .................... ..... 0010111 @u
80 jal .................... ..... 1101111 @j
81 jalr ............ ..... 000 ..... 1100111 @i
82 beq ....... ..... ..... 000 ..... 1100011 @b
83 bne ....... ..... ..... 001 ..... 1100011 @b
84 blt ....... ..... ..... 100 ..... 1100011 @b
85 bge ....... ..... ..... 101 ..... 1100011 @b
86 bltu ....... ..... ..... 110 ..... 1100011 @b
87 bgeu ....... ..... ..... 111 ..... 1100011 @b
88 lb ............ ..... 000 ..... 0000011 @i
89 lh ............ ..... 001 ..... 0000011 @i
90 lw ............ ..... 010 ..... 0000011 @i
91 lbu ............ ..... 100 ..... 0000011 @i
92 lhu ............ ..... 101 ..... 0000011 @i
93 sb ....... ..... ..... 000 ..... 0100011 @s
94 sh ....... ..... ..... 001 ..... 0100011 @s
95 sw ....... ..... ..... 010 ..... 0100011 @s
96 addi ............ ..... 000 ..... 0010011 @i
97 slti ............ ..... 010 ..... 0010011 @i
98 sltiu ............ ..... 011 ..... 0010011 @i
99 xori ............ ..... 100 ..... 0010011 @i
100 ori ............ ..... 110 ..... 0010011 @i
101 andi ............ ..... 111 ..... 0010011 @i
102 slli 00.... ...... ..... 001 ..... 0010011 @sh
103 srli 00.... ...... ..... 101 ..... 0010011 @sh
104 srai 01.... ...... ..... 101 ..... 0010011 @sh
105 add 0000000 ..... ..... 000 ..... 0110011 @r
106 sub 0100000 ..... ..... 000 ..... 0110011 @r
107 sll 0000000 ..... ..... 001 ..... 0110011 @r
108 slt 0000000 ..... ..... 010 ..... 0110011 @r
109 sltu 0000000 ..... ..... 011 ..... 0110011 @r
110 xor 0000000 ..... ..... 100 ..... 0110011 @r
111 srl 0000000 ..... ..... 101 ..... 0110011 @r
112 sra 0100000 ..... ..... 101 ..... 0110011 @r
113 or 0000000 ..... ..... 110 ..... 0110011 @r
114 and 0000000 ..... ..... 111 ..... 0110011 @r
115 fence ---- pred:4 succ:4 ----- 000 ----- 0001111
116 fence_i ---- ---- ---- ----- 001 ----- 0001111
117 csrrw ............ ..... 001 ..... 1110011 @csr
118 csrrs ............ ..... 010 ..... 1110011 @csr
119 csrrc ............ ..... 011 ..... 1110011 @csr
120 csrrwi ............ ..... 101 ..... 1110011 @csr
121 csrrsi ............ ..... 110 ..... 1110011 @csr
122 csrrci ............ ..... 111 ..... 1110011 @csr
124 # *** RV32M Standard Extension ***
125 mul 0000001 ..... ..... 000 ..... 0110011 @r
126 mulh 0000001 ..... ..... 001 ..... 0110011 @r
127 mulhsu 0000001 ..... ..... 010 ..... 0110011 @r
128 mulhu 0000001 ..... ..... 011 ..... 0110011 @r
129 div 0000001 ..... ..... 100 ..... 0110011 @r
130 divu 0000001 ..... ..... 101 ..... 0110011 @r
131 rem 0000001 ..... ..... 110 ..... 0110011 @r
132 remu 0000001 ..... ..... 111 ..... 0110011 @r
134 # *** RV32A Standard Extension ***
135 lr_w 00010 . . 00000 ..... 010 ..... 0101111 @atom_ld
136 sc_w 00011 . . ..... ..... 010 ..... 0101111 @atom_st
137 amoswap_w 00001 . . ..... ..... 010 ..... 0101111 @atom_st
138 amoadd_w 00000 . . ..... ..... 010 ..... 0101111 @atom_st
139 amoxor_w 00100 . . ..... ..... 010 ..... 0101111 @atom_st
140 amoand_w 01100 . . ..... ..... 010 ..... 0101111 @atom_st
141 amoor_w 01000 . . ..... ..... 010 ..... 0101111 @atom_st
142 amomin_w 10000 . . ..... ..... 010 ..... 0101111 @atom_st
143 amomax_w 10100 . . ..... ..... 010 ..... 0101111 @atom_st
144 amominu_w 11000 . . ..... ..... 010 ..... 0101111 @atom_st
145 amomaxu_w 11100 . . ..... ..... 010 ..... 0101111 @atom_st
147 # *** RV32F Standard Extension ***
148 flw ............ ..... 010 ..... 0000111 @i
149 fsw ....... ..... ..... 010 ..... 0100111 @s
150 fmadd_s ..... 00 ..... ..... ... ..... 1000011 @r4_rm
151 fmsub_s ..... 00 ..... ..... ... ..... 1000111 @r4_rm
152 fnmsub_s ..... 00 ..... ..... ... ..... 1001011 @r4_rm
153 fnmadd_s ..... 00 ..... ..... ... ..... 1001111 @r4_rm
154 fadd_s 0000000 ..... ..... ... ..... 1010011 @r_rm
155 fsub_s 0000100 ..... ..... ... ..... 1010011 @r_rm
156 fmul_s 0001000 ..... ..... ... ..... 1010011 @r_rm
157 fdiv_s 0001100 ..... ..... ... ..... 1010011 @r_rm
158 fsqrt_s 0101100 00000 ..... ... ..... 1010011 @r2_rm
159 fsgnj_s 0010000 ..... ..... 000 ..... 1010011 @r
160 fsgnjn_s 0010000 ..... ..... 001 ..... 1010011 @r
161 fsgnjx_s 0010000 ..... ..... 010 ..... 1010011 @r
162 fmin_s 0010100 ..... ..... 000 ..... 1010011 @r
163 fmax_s 0010100 ..... ..... 001 ..... 1010011 @r
164 fcvt_w_s 1100000 00000 ..... ... ..... 1010011 @r2_rm
165 fcvt_wu_s 1100000 00001 ..... ... ..... 1010011 @r2_rm
166 fmv_x_w 1110000 00000 ..... 000 ..... 1010011 @r2
167 feq_s 1010000 ..... ..... 010 ..... 1010011 @r
168 flt_s 1010000 ..... ..... 001 ..... 1010011 @r
169 fle_s 1010000 ..... ..... 000 ..... 1010011 @r
170 fclass_s 1110000 00000 ..... 001 ..... 1010011 @r2
171 fcvt_s_w 1101000 00000 ..... ... ..... 1010011 @r2_rm
172 fcvt_s_wu 1101000 00001 ..... ... ..... 1010011 @r2_rm
173 fmv_w_x 1111000 00000 ..... 000 ..... 1010011 @r2
175 # *** RV32D Standard Extension ***
176 fld ............ ..... 011 ..... 0000111 @i
177 fsd ....... ..... ..... 011 ..... 0100111 @s
178 fmadd_d ..... 01 ..... ..... ... ..... 1000011 @r4_rm
179 fmsub_d ..... 01 ..... ..... ... ..... 1000111 @r4_rm
180 fnmsub_d ..... 01 ..... ..... ... ..... 1001011 @r4_rm
181 fnmadd_d ..... 01 ..... ..... ... ..... 1001111 @r4_rm
182 fadd_d 0000001 ..... ..... ... ..... 1010011 @r_rm
183 fsub_d 0000101 ..... ..... ... ..... 1010011 @r_rm
184 fmul_d 0001001 ..... ..... ... ..... 1010011 @r_rm
185 fdiv_d 0001101 ..... ..... ... ..... 1010011 @r_rm
186 fsqrt_d 0101101 00000 ..... ... ..... 1010011 @r2_rm
187 fsgnj_d 0010001 ..... ..... 000 ..... 1010011 @r
188 fsgnjn_d 0010001 ..... ..... 001 ..... 1010011 @r
189 fsgnjx_d 0010001 ..... ..... 010 ..... 1010011 @r
190 fmin_d 0010101 ..... ..... 000 ..... 1010011 @r
191 fmax_d 0010101 ..... ..... 001 ..... 1010011 @r
192 fcvt_s_d 0100000 00001 ..... ... ..... 1010011 @r2_rm
193 fcvt_d_s 0100001 00000 ..... ... ..... 1010011 @r2_rm
194 feq_d 1010001 ..... ..... 010 ..... 1010011 @r
195 flt_d 1010001 ..... ..... 001 ..... 1010011 @r
196 fle_d 1010001 ..... ..... 000 ..... 1010011 @r
197 fclass_d 1110001 00000 ..... 001 ..... 1010011 @r2
198 fcvt_w_d 1100001 00000 ..... ... ..... 1010011 @r2_rm
199 fcvt_wu_d 1100001 00001 ..... ... ..... 1010011 @r2_rm
200 fcvt_d_w 1101001 00000 ..... ... ..... 1010011 @r2_rm
201 fcvt_d_wu 1101001 00001 ..... ... ..... 1010011 @r2_rm