From be34e0221d12fbe55d59739cd86c628f45ffdf65 Mon Sep 17 00:00:00 2001 From: Yang Liu Date: Tue, 12 Sep 2023 07:46:13 +0000 Subject: [PATCH 1/3] [DYNAREC_RV64] Added support for xtheadba --- src/dynarec/rv64/dynarec_rv64_0f.c | 44 +++++++++++++++++++------- src/dynarec/rv64/dynarec_rv64_helper.c | 10 ++++++ 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/src/dynarec/rv64/dynarec_rv64_0f.c b/src/dynarec/rv64/dynarec_rv64_0f.c index 9e225bd21..22062ce85 100644 --- a/src/dynarec/rv64/dynarec_rv64_0f.c +++ b/src/dynarec/rv64/dynarec_rv64_0f.c @@ -418,7 +418,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SRLI(x3, gd, 8); SLLI(x4, x2, 16); AND(x3, x3, x4); - OR(x1, x1, x3); + OR(x1, x1, x3); SLLI(x3, gd, 8); SLLI(x4, x2, 24); AND(x3, x3, x4); @@ -436,7 +436,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni LUI(x2, 0xff0); AND(gd, gd, x2); OR(gd, gd, x1); - } + } } break; case 0xF1: @@ -477,7 +477,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SRLI(x3, gd, 8); SLLI(x4, x2, 16); AND(x3, x3, x4); - OR(x1, x1, x3); + OR(x1, x1, x3); SLLI(x3, gd, 8); SLLI(x4, x2, 24); AND(x3, x3, x4); @@ -1097,8 +1097,14 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x3, x1, &fixedaddress, rex, NULL, 1, 0); SRAIxw(x1, gd, 5+rex.w); // r1 = (gd>>5) - SLLI(x1, x1, 2+rex.w); - ADD(x3, wback, x1); //(&ed)+=r1*4; + if (rv64_zba) { + SHxADD(x3, x1, 2+rex.w, wback); + } else if (rv64_xtheadba) { + TH_ADDSL(x3, wback, x1, 2+rex.w); + } else { + SLLI(x1, x1, 2+rex.w); + ADD(x3, wback, x1); + } LDxw(x1, x3, fixedaddress); ed = x1; } @@ -1131,8 +1137,14 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x3, x1, &fixedaddress, rex, NULL, 1, 0); SRAI(x1, gd, 5+rex.w); - SLLI(x1, x1, 2+rex.w); - ADD(x3, wback, x1); + if (rv64_zba) { + SHxADD(x3, x1, 2+rex.w, wback); + } else if (rv64_xtheadba) { + TH_ADDSL(x3, wback, x1, 2+rex.w); + } else { + SLLI(x1, x1, 2+rex.w); + ADD(x3, wback, x1); + } LDxw(x1, x3, fixedaddress); ed = x1; wback = x3; @@ -1279,8 +1291,14 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x2, x1, &fixedaddress, rex, NULL, 1, 0); SRAI(x1, gd, 5+rex.w); - SLLI(x1, x1, 2+rex.w); - ADD(x3, wback, x1); + if (rv64_zba) { + SHxADD(x3, x1, 2+rex.w, wback); + } else if (rv64_xtheadba) { + TH_ADDSL(x3, wback, x1, 2+rex.w); + } else { + SLLI(x1, x1, 2+rex.w); + ADD(x3, wback, x1); + } LDxw(x1, x3, fixedaddress); ed = x1; wback = x3; @@ -1449,8 +1467,12 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x3, x1, &fixedaddress, rex, NULL, 1, 0); SRAI(x1, gd, 5+rex.w); - SLLI(x1, x1, 2+rex.w); - ADD(x3, wback, x1); + if (rv64_xtheadba) { + TH_ADDSL(x3, wback, x1, 2+rex.w); + } else { + SLLI(x1, x1, 2+rex.w); + ADD(x3, wback, x1); + } LDxw(x1, x3, fixedaddress); ed = x1; wback = x3; diff --git a/src/dynarec/rv64/dynarec_rv64_helper.c b/src/dynarec/rv64/dynarec_rv64_helper.c index a005c3b9e..f42ea2a19 100644 --- a/src/dynarec/rv64/dynarec_rv64_helper.c +++ b/src/dynarec/rv64/dynarec_rv64_helper.c @@ -59,6 +59,8 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if((sib>>6)) { if(rv64_zba) { SHxADD(ret, xRAX+sib_reg, sib>>6, scratch); + } else if (rv64_xtheadba) { + TH_ADDSL(ret, scratch, xRAX+sib_reg, sib>>6); } else { SLLI(ret, xRAX+sib_reg, (sib>>6)); ADD(ret, ret, scratch); @@ -85,6 +87,8 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if(sib>>6) { if(rv64_zba) { SHxADD(ret, xRAX+sib_reg, sib>>6, xRAX+sib_reg2); + } else if (rv64_xtheadba) { + TH_ADDSL(ret, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); } else { SLLI(scratch, xRAX+sib_reg, (sib>>6)); ADD(ret, xRAX+sib_reg2, scratch); @@ -149,6 +153,8 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if(sib>>6) { if(rv64_zba) { SHxADD(ret, xRAX+sib_reg, sib>>6, xRAX+sib_reg2); + } else if (rv64_xtheadba) { + TH_ADDSL(ret, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); } else { SLLI(scratch, xRAX+sib_reg, (sib>>6)); ADD(ret, xRAX+sib_reg2, scratch); @@ -168,6 +174,8 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if(sib>>6) { if(rv64_zba) { SHxADD(scratch, xRAX+sib_reg, sib>>6, xRAX+sib_reg2); + } else if (rv64_xtheadba) { + TH_ADDSL(scratch, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); } else { SLLI(scratch, xRAX+sib_reg, (sib>>6)); ADD(scratch, xRAX+sib_reg2, scratch); @@ -189,6 +197,8 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if(sib>>6) { if(rv64_zba) { SHxADD(ret, xRAX+sib_reg, sib>>6, scratch); + } else if (rv64_xtheadba) { + TH_ADDSL(ret, scratch, xRAX+sib_reg, sib>>6); } else { SLLI(ret, xRAX+sib_reg, (sib>>6)); ADD(ret, scratch, ret); From 75958f1f315f15206618185240bab8080c8bfd0f Mon Sep 17 00:00:00 2001 From: Yang Liu Date: Tue, 12 Sep 2023 08:27:23 +0000 Subject: [PATCH 2/3] Use macro --- src/dynarec/rv64/dynarec_rv64_0f.c | 34 +++---------------- src/dynarec/rv64/dynarec_rv64_helper.c | 45 +++----------------------- src/dynarec/rv64/rv64_emitter.h | 10 ++++++ 3 files changed, 19 insertions(+), 70 deletions(-) diff --git a/src/dynarec/rv64/dynarec_rv64_0f.c b/src/dynarec/rv64/dynarec_rv64_0f.c index 22062ce85..b0f4a3c41 100644 --- a/src/dynarec/rv64/dynarec_rv64_0f.c +++ b/src/dynarec/rv64/dynarec_rv64_0f.c @@ -1097,14 +1097,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x3, x1, &fixedaddress, rex, NULL, 1, 0); SRAIxw(x1, gd, 5+rex.w); // r1 = (gd>>5) - if (rv64_zba) { - SHxADD(x3, x1, 2+rex.w, wback); - } else if (rv64_xtheadba) { - TH_ADDSL(x3, wback, x1, 2+rex.w); - } else { - SLLI(x1, x1, 2+rex.w); - ADD(x3, wback, x1); - } + ADDSL(x3, wback, x1, 2+rex.w); LDxw(x1, x3, fixedaddress); ed = x1; } @@ -1137,14 +1130,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x3, x1, &fixedaddress, rex, NULL, 1, 0); SRAI(x1, gd, 5+rex.w); - if (rv64_zba) { - SHxADD(x3, x1, 2+rex.w, wback); - } else if (rv64_xtheadba) { - TH_ADDSL(x3, wback, x1, 2+rex.w); - } else { - SLLI(x1, x1, 2+rex.w); - ADD(x3, wback, x1); - } + ADDSL(x3, wback, x1, 2+rex.w); LDxw(x1, x3, fixedaddress); ed = x1; wback = x3; @@ -1291,14 +1277,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x2, x1, &fixedaddress, rex, NULL, 1, 0); SRAI(x1, gd, 5+rex.w); - if (rv64_zba) { - SHxADD(x3, x1, 2+rex.w, wback); - } else if (rv64_xtheadba) { - TH_ADDSL(x3, wback, x1, 2+rex.w); - } else { - SLLI(x1, x1, 2+rex.w); - ADD(x3, wback, x1); - } + ADDSL(x3, wback, x1, 2+rex.w); LDxw(x1, x3, fixedaddress); ed = x1; wback = x3; @@ -1467,12 +1446,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x3, x1, &fixedaddress, rex, NULL, 1, 0); SRAI(x1, gd, 5+rex.w); - if (rv64_xtheadba) { - TH_ADDSL(x3, wback, x1, 2+rex.w); - } else { - SLLI(x1, x1, 2+rex.w); - ADD(x3, wback, x1); - } + ADDSL(x3, wback, x1, 2+rex.w); LDxw(x1, x3, fixedaddress); ed = x1; wback = x3; diff --git a/src/dynarec/rv64/dynarec_rv64_helper.c b/src/dynarec/rv64/dynarec_rv64_helper.c index f42ea2a19..bb9d518e5 100644 --- a/src/dynarec/rv64/dynarec_rv64_helper.c +++ b/src/dynarec/rv64/dynarec_rv64_helper.c @@ -57,14 +57,7 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if(tmp && ((tmp<-2048) || (tmp>maxval) || !i12)) { MOV64x(scratch, tmp); if((sib>>6)) { - if(rv64_zba) { - SHxADD(ret, xRAX+sib_reg, sib>>6, scratch); - } else if (rv64_xtheadba) { - TH_ADDSL(ret, scratch, xRAX+sib_reg, sib>>6); - } else { - SLLI(ret, xRAX+sib_reg, (sib>>6)); - ADD(ret, ret, scratch); - } + ADDSL(ret, scratch, xRAX+sib_reg, sib>>6); } else { ADD(ret, xRAX+sib_reg, scratch); } @@ -85,14 +78,7 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, } else { if (sib_reg!=4) { if(sib>>6) { - if(rv64_zba) { - SHxADD(ret, xRAX+sib_reg, sib>>6, xRAX+sib_reg2); - } else if (rv64_xtheadba) { - TH_ADDSL(ret, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); - } else { - SLLI(scratch, xRAX+sib_reg, (sib>>6)); - ADD(ret, xRAX+sib_reg2, scratch); - } + ADDSL(ret, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); } else { ADD(ret, xRAX+sib_reg2, xRAX+sib_reg); } @@ -151,14 +137,7 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if((nextop&7)==4) { if (sib_reg!=4) { if(sib>>6) { - if(rv64_zba) { - SHxADD(ret, xRAX+sib_reg, sib>>6, xRAX+sib_reg2); - } else if (rv64_xtheadba) { - TH_ADDSL(ret, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); - } else { - SLLI(scratch, xRAX+sib_reg, (sib>>6)); - ADD(ret, xRAX+sib_reg2, scratch); - } + ADDSL(ret, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); } else { ADD(ret, xRAX+sib_reg2, xRAX+sib_reg); } @@ -172,14 +151,7 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if((nextop&7)==4) { if (sib_reg!=4) { if(sib>>6) { - if(rv64_zba) { - SHxADD(scratch, xRAX+sib_reg, sib>>6, xRAX+sib_reg2); - } else if (rv64_xtheadba) { - TH_ADDSL(scratch, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); - } else { - SLLI(scratch, xRAX+sib_reg, (sib>>6)); - ADD(scratch, xRAX+sib_reg2, scratch); - } + ADDSL(scratch, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); } else { ADD(scratch, xRAX+sib_reg2, xRAX+sib_reg); } @@ -195,14 +167,7 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if (sib_reg!=4) { ADD(scratch, scratch, xRAX+sib_reg2); if(sib>>6) { - if(rv64_zba) { - SHxADD(ret, xRAX+sib_reg, sib>>6, scratch); - } else if (rv64_xtheadba) { - TH_ADDSL(ret, scratch, xRAX+sib_reg, sib>>6); - } else { - SLLI(ret, xRAX+sib_reg, (sib>>6)); - ADD(ret, scratch, ret); - } + ADDSL(ret, scratch, xRAX+sib_reg, sib>>6); } else { ADD(ret, scratch, xRAX+sib_reg); } diff --git a/src/dynarec/rv64/rv64_emitter.h b/src/dynarec/rv64/rv64_emitter.h index 6457ad592..2719a9008 100644 --- a/src/dynarec/rv64/rv64_emitter.h +++ b/src/dynarec/rv64/rv64_emitter.h @@ -310,6 +310,16 @@ f28–31 ft8–11 FP temporaries Caller // rd = rs1 + imm12 #define ADDIz(rd, rs1, imm12) EMIT(I_type((imm12)&0b111111111111, rs1, 0b000, rd, rex.is32bits?0b0011011:0b0010011)) +// rd = rs1 + (rs2 << imm2), rs2 might be used as scratch. +#define ADDSL(rd, rs1, rs2, imm2) if (rv64_zba) { \ + SHxADD(rd, rs2, imm2, rs1); \ + } else if (rv64_xtheadba) { \ + TH_ADDSL(rd, rs1, rs2, imm2); \ + } else { \ + SLLI(rs2, rs2, imm2); \ + ADD(rd, rs1, rs2); \ + } \ + #define SEXT_W(rd, rs1) ADDIW(rd, rs1, 0) // rd = rs1< Date: Tue, 12 Sep 2023 08:54:18 +0000 Subject: [PATCH 3/3] Fixed CI and simplified --- src/dynarec/rv64/dynarec_rv64_0f.c | 8 +++---- src/dynarec/rv64/dynarec_rv64_helper.c | 30 +++++--------------------- src/dynarec/rv64/rv64_emitter.h | 20 +++++++++-------- 3 files changed, 20 insertions(+), 38 deletions(-) diff --git a/src/dynarec/rv64/dynarec_rv64_0f.c b/src/dynarec/rv64/dynarec_rv64_0f.c index b0f4a3c41..8e85cc8e4 100644 --- a/src/dynarec/rv64/dynarec_rv64_0f.c +++ b/src/dynarec/rv64/dynarec_rv64_0f.c @@ -1097,7 +1097,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x3, x1, &fixedaddress, rex, NULL, 1, 0); SRAIxw(x1, gd, 5+rex.w); // r1 = (gd>>5) - ADDSL(x3, wback, x1, 2+rex.w); + ADDSL(x3, wback, x1, 2+rex.w, x1); LDxw(x1, x3, fixedaddress); ed = x1; } @@ -1130,7 +1130,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x3, x1, &fixedaddress, rex, NULL, 1, 0); SRAI(x1, gd, 5+rex.w); - ADDSL(x3, wback, x1, 2+rex.w); + ADDSL(x3, wback, x1, 2+rex.w, x1); LDxw(x1, x3, fixedaddress); ed = x1; wback = x3; @@ -1277,7 +1277,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x2, x1, &fixedaddress, rex, NULL, 1, 0); SRAI(x1, gd, 5+rex.w); - ADDSL(x3, wback, x1, 2+rex.w); + ADDSL(x3, wback, x1, 2+rex.w, x1); LDxw(x1, x3, fixedaddress); ed = x1; wback = x3; @@ -1446,7 +1446,7 @@ uintptr_t dynarec64_0F(dynarec_rv64_t* dyn, uintptr_t addr, uintptr_t ip, int ni SMREAD(); addr = geted(dyn, addr, ninst, nextop, &wback, x3, x1, &fixedaddress, rex, NULL, 1, 0); SRAI(x1, gd, 5+rex.w); - ADDSL(x3, wback, x1, 2+rex.w); + ADDSL(x3, wback, x1, 2+rex.w, x1); LDxw(x1, x3, fixedaddress); ed = x1; wback = x3; diff --git a/src/dynarec/rv64/dynarec_rv64_helper.c b/src/dynarec/rv64/dynarec_rv64_helper.c index bb9d518e5..1b89b08b0 100644 --- a/src/dynarec/rv64/dynarec_rv64_helper.c +++ b/src/dynarec/rv64/dynarec_rv64_helper.c @@ -56,11 +56,7 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if (sib_reg!=4) { if(tmp && ((tmp<-2048) || (tmp>maxval) || !i12)) { MOV64x(scratch, tmp); - if((sib>>6)) { - ADDSL(ret, scratch, xRAX+sib_reg, sib>>6); - } else { - ADD(ret, xRAX+sib_reg, scratch); - } + ADDSL(ret, scratch, xRAX+sib_reg, sib>>6, ret); } else { if(sib>>6) { SLLI(ret, xRAX+sib_reg, (sib>>6)); @@ -77,11 +73,7 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, } } else { if (sib_reg!=4) { - if(sib>>6) { - ADDSL(ret, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); - } else { - ADD(ret, xRAX+sib_reg2, xRAX+sib_reg); - } + ADDSL(ret, xRAX+sib_reg2, xRAX+sib_reg, sib>>6, scratch); } else { ret = xRAX+sib_reg2; } @@ -136,11 +128,7 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, *fixaddress = i64; if((nextop&7)==4) { if (sib_reg!=4) { - if(sib>>6) { - ADDSL(ret, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); - } else { - ADD(ret, xRAX+sib_reg2, xRAX+sib_reg); - } + ADDSL(ret, xRAX+sib_reg2, xRAX+sib_reg, sib>>6, scratch); } else { ret = xRAX+sib_reg2; } @@ -150,11 +138,7 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if(i64>=-2048 && i64<=2047) { if((nextop&7)==4) { if (sib_reg!=4) { - if(sib>>6) { - ADDSL(scratch, xRAX+sib_reg2, xRAX+sib_reg, sib>>6); - } else { - ADD(scratch, xRAX+sib_reg2, xRAX+sib_reg); - } + ADDSL(scratch, xRAX+sib_reg2, xRAX+sib_reg, sib>>6, scratch); } else { scratch = xRAX+sib_reg2; } @@ -166,11 +150,7 @@ uintptr_t geted(dynarec_rv64_t* dyn, uintptr_t addr, int ninst, uint8_t nextop, if((nextop&7)==4) { if (sib_reg!=4) { ADD(scratch, scratch, xRAX+sib_reg2); - if(sib>>6) { - ADDSL(ret, scratch, xRAX+sib_reg, sib>>6); - } else { - ADD(ret, scratch, xRAX+sib_reg); - } + ADDSL(ret, scratch, xRAX+sib_reg, sib>>6, ret); } else { PASS3(int tmp = xRAX+sib_reg2); ADD(ret, tmp, scratch); diff --git a/src/dynarec/rv64/rv64_emitter.h b/src/dynarec/rv64/rv64_emitter.h index 2719a9008..23f4f73df 100644 --- a/src/dynarec/rv64/rv64_emitter.h +++ b/src/dynarec/rv64/rv64_emitter.h @@ -310,15 +310,17 @@ f28–31 ft8–11 FP temporaries Caller // rd = rs1 + imm12 #define ADDIz(rd, rs1, imm12) EMIT(I_type((imm12)&0b111111111111, rs1, 0b000, rd, rex.is32bits?0b0011011:0b0010011)) -// rd = rs1 + (rs2 << imm2), rs2 might be used as scratch. -#define ADDSL(rd, rs1, rs2, imm2) if (rv64_zba) { \ - SHxADD(rd, rs2, imm2, rs1); \ - } else if (rv64_xtheadba) { \ - TH_ADDSL(rd, rs1, rs2, imm2); \ - } else { \ - SLLI(rs2, rs2, imm2); \ - ADD(rd, rs1, rs2); \ - } \ +// rd = rs1 + (rs2 << imm2) +#define ADDSL(rd, rs1, rs2, imm2, scratch) if (!imm2) { \ + ADD(rd, rs1, rs2); \ + } else if (rv64_zba) { \ + SHxADD(rd, rs2, imm2, rs1); \ + } else if (rv64_xtheadba) { \ + TH_ADDSL(rd, rs1, rs2, imm2); \ + } else { \ + SLLI(scratch, rs2, imm2); \ + ADD(rd, rs1, scratch); \ + } \ #define SEXT_W(rd, rs1) ADDIW(rd, rs1, 0)