57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
#ifndef __SPL_LAYOUT_H__
|
|
#define __SPL_LAYOUT_H__
|
|
|
|
#include "spl_type.h"
|
|
|
|
typedef struct {
|
|
usize size;
|
|
usize abi_align;
|
|
usize pref_align;
|
|
VEC(usize) invalid_values;
|
|
} spl_layout_scalar_t;
|
|
|
|
typedef struct {
|
|
usize add_space;
|
|
usize ptr_size;
|
|
usize ptr_align;
|
|
} spl_layout_ptr_t;
|
|
|
|
typedef struct {
|
|
bool allow_field_reordering;
|
|
enum { ALIGN_MAX, ALIGN_FIXED, ALIGN_MAX_WITH_MIN } align_rule;
|
|
usize fixed_align;
|
|
} spl_layout_agg_t;
|
|
|
|
typedef struct {
|
|
usize size_bits;
|
|
usize align_bits;
|
|
VEC(usize) field_bit_offsets;
|
|
VEC(usize) field_bit_sizes;
|
|
bool resolved;
|
|
} spl_layout_info_t;
|
|
|
|
typedef struct {
|
|
enum { SPL_BIG_ENDIAN, SPL_LITTLE_ENDIAN } endian; // TODO 更多位存储方式
|
|
|
|
} spl_layout_target_t;
|
|
|
|
typedef struct {
|
|
VEC(spl_layout_scalar_t) scalars;
|
|
VEC(spl_layout_ptr_t) pointers;
|
|
spl_layout_agg_t aggregate;
|
|
VEC(spl_layout_info_t) infos;
|
|
spl_layout_target_t *target;
|
|
} spl_layout_t;
|
|
|
|
void spl_layout_init(spl_layout_t *layout, spl_layout_target_t *target);
|
|
void spl_layout_drop(spl_layout_t *layout);
|
|
|
|
void spl_layout_resolve(spl_layout_t *layout, spl_type_t *type);
|
|
|
|
void spl_layout_add_scalar(spl_layout_t *layout, usize size, usize abi_align);
|
|
void spl_layout_add_ptr(spl_layout_t *layout, usize addr_space, usize size, usize align);
|
|
|
|
const spl_layout_info_t *spl_layout_info_of(spl_layout_t *layout, spl_type_id_t id);
|
|
|
|
#endif /* __SPL_LAYOUT_H__ */
|