13
13
#include <linux/filter.h>
14
14
#include <asm/cacheflush.h>
15
15
16
+ /* verify runtime detection extension status */
17
+ #define rv_ext_enabled (ext ) \
18
+ (IS_ENABLED(CONFIG_RISCV_ISA_##ext) && riscv_has_extension_likely(RISCV_ISA_EXT_##ext))
19
+
16
20
static inline bool rvc_enabled (void )
17
21
{
18
22
return IS_ENABLED (CONFIG_RISCV_ISA_C );
19
23
}
20
24
21
- static inline bool rvzba_enabled (void )
22
- {
23
- return IS_ENABLED (CONFIG_RISCV_ISA_ZBA ) && riscv_has_extension_likely (RISCV_ISA_EXT_ZBA );
24
- }
25
-
26
- static inline bool rvzbb_enabled (void )
27
- {
28
- return IS_ENABLED (CONFIG_RISCV_ISA_ZBB ) && riscv_has_extension_likely (RISCV_ISA_EXT_ZBB );
29
- }
30
-
31
25
enum {
32
26
RV_REG_ZERO = 0 , /* The constant value 0 */
33
27
RV_REG_RA = 1 , /* Return address */
@@ -1123,7 +1117,7 @@ static inline void emit_sw(u8 rs1, s32 off, u8 rs2, struct rv_jit_context *ctx)
1123
1117
1124
1118
static inline void emit_sh2add (u8 rd , u8 rs1 , u8 rs2 , struct rv_jit_context * ctx )
1125
1119
{
1126
- if (rvzba_enabled ( )) {
1120
+ if (rv_ext_enabled ( ZBA )) {
1127
1121
emit (rvzba_sh2add (rd , rs1 , rs2 ), ctx );
1128
1122
return ;
1129
1123
}
@@ -1134,7 +1128,7 @@ static inline void emit_sh2add(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx
1134
1128
1135
1129
static inline void emit_sh3add (u8 rd , u8 rs1 , u8 rs2 , struct rv_jit_context * ctx )
1136
1130
{
1137
- if (rvzba_enabled ( )) {
1131
+ if (rv_ext_enabled ( ZBA )) {
1138
1132
emit (rvzba_sh3add (rd , rs1 , rs2 ), ctx );
1139
1133
return ;
1140
1134
}
@@ -1184,7 +1178,7 @@ static inline void emit_subw(u8 rd, u8 rs1, u8 rs2, struct rv_jit_context *ctx)
1184
1178
1185
1179
static inline void emit_sextb (u8 rd , u8 rs , struct rv_jit_context * ctx )
1186
1180
{
1187
- if (rvzbb_enabled ( )) {
1181
+ if (rv_ext_enabled ( ZBB )) {
1188
1182
emit (rvzbb_sextb (rd , rs ), ctx );
1189
1183
return ;
1190
1184
}
@@ -1195,7 +1189,7 @@ static inline void emit_sextb(u8 rd, u8 rs, struct rv_jit_context *ctx)
1195
1189
1196
1190
static inline void emit_sexth (u8 rd , u8 rs , struct rv_jit_context * ctx )
1197
1191
{
1198
- if (rvzbb_enabled ( )) {
1192
+ if (rv_ext_enabled ( ZBB )) {
1199
1193
emit (rvzbb_sexth (rd , rs ), ctx );
1200
1194
return ;
1201
1195
}
@@ -1211,7 +1205,7 @@ static inline void emit_sextw(u8 rd, u8 rs, struct rv_jit_context *ctx)
1211
1205
1212
1206
static inline void emit_zexth (u8 rd , u8 rs , struct rv_jit_context * ctx )
1213
1207
{
1214
- if (rvzbb_enabled ( )) {
1208
+ if (rv_ext_enabled ( ZBB )) {
1215
1209
emit (rvzbb_zexth (rd , rs ), ctx );
1216
1210
return ;
1217
1211
}
@@ -1222,7 +1216,7 @@ static inline void emit_zexth(u8 rd, u8 rs, struct rv_jit_context *ctx)
1222
1216
1223
1217
static inline void emit_zextw (u8 rd , u8 rs , struct rv_jit_context * ctx )
1224
1218
{
1225
- if (rvzba_enabled ( )) {
1219
+ if (rv_ext_enabled ( ZBA )) {
1226
1220
emit (rvzba_zextw (rd , rs ), ctx );
1227
1221
return ;
1228
1222
}
@@ -1233,7 +1227,7 @@ static inline void emit_zextw(u8 rd, u8 rs, struct rv_jit_context *ctx)
1233
1227
1234
1228
static inline void emit_bswap (u8 rd , s32 imm , struct rv_jit_context * ctx )
1235
1229
{
1236
- if (rvzbb_enabled ( )) {
1230
+ if (rv_ext_enabled ( ZBB )) {
1237
1231
int bits = 64 - imm ;
1238
1232
1239
1233
emit (rvzbb_rev8 (rd , rd ), ctx );
0 commit comments