• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2022 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * on the rights to use, copy, modify, merge, publish, distribute, sub
8  * license, and/or sell copies of the Software, and to permit persons to whom
9  * the Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18  * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21  * USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 #ifndef BRW_ISA_ENCODING_H
24 #define BRW_ISA_ENCODING_H
25 
26 #include "dev/intel_device_info.h"
27 #include "brw_eu_defines.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 struct opcode_desc;
34 
35 struct brw_isa_info {
36    const struct intel_device_info *devinfo;
37 
38    /* A mapping from enum opcode to the corresponding opcode_desc */
39    const struct opcode_desc *ir_to_descs[NUM_BRW_OPCODES];
40 
41    /** A mapping from a HW opcode encoding to the corresponding opcode_desc */
42    const struct opcode_desc *hw_to_descs[128];
43 };
44 
45 void brw_init_isa_info(struct brw_isa_info *isa,
46                        const struct intel_device_info *devinfo);
47 
48 struct opcode_desc {
49    unsigned ir;
50    unsigned hw;
51    const char *name;
52    int nsrc;
53    int ndst;
54    int gfx_vers;
55 };
56 
57 const struct opcode_desc *
58 brw_opcode_desc(const struct brw_isa_info *isa, enum opcode opcode);
59 
60 const struct opcode_desc *
61 brw_opcode_desc_from_hw(const struct brw_isa_info *isa, unsigned hw);
62 
63 static inline unsigned
brw_opcode_encode(const struct brw_isa_info * isa,enum opcode opcode)64 brw_opcode_encode(const struct brw_isa_info *isa, enum opcode opcode)
65 {
66    return brw_opcode_desc(isa, opcode)->hw;
67 }
68 
69 static inline enum opcode
brw_opcode_decode(const struct brw_isa_info * isa,unsigned hw)70 brw_opcode_decode(const struct brw_isa_info *isa, unsigned hw)
71 {
72    const struct opcode_desc *desc = brw_opcode_desc_from_hw(isa, hw);
73    return desc ? (enum opcode)desc->ir : BRW_OPCODE_ILLEGAL;
74 }
75 
76 static inline bool
is_3src(const struct brw_isa_info * isa,enum opcode opcode)77 is_3src(const struct brw_isa_info *isa, enum opcode opcode)
78 {
79    const struct opcode_desc *desc = brw_opcode_desc(isa, opcode);
80    return desc && desc->nsrc == 3;
81 }
82 
83 #ifdef __cplusplus
84 }
85 #endif
86 #endif
87