2001-03-28 17:17:56 +00:00
|
|
|
/* Copyright (C) 1996-1997 Id Software, Inc.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-28 17:17:56 +00:00
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-28 17:17:56 +00:00
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-28 17:17:56 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-28 17:17:56 +00:00
|
|
|
See file, 'COPYING', for details.
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
|
|
|
|
2001-03-28 17:17:56 +00:00
|
|
|
// this file is shared by QuakeForge and qfcc
|
2020-02-24 03:21:20 +00:00
|
|
|
#ifndef __QF_pr_comp_h
|
|
|
|
#define __QF_pr_comp_h
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2001-03-27 23:36:02 +00:00
|
|
|
#include "QF/qtypes.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-01-18 09:41:39 +00:00
|
|
|
typedef int32_t pr_string_t __attribute__((aligned(4)));
|
|
|
|
typedef float pr_float_t __attribute__((aligned(4)));
|
|
|
|
typedef float pr_vector_t[3] __attribute__((aligned(4)));
|
|
|
|
typedef uint32_t pr_entity_t __attribute__((aligned(4)));
|
|
|
|
typedef uint32_t pr_field_t __attribute__((aligned(4)));
|
|
|
|
typedef uint32_t pr_func_t __attribute__((aligned(4)));
|
|
|
|
typedef uint32_t pr_ptr_t __attribute__((aligned(4)));
|
|
|
|
typedef float pr_quaternion_t[4] __attribute__((aligned(4)));
|
|
|
|
typedef int32_t pr_int_t __attribute__((aligned(4)));
|
|
|
|
typedef uint32_t pr_uint_t __attribute__((aligned(4)));
|
|
|
|
typedef int16_t pr_short_t __attribute__((aligned(2)));
|
|
|
|
typedef double pr_double_t __attribute__((aligned(8)));
|
|
|
|
typedef int64_t pr_long_t __attribute__((aligned(8)));
|
|
|
|
typedef uint64_t pr_ulong_t __attribute__((aligned(8)));
|
|
|
|
typedef uint16_t pr_ushort_t __attribute__((aligned(2)));;
|
2022-01-02 08:48:43 +00:00
|
|
|
|
2022-04-26 06:10:00 +00:00
|
|
|
#define PR_PTR(t, p) (*(pr_##t##_t *) (p))
|
|
|
|
|
2022-01-02 08:48:43 +00:00
|
|
|
#define PR_VEC_TYPE(t,n,s) \
|
|
|
|
typedef t n __attribute__ ((vector_size (s*sizeof (t))))
|
|
|
|
|
|
|
|
PR_VEC_TYPE (pr_int_t, pr_ivec2_t, 2);
|
2022-01-30 01:47:37 +00:00
|
|
|
typedef pr_int_t pr_ivec3_t[3];
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (pr_int_t, pr_ivec4_t, 4);
|
2022-01-30 01:47:37 +00:00
|
|
|
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (pr_uint_t, pr_uivec2_t, 2);
|
2022-01-30 01:47:37 +00:00
|
|
|
typedef pr_uint_t pr_uivec3_t[3];
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (pr_uint_t, pr_uivec4_t, 4);
|
2022-01-30 01:47:37 +00:00
|
|
|
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (float, pr_vec2_t, 2);
|
2022-01-30 01:47:37 +00:00
|
|
|
typedef pr_float_t pr_vec3_t[3];
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (float, pr_vec4_t, 4);
|
2022-01-30 01:47:37 +00:00
|
|
|
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (pr_long_t, pr_lvec2_t, 2);
|
2022-01-30 01:47:37 +00:00
|
|
|
typedef pr_long_t pr_lvec3_t[3];
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (pr_long_t, pr_lvec4_t, 4);
|
2022-01-30 01:47:37 +00:00
|
|
|
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (pr_ulong_t, pr_ulvec2_t, 2);
|
2022-01-30 01:47:37 +00:00
|
|
|
typedef pr_ulong_t pr_ulvec3_t[3];
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (pr_ulong_t, pr_ulvec4_t, 4);
|
2022-01-30 01:47:37 +00:00
|
|
|
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (double, pr_dvec2_t, 2);
|
2022-01-30 01:47:37 +00:00
|
|
|
typedef pr_double_t pr_dvec3_t[3];
|
2022-01-02 08:48:43 +00:00
|
|
|
PR_VEC_TYPE (double, pr_dvec4_t, 4);
|
2001-03-28 17:17:56 +00:00
|
|
|
|
2022-01-30 01:47:37 +00:00
|
|
|
|
2022-01-18 03:24:43 +00:00
|
|
|
#define EV_TYPE(type) ev_##type,
|
2001-03-01 21:11:35 +00:00
|
|
|
typedef enum {
|
2022-01-18 03:24:43 +00:00
|
|
|
#include "QF/progs/pr_type_names.h"
|
2011-01-09 10:41:24 +00:00
|
|
|
ev_invalid, // invalid type. used for instruction checking
|
2001-06-04 17:51:39 +00:00
|
|
|
ev_type_count // not a type, gives number of types
|
2001-03-01 21:11:35 +00:00
|
|
|
} etype_t;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2022-01-30 01:47:37 +00:00
|
|
|
#define PR_SIZEOF(type) (sizeof (pr_##type##_t) / (sizeof (pr_int_t)))
|
2022-01-23 05:27:36 +00:00
|
|
|
#define PR_ALIGNOF(type) (__alignof__ (pr_##type##_t) / __alignof__ (pr_int_t))
|
|
|
|
|
2020-02-25 16:20:28 +00:00
|
|
|
extern const pr_ushort_t pr_type_size[ev_type_count];
|
2022-01-18 09:41:39 +00:00
|
|
|
extern const pr_ushort_t pr_type_alignment[ev_type_count];
|
2020-02-25 16:20:28 +00:00
|
|
|
extern const char * const pr_type_name[ev_type_count];
|
2001-03-28 17:17:56 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#define OFS_NULL 0
|
|
|
|
#define OFS_RETURN 1
|
|
|
|
#define OFS_PARM0 4 // leave 3 ofs for each parm to hold vectors
|
|
|
|
#define OFS_PARM1 7
|
|
|
|
#define OFS_PARM2 10
|
|
|
|
#define OFS_PARM3 13
|
|
|
|
#define OFS_PARM4 16
|
|
|
|
#define OFS_PARM5 19
|
|
|
|
#define OFS_PARM6 22
|
|
|
|
#define OFS_PARM7 25
|
|
|
|
#define RESERVED_OFS 28
|
|
|
|
|
2001-03-28 17:17:56 +00:00
|
|
|
|
2001-06-03 19:32:50 +00:00
|
|
|
typedef enum {
|
2022-01-02 12:06:14 +00:00
|
|
|
OP_DONE_v6p,
|
|
|
|
OP_MUL_F_v6p,
|
|
|
|
OP_MUL_V_v6p,
|
|
|
|
OP_MUL_FV_v6p,
|
|
|
|
OP_MUL_VF_v6p,
|
|
|
|
OP_DIV_F_v6p,
|
|
|
|
OP_ADD_F_v6p,
|
|
|
|
OP_ADD_V_v6p,
|
|
|
|
OP_SUB_F_v6p,
|
|
|
|
OP_SUB_V_v6p,
|
|
|
|
|
|
|
|
OP_EQ_F_v6p,
|
|
|
|
OP_EQ_V_v6p,
|
|
|
|
OP_EQ_S_v6p,
|
|
|
|
OP_EQ_E_v6p,
|
|
|
|
OP_EQ_FN_v6p,
|
|
|
|
|
|
|
|
OP_NE_F_v6p,
|
|
|
|
OP_NE_V_v6p,
|
|
|
|
OP_NE_S_v6p,
|
|
|
|
OP_NE_E_v6p,
|
|
|
|
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6p,
|
|
|
|
OP_CONV_ID_v6p,
|
|
|
|
OP_CONV_DI_v6p,
|
|
|
|
OP_STORE_D_v6p,
|
|
|
|
OP_STOREB_D_v6p,
|
|
|
|
OP_STOREBI_D_v6p,
|
|
|
|
OP_STOREP_D_v6p,
|
|
|
|
OP_LOAD_D_v6p,
|
|
|
|
OP_LOADB_D_v6p,
|
|
|
|
OP_LOADBI_D_v6p,
|
|
|
|
OP_ADDRESS_D_v6p,
|
|
|
|
|
|
|
|
OP_MOD_I_v6p,
|
|
|
|
OP_MOD_F_v6p,
|
|
|
|
OP_MOD_D_v6p,
|
|
|
|
|
|
|
|
OP_MEMSETI_v6p,
|
|
|
|
OP_MEMSETP_v6p,
|
|
|
|
OP_MEMSETPI_v6p,
|
|
|
|
} pr_opcode_v6p_e;
|
2020-02-26 04:40:26 +00:00
|
|
|
#define OP_BREAK 0x8000
|
2001-02-19 21:15:25 +00:00
|
|
|
|
[gamecode] Add a new Ruamoko instruction set
When it's finalized (most of the conversion operations will go, probably
the float bit ops, maybe (very undecided) the 3-component vector ops,
and likely the CALLN ops), this will be the actual instruction set for
Ruamoko.
Main features:
- Significant reduction in redundant instructions: no more multiple
opcodes to move the one operand size.
- load, store, push, and pop share unified addressing mode encoding
(with the exception of mode 0 for load as that is redundant with mode
0 for store, thus load mode 0 gives quick access to entity.field).
- Full support for both 32 and 64 bit signed integer, unsigned integer,
and floating point values.
- SIMD for 1, 2, (currently) 3, and 4 components. Transfers support up
to 128-bit wide operations (need two operations to transfer a full
4-component double/long vector), but all math operations support both
128-bit (32-bit components) and 256-bit (64-bit components) vectors.
- "Interpreted" operations for the various vector sizes: complex dot
and multiplication, 3d vector dot and cross product, quaternion dot
and multiplication, along with qv and vq shortcuts.
- 4-component swizzles for both sizes (not yet implemented, but the
instructions are allocated), with the option to zero or negate (thus
conjugates for complex and quaternion values) individual components.
- "Based offsets": all relevant instructions include base register
indices for all three operands allowing for direct access to any of
four areas (eg, current entity, current stack frame, Objective-QC
self, ...) instructions to set a register and push/pop the four
registers to/from the stack.
Remaining work:
- Implement swizzle operations and a few other stragglers.
= Make a decision about conversion operations (if any instructions
remain, they'll be just single-component (at 14 meaningful pairs,
that's a lot of instructions to waste on SIMD versions).
- Decide whether to keep CALL1-CALL8: probably little point in
supporting two different calling conventions, and it would free up
another eight instructions.
- Unit tests for the instructions.
- Teach qfcc to generate code for the new instruction set (hah, biggest
job, I'm sure, though hopefully not as crazy as the rewrite eleven
years ago).
2022-01-02 14:15:15 +00:00
|
|
|
typedef enum {
|
2022-04-12 12:01:41 +00:00
|
|
|
#ifndef IN_DOXYGEN
|
2022-01-08 16:04:51 +00:00
|
|
|
#include "QF/progs/pr_opcode.hinc"
|
2022-04-12 12:01:41 +00:00
|
|
|
#endif
|
[gamecode] Add a new Ruamoko instruction set
When it's finalized (most of the conversion operations will go, probably
the float bit ops, maybe (very undecided) the 3-component vector ops,
and likely the CALLN ops), this will be the actual instruction set for
Ruamoko.
Main features:
- Significant reduction in redundant instructions: no more multiple
opcodes to move the one operand size.
- load, store, push, and pop share unified addressing mode encoding
(with the exception of mode 0 for load as that is redundant with mode
0 for store, thus load mode 0 gives quick access to entity.field).
- Full support for both 32 and 64 bit signed integer, unsigned integer,
and floating point values.
- SIMD for 1, 2, (currently) 3, and 4 components. Transfers support up
to 128-bit wide operations (need two operations to transfer a full
4-component double/long vector), but all math operations support both
128-bit (32-bit components) and 256-bit (64-bit components) vectors.
- "Interpreted" operations for the various vector sizes: complex dot
and multiplication, 3d vector dot and cross product, quaternion dot
and multiplication, along with qv and vq shortcuts.
- 4-component swizzles for both sizes (not yet implemented, but the
instructions are allocated), with the option to zero or negate (thus
conjugates for complex and quaternion values) individual components.
- "Based offsets": all relevant instructions include base register
indices for all three operands allowing for direct access to any of
four areas (eg, current entity, current stack frame, Objective-QC
self, ...) instructions to set a register and push/pop the four
registers to/from the stack.
Remaining work:
- Implement swizzle operations and a few other stragglers.
= Make a decision about conversion operations (if any instructions
remain, they'll be just single-component (at 14 meaningful pairs,
that's a lot of instructions to waste on SIMD versions).
- Decide whether to keep CALL1-CALL8: probably little point in
supporting two different calling conventions, and it would free up
another eight instructions.
- Unit tests for the instructions.
- Teach qfcc to generate code for the new instruction set (hah, biggest
job, I'm sure, though hopefully not as crazy as the rewrite eleven
years ago).
2022-01-02 14:15:15 +00:00
|
|
|
} pr_opcode_e;
|
2022-01-08 16:04:51 +00:00
|
|
|
|
2022-01-09 04:56:09 +00:00
|
|
|
// Used for both branch and comparison, with jump and call being ignored for
|
|
|
|
// comparison. For branches, the test is against zero, while for comparison,
|
|
|
|
// it's a cmp b (where cmp takes the place of "branch" in the enum names).
|
|
|
|
typedef enum {
|
|
|
|
pr_branch_eq,
|
|
|
|
pr_branch_lt,
|
|
|
|
pr_branch_gt,
|
|
|
|
pr_branch_jump,
|
|
|
|
pr_branch_ne,
|
|
|
|
pr_branch_ge,
|
|
|
|
pr_branch_le,
|
|
|
|
pr_branch_call,
|
|
|
|
} pr_branch_e;
|
|
|
|
|
[gamecode] Add a new Ruamoko instruction set
When it's finalized (most of the conversion operations will go, probably
the float bit ops, maybe (very undecided) the 3-component vector ops,
and likely the CALLN ops), this will be the actual instruction set for
Ruamoko.
Main features:
- Significant reduction in redundant instructions: no more multiple
opcodes to move the one operand size.
- load, store, push, and pop share unified addressing mode encoding
(with the exception of mode 0 for load as that is redundant with mode
0 for store, thus load mode 0 gives quick access to entity.field).
- Full support for both 32 and 64 bit signed integer, unsigned integer,
and floating point values.
- SIMD for 1, 2, (currently) 3, and 4 components. Transfers support up
to 128-bit wide operations (need two operations to transfer a full
4-component double/long vector), but all math operations support both
128-bit (32-bit components) and 256-bit (64-bit components) vectors.
- "Interpreted" operations for the various vector sizes: complex dot
and multiplication, 3d vector dot and cross product, quaternion dot
and multiplication, along with qv and vq shortcuts.
- 4-component swizzles for both sizes (not yet implemented, but the
instructions are allocated), with the option to zero or negate (thus
conjugates for complex and quaternion values) individual components.
- "Based offsets": all relevant instructions include base register
indices for all three operands allowing for direct access to any of
four areas (eg, current entity, current stack frame, Objective-QC
self, ...) instructions to set a register and push/pop the four
registers to/from the stack.
Remaining work:
- Implement swizzle operations and a few other stragglers.
= Make a decision about conversion operations (if any instructions
remain, they'll be just single-component (at 14 meaningful pairs,
that's a lot of instructions to waste on SIMD versions).
- Decide whether to keep CALL1-CALL8: probably little point in
supporting two different calling conventions, and it would free up
another eight instructions.
- Unit tests for the instructions.
- Teach qfcc to generate code for the new instruction set (hah, biggest
job, I'm sure, though hopefully not as crazy as the rewrite eleven
years ago).
2022-01-02 14:15:15 +00:00
|
|
|
#define OP_A_SHIFT (9)
|
|
|
|
#define OP_B_SHIFT (11)
|
|
|
|
#define OP_C_SHIFT (13)
|
|
|
|
#define OP_A_BASE (3 << OP_A_SHIFT)
|
|
|
|
#define OP_B_BASE (3 << OP_B_SHIFT)
|
|
|
|
#define OP_C_BASE (3 << OP_C_SHIFT)
|
2022-01-03 08:54:54 +00:00
|
|
|
#define OP_MASK (~(OP_BREAK|OP_A_BASE|OP_B_BASE|OP_C_BASE))
|
[gamecode] Add a new Ruamoko instruction set
When it's finalized (most of the conversion operations will go, probably
the float bit ops, maybe (very undecided) the 3-component vector ops,
and likely the CALLN ops), this will be the actual instruction set for
Ruamoko.
Main features:
- Significant reduction in redundant instructions: no more multiple
opcodes to move the one operand size.
- load, store, push, and pop share unified addressing mode encoding
(with the exception of mode 0 for load as that is redundant with mode
0 for store, thus load mode 0 gives quick access to entity.field).
- Full support for both 32 and 64 bit signed integer, unsigned integer,
and floating point values.
- SIMD for 1, 2, (currently) 3, and 4 components. Transfers support up
to 128-bit wide operations (need two operations to transfer a full
4-component double/long vector), but all math operations support both
128-bit (32-bit components) and 256-bit (64-bit components) vectors.
- "Interpreted" operations for the various vector sizes: complex dot
and multiplication, 3d vector dot and cross product, quaternion dot
and multiplication, along with qv and vq shortcuts.
- 4-component swizzles for both sizes (not yet implemented, but the
instructions are allocated), with the option to zero or negate (thus
conjugates for complex and quaternion values) individual components.
- "Based offsets": all relevant instructions include base register
indices for all three operands allowing for direct access to any of
four areas (eg, current entity, current stack frame, Objective-QC
self, ...) instructions to set a register and push/pop the four
registers to/from the stack.
Remaining work:
- Implement swizzle operations and a few other stragglers.
= Make a decision about conversion operations (if any instructions
remain, they'll be just single-component (at 14 meaningful pairs,
that's a lot of instructions to waste on SIMD versions).
- Decide whether to keep CALL1-CALL8: probably little point in
supporting two different calling conventions, and it would free up
another eight instructions.
- Unit tests for the instructions.
- Teach qfcc to generate code for the new instruction set (hah, biggest
job, I'm sure, though hopefully not as crazy as the rewrite eleven
years ago).
2022-01-02 14:15:15 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
OP_with_zero,
|
|
|
|
OP_with_base,
|
|
|
|
OP_with_stack,
|
|
|
|
OP_with_entity,
|
|
|
|
} pr_with_e;
|
|
|
|
|
2022-01-02 12:06:14 +00:00
|
|
|
typedef struct v6p_opcode_s {
|
2021-12-31 10:16:02 +00:00
|
|
|
const char *name;
|
|
|
|
const char *opname;
|
|
|
|
etype_t type_a, type_b, type_c;
|
2003-04-17 00:01:48 +00:00
|
|
|
unsigned int min_version;
|
2021-12-31 10:16:02 +00:00
|
|
|
const char *fmt;
|
2022-01-02 12:06:14 +00:00
|
|
|
} v6p_opcode_t;
|
2001-07-14 02:34:16 +00:00
|
|
|
|
2022-01-02 12:06:14 +00:00
|
|
|
extern const v6p_opcode_t pr_v6p_opcodes[];
|
|
|
|
const v6p_opcode_t *PR_v6p_Opcode (pr_ushort_t opcode) __attribute__((const));
|
2022-01-05 10:09:07 +00:00
|
|
|
|
|
|
|
typedef struct opcode_s {
|
|
|
|
const char *opname;
|
|
|
|
const char *mnemonic;
|
2022-01-05 13:33:59 +00:00
|
|
|
int widths[3]; ///< component count for each argument (1-4)
|
|
|
|
etype_t types[3]; ///< component type for each argument
|
2022-01-05 10:09:07 +00:00
|
|
|
const char *fmt;
|
|
|
|
} opcode_t;
|
|
|
|
extern const opcode_t pr_opcodes[512];
|
|
|
|
const opcode_t *PR_Opcode (pr_ushort_t opcode) __attribute__((const));
|
|
|
|
|
2011-01-19 02:35:34 +00:00
|
|
|
typedef struct dstatement_s {
|
[gamecode] Add a new Ruamoko instruction set
When it's finalized (most of the conversion operations will go, probably
the float bit ops, maybe (very undecided) the 3-component vector ops,
and likely the CALLN ops), this will be the actual instruction set for
Ruamoko.
Main features:
- Significant reduction in redundant instructions: no more multiple
opcodes to move the one operand size.
- load, store, push, and pop share unified addressing mode encoding
(with the exception of mode 0 for load as that is redundant with mode
0 for store, thus load mode 0 gives quick access to entity.field).
- Full support for both 32 and 64 bit signed integer, unsigned integer,
and floating point values.
- SIMD for 1, 2, (currently) 3, and 4 components. Transfers support up
to 128-bit wide operations (need two operations to transfer a full
4-component double/long vector), but all math operations support both
128-bit (32-bit components) and 256-bit (64-bit components) vectors.
- "Interpreted" operations for the various vector sizes: complex dot
and multiplication, 3d vector dot and cross product, quaternion dot
and multiplication, along with qv and vq shortcuts.
- 4-component swizzles for both sizes (not yet implemented, but the
instructions are allocated), with the option to zero or negate (thus
conjugates for complex and quaternion values) individual components.
- "Based offsets": all relevant instructions include base register
indices for all three operands allowing for direct access to any of
four areas (eg, current entity, current stack frame, Objective-QC
self, ...) instructions to set a register and push/pop the four
registers to/from the stack.
Remaining work:
- Implement swizzle operations and a few other stragglers.
= Make a decision about conversion operations (if any instructions
remain, they'll be just single-component (at 14 meaningful pairs,
that's a lot of instructions to waste on SIMD versions).
- Decide whether to keep CALL1-CALL8: probably little point in
supporting two different calling conventions, and it would free up
another eight instructions.
- Unit tests for the instructions.
- Teach qfcc to generate code for the new instruction set (hah, biggest
job, I'm sure, though hopefully not as crazy as the rewrite eleven
years ago).
2022-01-02 14:15:15 +00:00
|
|
|
pr_opcode_e op:16; // will be pr_opcode_v6p_e for older progs
|
2007-04-04 12:30:49 +00:00
|
|
|
pr_ushort_t a,b,c;
|
2014-02-03 07:47:51 +00:00
|
|
|
} GCC_STRUCT dstatement_t;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-01 06:58:32 +00:00
|
|
|
typedef struct ddef_s {
|
2020-02-23 13:21:25 +00:00
|
|
|
pr_ushort_t type; // if DEF_SAVEGLOBAL bit is set
|
2001-02-19 21:15:25 +00:00
|
|
|
// the variable needs to be saved in savegames
|
2007-04-04 12:30:49 +00:00
|
|
|
pr_ushort_t ofs;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_string_t name;
|
2001-02-19 21:15:25 +00:00
|
|
|
} ddef_t;
|
|
|
|
|
2020-02-22 05:11:15 +00:00
|
|
|
typedef struct xdef_s {
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t type; ///< pointer to type definition
|
|
|
|
pr_ptr_t ofs; ///< 32-bit version of ddef_t.ofs
|
2020-02-22 05:11:15 +00:00
|
|
|
} xdef_t;
|
|
|
|
|
|
|
|
typedef struct pr_xdefs_s {
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t xdefs;
|
2020-02-22 05:11:15 +00:00
|
|
|
pr_int_t num_xdefs;
|
|
|
|
} pr_xdefs_t;
|
|
|
|
|
2020-02-22 13:33:44 +00:00
|
|
|
typedef struct pr_def_s {
|
2020-02-23 14:29:58 +00:00
|
|
|
pr_ushort_t type;
|
|
|
|
pr_ushort_t size; ///< may not be correct
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t ofs;
|
|
|
|
pr_string_t name;
|
|
|
|
pr_ptr_t type_encoding;
|
2020-02-22 13:33:44 +00:00
|
|
|
} pr_def_t;
|
|
|
|
|
2020-02-16 08:10:43 +00:00
|
|
|
typedef struct dparmsize_s {
|
|
|
|
uint8_t size:5;
|
|
|
|
uint8_t alignment:3;
|
|
|
|
} dparmsize_t;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#define DEF_SAVEGLOBAL (1<<15)
|
|
|
|
|
2022-01-23 05:17:25 +00:00
|
|
|
#define PR_MAX_PARAMS 8
|
2022-02-05 09:37:23 +00:00
|
|
|
#define PR_MAX_RETURN 32 // maximum size of return value
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2002-06-01 06:58:32 +00:00
|
|
|
typedef struct dfunction_s {
|
2007-04-04 12:30:49 +00:00
|
|
|
pr_int_t first_statement; // negative numbers are builtins
|
2022-01-27 01:55:06 +00:00
|
|
|
pr_uint_t params_start; // beginning of locals data space
|
|
|
|
pr_uint_t locals; // total ints of params + locals
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2020-02-25 12:23:13 +00:00
|
|
|
pr_uint_t profile; // runtime
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_string_t name; // source function name
|
|
|
|
pr_string_t file; // source file defined in
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2022-01-27 01:55:06 +00:00
|
|
|
pr_int_t numparams; // -ve is varargs (1s comp of real count)
|
|
|
|
dparmsize_t param_size[PR_MAX_PARAMS];
|
2001-02-19 21:15:25 +00:00
|
|
|
} dfunction_t;
|
|
|
|
|
2022-04-26 06:10:00 +00:00
|
|
|
typedef struct pr_type_s {
|
|
|
|
union {
|
|
|
|
pr_int_t value;
|
|
|
|
pr_uint_t uint_value;
|
|
|
|
pr_float_t float_value;
|
|
|
|
};
|
2002-06-07 20:56:54 +00:00
|
|
|
} pr_type_t;
|
|
|
|
|
2022-01-18 13:58:26 +00:00
|
|
|
typedef pr_type_t pr_void_t; // so size of void is 1
|
|
|
|
|
2002-10-16 22:17:26 +00:00
|
|
|
typedef struct pr_va_list_s {
|
2007-04-04 12:30:49 +00:00
|
|
|
pr_int_t count;
|
2022-01-18 03:11:14 +00:00
|
|
|
pr_ptr_t list; // pr_type_t
|
2002-10-16 22:17:26 +00:00
|
|
|
} pr_va_list_t;
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-01-09 10:41:24 +00:00
|
|
|
#define PROG_VERSION_ENCODE(a,b,c) \
|
|
|
|
( (((0x##a) & 0x0ff) << 24) \
|
|
|
|
|(((0x##b) & 0xfff) << 12) \
|
|
|
|
|(((0x##c) & 0xfff) << 0) )
|
2001-06-09 06:25:33 +00:00
|
|
|
#define PROG_ID_VERSION 6
|
2022-01-03 04:56:43 +00:00
|
|
|
#define PROG_V6P_VERSION PROG_VERSION_ENCODE(0,fff,00a)
|
|
|
|
#define PROG_VERSION PROG_VERSION_ENCODE(0,fff,010)
|
2001-06-09 06:25:33 +00:00
|
|
|
|
2022-01-26 10:30:25 +00:00
|
|
|
typedef struct pr_chunk_s {
|
|
|
|
pr_uint_t offset;
|
|
|
|
pr_uint_t count;
|
|
|
|
} pr_chunk_t;
|
|
|
|
|
2002-06-01 06:58:32 +00:00
|
|
|
typedef struct dprograms_s {
|
2007-04-04 12:30:49 +00:00
|
|
|
pr_uint_t version;
|
2022-01-26 10:30:25 +00:00
|
|
|
pr_uint_t crc; // checksum of header file
|
|
|
|
|
|
|
|
pr_chunk_t statements; // statement 0 is an error
|
|
|
|
pr_chunk_t globaldefs;
|
|
|
|
pr_chunk_t fielddefs;
|
|
|
|
pr_chunk_t functions; // function 0 is an empty
|
|
|
|
pr_chunk_t strings; // first string is a null string, count is bytes
|
|
|
|
pr_chunk_t globals;
|
2012-05-21 23:23:22 +00:00
|
|
|
|
2007-04-04 12:30:49 +00:00
|
|
|
pr_uint_t entityfields;
|
2001-02-19 21:15:25 +00:00
|
|
|
} dprograms_t;
|
|
|
|
|
2020-02-24 03:21:20 +00:00
|
|
|
#endif//__QF_pr_comp_h
|