From 4e816c5ed8e0a1b0ccb89a78ea020bb147096a5f Mon Sep 17 00:00:00 2001 From: 4vtomat Date: Sat, 9 Apr 2022 03:04:04 -0700 Subject: Replaced vector loop compare body with newly defined macro This commit uses new macro to replace loop compare body to enhance code reuse. --- riscv/decode.h | 101 +++++++-------------------------------------------------- 1 file changed, 11 insertions(+), 90 deletions(-) (limited to 'riscv/decode.h') diff --git a/riscv/decode.h b/riscv/decode.h index 7dd86e3..e0d70bf 100644 --- a/riscv/decode.h +++ b/riscv/decode.h @@ -896,113 +896,34 @@ static inline bool is_aligned(const unsigned val, const unsigned pos) } // comparision result to masking register -#define VI_VV_LOOP_CMP(BODY) \ - VI_CHECK_MSS(true); \ +#define VI_LOOP_CMP_BODY(PARAMS, BODY) \ VI_LOOP_CMP_BASE \ - if (sew == e8){ \ - VV_CMP_PARAMS(e8); \ - BODY; \ - }else if(sew == e16){ \ - VV_CMP_PARAMS(e16); \ - BODY; \ - }else if(sew == e32){ \ - VV_CMP_PARAMS(e32); \ - BODY; \ - }else if(sew == e64){ \ - VV_CMP_PARAMS(e64); \ - BODY; \ - } \ + INSNS_BASE(PARAMS, BODY) \ VI_LOOP_CMP_END +#define VI_VV_LOOP_CMP(BODY) \ + VI_CHECK_MSS(true); \ + VI_LOOP_CMP_BODY(VV_CMP_PARAMS, BODY) + #define VI_VX_LOOP_CMP(BODY) \ VI_CHECK_MSS(false); \ - VI_LOOP_CMP_BASE \ - if (sew == e8){ \ - VX_CMP_PARAMS(e8); \ - BODY; \ - }else if(sew == e16){ \ - VX_CMP_PARAMS(e16); \ - BODY; \ - }else if(sew == e32){ \ - VX_CMP_PARAMS(e32); \ - BODY; \ - }else if(sew == e64){ \ - VX_CMP_PARAMS(e64); \ - BODY; \ - } \ - VI_LOOP_CMP_END + VI_LOOP_CMP_BODY(VX_CMP_PARAMS, BODY) #define VI_VI_LOOP_CMP(BODY) \ VI_CHECK_MSS(false); \ - VI_LOOP_CMP_BASE \ - if (sew == e8){ \ - VI_CMP_PARAMS(e8); \ - BODY; \ - }else if(sew == e16){ \ - VI_CMP_PARAMS(e16); \ - BODY; \ - }else if(sew == e32){ \ - VI_CMP_PARAMS(e32); \ - BODY; \ - }else if(sew == e64){ \ - VI_CMP_PARAMS(e64); \ - BODY; \ - } \ - VI_LOOP_CMP_END + VI_LOOP_CMP_BODY(VI_CMP_PARAMS, BODY) #define VI_VV_ULOOP_CMP(BODY) \ VI_CHECK_MSS(true); \ - VI_LOOP_CMP_BASE \ - if (sew == e8){ \ - VV_UCMP_PARAMS(e8); \ - BODY; \ - }else if(sew == e16){ \ - VV_UCMP_PARAMS(e16); \ - BODY; \ - }else if(sew == e32){ \ - VV_UCMP_PARAMS(e32); \ - BODY; \ - }else if(sew == e64){ \ - VV_UCMP_PARAMS(e64); \ - BODY; \ - } \ - VI_LOOP_CMP_END + VI_LOOP_CMP_BODY(VV_UCMP_PARAMS, BODY) #define VI_VX_ULOOP_CMP(BODY) \ VI_CHECK_MSS(false); \ - VI_LOOP_CMP_BASE \ - if (sew == e8){ \ - VX_UCMP_PARAMS(e8); \ - BODY; \ - }else if(sew == e16){ \ - VX_UCMP_PARAMS(e16); \ - BODY; \ - }else if(sew == e32){ \ - VX_UCMP_PARAMS(e32); \ - BODY; \ - }else if(sew == e64){ \ - VX_UCMP_PARAMS(e64); \ - BODY; \ - } \ - VI_LOOP_CMP_END + VI_LOOP_CMP_BODY(VX_UCMP_PARAMS, BODY) #define VI_VI_ULOOP_CMP(BODY) \ VI_CHECK_MSS(false); \ - VI_LOOP_CMP_BASE \ - if (sew == e8){ \ - VI_UCMP_PARAMS(e8); \ - BODY; \ - }else if(sew == e16){ \ - VI_UCMP_PARAMS(e16); \ - BODY; \ - }else if(sew == e32){ \ - VI_UCMP_PARAMS(e32); \ - BODY; \ - }else if(sew == e64){ \ - VI_UCMP_PARAMS(e64); \ - BODY; \ - } \ - VI_LOOP_CMP_END + VI_LOOP_CMP_BODY(VI_UCMP_PARAMS, BODY) // merge and copy loop #define VI_MERGE_VARS \ -- cgit v1.1