From 16e8a3548ffbfd761f344ad8d3189b7cf201d567 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Tue, 12 Mar 2024 10:34:51 +0100 Subject: [PATCH] isaspec: deocde: Hide all the internals ISA details There are no users of these defines, structs and functions outside of the generated isa.c file. I left the empty header as it will be used in later commits. Signed-off-by: Christian Gmeiner Reviewed-by: Rob Clark Part-of: --- src/compiler/isaspec/decode.py | 92 +++++++++++++++++----------------- 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/src/compiler/isaspec/decode.py b/src/compiler/isaspec/decode.py index 5ab9c15599b..2a9a6bb92f6 100755 --- a/src/compiler/isaspec/decode.py +++ b/src/compiler/isaspec/decode.py @@ -105,6 +105,52 @@ template = """\ #include "${header}" +#include +#include + +#define BITMASK_WORDS BITSET_WORDS(${isa.bitsize}) + +typedef struct { + BITSET_WORD bitset[BITMASK_WORDS]; +} bitmask_t; + + +#define BITSET_FORMAT ${isa.format()} +#define BITSET_VALUE(v) ${isa.value()} + +static inline void +next_instruction(bitmask_t *instr, BITSET_WORD *start) +{ + %for i in range(0, int(isa.bitsize / 32)): + instr->bitset[${i}] = *(start + ${i}); + %endfor +} + +static inline uint64_t +bitmask_to_uint64_t(bitmask_t mask) +{ +% if isa.bitsize <= 32: + return mask.bitset[0]; +% else: + return ((uint64_t)mask.bitset[1] << 32) | mask.bitset[0]; +% endif +} + +static inline bitmask_t +uint64_t_to_bitmask(uint64_t val) +{ + bitmask_t mask = { + .bitset[0] = val & 0xffffffff, +% if isa.bitsize > 32: + .bitset[1] = (val >> 32) & 0xffffffff, +% endif + }; + + return mask; +} + +#include "isaspec_decode_decl.h" + /* * enum tables, these don't have any link back to other tables so just * dump them up front before the bitset tables @@ -328,52 +374,6 @@ header = """\ #ifndef _${guard}_ #define _${guard}_ -#include -#include - -#define BITMASK_WORDS BITSET_WORDS(${isa.bitsize}) - -typedef struct { - BITSET_WORD bitset[BITMASK_WORDS]; -} bitmask_t; - - -#define BITSET_FORMAT ${isa.format()} -#define BITSET_VALUE(v) ${isa.value()} - -static inline void -next_instruction(bitmask_t *instr, BITSET_WORD *start) -{ - %for i in range(0, int(isa.bitsize / 32)): - instr->bitset[${i}] = *(start + ${i}); - %endfor -} - -static inline uint64_t -bitmask_to_uint64_t(bitmask_t mask) -{ -% if isa.bitsize <= 32: - return mask.bitset[0]; -% else: - return ((uint64_t)mask.bitset[1] << 32) | mask.bitset[0]; -% endif -} - -static inline bitmask_t -uint64_t_to_bitmask(uint64_t val) -{ - bitmask_t mask = { - .bitset[0] = val & 0xffffffff, -% if isa.bitsize > 32: - .bitset[1] = (val >> 32) & 0xffffffff, -% endif - }; - - return mask; -} - -#include "isaspec_decode_decl.h" - #endif /* _${guard}_ */ """