Skip to content

Instantly share code, notes, and snippets.

@neobrain
Last active October 26, 2020 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neobrain/6ed5527c56c044c2985f14f25dbc7b8f to your computer and use it in GitHub Desktop.
Save neobrain/6ed5527c56c044c2985f14f25dbc7b8f to your computer and use it in GitHub Desktop.
ACO IR formatter
# Reads RADV_DEBUG output and formats ACO IR (skipping non-shader code)
# Usage:
# * awk log -f aco_format.awk
# * cat | awk -f aco_format.awk
BEGIN {
# All defs go into $1
FS="="
}
{
if (($0 ~ /^\s*[vs].+: %/) ||
($0 ~ /^\s*exp %/) ||
($0 ~ /^\s*p_unit_test /) ||
($0 ~ /^\s*p_logical_start\s*$/) ||
($0 ~ /^\s*p_logical_end\s*$/) ||
($0 ~ /^\s*s_endpgm\s*$/)) {
num_defs = NF > 1 ? split($1, defs, ",") : 0
formatted_defs = ""
for (def = 1; def <= num_defs; def++) {
sub(/^\s*/, "", defs[def])
formatted_defs = formatted_defs " "
if (num_defs > 1) {
# Print definition index
formatted_defs = formatted_defs sprintf("%s(%d) ", (def < 10) ? " " : "", def)
} else {
formatted_defs = formatted_defs " "
}
if (def != num_defs) {
formatted_defs = formatted_defs sprintf("%s,\n", defs[def])
} else {
formatted = sprintf("%s", defs[def])
formatted_defs = formatted_defs sprintf("%-24s= ", formatted)
}
}
printf("%s", formatted_defs)
if (formatted_defs == "") {
# Padding for def-less ops
printf("%35s", "")
}
for (i = NF > 1 ? 2 : 1; i <= NF; i++) {
sub(/^\s*/, "", $i)
printf("%s", $i)
}
print ""
} else {
print $0
}
}
ACO shader stage: vertex_vs
BB0
/* logical preds: / linear preds: / kind: uniform, top-level, export_end, */
(1) s2: %259:s[0-1],
(2) s1: %260:s[2],
(3) s1: %261:s[3],
(4) s1: %262:s[4],
(5) s1: %263:s[5],
(6) s1: %264:s[6],
(7) s1: %265:s[7],
(8) v1: %266:v[0],
(9) v1: %267:v[1],
(10) v1: %268:v[2],
(11) v1: %269:v[3],
(12) s2: %270:exec = p_startpgm
p_logical_start
s1: %403:s[2] = p_parallelcopy %263:s[5]
s2: %271:s[4-5] = p_create_vector %262:s[4], 0xffff8000
s4: %273:s[8-11] = s_load_dwordx4 %271:s[4-5], 0 storage: semantics: scope:invocation
v1: %274:v[0] = v_add_u32 %403:s[2], %266:v[0]
s4: %300:s[4-7] = s_load_dwordx4 %271:s[4-5], 16 storage: semantics: scope:invocation
v4: %40:v[4-7] = buffer_load_dwordx4 %300:s[4-7], %274:v[0], 0 idxen storage: semantics: scope:invocation
v2: %115:v[2-3] = buffer_load_dwordx2 %300:s[4-7], %274:v[0], 0 offset:16 idxen storage: semantics: scope:invocation
v4: %2:v[8-11] = tbuffer_load_format_xyzw %273:s[8-11], %274:v[0], 0 dfmt:8_8_8_8 nfmt:uint offset:4 idxen storage: semantics: scope:invocation
v4: %25:v[12-15] = tbuffer_load_format_xyzw %273:s[8-11], %274:v[0], 0 dfmt:8_8_8_8 nfmt:uint idxen storage: semantics: scope:invocation
v4: %149:v[16-19] = tbuffer_load_format_xyzw %273:s[8-11], %274:v[0], 0 dfmt:8_8_8_8 nfmt:uint offset:8 idxen storage: semantics: scope:invocation
s2: %16:s[0-1] = p_create_vector %261:s[3], 0xffff8000
(1) s1: %331:s[2],
(2) s1: %330:scc = s_add_i32 16, %261:s[3]
v2: %255:v[0-1] = tbuffer_load_format_xy %273:s[8-11], %274:v[0], 0 dfmt:16_16 nfmt:float offset:16 idxen storage: semantics: scope:invocation
s2: %81:s[2-3] = p_create_vector %331:s[2], 0xffff8000
s4: %333:s[4-7] = s_load_dwordx4 %81:s[2-3], 0 storage: semantics: scope:invocation
s4: %284:s[0-3] = s_load_dwordx4 %16:s[0-1], 0 storage: semantics: scope:invocation
s4: %20:s[8-11] = s_buffer_load_dwordx4 %284:s[0-3], 16 storage: semantics: scope:invocation
s4: %58:s[12-15] = s_buffer_load_dwordx4 %284:s[0-3], 64 storage: semantics: scope:invocation
s4: %66:s[16-19] = s_buffer_load_dwordx4 %284:s[0-3], 0x50 storage: semantics: scope:invocation
s4: %74:s[20-23] = s_buffer_load_dwordx4 %284:s[0-3], 0x60 storage: semantics: scope:invocation
s4: %84:s[24-27] = s_buffer_load_dwordx4 %333:s[4-7], 0x1d0 storage: semantics: scope:invocation
s4: %92:s[28-31] = s_buffer_load_dwordx4 %333:s[4-7], 0x1e0 storage: semantics: scope:invocation
s4: %100:s[32-35] = s_buffer_load_dwordx4 %333:s[4-7], 0x1b0 storage: semantics: scope:invocation
s4: %108:s[4-7] = s_buffer_load_dwordx4 %333:s[4-7], 0x1c0 storage: semantics: scope:invocation
s4: %123:s[36-39] = s_buffer_load_dwordx4 %284:s[0-3], 0x70 storage: semantics: scope:invocation
s4: %131:s[40-43] = s_buffer_load_dwordx4 %284:s[0-3], 0x80 storage: semantics: scope:invocation
s4: %139:s[0-3] = s_buffer_load_dwordx4 %284:s[0-3], 0x90 storage: semantics: scope:invocation
s1: %7:s[44] = s_brev_b32 1
v1: %279:v[20] = v_mov_b32 0xc3000000
s1: %17:s[45] = s_mov_b32 0x43800000
(1) v1: %275:v[8],
(2) v1: %276:v[9],
(3) v1: %277:v[10],
(4) v1: %278:v[11] = p_split_vector %2:v[8-11]
v1: %3:v[8] = v_cvt_f32_u32 %275:v[8]
v1: %4:v[9] = v_cvt_f32_u32 %276:v[9]
s2: %10:vcc = v_cmp_le_f32 0x43000000, %4:v[9]
v1: %11:v[20] = v_cndmask_b32 %7:s[44], %279:v[20], %10:vcc
v1: %15:v[9] = v_add_f32 %4:v[9], %11:v[20]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment