Path: blob/21.2-virgl/src/freedreno/isa/ir3-disasm.c
4564 views
/*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#include <fcntl.h>24#include <stdbool.h>25#include <stdio.h>26#include <stdlib.h>27#include <sys/types.h>28#include <sys/stat.h>29#include <unistd.h>3031#include "util/os_file.h"3233#include "isa.h"343536static void37disasm_instr_cb(void *d, unsigned n, uint64_t instr)38{39uint32_t *dwords = (uint32_t *)&instr;40printf("%3d[%08x_%08x] ", n, dwords[1], dwords[0]);41}4243int44main(int argc, char **argv)45{46size_t sz;47void *raw = os_read_file(argv[1], &sz);4849isa_decode(raw, sz, stdout, &(struct isa_decode_options) {50.show_errors = true,51.branch_labels = true,52.instr_cb = disasm_instr_cb,53});5455return 0;56}575859