-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisasm_config.h.in
More file actions
53 lines (45 loc) · 2.1 KB
/
disasm_config.h.in
File metadata and controls
53 lines (45 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#define VER_MAJOR @disasm_test_VERSION_MAJOR@
#define VER_MINOR @disasm_test_VERSION_MINOR@
#define VER_REVISION @disasm_test_VERSION_PATCH@
#define VER_EXTRA @disasm_test_VERSION_TWEAK@
#define xstr(s) astr(s)
#define astr(s) #s
#define VCIV_VERSION "" xstr(VER_MAJOR) "." xstr(VER_MINOR) "." xstr(VER_REVISION)
#cmakedefine IS_BE
#ifdef IS_BE
// read a little-endian 16bit word properly
#define READ_WORD(x) (uint16_t)((((uint16_t)(*((x)+1)) << 8))|(*(x)))
// read the little-endian 32bit dword as how SCALAR48 needs it
#define READ_DWORD_X(x) (uint32_t)((((uint32_t)READ_WORD((x)+2)) << 16)|READ_WORD(x))
// read as SCALAR32 expects it
#define READ_DWORD(x) (uint32_t)(((uint32_t)READ_WORD(x+2)) << 16)|READ_WORD((x))
#else
#define READ_WORD(x) (uint16_t)(*((uint16_t *)(x)))
#define READ_DWORD_X(x) (uint32_t)(*((uint32_t *)(x)))
#define READ_DWORD(x) [](uint8_t *ins)->int { \
auto b = (((uint32_t)READ_WORD(ins)) << 16); \
return (uint32_t)(b | READ_WORD(ins+2)); \
} (x)
#endif
//
// SCALAR16 -> x == 000? ????
// SCALAR32 -> x == 0001 000?
// SCALAR48 -> x == 0001 110?
// VECTOR48 -> x == 0001 1110
// VECTOR80 -> x == 0001 1111
#define IS_SCALAR16(x) (!((x) & 0x10))
#define IS_SCALAR48(x) (!IS_SCALAR16(x) && (((x) & 0x1c) && !((x) & 0x02)))
#define IS_VECTOR80(x) ((x) == 0x1f)
#define IS_VECTOR48(x) ((x) == 0x1e)
#define IS_SCALAR32(x) (!IS_SCALAR48(x) && !IS_VECTOR48(x) && !IS_VECTOR80(x) && !IS_SCALAR16(x))
#define P(x, y) vc4_parameter((x), (y))
#define PR(y) P(ParameterTypes::REGISTER, (uint32_t)(y))
#define PO(y) P(ParameterTypes::OFFSET, (int32_t)(y))
#define P_I(y) P(ParameterTypes::IMMEDIATE, (uint32_t)(y))
#define PD(y) P(ParameterTypes::DATA, (y))
#define PV(y) P(ParameterTypes::VECTOR_REGISTER, (y))
#define NI(n, f) (new INSTRUCTION_TYPE((n), (f)))
#define D(n) INSTRUCTION_TYPE *n(INSTRUCTION_STORAGE insn, uint32_t src_addr)
#define RV(n) return ((INSTRUCTION_TYPE *)(n))
#define DZ(n) INSTRUCTION_TYPE *n(INSTRUCTION_STORAGE insn, uint32_t src_addr, std::string opname)
#define GI INSTRUCTION_TYPE *getInstruction(uint8_t *buffer, uint32_t src_addr)