mirror of
https://github.com/pound-emu/pound.git
synced 2025-12-11 07:36:57 +00:00
Compare commits
2 commits
621665c659
...
dfd91ced48
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dfd91ced48 | ||
|
|
14ef99faf9 |
3 changed files with 103 additions and 18 deletions
28
src/jit/a32_types.h
Normal file
28
src/jit/a32_types.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef POUND_JIT_ARM32_TYPES_H
|
||||
#define POUND_JIT_ARM32_TYPES_H
|
||||
|
||||
namespace pound::jit {
|
||||
typedef enum
|
||||
{
|
||||
A32_REGISTER_R0,
|
||||
A32_REGISTER_R2,
|
||||
A32_REGISTER_R3,
|
||||
A32_REGISTER_R4,
|
||||
A32_REGISTER_R5,
|
||||
A32_REGISTER_R6,
|
||||
A32_REGISTER_R7,
|
||||
A32_REGISTER_R8,
|
||||
A32_REGISTER_R9,
|
||||
A32_REGISTER_R10,
|
||||
A32_REGISTER_R11,
|
||||
A32_REGISTER_R12,
|
||||
A32_REGISTER_R13,
|
||||
A32_REGISTER_R14,
|
||||
A32_REGISTER_R15,
|
||||
A32_REGISTER_SP = A32_REGISTER_R13,
|
||||
A32_REGISTER_LP = A32_REGISTER_R14,
|
||||
A32_REGISTER_PC = A32_REGISTER_R15,
|
||||
A32_REGISTER_INVALID = 99,
|
||||
} a32_register_t;
|
||||
}
|
||||
#endif // POUND_JIT_ARM32_TYPES_H
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
/**
|
||||
* @file type.h
|
||||
*
|
||||
* @brief Defines the type system for the Pound JIT Intermediate Representation.
|
||||
*
|
||||
* @brief Defines the type system for the Pound JIT Intermediate
|
||||
* Representation.
|
||||
*
|
||||
* This header declares the `type_t ` enumeration, which forms the basis of
|
||||
* type identification and checking within the JIT's IR.
|
||||
* type identification and checking within the JIT's IR.
|
||||
*/
|
||||
|
||||
namespace pound::jit::ir {
|
||||
|
|
@ -17,15 +18,15 @@ namespace pound::jit::ir {
|
|||
*/
|
||||
typedef enum
|
||||
{
|
||||
IR_TYPE_VOID = 0,
|
||||
IR_TYPE_U1 = 1 << 0,
|
||||
IR_TYPE_U8 = 1 << 1,
|
||||
IR_TYPE_U16 = 1 << 2,
|
||||
IR_TYPE_U32 = 1 << 3,
|
||||
IR_TYPE_U64 = 1 << 4,
|
||||
IR_TYPE_U128 = 1 << 5,
|
||||
IR_TYPE_VOID = 0,
|
||||
IR_TYPE_U1 = 1 << 0,
|
||||
IR_TYPE_U8 = 1 << 1,
|
||||
IR_TYPE_U16 = 1 << 2,
|
||||
IR_TYPE_U32 = 1 << 3,
|
||||
IR_TYPE_U64 = 1 << 4,
|
||||
IR_TYPE_U128 = 1 << 5,
|
||||
IR_TYPE_A32_REGISTER = 1 << 6, // ARM32 GPR R0-R14
|
||||
#if 0
|
||||
IR_TYPE_A32_REG = 1 << 6, // ARM32 GPR R0-R14
|
||||
IR_TYPE_A32_EXT_REG = 1 << 7, // ARM32 Extended Registers (e.g., for
|
||||
// VFP/NEON, or just R15 if treated specially)
|
||||
IR_TYPE_A32_CPSR = 1 << 8, // ARM32 CPSR/SPSR
|
||||
|
|
@ -56,4 +57,4 @@ typedef enum
|
|||
* compatibility rules. false otherwise.
|
||||
*/
|
||||
bool are_types_compatible(const type_t t1, const type_t t2);
|
||||
} //namespace pound::jit::ir
|
||||
} // namespace pound::jit::ir
|
||||
|
|
|
|||
|
|
@ -1,21 +1,28 @@
|
|||
#include "type.h"
|
||||
#include "jit/a32_types.h"
|
||||
#include "common/passert.h"
|
||||
#include <stdint.h>
|
||||
|
||||
namespace pound::jit::ir
|
||||
{
|
||||
namespace pound::jit::ir {
|
||||
typedef struct
|
||||
{
|
||||
type_t type;
|
||||
union
|
||||
{
|
||||
uint64_t immediate_u64;
|
||||
uint32_t immediate_u32;
|
||||
uint8_t immediate_u8;
|
||||
bool immediate_u1;
|
||||
uint64_t immediate_u64;
|
||||
uint32_t immediate_u32;
|
||||
pound::jit::a32_register_t immediate_a32_register;
|
||||
uint8_t immediate_u8;
|
||||
bool immediate_u1;
|
||||
} inner;
|
||||
} value_t;
|
||||
|
||||
/*
|
||||
* ============================================================================
|
||||
* Init Functions
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
void
|
||||
value_init (value_t *value)
|
||||
{
|
||||
|
|
@ -54,4 +61,53 @@ value_init_from_u1 (value_t *value, bool u1)
|
|||
value->type = IR_TYPE_U1;
|
||||
value->inner.immediate_u1 = u1;
|
||||
}
|
||||
|
||||
void
|
||||
value_init_from_a32_register (value_t *value, a32_register_t reg)
|
||||
{
|
||||
PVM_ASSERT(nullptr != value);
|
||||
value->type = IR_TYPE_A32_REGISTER;
|
||||
value->inner.immediate_a32_register = reg;
|
||||
}
|
||||
|
||||
/*
|
||||
* ============================================================================
|
||||
* Getter Functions
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
uint64_t
|
||||
value_get_u64 (value_t *value)
|
||||
{
|
||||
PVM_ASSERT(IR_TYPE_U64 == value->type);
|
||||
return value->inner.immediate_u64;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
value_get_u32 (value_t *value)
|
||||
{
|
||||
PVM_ASSERT(IR_TYPE_U32 == value->type);
|
||||
return value->inner.immediate_u32;
|
||||
}
|
||||
|
||||
uint8_t
|
||||
value_get_u8 (value_t *value)
|
||||
{
|
||||
PVM_ASSERT(IR_TYPE_U8 == value->type);
|
||||
return value->inner.immediate_u8;
|
||||
}
|
||||
|
||||
bool
|
||||
value_get_u1 (value_t *value)
|
||||
{
|
||||
PVM_ASSERT(IR_TYPE_U1 == value->type);
|
||||
return value->inner.immediate_u1;
|
||||
}
|
||||
|
||||
pound::jit::a32_register_t
|
||||
value_get_a32_register (value_t *value)
|
||||
{
|
||||
PVM_ASSERT(IR_TYPE_A32_REGISTER == value->type);
|
||||
return value->inner.immediate_a32_register;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue