xref: /aosp_15_r20/external/mesa3d/src/freedreno/afuc/isa.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2020 Google, Inc.
3  * Copyright © 2023 Valve Corporation
4  * SPDX-License-Identifier: MIT
5  */
6 
7 #ifndef _ISA_H_
8 #define _ISA_H_
9 
10 #include <stdlib.h>
11 
12 #include "compiler/isaspec/isaspec.h"
13 #include "afuc.h"
14 
__instruction_create(afuc_opc opc)15 static inline struct afuc_instr *__instruction_create(afuc_opc opc)
16 {
17    struct afuc_instr *instr = calloc(1, sizeof(struct afuc_instr));
18 
19    switch (opc) {
20 #define ALU(name) \
21    case OPC_##name##I: \
22       instr->opc = OPC_##name; \
23       instr->has_immed = true; \
24       break;
25    ALU(ADD)
26    ALU(ADDHI)
27    ALU(SUB)
28    ALU(SUBHI)
29    ALU(AND)
30    ALU(OR)
31    ALU(XOR)
32    ALU(NOT)
33    ALU(SHL)
34    ALU(USHR)
35    ALU(ISHR)
36    ALU(ROT)
37    ALU(MUL8)
38    ALU(MIN)
39    ALU(MAX)
40    ALU(CMP)
41 #undef ALU
42 
43    default:
44       instr->opc = opc;
45    }
46 
47    return instr;
48 }
49 
50 #endif /* _ISA_H_ */
51