Alyssa Rosenzweig | eceaea4 | 2020-03-02 19:47:11 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 Collabora Ltd. |
| 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 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | * and/or sell copies of the Software, and to permit persons to whom the |
| 9 | * 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 NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | * SOFTWARE. |
| 22 | * |
| 23 | * Authors (Collabora): |
| 24 | * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> |
| 25 | */ |
| 26 | |
| 27 | #ifndef __BIFROST_COMPILER_H |
| 28 | #define __BIFROST_COMPILER_H |
| 29 | |
Alyssa Rosenzweig | e7dc2a7 | 2020-03-02 20:06:34 -0500 | [diff] [blame^] | 30 | /* Bifrost opcodes are tricky -- the same op may exist on both FMA and |
| 31 | * ADD with two completely different opcodes, and opcodes can be varying |
| 32 | * length in some cases. Then we have different opcodes for int vs float |
| 33 | * and then sometimes even for different typesizes. Further, virtually |
| 34 | * every op has a number of flags which depend on the op. In constrast |
| 35 | * to Midgard where you have a strict ALU/LDST/TEX division and within |
| 36 | * ALU you have strict int/float and that's it... here it's a *lot* more |
| 37 | * involved. As such, we use something much higher level for our IR, |
| 38 | * encoding "classes" of operations, letting the opcode details get |
| 39 | * sorted out at emit time. |
| 40 | * |
| 41 | * Please keep this list alphabetized. Please use a dictionary if you |
| 42 | * don't know how to do that. |
| 43 | */ |
| 44 | |
| 45 | enum bi_class { |
| 46 | BI_ADD, |
| 47 | BI_ATEST, |
| 48 | BI_BRANCH, |
| 49 | BI_CMP, |
| 50 | BI_BLEND, |
| 51 | BI_BITWISE, |
| 52 | BI_CONVERT, |
| 53 | BI_CSEL, |
| 54 | BI_DISCARD, |
| 55 | BI_FMA, |
| 56 | BI_FREXP, |
| 57 | BI_LOAD, |
| 58 | BI_LOAD_ATTR, |
| 59 | BI_LOAD_VAR, |
| 60 | BI_LOAD_VAR_ADDRESS, |
| 61 | BI_MINMAX, |
| 62 | BI_MOV, |
| 63 | BI_SHIFT, |
| 64 | BI_STORE, |
| 65 | BI_STORE_VAR, |
| 66 | BI_SPECIAL, /* _FAST, _TABLE on supported GPUs */ |
| 67 | BI_TEX, |
| 68 | BI_ROUND, |
| 69 | }; |
| 70 | |
| 71 | typedef struct { |
| 72 | struct list_head link; /* Must be first */ |
| 73 | enum bi_class type; |
| 74 | } bi_instruction; |
| 75 | |
| 76 | typedef struct { |
| 77 | struct list_head link; /* must be first */ |
| 78 | struct list_head instructions; /* list of bi_instructions */ |
| 79 | } bi_block; |
| 80 | |
Alyssa Rosenzweig | eceaea4 | 2020-03-02 19:47:11 -0500 | [diff] [blame] | 81 | typedef struct { |
| 82 | nir_shader *nir; |
Alyssa Rosenzweig | e7dc2a7 | 2020-03-02 20:06:34 -0500 | [diff] [blame^] | 83 | struct list_head blocks; /* list of bi_block */ |
Alyssa Rosenzweig | eceaea4 | 2020-03-02 19:47:11 -0500 | [diff] [blame] | 84 | } bi_context; |
| 85 | |
| 86 | #endif |