18b453a2bSTaylor Simpson /* 28b453a2bSTaylor Simpson * Copyright(c) 2019-2021 Qualcomm Innovation Center, Inc. All Rights Reserved. 38b453a2bSTaylor Simpson * 48b453a2bSTaylor Simpson * This program is free software; you can redistribute it and/or modify 58b453a2bSTaylor Simpson * it under the terms of the GNU General Public License as published by 68b453a2bSTaylor Simpson * the Free Software Foundation; either version 2 of the License, or 78b453a2bSTaylor Simpson * (at your option) any later version. 88b453a2bSTaylor Simpson * 98b453a2bSTaylor Simpson * This program is distributed in the hope that it will be useful, 108b453a2bSTaylor Simpson * but WITHOUT ANY WARRANTY; without even the implied warranty of 118b453a2bSTaylor Simpson * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 128b453a2bSTaylor Simpson * GNU General Public License for more details. 138b453a2bSTaylor Simpson * 148b453a2bSTaylor Simpson * You should have received a copy of the GNU General Public License 158b453a2bSTaylor Simpson * along with this program; if not, see <http://www.gnu.org/licenses/>. 168b453a2bSTaylor Simpson */ 178b453a2bSTaylor Simpson 188b453a2bSTaylor Simpson #ifndef HEXAGON_TRANSLATE_H 198b453a2bSTaylor Simpson #define HEXAGON_TRANSLATE_H 208b453a2bSTaylor Simpson 218b453a2bSTaylor Simpson #include "qemu/bitmap.h" 228b453a2bSTaylor Simpson #include "cpu.h" 238b453a2bSTaylor Simpson #include "exec/translator.h" 248b453a2bSTaylor Simpson #include "tcg/tcg-op.h" 258b453a2bSTaylor Simpson #include "internal.h" 268b453a2bSTaylor Simpson 278b453a2bSTaylor Simpson typedef struct DisasContext { 288b453a2bSTaylor Simpson DisasContextBase base; 298b453a2bSTaylor Simpson uint32_t mem_idx; 308b453a2bSTaylor Simpson uint32_t num_packets; 318b453a2bSTaylor Simpson uint32_t num_insns; 328b453a2bSTaylor Simpson int reg_log[REG_WRITES_MAX]; 338b453a2bSTaylor Simpson int reg_log_idx; 348b453a2bSTaylor Simpson DECLARE_BITMAP(regs_written, TOTAL_PER_THREAD_REGS); 358b453a2bSTaylor Simpson int preg_log[PRED_WRITES_MAX]; 368b453a2bSTaylor Simpson int preg_log_idx; 37*6c677c60STaylor Simpson DECLARE_BITMAP(pregs_written, NUM_PREGS); 388b453a2bSTaylor Simpson uint8_t store_width[STORES_MAX]; 398b453a2bSTaylor Simpson uint8_t s1_store_processed; 408b453a2bSTaylor Simpson } DisasContext; 418b453a2bSTaylor Simpson 428b453a2bSTaylor Simpson static inline void ctx_log_reg_write(DisasContext *ctx, int rnum) 438b453a2bSTaylor Simpson { 448b453a2bSTaylor Simpson #if HEX_DEBUG 458b453a2bSTaylor Simpson if (test_bit(rnum, ctx->regs_written)) { 468b453a2bSTaylor Simpson HEX_DEBUG_LOG("WARNING: Multiple writes to r%d\n", rnum); 478b453a2bSTaylor Simpson } 488b453a2bSTaylor Simpson #endif 498b453a2bSTaylor Simpson ctx->reg_log[ctx->reg_log_idx] = rnum; 508b453a2bSTaylor Simpson ctx->reg_log_idx++; 518b453a2bSTaylor Simpson set_bit(rnum, ctx->regs_written); 528b453a2bSTaylor Simpson } 538b453a2bSTaylor Simpson 548b453a2bSTaylor Simpson static inline void ctx_log_reg_write_pair(DisasContext *ctx, int rnum) 558b453a2bSTaylor Simpson { 568b453a2bSTaylor Simpson ctx_log_reg_write(ctx, rnum); 578b453a2bSTaylor Simpson ctx_log_reg_write(ctx, rnum + 1); 588b453a2bSTaylor Simpson } 598b453a2bSTaylor Simpson 608b453a2bSTaylor Simpson static inline void ctx_log_pred_write(DisasContext *ctx, int pnum) 618b453a2bSTaylor Simpson { 628b453a2bSTaylor Simpson ctx->preg_log[ctx->preg_log_idx] = pnum; 638b453a2bSTaylor Simpson ctx->preg_log_idx++; 64*6c677c60STaylor Simpson set_bit(pnum, ctx->pregs_written); 658b453a2bSTaylor Simpson } 668b453a2bSTaylor Simpson 678b453a2bSTaylor Simpson static inline bool is_preloaded(DisasContext *ctx, int num) 688b453a2bSTaylor Simpson { 698b453a2bSTaylor Simpson return test_bit(num, ctx->regs_written); 708b453a2bSTaylor Simpson } 718b453a2bSTaylor Simpson 728b453a2bSTaylor Simpson extern TCGv hex_gpr[TOTAL_PER_THREAD_REGS]; 738b453a2bSTaylor Simpson extern TCGv hex_pred[NUM_PREGS]; 748b453a2bSTaylor Simpson extern TCGv hex_next_PC; 758b453a2bSTaylor Simpson extern TCGv hex_this_PC; 768b453a2bSTaylor Simpson extern TCGv hex_slot_cancelled; 778b453a2bSTaylor Simpson extern TCGv hex_branch_taken; 788b453a2bSTaylor Simpson extern TCGv hex_new_value[TOTAL_PER_THREAD_REGS]; 798b453a2bSTaylor Simpson extern TCGv hex_reg_written[TOTAL_PER_THREAD_REGS]; 808b453a2bSTaylor Simpson extern TCGv hex_new_pred_value[NUM_PREGS]; 818b453a2bSTaylor Simpson extern TCGv hex_pred_written; 828b453a2bSTaylor Simpson extern TCGv hex_store_addr[STORES_MAX]; 838b453a2bSTaylor Simpson extern TCGv hex_store_width[STORES_MAX]; 848b453a2bSTaylor Simpson extern TCGv hex_store_val32[STORES_MAX]; 858b453a2bSTaylor Simpson extern TCGv_i64 hex_store_val64[STORES_MAX]; 868b453a2bSTaylor Simpson extern TCGv hex_dczero_addr; 878b453a2bSTaylor Simpson extern TCGv hex_llsc_addr; 888b453a2bSTaylor Simpson extern TCGv hex_llsc_val; 898b453a2bSTaylor Simpson extern TCGv_i64 hex_llsc_val_i64; 908b453a2bSTaylor Simpson 918b453a2bSTaylor Simpson void process_store(DisasContext *ctx, Packet *pkt, int slot_num); 928b453a2bSTaylor Simpson #endif 93