/*1* Copyright © 2020 Google, Inc.2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*/2223#ifndef _ISA_H_24#define _ISA_H_2526#include <stdbool.h>27#include <stdint.h>2829#include <stdio.h>3031struct isa_decode_value {32/** for {NAME} */33const char *str;34/** for all other fields */35uint64_t num;36};3738struct isa_decode_hook {39const char *fieldname;40void (*cb)(void *data, struct isa_decode_value *val);41};4243struct isa_decode_options {44uint32_t gpu_id;4546/** show errors detected in decoding, like unexpected dontcare bits */47bool show_errors;4849/**50* If non-zero, maximum # of instructions that are unmatched before51* bailing, ie. to trigger stopping if we start trying to decode52* random garbage.53*/54unsigned max_errors;5556/** Generate branch target labels */57bool branch_labels;5859/**60* Flag which can be set, for ex, but decode hook to trigger end of61* decoding62*/63bool stop;6465/**66* Data passed back to decode hooks67*/68void *cbdata;6970/**71* Callback for field decode72*/73void (*field_cb)(void *data, const char *field_name, struct isa_decode_value *val);7475/**76* Callback prior to instruction decode77*/78void (*instr_cb)(void *data, unsigned n, uint64_t instr);79};8081void isa_decode(void *bin, int sz, FILE *out, const struct isa_decode_options *options);828384struct ir3_shader_variant;85void * isa_assemble(struct ir3_shader_variant *v);8687#endif /* _ISA_H_ */888990