• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2020 Google, Inc.
3  * Copyright © 2023 Valve Corporation
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
25 #ifndef _ISA_H_
26 #define _ISA_H_
27 
28 #include <stdlib.h>
29 
30 #include "compiler/isaspec/isaspec.h"
31 #include "afuc.h"
32 
__instruction_create(afuc_opc opc)33 static inline struct afuc_instr *__instruction_create(afuc_opc opc)
34 {
35    struct afuc_instr *instr = calloc(1, sizeof(struct afuc_instr));
36 
37    switch (opc) {
38 #define ALU(name) \
39    case OPC_##name##I: \
40       instr->opc = OPC_##name; \
41       instr->has_immed = true; \
42       break;
43    ALU(ADD)
44    ALU(ADDHI)
45    ALU(SUB)
46    ALU(SUBHI)
47    ALU(AND)
48    ALU(OR)
49    ALU(XOR)
50    ALU(NOT)
51    ALU(SHL)
52    ALU(USHR)
53    ALU(ISHR)
54    ALU(ROT)
55    ALU(MUL8)
56    ALU(MIN)
57    ALU(MAX)
58    ALU(CMP)
59 #undef ALU
60 
61    default:
62       instr->opc = opc;
63    }
64 
65    return instr;
66 }
67 
68 #endif /* _ISA_H_ */
69