1 /* 2 * Copyright © 2020 Google, Inc. 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 24 #ifndef _ISA_H_ 25 #define _ISA_H_ 26 27 #include <stdbool.h> 28 #include <stdint.h> 29 30 #include <stdio.h> 31 32 struct isa_decode_value { 33 /** for {NAME} */ 34 const char *str; 35 /** for all other fields */ 36 uint64_t num; 37 }; 38 39 struct isa_decode_hook { 40 const char *fieldname; 41 void (*cb)(void *data, struct isa_decode_value *val); 42 }; 43 44 struct isa_decode_options { 45 uint32_t gpu_id; 46 47 /** show errors detected in decoding, like unexpected dontcare bits */ 48 bool show_errors; 49 50 /** 51 * If non-zero, maximum # of instructions that are unmatched before 52 * bailing, ie. to trigger stopping if we start trying to decode 53 * random garbage. 54 */ 55 unsigned max_errors; 56 57 /** Generate branch target labels */ 58 bool branch_labels; 59 60 /** 61 * Flag which can be set, for ex, but decode hook to trigger end of 62 * decoding 63 */ 64 bool stop; 65 66 /** 67 * Data passed back to decode hooks 68 */ 69 void *cbdata; 70 71 /** 72 * Callback for field decode 73 */ 74 void (*field_cb)(void *data, const char *field_name, struct isa_decode_value *val); 75 76 /** 77 * Callback prior to instruction decode 78 */ 79 void (*instr_cb)(void *data, unsigned n, void *instr); 80 }; 81 82 void isa_decode(void *bin, int sz, FILE *out, const struct isa_decode_options *options); 83 84 85 struct ir3_shader_variant; 86 void * isa_assemble(struct ir3_shader_variant *v); 87 88 #endif /* _ISA_H_ */ 89