sim: cr16: migrate to standard uintXX_t types

This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

Also migrate off the sim-specific unsignedXX types.
This commit is contained in:
Mike Frysinger
2021-12-05 12:22:54 -05:00
parent f9f4242296
commit 32267d593a
3 changed files with 621 additions and 630 deletions

View File

@@ -44,25 +44,16 @@ extern int cr16_debug;
#include "sim-config.h"
#include "sim-types.h"
typedef unsigned8 uint8;
typedef signed8 int8;
typedef unsigned16 uint16;
typedef signed16 int16;
typedef unsigned32 uint32;
typedef signed32 int32;
typedef unsigned64 uint64;
typedef signed64 int64;
/* FIXME: CR16 defines */
typedef uint16 reg_t;
typedef uint32 creg_t;
typedef uint16_t reg_t;
typedef uint32_t creg_t;
struct simops
{
char mnemonic[12];
uint32 size;
uint32 mask;
uint32 opcode;
uint32_t size;
uint32_t mask;
uint32_t opcode;
int format;
char fname[12];
void (*func)(SIM_DESC, SIM_CPU *);
@@ -205,7 +196,7 @@ struct _state
#define GPR32(N) \
(N < 12) ? \
((((uint16) State.regs[(N) + 1]) << 16) | (uint16) State.regs[(N)]) \
((((uint16_t) State.regs[(N) + 1]) << 16) | (uint16_t) State.regs[(N)]) \
: GPR (N)
#define SET_GPR32(N,VAL) do { \
@@ -232,7 +223,7 @@ struct _state
/* trace data */
struct {
uint16 psw;
uint16_t psw;
} trace;
int pc_changed;
@@ -247,8 +238,8 @@ struct _state
extern struct _state State;
extern uint32 OP[4];
extern uint32 sign_flag;
extern uint32_t OP[4];
extern uint32_t sign_flag;
extern struct simops Simops[];
enum
@@ -394,7 +385,7 @@ enum
/* Yes, this is as whacked as it looks. The sim currently reads little endian
for 16 bits, but then merge them like big endian to get 32 bits. */
static inline uint32 get_longword (SIM_CPU *cpu, address_word addr)
static inline uint32_t get_longword (SIM_CPU *cpu, address_word addr)
{
return (RW (addr) << 16) | RW (addr + 2);
}

View File

@@ -42,19 +42,19 @@ struct _state State;
int cr16_debug;
uint32 OP[4];
uint32 sign_flag;
uint32_t OP[4];
uint32_t sign_flag;
static struct hash_entry *lookup_hash (SIM_DESC, SIM_CPU *, uint64 ins, int size);
static void get_operands (operand_desc *s, uint64 mcode, int isize, int nops);
static struct hash_entry *lookup_hash (SIM_DESC, SIM_CPU *, uint64_t ins, int size);
static void get_operands (operand_desc *s, uint64_t mcode, int isize, int nops);
#define MAX_HASH 16
struct hash_entry
{
struct hash_entry *next;
uint32 opcode;
uint32 mask;
uint32_t opcode;
uint32_t mask;
int format;
int size;
struct simops *ops;
@@ -77,9 +77,9 @@ hash(unsigned long long insn, int format)
INLINE static struct hash_entry *
lookup_hash (SIM_DESC sd, SIM_CPU *cpu, uint64 ins, int size)
lookup_hash (SIM_DESC sd, SIM_CPU *cpu, uint64_t ins, int size)
{
uint32 mask;
uint32_t mask;
struct hash_entry *h;
h = &hash_table[hash(ins,1)];
@@ -108,10 +108,10 @@ lookup_hash (SIM_DESC sd, SIM_CPU *cpu, uint64 ins, int size)
}
INLINE static void
get_operands (operand_desc *s, uint64 ins, int isize, int nops)
get_operands (operand_desc *s, uint64_t ins, int isize, int nops)
{
uint32 i, opn = 0, start_bit = 0, op_type = 0;
int32 op_size = 0, mask = 0;
uint32_t i, opn = 0, start_bit = 0, op_type = 0;
int32_t op_size = 0, mask = 0;
if (isize == 1) /* Trunkcate the extra 16 bits of INS. */
ins = ins >> 16;
@@ -328,7 +328,7 @@ get_operands (operand_desc *s, uint64 ins, int isize, int nops)
}
static int
do_run (SIM_DESC sd, SIM_CPU *cpu, uint64 mcode)
do_run (SIM_DESC sd, SIM_CPU *cpu, uint64_t mcode)
{
struct hash_entry *h;
@@ -579,8 +579,8 @@ sim_open (SIM_OPEN_KIND kind, struct host_callback_struct *cb,
static void
step_once (SIM_DESC sd, SIM_CPU *cpu)
{
uint32 curr_ins_size = 0;
uint64 mcode = RLW (PC);
uint32_t curr_ins_size = 0;
uint64_t mcode = RLW (PC);
State.pc_changed = 0;
@@ -689,10 +689,10 @@ sim_create_inferior (SIM_DESC sd, struct bfd *abfd,
return SIM_RC_OK;
}
static uint32
static uint32_t
cr16_extract_unsigned_integer (unsigned char *addr, int len)
{
uint32 retval;
uint32_t retval;
unsigned char * p;
unsigned char * startaddr = (unsigned char *)addr;
unsigned char * endaddr = startaddr + len;
@@ -706,7 +706,7 @@ cr16_extract_unsigned_integer (unsigned char *addr, int len)
}
static void
cr16_store_unsigned_integer (unsigned char *addr, int len, uint32 val)
cr16_store_unsigned_integer (unsigned char *addr, int len, uint32_t val)
{
unsigned char *p;
unsigned char *startaddr = addr;

File diff suppressed because it is too large Load Diff