Helpers for reading and writing registers
Helpers for getting and setting parts of values (e.g., set bit)
Signed-off-by: Taylor Simpson <address@hidden>
---
target/hexagon/genptr_helpers.h | 323 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 323 insertions(+)
create mode 100644 target/hexagon/genptr_helpers.h
diff --git a/target/hexagon/genptr_helpers.h b/target/hexagon/genptr_helpers.h
new file mode 100644
index 0000000..2b91fdb
--- /dev/null
+++ b/target/hexagon/genptr_helpers.h
@@ -0,0 +1,323 @@
+/*
+ * Copyright (c) 2019 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GENPTR_HELPERS_H
+#define GENPTR_HELPERS_H
+
+static inline TCGv gen_read_reg(TCGv result, int num)
+{
+ tcg_gen_mov_tl(result, hex_gpr[num]);
+ return result;
+}
+
+static inline TCGv gen_read_preg(TCGv pred, uint8_t num)
+{
+ tcg_gen_mov_tl(pred, hex_pred[num]);
+ return pred;
+}
+
+static inline TCGv gen_newreg_st(TCGv result, TCGv_env cpu_env, TCGv rnum)
+{
+ gen_helper_new_value(result, cpu_env, rnum);
+ return result;
+}
+
+static inline bool is_preloaded(DisasContext *ctx, int num)
+{
+ int i;
+ for (i = 0; i < ctx->ctx_reg_log_idx; i++) {
+ if (ctx->ctx_reg_log[i] == num) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static inline void gen_log_reg_write(int rnum, TCGv val, int slot,
+ int is_predicated)
+{
+ if (is_predicated) {
+ TCGv one = tcg_const_tl(1);
+ TCGv zero = tcg_const_tl(0);
+ TCGv slot_mask = tcg_temp_new();
+
+ tcg_gen_andi_tl(slot_mask, hex_slot_cancelled, 1 << slot);
+ tcg_gen_movcond_tl(TCG_COND_EQ, hex_new_value[rnum], slot_mask, zero,
+ val, hex_new_value[rnum]);
+
+ tcg_temp_free(one);
+ tcg_temp_free(zero);
+ tcg_temp_free(slot_mask);
+ } else {
+ tcg_gen_mov_tl(hex_new_value[rnum], val);
+ }
+}