Re: [PATCH v3 25/30] Hexagon HVX (target/hexagon) instruction decoding

2021-09-20 Thread Richard Henderson

On 9/20/21 2:24 PM, Taylor Simpson wrote:

Add new file to target/hexagon/meson.build

Signed-off-by: Taylor Simpson
---
  target/hexagon/mmvec/decode_ext_mmvec.h |  24 
  target/hexagon/decode.c |  24 +++-
  target/hexagon/mmvec/decode_ext_mmvec.c | 236 
  target/hexagon/meson.build  |   1 +
  4 files changed, 283 insertions(+), 2 deletions(-)
  create mode 100644 target/hexagon/mmvec/decode_ext_mmvec.h
  create mode 100644 target/hexagon/mmvec/decode_ext_mmvec.c


Acked-by: Richard Henderson 

r~



[PATCH v3 25/30] Hexagon HVX (target/hexagon) instruction decoding

2021-09-20 Thread Taylor Simpson
Add new file to target/hexagon/meson.build

Signed-off-by: Taylor Simpson 
---
 target/hexagon/mmvec/decode_ext_mmvec.h |  24 
 target/hexagon/decode.c |  24 +++-
 target/hexagon/mmvec/decode_ext_mmvec.c | 236 
 target/hexagon/meson.build  |   1 +
 4 files changed, 283 insertions(+), 2 deletions(-)
 create mode 100644 target/hexagon/mmvec/decode_ext_mmvec.h
 create mode 100644 target/hexagon/mmvec/decode_ext_mmvec.c

diff --git a/target/hexagon/mmvec/decode_ext_mmvec.h 
b/target/hexagon/mmvec/decode_ext_mmvec.h
new file mode 100644
index 000..3664b68
--- /dev/null
+++ b/target/hexagon/mmvec/decode_ext_mmvec.h
@@ -0,0 +1,24 @@
+/*
+ *  Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights 
Reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see .
+ */
+
+#ifndef HEXAGON_DECODE_EXT_MMVEC_H
+#define HEXAGON_DECODE_EXT_MMVEC_H
+
+void mmvec_ext_decode_checks(Packet *pkt, bool disas_only);
+SlotMask mmvec_ext_decode_find_iclass_slots(int opcode);
+
+#endif
diff --git a/target/hexagon/decode.c b/target/hexagon/decode.c
index d424245..653bfd7 100644
--- a/target/hexagon/decode.c
+++ b/target/hexagon/decode.c
@@ -22,6 +22,7 @@
 #include "decode.h"
 #include "insn.h"
 #include "printinsn.h"
+#include "mmvec/decode_ext_mmvec.h"
 
 #define fZXTN(N, M, VAL) ((VAL) & ((1LL << (N)) - 1))
 
@@ -566,8 +567,12 @@ static void decode_remove_extenders(Packet *packet)
 
 static SlotMask get_valid_slots(const Packet *pkt, unsigned int slot)
 {
-return find_iclass_slots(pkt->insn[slot].opcode,
- pkt->insn[slot].iclass);
+if (GET_ATTRIB(pkt->insn[slot].opcode, A_EXTENSION)) {
+return mmvec_ext_decode_find_iclass_slots(pkt->insn[slot].opcode);
+} else {
+return find_iclass_slots(pkt->insn[slot].opcode,
+ pkt->insn[slot].iclass);
+}
 }
 
 #define DECODE_NEW_TABLE(TAG, SIZE, WHATNOT) /* NOTHING */
@@ -728,6 +733,11 @@ decode_insns_tablewalk(Insn *insn, const DectreeTable 
*table,
 }
 decode_op(insn, opc, encoding);
 return 1;
+} else if (table->table[i].type == DECTREE_EXTSPACE) {
+/*
+ * For now, HVX will be the only coproc
+ */
+return decode_insns_tablewalk(insn, ext_trees[EXT_IDX_mmvec], 
encoding);
 } else {
 return 0;
 }
@@ -874,6 +884,7 @@ int decode_packet(int max_words, const uint32_t *words, 
Packet *pkt,
 int words_read = 0;
 bool end_of_packet = false;
 int new_insns = 0;
+int i;
 uint32_t encoding32;
 
 /* Initialize */
@@ -901,6 +912,11 @@ int decode_packet(int max_words, const uint32_t *words, 
Packet *pkt,
 return 0;
 }
 pkt->encod_pkt_size_in_bytes = words_read * 4;
+pkt->pkt_has_hvx = false;
+for (i = 0; i < num_insns; i++) {
+pkt->pkt_has_hvx |=
+GET_ATTRIB(pkt->insn[i].opcode, A_CVI);
+}
 
 /*
  * Check for :endloop in the parse bits
@@ -931,6 +947,10 @@ int decode_packet(int max_words, const uint32_t *words, 
Packet *pkt,
 decode_set_slot_number(pkt);
 decode_fill_newvalue_regno(pkt);
 
+if (pkt->pkt_has_hvx) {
+mmvec_ext_decode_checks(pkt, disas_only);
+}
+
 if (!disas_only) {
 decode_shuffle_for_execution(pkt);
 decode_split_cmpjump(pkt);
diff --git a/target/hexagon/mmvec/decode_ext_mmvec.c 
b/target/hexagon/mmvec/decode_ext_mmvec.c
new file mode 100644
index 000..061a65a
--- /dev/null
+++ b/target/hexagon/mmvec/decode_ext_mmvec.c
@@ -0,0 +1,236 @@
+/*
+ *  Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights 
Reserved.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, see .
+ */
+
+#include "qemu/osdep.h"