xref: /qemu/target/hexagon/translate.h (revision 8b453a2b)
1*8b453a2bSTaylor Simpson /*
2*8b453a2bSTaylor Simpson  *  Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved.
3*8b453a2bSTaylor Simpson  *
4*8b453a2bSTaylor Simpson  *  This program is free software; you can redistribute it and/or modify
5*8b453a2bSTaylor Simpson  *  it under the terms of the GNU General Public License as published by
6*8b453a2bSTaylor Simpson  *  the Free Software Foundation; either version 2 of the License, or
7*8b453a2bSTaylor Simpson  *  (at your option) any later version.
8*8b453a2bSTaylor Simpson  *
9*8b453a2bSTaylor Simpson  *  This program is distributed in the hope that it will be useful,
10*8b453a2bSTaylor Simpson  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11*8b453a2bSTaylor Simpson  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12*8b453a2bSTaylor Simpson  *  GNU General Public License for more details.
13*8b453a2bSTaylor Simpson  *
14*8b453a2bSTaylor Simpson  *  You should have received a copy of the GNU General Public License
15*8b453a2bSTaylor Simpson  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
16*8b453a2bSTaylor Simpson  */
17*8b453a2bSTaylor Simpson 
18*8b453a2bSTaylor Simpson #ifndef HEXAGON_TRANSLATE_H
19*8b453a2bSTaylor Simpson #define HEXAGON_TRANSLATE_H
20*8b453a2bSTaylor Simpson 
21*8b453a2bSTaylor Simpson #include "qemu/bitmap.h"
22*8b453a2bSTaylor Simpson #include "cpu.h"
23*8b453a2bSTaylor Simpson #include "exec/translator.h"
24*8b453a2bSTaylor Simpson #include "tcg/tcg-op.h"
25*8b453a2bSTaylor Simpson #include "internal.h"
26*8b453a2bSTaylor Simpson 
27*8b453a2bSTaylor Simpson typedef struct DisasContext {
28*8b453a2bSTaylor Simpson     DisasContextBase base;
29*8b453a2bSTaylor Simpson     uint32_t mem_idx;
30*8b453a2bSTaylor Simpson     uint32_t num_packets;
31*8b453a2bSTaylor Simpson     uint32_t num_insns;
32*8b453a2bSTaylor Simpson     int reg_log[REG_WRITES_MAX];
33*8b453a2bSTaylor Simpson     int reg_log_idx;
34*8b453a2bSTaylor Simpson     DECLARE_BITMAP(regs_written, TOTAL_PER_THREAD_REGS);
35*8b453a2bSTaylor Simpson     int preg_log[PRED_WRITES_MAX];
36*8b453a2bSTaylor Simpson     int preg_log_idx;
37*8b453a2bSTaylor Simpson     uint8_t store_width[STORES_MAX];
38*8b453a2bSTaylor Simpson     uint8_t s1_store_processed;
39*8b453a2bSTaylor Simpson } DisasContext;
40*8b453a2bSTaylor Simpson 
41*8b453a2bSTaylor Simpson static inline void ctx_log_reg_write(DisasContext *ctx, int rnum)
42*8b453a2bSTaylor Simpson {
43*8b453a2bSTaylor Simpson #if HEX_DEBUG
44*8b453a2bSTaylor Simpson     if (test_bit(rnum, ctx->regs_written)) {
45*8b453a2bSTaylor Simpson         HEX_DEBUG_LOG("WARNING: Multiple writes to r%d\n", rnum);
46*8b453a2bSTaylor Simpson     }
47*8b453a2bSTaylor Simpson #endif
48*8b453a2bSTaylor Simpson     ctx->reg_log[ctx->reg_log_idx] = rnum;
49*8b453a2bSTaylor Simpson     ctx->reg_log_idx++;
50*8b453a2bSTaylor Simpson     set_bit(rnum, ctx->regs_written);
51*8b453a2bSTaylor Simpson }
52*8b453a2bSTaylor Simpson 
53*8b453a2bSTaylor Simpson static inline void ctx_log_reg_write_pair(DisasContext *ctx, int rnum)
54*8b453a2bSTaylor Simpson {
55*8b453a2bSTaylor Simpson     ctx_log_reg_write(ctx, rnum);
56*8b453a2bSTaylor Simpson     ctx_log_reg_write(ctx, rnum + 1);
57*8b453a2bSTaylor Simpson }
58*8b453a2bSTaylor Simpson 
59*8b453a2bSTaylor Simpson static inline void ctx_log_pred_write(DisasContext *ctx, int pnum)
60*8b453a2bSTaylor Simpson {
61*8b453a2bSTaylor Simpson     ctx->preg_log[ctx->preg_log_idx] = pnum;
62*8b453a2bSTaylor Simpson     ctx->preg_log_idx++;
63*8b453a2bSTaylor Simpson }
64*8b453a2bSTaylor Simpson 
65*8b453a2bSTaylor Simpson static inline bool is_preloaded(DisasContext *ctx, int num)
66*8b453a2bSTaylor Simpson {
67*8b453a2bSTaylor Simpson     return test_bit(num, ctx->regs_written);
68*8b453a2bSTaylor Simpson }
69*8b453a2bSTaylor Simpson 
70*8b453a2bSTaylor Simpson extern TCGv hex_gpr[TOTAL_PER_THREAD_REGS];
71*8b453a2bSTaylor Simpson extern TCGv hex_pred[NUM_PREGS];
72*8b453a2bSTaylor Simpson extern TCGv hex_next_PC;
73*8b453a2bSTaylor Simpson extern TCGv hex_this_PC;
74*8b453a2bSTaylor Simpson extern TCGv hex_slot_cancelled;
75*8b453a2bSTaylor Simpson extern TCGv hex_branch_taken;
76*8b453a2bSTaylor Simpson extern TCGv hex_new_value[TOTAL_PER_THREAD_REGS];
77*8b453a2bSTaylor Simpson extern TCGv hex_reg_written[TOTAL_PER_THREAD_REGS];
78*8b453a2bSTaylor Simpson extern TCGv hex_new_pred_value[NUM_PREGS];
79*8b453a2bSTaylor Simpson extern TCGv hex_pred_written;
80*8b453a2bSTaylor Simpson extern TCGv hex_store_addr[STORES_MAX];
81*8b453a2bSTaylor Simpson extern TCGv hex_store_width[STORES_MAX];
82*8b453a2bSTaylor Simpson extern TCGv hex_store_val32[STORES_MAX];
83*8b453a2bSTaylor Simpson extern TCGv_i64 hex_store_val64[STORES_MAX];
84*8b453a2bSTaylor Simpson extern TCGv hex_dczero_addr;
85*8b453a2bSTaylor Simpson extern TCGv hex_llsc_addr;
86*8b453a2bSTaylor Simpson extern TCGv hex_llsc_val;
87*8b453a2bSTaylor Simpson extern TCGv_i64 hex_llsc_val_i64;
88*8b453a2bSTaylor Simpson 
89*8b453a2bSTaylor Simpson void gen_exception(int excp);
90*8b453a2bSTaylor Simpson void gen_exception_debug(void);
91*8b453a2bSTaylor Simpson 
92*8b453a2bSTaylor Simpson void process_store(DisasContext *ctx, Packet *pkt, int slot_num);
93*8b453a2bSTaylor Simpson #endif
94