• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2022 Imagination Technologies Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * 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 THE
18  * 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 
24 #ifndef ROGUE_VALIDATE_H
25 #define ROGUE_VALIDATE_H
26 
27 #include <stdbool.h>
28 #include <stddef.h>
29 #include <stdint.h>
30 #include <sys/types.h>
31 
32 #include "rogue_instr.h"
33 #include "rogue_operand.h"
34 #include "rogue_shader.h"
35 #include "util/macros.h"
36 
37 /**
38  * \brief Register rule description.
39  */
40 struct rogue_register_rule {
41    enum rogue_register_access access;
42    size_t max;
43    enum rogue_register_modifier modifiers;
44 };
45 
46 /**
47  * \brief Instruction operand rule description.
48  */
49 struct rogue_instr_operand_rule {
50    uint64_t mask;
51    ssize_t min;
52    ssize_t max;
53    ssize_t align;
54 };
55 
56 /**
57  * \brief Instruction rule description.
58  */
59 struct rogue_instr_rule {
60    uint64_t flags; /** A mask of #rogue_instr_flag values. */
61    size_t num_operands;
62    struct rogue_instr_operand_rule *operand_rules;
63 };
64 
65 PUBLIC
66 bool rogue_validate_operand(const struct rogue_operand *operand);
67 
68 PUBLIC
69 bool rogue_validate_instr(const struct rogue_instr *instr);
70 
71 PUBLIC
72 bool rogue_validate_shader(const struct rogue_shader *shader);
73 
74 #endif /* ROGUE_VALIDATE_H */
75