From 19e3ddcc323b809a8b71f9fb0998320e2ba95005 Mon Sep 17 00:00:00 2001 From: Ved Shanbhogue <91900059+ved-rivos@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:32:19 -0500 Subject: [PATCH] Add pseudo-instructions for Zimop/Zcmop (#194) * add mop.r.N and mop.rr.N pseudo-inst * add c.mop.N pseudo-inst * add arg_lut entries and emitted pseudoops for Zimop/Zcmop * add pseudoinsts for Zimop * add pseudoinsts for Zcmop * update zcmop mnemonics * update zcmop mnemonics --- constants.py | 57 ++++++++++++++++++++++++++++++ unratified/rv_zcmop | 24 +++++++------ unratified/rv_zimop | 84 ++++++++++++++++++++++++--------------------- 3 files changed, 114 insertions(+), 51 deletions(-) diff --git a/constants.py b/constants.py index 9ff08c05..1298aa7b 100644 --- a/constants.py +++ b/constants.py @@ -47,6 +47,14 @@ v = (int(row[1]), int(row[2])) arg_lut[k] = v +# for mop +arg_lut['mop_r_t_30'] = (30,30) +arg_lut['mop_r_t_27_26'] = (27,26) +arg_lut['mop_r_t_21_20'] = (21, 20) +arg_lut['mop_rr_t_30'] = (30,30) +arg_lut['mop_rr_t_27_26'] = (27, 26) +arg_lut['c_mop_t'] = (10,8) + # dictionary containing the mapping of the argument to the what the fields in # the latex table should be latex_mapping = {} @@ -156,4 +164,53 @@ 'srli_rv128', 'srli_rv32', 'umax32', + 'c_mop_1', + 'c_mop_3', + 'c_mop_5', + 'c_mop_7', + 'c_mop_9', + 'c_mop_11', + 'c_mop_13', + 'c_mop_15', + 'mop_r_0', + 'mop_r_1', + 'mop_r_2', + 'mop_r_3', + 'mop_r_4', + 'mop_r_5', + 'mop_r_6', + 'mop_r_7', + 'mop_r_8', + 'mop_r_9', + 'mop_r_10', + 'mop_r_11', + 'mop_r_12', + 'mop_r_13', + 'mop_r_14', + 'mop_r_15', + 'mop_r_16', + 'mop_r_17', + 'mop_r_18', + 'mop_r_19', + 'mop_r_20', + 'mop_r_21', + 'mop_r_22', + 'mop_r_23', + 'mop_r_24', + 'mop_r_25', + 'mop_r_26', + 'mop_r_27', + 'mop_r_28', + 'mop_r_29', + 'mop_r_30', + 'mop_r_31', + 'mop_r_32', + 'mop_rr_0', + 'mop_rr_1', + 'mop_rr_2', + 'mop_rr_3', + 'mop_rr_4', + 'mop_rr_5', + 'mop_rr_6', + 'mop_rr_7', ] diff --git a/unratified/rv_zcmop b/unratified/rv_zcmop index f58b7dfc..742a3d81 100644 --- a/unratified/rv_zcmop +++ b/unratified/rv_zcmop @@ -1,13 +1,15 @@ # Eight code points in the 16-bit encoding space -# are provided for MOPs; encoded in the reserved -# encoding space where c.lui N, 0 is encoded i.e -# Where N is determined for c.mop.M as M*2+1 +# are provided for MOPs; c.mop.N is encoded in +# the reserved encoding space where c.lui N, 0 is +# encoded. N ={1, 3, 5, 7, 9, 11, 13, and 15} +# Add a pseudo-inst c.mop.N that matches c.mop.* -c.mop.0 1..0=1 6..2=0 11..7=1 12=0 15..13=3 -c.mop.1 1..0=1 6..2=0 11..7=3 12=0 15..13=3 -c.mop.2 1..0=1 6..2=0 11..7=5 12=0 15..13=3 -c.mop.3 1..0=1 6..2=0 11..7=7 12=0 15..13=3 -c.mop.4 1..0=1 6..2=0 11..7=9 12=0 15..13=3 -c.mop.5 1..0=1 6..2=0 11..7=11 12=0 15..13=3 -c.mop.6 1..0=1 6..2=0 11..7=13 12=0 15..13=3 -c.mop.7 1..0=1 6..2=0 11..7=15 12=0 15..13=3 +c.mop.N c_mop_t 1..0=1 6..2=0 11=0 7=1 12=0 15..13=3 +$pseudo_op rv_zcmop::c.mop.N c.mop.1 1..0=1 6..2=0 11..7=1 12=0 15..13=3 +$pseudo_op rv_zcmop::c.mop.N c.mop.3 1..0=1 6..2=0 11..7=3 12=0 15..13=3 +$pseudo_op rv_zcmop::c.mop.N c.mop.5 1..0=1 6..2=0 11..7=5 12=0 15..13=3 +$pseudo_op rv_zcmop::c.mop.N c.mop.7 1..0=1 6..2=0 11..7=7 12=0 15..13=3 +$pseudo_op rv_zcmop::c.mop.N c.mop.9 1..0=1 6..2=0 11..7=9 12=0 15..13=3 +$pseudo_op rv_zcmop::c.mop.N c.mop.11 1..0=1 6..2=0 11..7=11 12=0 15..13=3 +$pseudo_op rv_zcmop::c.mop.N c.mop.13 1..0=1 6..2=0 11..7=13 12=0 15..13=3 +$pseudo_op rv_zcmop::c.mop.N c.mop.15 1..0=1 6..2=0 11..7=15 12=0 15..13=3 diff --git a/unratified/rv_zimop b/unratified/rv_zimop index 30e0fd78..c1dcea04 100644 --- a/unratified/rv_zimop +++ b/unratified/rv_zimop @@ -1,49 +1,53 @@ # The Zimop extension defines 32 MOP instructions named mop.r.0 -- mop.r.31. # They are encoded as 1-00--0111--sssss100ddddd1110011, where - denotes an # available opcode bit, s denotes the rs1 field, and d denotes the rd field. +# add a pseudo-inst mop.r.N that matches mop.r.* -mop.r.0 rd rs1 30=0 27=0 26=0 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.1 rd rs1 30=0 27=0 26=0 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.2 rd rs1 30=0 27=0 26=0 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.3 rd rs1 30=0 27=0 26=0 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.4 rd rs1 30=0 27=0 26=1 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.5 rd rs1 30=0 27=0 26=1 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.6 rd rs1 30=0 27=0 26=1 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.7 rd rs1 30=0 27=0 26=1 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.8 rd rs1 30=0 27=1 26=0 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.9 rd rs1 30=0 27=1 26=0 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.10 rd rs1 30=0 27=1 26=0 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.11 rd rs1 30=0 27=1 26=0 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.12 rd rs1 30=0 27=1 26=1 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.13 rd rs1 30=0 27=1 26=1 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.14 rd rs1 30=0 27=1 26=1 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.15 rd rs1 30=0 27=1 26=1 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.16 rd rs1 30=1 27=0 26=0 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.17 rd rs1 30=1 27=0 26=0 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.18 rd rs1 30=1 27=0 26=0 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.19 rd rs1 30=1 27=0 26=0 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.20 rd rs1 30=1 27=0 26=1 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.21 rd rs1 30=1 27=0 26=1 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.22 rd rs1 30=1 27=0 26=1 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.23 rd rs1 30=1 27=0 26=1 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.24 rd rs1 30=1 27=1 26=0 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.25 rd rs1 30=1 27=1 26=0 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.26 rd rs1 30=1 27=1 26=0 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.27 rd rs1 30=1 27=1 26=0 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.28 rd rs1 30=1 27=1 26=1 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.29 rd rs1 30=1 27=1 26=1 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.30 rd rs1 30=1 27=1 26=1 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 -mop.r.31 rd rs1 30=1 27=1 26=1 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +mop.r.N mop_r_t_30 mop_r_t_27_26 mop_r_t_21_20 rd rs1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.0 rd rs1 30=0 27=0 26=0 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.1 rd rs1 30=0 27=0 26=0 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.2 rd rs1 30=0 27=0 26=0 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.3 rd rs1 30=0 27=0 26=0 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.4 rd rs1 30=0 27=0 26=1 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.5 rd rs1 30=0 27=0 26=1 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.6 rd rs1 30=0 27=0 26=1 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.7 rd rs1 30=0 27=0 26=1 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.8 rd rs1 30=0 27=1 26=0 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.9 rd rs1 30=0 27=1 26=0 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.10 rd rs1 30=0 27=1 26=0 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.11 rd rs1 30=0 27=1 26=0 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.12 rd rs1 30=0 27=1 26=1 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.13 rd rs1 30=0 27=1 26=1 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.14 rd rs1 30=0 27=1 26=1 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.15 rd rs1 30=0 27=1 26=1 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.16 rd rs1 30=1 27=0 26=0 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.17 rd rs1 30=1 27=0 26=0 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.18 rd rs1 30=1 27=0 26=0 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.19 rd rs1 30=1 27=0 26=0 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.20 rd rs1 30=1 27=0 26=1 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.21 rd rs1 30=1 27=0 26=1 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.22 rd rs1 30=1 27=0 26=1 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.23 rd rs1 30=1 27=0 26=1 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.24 rd rs1 30=1 27=1 26=0 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.25 rd rs1 30=1 27=1 26=0 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.26 rd rs1 30=1 27=1 26=0 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.27 rd rs1 30=1 27=1 26=0 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.28 rd rs1 30=1 27=1 26=1 21=0 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.29 rd rs1 30=1 27=1 26=1 21=0 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.30 rd rs1 30=1 27=1 26=1 21=1 20=0 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.r.N mop.r.31 rd rs1 30=1 27=1 26=1 21=1 20=1 31=1 29..28=0 25..22=7 14..12=4 6..2=0x1C 1..0=3 # The Zimop extension additionally defines 8 MOP instructions named mop.rr.0 # -- mop.rr.7. They are encoded as 1-00--1tttttsssss100ddddd1110011, where t # denotes the rs2 field. +# add a pseudo-inst mop.rr.N taht matches mop.rr.* -mop.rr.0 rd rs1 rs2 30=0 27=0 26=0 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 -mop.rr.1 rd rs1 rs2 30=0 27=0 26=1 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 -mop.rr.2 rd rs1 rs2 30=0 27=1 26=0 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 -mop.rr.3 rd rs1 rs2 30=0 27=1 26=1 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 -mop.rr.4 rd rs1 rs2 30=1 27=0 26=0 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 -mop.rr.5 rd rs1 rs2 30=1 27=0 26=1 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 -mop.rr.6 rd rs1 rs2 30=1 27=1 26=0 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 -mop.rr.7 rd rs1 rs2 30=1 27=1 26=1 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 +mop.rr.N mop_rr_t_30 mop_rr_t_27_26 rd rs1 rs2 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.rr.N mop.rr.0 rd rs1 rs2 30=0 27=0 26=0 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.rr.N mop.rr.1 rd rs1 rs2 30=0 27=0 26=1 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.rr.N mop.rr.2 rd rs1 rs2 30=0 27=1 26=0 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.rr.N mop.rr.3 rd rs1 rs2 30=0 27=1 26=1 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.rr.N mop.rr.4 rd rs1 rs2 30=1 27=0 26=0 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.rr.N mop.rr.5 rd rs1 rs2 30=1 27=0 26=1 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.rr.N mop.rr.6 rd rs1 rs2 30=1 27=1 26=0 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3 +$pseudo_op rv_zimop::mop.rr.N mop.rr.7 rd rs1 rs2 30=1 27=1 26=1 31=1 29..28=0 25=1 14..12=4 6..2=0x1C 1..0=3