mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 07:28:11 +02:00
freedreno/decode: Add regex support for query-mode
Sometimes it is useful to query all regs matching a pattern. Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39319>
This commit is contained in:
parent
7841c556d7
commit
c4385d6fb0
1 changed files with 56 additions and 14 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <regex.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
|
@ -92,6 +93,7 @@ static int current_draw_count;
|
|||
* loaded:
|
||||
*/
|
||||
static int *queryvals;
|
||||
static int nqueryvals;
|
||||
|
||||
static bool
|
||||
quiet(int lvl)
|
||||
|
|
@ -792,6 +794,53 @@ static struct {
|
|||
|
||||
static struct rnn *rnn;
|
||||
|
||||
static void
|
||||
add_query_val(const char *querystr, int val)
|
||||
{
|
||||
printf("querystr: %s -> 0x%x\n", querystr, val);
|
||||
queryvals = realloc(queryvals, (nqueryvals + 1) * sizeof(!*queryvals));
|
||||
queryvals[nqueryvals] = val;
|
||||
nqueryvals++;
|
||||
}
|
||||
|
||||
static void
|
||||
add_query(const char *querystr)
|
||||
{
|
||||
int val = strtol(querystr, NULL, 0);
|
||||
|
||||
if (val) {
|
||||
add_query_val(querystr, val);
|
||||
return;
|
||||
}
|
||||
|
||||
regex_t regex;
|
||||
bool found = false;
|
||||
int ret;
|
||||
|
||||
ret = regcomp(®ex, querystr, REG_EXTENDED);
|
||||
if (ret) {
|
||||
errx(-1, "Invalid regex: %s\n", querystr);
|
||||
}
|
||||
|
||||
for (unsigned off = 0; off < regcnt(); off++) {
|
||||
const char *name = rnn_regname(rnn, off, false);
|
||||
|
||||
if (!name)
|
||||
continue;
|
||||
|
||||
ret = regexec(®ex, name, 0, NULL, 0);
|
||||
if (ret)
|
||||
continue;
|
||||
|
||||
add_query_val(name, off);
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
errx(-1, "no match: %s\n", querystr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
init_rnn(const char *gpuname)
|
||||
{
|
||||
|
|
@ -800,17 +849,10 @@ init_rnn(const char *gpuname)
|
|||
rnn_load(rnn, gpuname);
|
||||
|
||||
if (options->querystrs) {
|
||||
int i;
|
||||
queryvals = calloc(options->nquery, sizeof(queryvals[0]));
|
||||
|
||||
for (i = 0; i < options->nquery; i++) {
|
||||
int val = strtol(options->querystrs[i], NULL, 0);
|
||||
|
||||
if (val == 0)
|
||||
val = regbase(options->querystrs[i]);
|
||||
|
||||
queryvals[i] = val;
|
||||
printf("querystr: %s -> 0x%x\n", options->querystrs[i], queryvals[i]);
|
||||
/* If parsing multiple files, clear the old queryvals: */
|
||||
nqueryvals = 0;
|
||||
for (int i = 0; i < options->nquery; i++) {
|
||||
add_query(options->querystrs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1166,7 +1208,7 @@ skip_query(void)
|
|||
/* never skip: */
|
||||
return false;
|
||||
case QUERY_WRITTEN:
|
||||
for (int i = 0; i < options->nquery; i++) {
|
||||
for (int i = 0; i < nqueryvals; i++) {
|
||||
uint32_t regbase = queryvals[i];
|
||||
if (!reg_written(regbase)) {
|
||||
continue;
|
||||
|
|
@ -1177,7 +1219,7 @@ skip_query(void)
|
|||
}
|
||||
return true;
|
||||
case QUERY_DELTA:
|
||||
for (int i = 0; i < options->nquery; i++) {
|
||||
for (int i = 0; i < nqueryvals; i++) {
|
||||
uint32_t regbase = queryvals[i];
|
||||
if (!reg_written(regbase)) {
|
||||
continue;
|
||||
|
|
@ -1207,7 +1249,7 @@ __do_query(const char *primtype, uint32_t num_indices)
|
|||
bin_y2 = scissor_br >> 16;
|
||||
}
|
||||
|
||||
for (int i = 0; i < options->nquery; i++) {
|
||||
for (int i = 0; i < nqueryvals; i++) {
|
||||
uint32_t regbase = queryvals[i];
|
||||
if (!reg_written(regbase))
|
||||
continue;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue