17ec681f3Smrg#!/usr/bin/env python3 27ec681f3Smrg 37ec681f3Smrgimport sys, io, re, json 47ec681f3Smrgfrom canonicalize import json_canonicalize 57ec681f3Smrg 67ec681f3Smrg######### BEGIN HARDCODED CONFIGURATION 77ec681f3Smrg 87ec681f3Smrggfx_versions = { 97ec681f3Smrg 'gfx6': [ 107ec681f3Smrg None, 117ec681f3Smrg 'asic_reg/gca/gfx_6_0_d.h', 127ec681f3Smrg 'asic_reg/gca/gfx_6_0_sh_mask.h', 137ec681f3Smrg 'asic_reg/gca/gfx_7_2_enum.h' # the file for gfx6 doesn't exist 147ec681f3Smrg ], 157ec681f3Smrg 'gfx7': [ 167ec681f3Smrg None, 177ec681f3Smrg 'asic_reg/gca/gfx_7_2_d.h', 187ec681f3Smrg 'asic_reg/gca/gfx_7_2_sh_mask.h', 197ec681f3Smrg 'asic_reg/gca/gfx_7_2_enum.h' 207ec681f3Smrg ], 217ec681f3Smrg 'gfx8': [ 227ec681f3Smrg None, 237ec681f3Smrg 'asic_reg/gca/gfx_8_0_d.h', 247ec681f3Smrg 'asic_reg/gca/gfx_8_0_sh_mask.h', 257ec681f3Smrg 'asic_reg/gca/gfx_8_0_enum.h', 267ec681f3Smrg ], 277ec681f3Smrg 'gfx81': [ 287ec681f3Smrg None, 297ec681f3Smrg 'asic_reg/gca/gfx_8_1_d.h', 307ec681f3Smrg 'asic_reg/gca/gfx_8_1_sh_mask.h', 317ec681f3Smrg 'asic_reg/gca/gfx_8_1_enum.h', 327ec681f3Smrg ], 337ec681f3Smrg 'gfx9': [ 347ec681f3Smrg 'vega10_ip_offset.h', 357ec681f3Smrg 'asic_reg/gc/gc_9_2_1_offset.h', 367ec681f3Smrg 'asic_reg/gc/gc_9_2_1_sh_mask.h', 377ec681f3Smrg 'vega10_enum.h', 387ec681f3Smrg ], 397ec681f3Smrg 'gfx10': [ 407ec681f3Smrg 'navi14_ip_offset.h', 417ec681f3Smrg 'asic_reg/gc/gc_10_1_0_offset.h', 427ec681f3Smrg 'asic_reg/gc/gc_10_1_0_sh_mask.h', 437ec681f3Smrg 'navi10_enum.h', 447ec681f3Smrg ], 457ec681f3Smrg 'gfx103': [ 467ec681f3Smrg 'sienna_cichlid_ip_offset.h', 477ec681f3Smrg 'asic_reg/gc/gc_10_3_0_offset.h', 487ec681f3Smrg 'asic_reg/gc/gc_10_3_0_sh_mask.h', 497ec681f3Smrg 'navi10_enum.h', # the file for gfx10.3 doesn't exist 507ec681f3Smrg ], 517ec681f3Smrg} 527ec681f3Smrg 537ec681f3Smrg# match: static const struct IP_BASE GC_BASE ={ { { { 0x00001260, 0x0000A000, 0x02402C00, 0, 0 } }, 547ec681f3Smrgre_base = re.compile(r'^static const struct IP_BASE.*GC_BASE\s*=\s*{ { { { (\w+), (\w+), (\w+), (\w+), (\w+).*} },\n') 557ec681f3Smrg 567ec681f3Smrg# match: #define mmSDMA0_DEC_START 0x0000 577ec681f3Smrg# match: #define ixSDMA0_DEC_START 0x0000 587ec681f3Smrg# match: #define regSDMA0_DEC_START 0x0000 597ec681f3Smrgre_offset = re.compile(r'^#define (?P<mm>(mm|ix|reg))(?P<name>\w+)\s+(?P<value>\w+)\n') 607ec681f3Smrg 617ec681f3Smrg# match: #define SDMA0_DEC_START__START__SHIFT 0x0 627ec681f3Smrgre_shift = re.compile(r'^#define (?P<name>\w+)__(?P<field>\w+)__SHIFT\s+(?P<value>\w+)\n') 637ec681f3Smrg 647ec681f3Smrg# match: #define SDMA0_DEC_START__START_MASK 0xFFFFFFFFL 657ec681f3Smrg# match: #define SDMA0_DEC_START__START_MASK 0xFFFFFFFF 667ec681f3Smrgre_mask = re.compile(r'^#define (?P<name>\w+)__(?P<field>\w+)_MASK\s+(?P<value>[0-9a-fA-Fx]+)L?\n') 677ec681f3Smrg 687ec681f3Smrgdef register_filter(gfx_version, name, offset, already_added): 697ec681f3Smrg # Only accept writeable registers and debug registers 707ec681f3Smrg return ((offset // 0x1000 in [0xB, 0x28, 0x30, 0x31, 0x34, 0x35, 0x36, 0x37] or 717ec681f3Smrg # Add SQ_WAVE registers for trap handlers 727ec681f3Smrg name.startswith('SQ_WAVE_') or 737ec681f3Smrg # Add registers in the 0x8000 range used by all generations 747ec681f3Smrg (offset // 0x1000 == 0x8 and 757ec681f3Smrg (name.startswith('SQ_IMG_') or 767ec681f3Smrg name.startswith('SQ_BUF_') or 777ec681f3Smrg name.startswith('SQ_THREAD') or 787ec681f3Smrg name.startswith('GRBM_STATUS') or 797ec681f3Smrg name.startswith('CP_CP'))) or 807ec681f3Smrg # Add all registers in the 0x8000 range for gfx6 817ec681f3Smrg (gfx_version == 'gfx6' and offset // 0x1000 == 0x8) or 827ec681f3Smrg # Add registers in the 0x9000 range 837ec681f3Smrg (offset // 0x1000 == 0x9 and 847ec681f3Smrg (name in ['TA_CS_BC_BASE_ADDR', 'GB_ADDR_CONFIG', 'SPI_CONFIG_CNTL'] or 857ec681f3Smrg (name.startswith('GB') and 'TILE_MODE' in name)))) and 867ec681f3Smrg # Remove SQ compiler definitions 877ec681f3Smrg offset // 4 not in (0x23B0, 0x23B1, 0x237F) and 887ec681f3Smrg # Remove conflicts (multiple definitions for the same offset) 897ec681f3Smrg not already_added and 907ec681f3Smrg 'PREF_PRI_ACCUM' not in name) 917ec681f3Smrg 927ec681f3Smrg# Mapping from field names to enum types 937ec681f3Smrgenum_map = { 947ec681f3Smrg # Format: 957ec681f3Smrg # field: [type1] - all registers use the same enum 967ec681f3Smrg # OR: 977ec681f3Smrg # field: [type1, reg1, type2, reg2, ...] - apply different enums to different registers 987ec681f3Smrg "ALPHA_COMB_FCN": ["CombFunc", "CB_BLEND0_CONTROL", "SX_OPT_COMB_FCN", "SX_MRT0_BLEND_OPT"], 997ec681f3Smrg "ALPHA_DESTBLEND": ["BlendOp"], 1007ec681f3Smrg "ALPHA_DST_OPT": ["SX_BLEND_OPT"], 1017ec681f3Smrg "ALPHA_SRCBLEND": ["BlendOp"], 1027ec681f3Smrg "ALPHA_SRC_OPT": ["SX_BLEND_OPT"], 1037ec681f3Smrg "ARRAY_MODE": ["ArrayMode"], 1047ec681f3Smrg "BANK_HEIGHT": ["BankHeight"], 1057ec681f3Smrg "BANK_WIDTH": ["BankWidth"], 1067ec681f3Smrg "BC_SWIZZLE": ["SQ_IMG_RSRC_WORD4__BC_SWIZZLE"], 1077ec681f3Smrg "BIN_MAPPING_MODE": ["BinMapMode"], 1087ec681f3Smrg "BINNING_MODE": ["BinningMode"], 1097ec681f3Smrg "BIN_SIZE_X_EXTEND": ["BinSizeExtend"], 1107ec681f3Smrg "BIN_SIZE_Y_EXTEND": ["BinSizeExtend"], 1117ec681f3Smrg "BLEND_OPT_DISCARD_PIXEL": ["BlendOpt"], 1127ec681f3Smrg "BLEND_OPT_DONT_RD_DST": ["BlendOpt"], 1137ec681f3Smrg "BORDER_COLOR_TYPE": ["SQ_TEX_BORDER_COLOR"], 1147ec681f3Smrg "BUF_TYPE": ["VGT_DMA_BUF_TYPE"], 1157ec681f3Smrg "CLAMP_X": ["SQ_TEX_CLAMP"], 1167ec681f3Smrg "CLAMP_Y": ["SQ_TEX_CLAMP"], 1177ec681f3Smrg "CLAMP_Z": ["SQ_TEX_CLAMP"], 1187ec681f3Smrg "CLEAR_FILTER_SEL": ["CBPerfClearFilterSel"], 1197ec681f3Smrg "CLIP_RULE": ["CLIP_RULE"], 1207ec681f3Smrg "CMASK_ADDR_TYPE": ["CmaskAddr"], 1217ec681f3Smrg "CMASK_RD_POLICY": ["ReadPolicy"], 1227ec681f3Smrg "CMASK_WR_POLICY": ["WritePolicy"], 1237ec681f3Smrg "COL0_EXPORT_FORMAT": ["SPI_SHADER_EX_FORMAT"], 1247ec681f3Smrg "COL1_EXPORT_FORMAT": ["SPI_SHADER_EX_FORMAT"], 1257ec681f3Smrg "COL2_EXPORT_FORMAT": ["SPI_SHADER_EX_FORMAT"], 1267ec681f3Smrg "COL3_EXPORT_FORMAT": ["SPI_SHADER_EX_FORMAT"], 1277ec681f3Smrg "COL4_EXPORT_FORMAT": ["SPI_SHADER_EX_FORMAT"], 1287ec681f3Smrg "COL5_EXPORT_FORMAT": ["SPI_SHADER_EX_FORMAT"], 1297ec681f3Smrg "COL6_EXPORT_FORMAT": ["SPI_SHADER_EX_FORMAT"], 1307ec681f3Smrg "COL7_EXPORT_FORMAT": ["SPI_SHADER_EX_FORMAT"], 1317ec681f3Smrg "COLOR_COMB_FCN": ["CombFunc", "CB_BLEND0_CONTROL", "SX_OPT_COMB_FCN", "SX_MRT0_BLEND_OPT"], 1327ec681f3Smrg "COLOR_DESTBLEND": ["BlendOp"], 1337ec681f3Smrg "COLOR_DST_OPT": ["SX_BLEND_OPT"], 1347ec681f3Smrg "COLOR_RD_POLICY": ["ReadPolicy"], 1357ec681f3Smrg "COLOR_SRCBLEND": ["BlendOp"], 1367ec681f3Smrg "COLOR_SRC_OPT": ["SX_BLEND_OPT"], 1377ec681f3Smrg "COLOR_WR_POLICY": ["WritePolicy"], 1387ec681f3Smrg "COMPAREFUNC0": ["CompareFrag"], 1397ec681f3Smrg "COMPAREFUNC1": ["CompareFrag"], 1407ec681f3Smrg "COMP_SWAP": ["SurfaceSwap"], 1417ec681f3Smrg "CONSERVATIVE_Z_EXPORT": ["ConservativeZExport"], 1427ec681f3Smrg "COVERAGE_TO_SHADER_SELECT": ["CovToShaderSel"], 1437ec681f3Smrg "CUT_MODE": ["VGT_GS_CUT_MODE"], 1447ec681f3Smrg "DATA_FORMAT": ["BUF_DATA_FORMAT", "SQ_BUF_RSRC_WORD3", "IMG_DATA_FORMAT", "SQ_IMG_RSRC_WORD1"], 1457ec681f3Smrg "DCC_RD_POLICY": ["ReadPolicy"], 1467ec681f3Smrg "DCC_WR_POLICY": ["WritePolicy"], 1477ec681f3Smrg "DEPTH_COMPARE_FUNC": ["SQ_TEX_DEPTH_COMPARE"], 1487ec681f3Smrg "DETECT_ONE": ["VGT_DETECT_ONE"], 1497ec681f3Smrg "DETECT_ZERO": ["VGT_DETECT_ZERO"], 1507ec681f3Smrg "DISTRIBUTION_MODE": ["VGT_DIST_MODE"], 1517ec681f3Smrg "DST_SEL_W": ["SQ_SEL_XYZW01"], 1527ec681f3Smrg "DST_SEL_X": ["SQ_SEL_XYZW01"], 1537ec681f3Smrg "DST_SEL_Y": ["SQ_SEL_XYZW01"], 1547ec681f3Smrg "DST_SEL_Z": ["SQ_SEL_XYZW01"], 1557ec681f3Smrg "ENDIAN": ["SurfaceEndian"], 1567ec681f3Smrg "ES_EN": ["VGT_STAGES_ES_EN"], 1577ec681f3Smrg "EVENT_TYPE": ["VGT_EVENT_TYPE"], 1587ec681f3Smrg "EXCP": ["EXCP_EN"], 1597ec681f3Smrg "EXCP_EN": ["EXCP_EN"], 1607ec681f3Smrg "FAULT_BEHAVIOR": ["DbPRTFaultBehavior"], 1617ec681f3Smrg "FILTER_MODE": ["SQ_IMG_FILTER_TYPE"], 1627ec681f3Smrg "FLOAT_MODE": ["FLOAT_MODE"], 1637ec681f3Smrg "FMASK_RD_POLICY": ["ReadPolicy"], 1647ec681f3Smrg "FMASK_WR_POLICY": ["WritePolicy"], 1657ec681f3Smrg "FORCE_FULL_Z_RANGE": ["ForceControl"], 1667ec681f3Smrg "FORCE_HIS_ENABLE0": ["ForceControl"], 1677ec681f3Smrg "FORCE_HIS_ENABLE1": ["ForceControl"], 1687ec681f3Smrg "FORCE_HIZ_ENABLE": ["ForceControl"], 1697ec681f3Smrg "FORCE_Z_LIMIT_SUMM": ["ZLimitSumm"], 1707ec681f3Smrg "FORMAT": ["ColorFormat", "CB_COLOR0_INFO", "StencilFormat", "DB_STENCIL_INFO", "ZFormat", "DB_Z_INFO"], 1717ec681f3Smrg "GS_EN": ["VGT_STAGES_GS_EN"], 1727ec681f3Smrg "HIZ_ZFUNC": ["CompareFrag"], 1737ec681f3Smrg "HS_EN": ["VGT_STAGES_HS_EN"], 1747ec681f3Smrg "HTILE_RD_POLICY": ["ReadPolicy"], 1757ec681f3Smrg "HTILE_WR_POLICY": ["WritePolicy"], 1767ec681f3Smrg "IDX0_EXPORT_FORMAT": ["SPI_SHADER_FORMAT"], 1777ec681f3Smrg "INDEX_TYPE": ["VGT_INDEX_TYPE_MODE"], 1787ec681f3Smrg "LS_EN": ["VGT_STAGES_LS_EN"], 1797ec681f3Smrg "MACRO_TILE_ASPECT": ["MacroTileAspect"], 1807ec681f3Smrg "MAJOR_MODE": ["VGT_DI_MAJOR_MODE_SELECT"], 1817ec681f3Smrg "MAX_UNCOMPRESSED_BLOCK_SIZE": ["CB_COLOR_DCC_CONTROL__MAX_UNCOMPRESSED_BLOCK_SIZE"], 1827ec681f3Smrg "MICRO_TILE_MODE": ["GB_TILE_MODE0__MICRO_TILE_MODE"], 1837ec681f3Smrg "MICRO_TILE_MODE_NEW": ["MicroTileMode"], 1847ec681f3Smrg "MIN_COMPRESSED_BLOCK_SIZE": ["CB_COLOR_DCC_CONTROL__MIN_COMPRESSED_BLOCK_SIZE"], 1857ec681f3Smrg "MIP_FILTER": ["SQ_TEX_MIP_FILTER"], 1867ec681f3Smrg "MODE": ["CBMode", "CB_COLOR_CONTROL", "VGT_GS_MODE_TYPE", "VGT_GS_MODE"], 1877ec681f3Smrg "MRT0_EPSILON": ["SX_BLEND_OPT_EPSILON__MRT0_EPSILON"], 1887ec681f3Smrg "MRT0": ["SX_DOWNCONVERT_FORMAT"], 1897ec681f3Smrg "MRT1": ["SX_DOWNCONVERT_FORMAT"], 1907ec681f3Smrg "MRT2": ["SX_DOWNCONVERT_FORMAT"], 1917ec681f3Smrg "MRT3": ["SX_DOWNCONVERT_FORMAT"], 1927ec681f3Smrg "MRT4": ["SX_DOWNCONVERT_FORMAT"], 1937ec681f3Smrg "MRT5": ["SX_DOWNCONVERT_FORMAT"], 1947ec681f3Smrg "MRT6": ["SX_DOWNCONVERT_FORMAT"], 1957ec681f3Smrg "MRT7": ["SX_DOWNCONVERT_FORMAT"], 1967ec681f3Smrg "NUM_BANKS": ["NumBanks"], 1977ec681f3Smrg "NUM_FORMAT": ["BUF_NUM_FORMAT", "SQ_BUF_RSRC_WORD3", "IMG_NUM_FORMAT", "SQ_IMG_RSRC_WORD1"], 1987ec681f3Smrg "NUMBER_TYPE": ["SurfaceNumber"], 1997ec681f3Smrg "OFFCHIP_GRANULARITY": ["VGT_HS_OFFCHIP_PARAM__OFFCHIP_GRANULARITY"], 2007ec681f3Smrg "OP_FILTER_SEL": ["CBPerfOpFilterSel"], 2017ec681f3Smrg "OUTPRIM_TYPE_1": ["VGT_GS_OUTPRIM_TYPE"], 2027ec681f3Smrg "OUTPRIM_TYPE_2": ["VGT_GS_OUTPRIM_TYPE"], 2037ec681f3Smrg "OUTPRIM_TYPE_3": ["VGT_GS_OUTPRIM_TYPE"], 2047ec681f3Smrg "OUTPRIM_TYPE": ["VGT_GS_OUTPRIM_TYPE"], 2057ec681f3Smrg "PARTIAL_SQUAD_LAUNCH_CONTROL": ["DbPSLControl"], 2067ec681f3Smrg "PARTITIONING": ["VGT_TESS_PARTITION"], 2077ec681f3Smrg "PERFMON_ENABLE_MODE": ["CP_PERFMON_ENABLE_MODE"], 2087ec681f3Smrg "PERFMON_STATE": ["CP_PERFMON_STATE"], 2097ec681f3Smrg "PIPE_CONFIG": ["PipeConfig"], 2107ec681f3Smrg "PKR_MAP": ["PkrMap"], 2117ec681f3Smrg "PKR_XSEL2": ["PkrXsel2"], 2127ec681f3Smrg "PKR_XSEL": ["PkrXsel"], 2137ec681f3Smrg "PKR_YSEL": ["PkrYsel"], 2147ec681f3Smrg "PNT_SPRITE_OVRD_W": ["SPI_PNT_SPRITE_OVERRIDE"], 2157ec681f3Smrg "PNT_SPRITE_OVRD_X": ["SPI_PNT_SPRITE_OVERRIDE"], 2167ec681f3Smrg "PNT_SPRITE_OVRD_Y": ["SPI_PNT_SPRITE_OVERRIDE"], 2177ec681f3Smrg "PNT_SPRITE_OVRD_Z": ["SPI_PNT_SPRITE_OVERRIDE"], 2187ec681f3Smrg "POLYMODE_BACK_PTYPE": ["PA_SU_SC_MODE_CNTL__POLYMODE_FRONT_PTYPE"], 2197ec681f3Smrg "POLYMODE_FRONT_PTYPE": ["PA_SU_SC_MODE_CNTL__POLYMODE_FRONT_PTYPE"], 2207ec681f3Smrg "POLY_MODE": ["PA_SU_SC_MODE_CNTL__POLY_MODE"], 2217ec681f3Smrg "POS0_EXPORT_FORMAT": ["SPI_SHADER_FORMAT"], 2227ec681f3Smrg "POS1_EXPORT_FORMAT": ["SPI_SHADER_FORMAT"], 2237ec681f3Smrg "POS2_EXPORT_FORMAT": ["SPI_SHADER_FORMAT"], 2247ec681f3Smrg "POS3_EXPORT_FORMAT": ["SPI_SHADER_FORMAT"], 2257ec681f3Smrg "POS4_EXPORT_FORMAT": ["SPI_SHADER_FORMAT"], 2267ec681f3Smrg "PRIM_TYPE": ["VGT_DI_PRIM_TYPE"], 2277ec681f3Smrg "PUNCHOUT_MODE": ["DB_DFSM_CONTROL__PUNCHOUT_MODE"], 2287ec681f3Smrg "QUANT_MODE": ["QUANT_MODE"], 2297ec681f3Smrg "RB_MAP_PKR0": ["RbMap"], 2307ec681f3Smrg "RB_MAP_PKR1": ["RbMap"], 2317ec681f3Smrg "RB_XSEL2": ["RbXsel2"], 2327ec681f3Smrg "RB_XSEL": ["RbXsel"], 2337ec681f3Smrg "RB_YSEL": ["RbYsel"], 2347ec681f3Smrg "ROP3": ["ROP3"], 2357ec681f3Smrg "RDREQ_POLICY": ["VGT_RDREQ_POLICY"], 2367ec681f3Smrg "REG_INCLUDE": ["ThreadTraceRegInclude"], 2377ec681f3Smrg "ROUND_MODE": ["PA_SU_VTX_CNTL__ROUND_MODE", "PA_SU_VTX_CNTL"], 2387ec681f3Smrg "SC_MAP": ["ScMap"], 2397ec681f3Smrg "SC_XSEL": ["ScXsel"], 2407ec681f3Smrg "SC_YSEL": ["ScYsel"], 2417ec681f3Smrg "SE_MAP": ["SeMap"], 2427ec681f3Smrg "SE_PAIR_MAP": ["SePairMap"], 2437ec681f3Smrg "SE_PAIR_XSEL": ["SePairXsel"], 2447ec681f3Smrg "SE_PAIR_YSEL": ["SePairYsel"], 2457ec681f3Smrg "SE_XSEL": ["SeXsel"], 2467ec681f3Smrg "SE_YSEL": ["SeYsel"], 2477ec681f3Smrg "SOURCE_SELECT": ["VGT_DI_SOURCE_SELECT"], 2487ec681f3Smrg "SPM_PERFMON_STATE": ["SPM_PERFMON_STATE"], 2497ec681f3Smrg "S_RD_POLICY": ["ReadPolicy"], 2507ec681f3Smrg "STENCILFAIL_BF": ["StencilOp"], 2517ec681f3Smrg "STENCILFAIL": ["StencilOp"], 2527ec681f3Smrg "STENCILFUNC_BF": ["CompareFrag"], 2537ec681f3Smrg "STENCILFUNC": ["CompareFrag"], 2547ec681f3Smrg "STENCILZFAIL_BF": ["StencilOp"], 2557ec681f3Smrg "STENCILZFAIL": ["StencilOp"], 2567ec681f3Smrg "STENCILZPASS_BF": ["StencilOp"], 2577ec681f3Smrg "STENCILZPASS": ["StencilOp"], 2587ec681f3Smrg "SWAP_MODE": ["VGT_DMA_SWAP_MODE"], 2597ec681f3Smrg "S_WR_POLICY": ["WritePolicy"], 2607ec681f3Smrg "TILE_SPLIT": ["TileSplit"], 2617ec681f3Smrg "TOKEN_EXCLUDE": ["ThreadTraceTokenExclude"], 2627ec681f3Smrg "TOPOLOGY": ["VGT_TESS_TOPOLOGY"], 2637ec681f3Smrg "TYPE": ["SQ_RSRC_BUF_TYPE", "SQ_BUF_RSRC_WORD3", "SQ_RSRC_IMG_TYPE", "SQ_IMG_RSRC_WORD3", "VGT_TESS_TYPE", "VGT_TF_PARAM"], 2647ec681f3Smrg "UNCERTAINTY_REGION_MODE": ["ScUncertaintyRegionMode"], 2657ec681f3Smrg "VRS_HTILE_ENCODING": ["VRSHtileEncoding"], 2667ec681f3Smrg "VS_EN": ["VGT_STAGES_VS_EN"], 2677ec681f3Smrg "XY_MAG_FILTER": ["SQ_TEX_XY_FILTER"], 2687ec681f3Smrg "XY_MIN_FILTER": ["SQ_TEX_XY_FILTER"], 2697ec681f3Smrg "Z_EXPORT_FORMAT": ["SPI_SHADER_EX_FORMAT"], 2707ec681f3Smrg "Z_FILTER": ["SQ_TEX_Z_FILTER"], 2717ec681f3Smrg "ZFUNC": ["CompareFrag"], 2727ec681f3Smrg "Z_ORDER": ["ZOrder"], 2737ec681f3Smrg "ZPCPSD_WR_POLICY": ["WritePolicy"], 2747ec681f3Smrg "Z_RD_POLICY": ["ReadPolicy"], 2757ec681f3Smrg "Z_WR_POLICY": ["WritePolicy"], 2767ec681f3Smrg 2777ec681f3Smrg "VERTEX_RATE_COMBINER_MODE": ["VRSCombinerMode"], 2787ec681f3Smrg "PRIMITIVE_RATE_COMBINER_MODE": ["VRSCombinerMode"], 2797ec681f3Smrg "HTILE_RATE_COMBINER_MODE": ["VRSCombinerMode"], 2807ec681f3Smrg "SAMPLE_ITER_COMBINER_MODE": ["VRSCombinerMode"], 2817ec681f3Smrg "VRS_OVERRIDE_RATE_COMBINER_MODE": ["VRSCombinerMode"], 2827ec681f3Smrg} 2837ec681f3Smrg 2847ec681f3Smrg# Enum definitions that are incomplete or missing in kernel headers 2857ec681f3SmrgDB_DFSM_CONTROL__PUNCHOUT_MODE = { 2867ec681f3Smrg "entries": [ 2877ec681f3Smrg {"name": "AUTO", "value": 0}, 2887ec681f3Smrg {"name": "FORCE_ON", "value": 1}, 2897ec681f3Smrg {"name": "FORCE_OFF", "value": 2}, 2907ec681f3Smrg {"name": "RESERVED", "value": 3} 2917ec681f3Smrg ] 2927ec681f3Smrg} 2937ec681f3Smrg 2947ec681f3SmrgColorFormat = { 2957ec681f3Smrg "entries": [ 2967ec681f3Smrg {"name": "COLOR_INVALID", "value": 0}, 2977ec681f3Smrg {"name": "COLOR_8", "value": 1}, 2987ec681f3Smrg {"name": "COLOR_16", "value": 2}, 2997ec681f3Smrg {"name": "COLOR_8_8", "value": 3}, 3007ec681f3Smrg {"name": "COLOR_32", "value": 4}, 3017ec681f3Smrg {"name": "COLOR_16_16", "value": 5}, 3027ec681f3Smrg {"name": "COLOR_10_11_11", "value": 6}, 3037ec681f3Smrg {"name": "COLOR_11_11_10", "value": 7}, 3047ec681f3Smrg {"name": "COLOR_10_10_10_2", "value": 8}, 3057ec681f3Smrg {"name": "COLOR_2_10_10_10", "value": 9}, 3067ec681f3Smrg {"name": "COLOR_8_8_8_8", "value": 10}, 3077ec681f3Smrg {"name": "COLOR_32_32", "value": 11}, 3087ec681f3Smrg {"name": "COLOR_16_16_16_16", "value": 12}, 3097ec681f3Smrg {"name": "COLOR_32_32_32_32", "value": 14}, 3107ec681f3Smrg {"name": "COLOR_5_6_5", "value": 16}, 3117ec681f3Smrg {"name": "COLOR_1_5_5_5", "value": 17}, 3127ec681f3Smrg {"name": "COLOR_5_5_5_1", "value": 18}, 3137ec681f3Smrg {"name": "COLOR_4_4_4_4", "value": 19}, 3147ec681f3Smrg {"name": "COLOR_8_24", "value": 20}, 3157ec681f3Smrg {"name": "COLOR_24_8", "value": 21}, 3167ec681f3Smrg {"name": "COLOR_X24_8_32_FLOAT", "value": 22}, 3177ec681f3Smrg {"name": "COLOR_5_9_9_9", "value": 24} 3187ec681f3Smrg ] 3197ec681f3Smrg} 3207ec681f3Smrg 3217ec681f3SmrgSQ_IMG_RSRC_WORD4__BC_SWIZZLE = { 3227ec681f3Smrg "entries": [ 3237ec681f3Smrg {"name": "BC_SWIZZLE_XYZW", "value": 0}, 3247ec681f3Smrg {"name": "BC_SWIZZLE_XWYZ", "value": 1}, 3257ec681f3Smrg {"name": "BC_SWIZZLE_WZYX", "value": 2}, 3267ec681f3Smrg {"name": "BC_SWIZZLE_WXYZ", "value": 3}, 3277ec681f3Smrg {"name": "BC_SWIZZLE_ZYXW", "value": 4}, 3287ec681f3Smrg {"name": "BC_SWIZZLE_YXWZ", "value": 5} 3297ec681f3Smrg ] 3307ec681f3Smrg} 3317ec681f3Smrg 3327ec681f3SmrgSX_DOWNCONVERT_FORMAT = { 3337ec681f3Smrg "entries": [ 3347ec681f3Smrg {"name": "SX_RT_EXPORT_NO_CONVERSION", "value": 0}, 3357ec681f3Smrg {"name": "SX_RT_EXPORT_32_R", "value": 1}, 3367ec681f3Smrg {"name": "SX_RT_EXPORT_32_A", "value": 2}, 3377ec681f3Smrg {"name": "SX_RT_EXPORT_10_11_11", "value": 3}, 3387ec681f3Smrg {"name": "SX_RT_EXPORT_2_10_10_10", "value": 4}, 3397ec681f3Smrg {"name": "SX_RT_EXPORT_8_8_8_8", "value": 5}, 3407ec681f3Smrg {"name": "SX_RT_EXPORT_5_6_5", "value": 6}, 3417ec681f3Smrg {"name": "SX_RT_EXPORT_1_5_5_5", "value": 7}, 3427ec681f3Smrg {"name": "SX_RT_EXPORT_4_4_4_4", "value": 8}, 3437ec681f3Smrg {"name": "SX_RT_EXPORT_16_16_GR", "value": 9}, 3447ec681f3Smrg {"name": "SX_RT_EXPORT_16_16_AR", "value": 10}, 3457ec681f3Smrg {"name": "SX_RT_EXPORT_9_9_9_E5", "value": 11} 3467ec681f3Smrg ] 3477ec681f3Smrg} 3487ec681f3Smrg 3497ec681f3SmrgThreadTraceRegInclude = { 3507ec681f3Smrg "entries": [ 3517ec681f3Smrg {"name": "REG_INCLUDE_SQDEC", "value": 1}, 3527ec681f3Smrg {"name": "REG_INCLUDE_SHDEC", "value": 2}, 3537ec681f3Smrg {"name": "REG_INCLUDE_GFXUDEC", "value": 4}, 3547ec681f3Smrg {"name": "REG_INCLUDE_COMP", "value": 8}, 3557ec681f3Smrg {"name": "REG_INCLUDE_CONTEXT", "value": 16}, 3567ec681f3Smrg {"name": "REG_INCLUDE_CONFIG", "value": 32}, 3577ec681f3Smrg {"name": "REG_INCLUDE_OTHER", "value": 64}, 3587ec681f3Smrg {"name": "REG_INCLUDE_READS", "value": 128} 3597ec681f3Smrg ] 3607ec681f3Smrg} 3617ec681f3Smrg 3627ec681f3SmrgThreadTraceTokenExclude = { 3637ec681f3Smrg "entries": [ 3647ec681f3Smrg {"name": "TOKEN_EXCLUDE_VMEMEXEC", "value": 1}, 3657ec681f3Smrg {"name": "TOKEN_EXCLUDE_ALUEXEC", "value": 2}, 3667ec681f3Smrg {"name": "TOKEN_EXCLUDE_VALUINST", "value": 4}, 3677ec681f3Smrg {"name": "TOKEN_EXCLUDE_WAVERDY", "value": 8}, 3687ec681f3Smrg {"name": "TOKEN_EXCLUDE_IMMED1", "value": 16}, 3697ec681f3Smrg {"name": "TOKEN_EXCLUDE_IMMEDIATE", "value": 32}, 3707ec681f3Smrg {"name": "TOKEN_EXCLUDE_REG", "value": 64}, 3717ec681f3Smrg {"name": "TOKEN_EXCLUDE_EVENT", "value": 128}, 3727ec681f3Smrg {"name": "TOKEN_EXCLUDE_INST", "value": 256}, 3737ec681f3Smrg {"name": "TOKEN_EXCLUDE_UTILCTR", "value": 512}, 3747ec681f3Smrg {"name": "TOKEN_EXCLUDE_WAVEALLOC", "value": 1024}, 3757ec681f3Smrg {"name": "TOKEN_EXCLUDE_PERF", "value": 2048} 3767ec681f3Smrg ] 3777ec681f3Smrg} 3787ec681f3Smrg 3797ec681f3SmrgGB_TILE_MODE0__MICRO_TILE_MODE = { 3807ec681f3Smrg "entries": [ 3817ec681f3Smrg {"name": "ADDR_SURF_DISPLAY_MICRO_TILING", "value": 0}, 3827ec681f3Smrg {"name": "ADDR_SURF_THIN_MICRO_TILING", "value": 1}, 3837ec681f3Smrg {"name": "ADDR_SURF_DEPTH_MICRO_TILING", "value": 2}, 3847ec681f3Smrg {"name": "ADDR_SURF_THICK_MICRO_TILING_GFX6", "value": 3} 3857ec681f3Smrg ] 3867ec681f3Smrg} 3877ec681f3Smrg 3887ec681f3SmrgIMG_DATA_FORMAT_STENCIL = { 3897ec681f3Smrg "entries": [ 3907ec681f3Smrg {"name": "IMG_DATA_FORMAT_S8_16", "value": 59}, 3917ec681f3Smrg {"name": "IMG_DATA_FORMAT_S8_32", "value": 60}, 3927ec681f3Smrg ] 3937ec681f3Smrg} 3947ec681f3Smrg 3957ec681f3SmrgVRSCombinerMode = { 3967ec681f3Smrg "entries": [ 3977ec681f3Smrg {"name": "VRS_COMB_MODE_PASSTHRU", "value": 0}, 3987ec681f3Smrg {"name": "VRS_COMB_MODE_OVERRIDE", "value": 1}, 3997ec681f3Smrg {"name": "VRS_COMB_MODE_MIN", "value": 2}, 4007ec681f3Smrg {"name": "VRS_COMB_MODE_MAX", "value": 3}, 4017ec681f3Smrg {"name": "VRS_COMB_MODE_SATURATE", "value": 4}, 4027ec681f3Smrg ] 4037ec681f3Smrg} 4047ec681f3Smrg 4057ec681f3SmrgVRSHtileEncoding = { 4067ec681f3Smrg "entries": [ 4077ec681f3Smrg {"name": "VRS_HTILE_DISABLE", "value": 0}, 4087ec681f3Smrg {"name": "VRS_HTILE_2BIT_ENCODING", "value": 1}, 4097ec681f3Smrg {"name": "VRS_HTILE_4BIT_ENCODING", "value": 2}, 4107ec681f3Smrg ] 4117ec681f3Smrg} 4127ec681f3Smrg 4137ec681f3Smrgmissing_enums_all = { 4147ec681f3Smrg 'FLOAT_MODE': { 4157ec681f3Smrg "entries": [ 4167ec681f3Smrg {"name": "FP_32_DENORMS", "value": 48}, 4177ec681f3Smrg {"name": "FP_64_DENORMS", "value": 192}, 4187ec681f3Smrg {"name": "FP_ALL_DENORMS", "value": 240} 4197ec681f3Smrg ] 4207ec681f3Smrg }, 4217ec681f3Smrg 'QUANT_MODE': { 4227ec681f3Smrg "entries": [ 4237ec681f3Smrg {"name": "X_16_8_FIXED_POINT_1_16TH", "value": 0}, 4247ec681f3Smrg {"name": "X_16_8_FIXED_POINT_1_8TH", "value": 1}, 4257ec681f3Smrg {"name": "X_16_8_FIXED_POINT_1_4TH", "value": 2}, 4267ec681f3Smrg {"name": "X_16_8_FIXED_POINT_1_2", "value": 3}, 4277ec681f3Smrg {"name": "X_16_8_FIXED_POINT_1", "value": 4}, 4287ec681f3Smrg {"name": "X_16_8_FIXED_POINT_1_256TH", "value": 5}, 4297ec681f3Smrg {"name": "X_14_10_FIXED_POINT_1_1024TH", "value": 6}, 4307ec681f3Smrg {"name": "X_12_12_FIXED_POINT_1_4096TH", "value": 7} 4317ec681f3Smrg ] 4327ec681f3Smrg }, 4337ec681f3Smrg "CLIP_RULE": { 4347ec681f3Smrg "entries": [ 4357ec681f3Smrg {"name": "OUT", "value": 1}, 4367ec681f3Smrg {"name": "IN_0", "value": 2}, 4377ec681f3Smrg {"name": "IN_1", "value": 4}, 4387ec681f3Smrg {"name": "IN_10", "value": 8}, 4397ec681f3Smrg {"name": "IN_2", "value": 16}, 4407ec681f3Smrg {"name": "IN_20", "value": 32}, 4417ec681f3Smrg {"name": "IN_21", "value": 64}, 4427ec681f3Smrg {"name": "IN_210", "value": 128}, 4437ec681f3Smrg {"name": "IN_3", "value": 256}, 4447ec681f3Smrg {"name": "IN_30", "value": 512}, 4457ec681f3Smrg {"name": "IN_31", "value": 1024}, 4467ec681f3Smrg {"name": "IN_310", "value": 2048}, 4477ec681f3Smrg {"name": "IN_32", "value": 4096}, 4487ec681f3Smrg {"name": "IN_320", "value": 8192}, 4497ec681f3Smrg {"name": "IN_321", "value": 16384}, 4507ec681f3Smrg {"name": "IN_3210", "value": 32768} 4517ec681f3Smrg ] 4527ec681f3Smrg }, 4537ec681f3Smrg 'PA_SU_VTX_CNTL__ROUND_MODE': { 4547ec681f3Smrg "entries": [ 4557ec681f3Smrg {"name": "X_TRUNCATE", "value": 0}, 4567ec681f3Smrg {"name": "X_ROUND", "value": 1}, 4577ec681f3Smrg {"name": "X_ROUND_TO_EVEN", "value": 2}, 4587ec681f3Smrg {"name": "X_ROUND_TO_ODD", "value": 3} 4597ec681f3Smrg ] 4607ec681f3Smrg }, 4617ec681f3Smrg "PA_SU_SC_MODE_CNTL__POLYMODE_FRONT_PTYPE": { 4627ec681f3Smrg "entries": [ 4637ec681f3Smrg {"name": "X_DRAW_POINTS", "value": 0}, 4647ec681f3Smrg {"name": "X_DRAW_LINES", "value": 1}, 4657ec681f3Smrg {"name": "X_DRAW_TRIANGLES", "value": 2} 4667ec681f3Smrg ] 4677ec681f3Smrg }, 4687ec681f3Smrg "PA_SU_SC_MODE_CNTL__POLY_MODE": { 4697ec681f3Smrg "entries": [ 4707ec681f3Smrg {"name": "X_DISABLE_POLY_MODE", "value": 0}, 4717ec681f3Smrg {"name": "X_DUAL_MODE", "value": 1} 4727ec681f3Smrg ] 4737ec681f3Smrg }, 4747ec681f3Smrg 'VGT_HS_OFFCHIP_PARAM__OFFCHIP_GRANULARITY': { 4757ec681f3Smrg "entries": [ 4767ec681f3Smrg {"name": "X_8K_DWORDS", "value": 0}, 4777ec681f3Smrg {"name": "X_4K_DWORDS", "value": 1}, 4787ec681f3Smrg {"name": "X_2K_DWORDS", "value": 2}, 4797ec681f3Smrg {"name": "X_1K_DWORDS", "value": 3} 4807ec681f3Smrg ] 4817ec681f3Smrg }, 4827ec681f3Smrg "ROP3": { 4837ec681f3Smrg "entries": [ 4847ec681f3Smrg {"name": "ROP3_CLEAR", "value": 0}, 4857ec681f3Smrg {"name": "X_0X05", "value": 5}, 4867ec681f3Smrg {"name": "X_0X0A", "value": 10}, 4877ec681f3Smrg {"name": "X_0X0F", "value": 15}, 4887ec681f3Smrg {"name": "ROP3_NOR", "value": 17}, 4897ec681f3Smrg {"name": "ROP3_AND_INVERTED", "value": 34}, 4907ec681f3Smrg {"name": "ROP3_COPY_INVERTED", "value": 51}, 4917ec681f3Smrg {"name": "ROP3_AND_REVERSE", "value": 68}, 4927ec681f3Smrg {"name": "X_0X50", "value": 80}, 4937ec681f3Smrg {"name": "ROP3_INVERT", "value": 85}, 4947ec681f3Smrg {"name": "X_0X5A", "value": 90}, 4957ec681f3Smrg {"name": "X_0X5F", "value": 95}, 4967ec681f3Smrg {"name": "ROP3_XOR", "value": 102}, 4977ec681f3Smrg {"name": "ROP3_NAND", "value": 119}, 4987ec681f3Smrg {"name": "ROP3_AND", "value": 136}, 4997ec681f3Smrg {"name": "ROP3_EQUIVALENT", "value": 153}, 5007ec681f3Smrg {"name": "X_0XA0", "value": 160}, 5017ec681f3Smrg {"name": "X_0XA5", "value": 165}, 5027ec681f3Smrg {"name": "ROP3_NO_OP", "value": 170}, 5037ec681f3Smrg {"name": "X_0XAF", "value": 175}, 5047ec681f3Smrg {"name": "ROP3_OR_INVERTED", "value": 187}, 5057ec681f3Smrg {"name": "ROP3_COPY", "value": 204}, 5067ec681f3Smrg {"name": "ROP3_OR_REVERSE", "value": 221}, 5077ec681f3Smrg {"name": "ROP3_OR", "value": 238}, 5087ec681f3Smrg {"name": "X_0XF0", "value": 240}, 5097ec681f3Smrg {"name": "X_0XF5", "value": 245}, 5107ec681f3Smrg {"name": "X_0XFA", "value": 250}, 5117ec681f3Smrg {"name": "ROP3_SET", "value": 255} 5127ec681f3Smrg ] 5137ec681f3Smrg }, 5147ec681f3Smrg "EXCP_EN": { 5157ec681f3Smrg "entries": [ 5167ec681f3Smrg {"name": "INVALID", "value": 1}, 5177ec681f3Smrg {"name": "INPUT_DENORMAL", "value": 2}, 5187ec681f3Smrg {"name": "DIVIDE_BY_ZERO", "value": 4}, 5197ec681f3Smrg {"name": "OVERFLOW", "value": 8}, 5207ec681f3Smrg {"name": "UNDERFLOW", "value": 16}, 5217ec681f3Smrg {"name": "INEXACT", "value": 32}, 5227ec681f3Smrg {"name": "INT_DIVIDE_BY_ZERO", "value": 64}, 5237ec681f3Smrg {"name": "ADDRESS_WATCH", "value": 128}, 5247ec681f3Smrg {"name": "MEMORY_VIOLATION", "value": 256} 5257ec681f3Smrg ] 5267ec681f3Smrg } 5277ec681f3Smrg} 5287ec681f3Smrg 5297ec681f3Smrgmissing_enums_gfx8plus = { 5307ec681f3Smrg **missing_enums_all, 5317ec681f3Smrg 'CB_COLOR_DCC_CONTROL__MAX_UNCOMPRESSED_BLOCK_SIZE': { 5327ec681f3Smrg "entries": [ 5337ec681f3Smrg {"name": "MAX_BLOCK_SIZE_64B", "value": 0}, 5347ec681f3Smrg {"name": "MAX_BLOCK_SIZE_128B", "value": 1}, 5357ec681f3Smrg {"name": "MAX_BLOCK_SIZE_256B", "value": 2} 5367ec681f3Smrg ] 5377ec681f3Smrg }, 5387ec681f3Smrg 'CB_COLOR_DCC_CONTROL__MIN_COMPRESSED_BLOCK_SIZE': { 5397ec681f3Smrg "entries": [ 5407ec681f3Smrg {"name": "MIN_BLOCK_SIZE_32B", "value": 0}, 5417ec681f3Smrg {"name": "MIN_BLOCK_SIZE_64B", "value": 1} 5427ec681f3Smrg ] 5437ec681f3Smrg }, 5447ec681f3Smrg} 5457ec681f3Smrg 5467ec681f3Smrgmissing_enums_gfx81plus = { 5477ec681f3Smrg **missing_enums_gfx8plus, 5487ec681f3Smrg "SX_BLEND_OPT_EPSILON__MRT0_EPSILON": { 5497ec681f3Smrg "entries": [ 5507ec681f3Smrg {"name": "EXACT", "value": 0}, 5517ec681f3Smrg {"name": "11BIT_FORMAT", "value": 1}, 5527ec681f3Smrg {"name": "10BIT_FORMAT", "value": 3}, 5537ec681f3Smrg {"name": "8BIT_FORMAT", "value": 6}, 5547ec681f3Smrg {"name": "6BIT_FORMAT", "value": 11}, 5557ec681f3Smrg {"name": "5BIT_FORMAT", "value": 13}, 5567ec681f3Smrg {"name": "4BIT_FORMAT", "value": 15} 5577ec681f3Smrg ] 5587ec681f3Smrg }, 5597ec681f3Smrg} 5607ec681f3Smrg 5617ec681f3Smrgenums_missing = { 5627ec681f3Smrg 'gfx6': { 5637ec681f3Smrg **missing_enums_all, 5647ec681f3Smrg "GB_TILE_MODE0__MICRO_TILE_MODE": GB_TILE_MODE0__MICRO_TILE_MODE, 5657ec681f3Smrg }, 5667ec681f3Smrg 'gfx7': { 5677ec681f3Smrg **missing_enums_all, 5687ec681f3Smrg }, 5697ec681f3Smrg 'gfx8': { 5707ec681f3Smrg **missing_enums_gfx8plus, 5717ec681f3Smrg }, 5727ec681f3Smrg 'gfx81': { 5737ec681f3Smrg **missing_enums_gfx81plus, 5747ec681f3Smrg }, 5757ec681f3Smrg 'gfx9': { 5767ec681f3Smrg **missing_enums_gfx81plus, 5777ec681f3Smrg "DB_DFSM_CONTROL__PUNCHOUT_MODE": DB_DFSM_CONTROL__PUNCHOUT_MODE, 5787ec681f3Smrg "IMG_DATA_FORMAT_STENCIL": IMG_DATA_FORMAT_STENCIL, 5797ec681f3Smrg "SQ_IMG_RSRC_WORD4__BC_SWIZZLE": SQ_IMG_RSRC_WORD4__BC_SWIZZLE, 5807ec681f3Smrg }, 5817ec681f3Smrg 'gfx10': { 5827ec681f3Smrg **missing_enums_gfx81plus, 5837ec681f3Smrg "DB_DFSM_CONTROL__PUNCHOUT_MODE": DB_DFSM_CONTROL__PUNCHOUT_MODE, 5847ec681f3Smrg "ThreadTraceRegInclude": ThreadTraceRegInclude, 5857ec681f3Smrg "ThreadTraceTokenExclude": ThreadTraceTokenExclude, 5867ec681f3Smrg }, 5877ec681f3Smrg 'gfx103': { 5887ec681f3Smrg **missing_enums_gfx81plus, 5897ec681f3Smrg "ColorFormat": ColorFormat, 5907ec681f3Smrg "SX_DOWNCONVERT_FORMAT": SX_DOWNCONVERT_FORMAT, 5917ec681f3Smrg "DB_DFSM_CONTROL__PUNCHOUT_MODE": DB_DFSM_CONTROL__PUNCHOUT_MODE, 5927ec681f3Smrg "ThreadTraceRegInclude": ThreadTraceRegInclude, 5937ec681f3Smrg "ThreadTraceTokenExclude": ThreadTraceTokenExclude, 5947ec681f3Smrg "VRSCombinerMode": VRSCombinerMode, 5957ec681f3Smrg "VRSHtileEncoding": VRSHtileEncoding, 5967ec681f3Smrg }, 5977ec681f3Smrg} 5987ec681f3Smrg 5997ec681f3Smrg# Register field definitions that are missing in kernel headers 6007ec681f3Smrgfields_missing = { 6017ec681f3Smrg # Format: 6027ec681f3Smrg # Register: [[Field, StartBit, EndBit, EnumType(optional), ReplaceField=True/False(optional)], ...] 6037ec681f3Smrg 'gfx6': { 6047ec681f3Smrg "COMPUTE_RESOURCE_LIMITS": [["WAVES_PER_SH_GFX6", 0, 5]], 6057ec681f3Smrg "GB_TILE_MODE0": [["MICRO_TILE_MODE", 0, 1, "GB_TILE_MODE0__MICRO_TILE_MODE"]], 6067ec681f3Smrg "SQ_IMG_SAMP_WORD3": [["UPGRADED_DEPTH", 29, 29]], 6077ec681f3Smrg "SQ_THREAD_TRACE_MASK": [["RANDOM_SEED", 16, 31]], 6087ec681f3Smrg }, 6097ec681f3Smrg 'gfx7': { 6107ec681f3Smrg "SQ_IMG_SAMP_WORD3": [["UPGRADED_DEPTH", 29, 29]], 6117ec681f3Smrg "SQ_THREAD_TRACE_MASK": [["RANDOM_SEED", 16, 31]], 6127ec681f3Smrg }, 6137ec681f3Smrg 'gfx8': { 6147ec681f3Smrg "SQ_IMG_SAMP_WORD3": [["UPGRADED_DEPTH", 29, 29]], 6157ec681f3Smrg "SQ_THREAD_TRACE_MASK": [["RANDOM_SEED", 16, 31]], 6167ec681f3Smrg }, 6177ec681f3Smrg 'gfx81': { 6187ec681f3Smrg "SQ_IMG_SAMP_WORD3": [["UPGRADED_DEPTH", 29, 29]], 6197ec681f3Smrg "SQ_THREAD_TRACE_MASK": [["RANDOM_SEED", 16, 31]], 6207ec681f3Smrg }, 6217ec681f3Smrg 'gfx9': { 6227ec681f3Smrg "SQ_IMG_RSRC_WORD1": [ 6237ec681f3Smrg ["DATA_FORMAT_STENCIL", 20, 25, "IMG_DATA_FORMAT_STENCIL"], 6247ec681f3Smrg ["NUM_FORMAT_FMASK", 26, 29, "IMG_NUM_FORMAT_FMASK"] 6257ec681f3Smrg ], 6267ec681f3Smrg }, 6277ec681f3Smrg 'gfx10': { 6287ec681f3Smrg "DB_RESERVED_REG_2": [["RESOURCE_LEVEL", 28, 31, None, True]], 6297ec681f3Smrg }, 6307ec681f3Smrg 'gfx103': { 6317ec681f3Smrg "DB_RESERVED_REG_2": [["RESOURCE_LEVEL", 28, 31, None, True]], 6327ec681f3Smrg "VGT_DRAW_PAYLOAD_CNTL": [["EN_VRS_RATE", 6, 6]], 6337ec681f3Smrg "VGT_SHADER_STAGES_EN": [["PRIMGEN_PASSTHRU_NO_MSG", 26, 26]], 6347ec681f3Smrg }, 6357ec681f3Smrg} 6367ec681f3Smrg 6377ec681f3Smrg######### END HARDCODED CONFIGURATION 6387ec681f3Smrg 6397ec681f3Smrgdef bitcount(n): 6407ec681f3Smrg return bin(n).count('1') 6417ec681f3Smrg 6427ec681f3Smrgdef generate_json(gfx_version, amd_headers_path): 6437ec681f3Smrg # Add the path to the filenames 6447ec681f3Smrg filenames = [amd_headers_path + '/' + a if a is not None else None for a in gfx_versions[gfx_version]] 6457ec681f3Smrg old_gen = filenames[0] is None 6467ec681f3Smrg 6477ec681f3Smrg # Open the files 6487ec681f3Smrg files = [open(a, 'r').readlines() if a is not None else None for a in filenames] 6497ec681f3Smrg 6507ec681f3Smrg # Parse the ip_offset.h file 6517ec681f3Smrg base_offsets = None 6527ec681f3Smrg if not old_gen: 6537ec681f3Smrg for line in files[0]: 6547ec681f3Smrg r = re_base.match(line) 6557ec681f3Smrg if r is not None: 6567ec681f3Smrg base_offsets = r.groups() 6577ec681f3Smrg 6587ec681f3Smrg if base_offsets is None: 6597ec681f3Smrg print('Can\'t parse: ' + filenames[0], file=sys.stderr) 6607ec681f3Smrg sys.exit(1) 6617ec681f3Smrg 6627ec681f3Smrg 6637ec681f3Smrg # Parse the offset.h file 6647ec681f3Smrg name = None 6657ec681f3Smrg offset = None 6667ec681f3Smrg added_offsets = set() 6677ec681f3Smrg regs = {} 6687ec681f3Smrg for line in files[1]: 6697ec681f3Smrg r = re_offset.match(line) 6707ec681f3Smrg if r is None: 6717ec681f3Smrg continue 6727ec681f3Smrg 6737ec681f3Smrg if '_BASE_IDX' not in r.group('name'): 6747ec681f3Smrg name = r.group('name') 6757ec681f3Smrg offset = int(r.group('value'), 0) * 4 6767ec681f3Smrg if not old_gen and r.group('mm') == 'mm': 6777ec681f3Smrg continue 6787ec681f3Smrg else: 6797ec681f3Smrg assert name == r.group('name')[:-9] 6807ec681f3Smrg idx = int(r.group('value')) 6817ec681f3Smrg assert idx < len(base_offsets) 6827ec681f3Smrg offset += int(base_offsets[idx], 0) * 4 6837ec681f3Smrg 6847ec681f3Smrg # Only accept writeable registers and debug registers 6857ec681f3Smrg if register_filter(gfx_version, name, offset, offset in added_offsets): 6867ec681f3Smrg regs[name] = { 6877ec681f3Smrg 'chips': [gfx_version], 6887ec681f3Smrg 'map': {'at': offset, 'to': 'mm'}, 6897ec681f3Smrg 'name': name, 6907ec681f3Smrg } 6917ec681f3Smrg added_offsets.add(offset) 6927ec681f3Smrg 6937ec681f3Smrg 6947ec681f3Smrg # Parse the sh_mask.h file 6957ec681f3Smrg shifts = {} 6967ec681f3Smrg masks = {} 6977ec681f3Smrg for line in files[2]: 6987ec681f3Smrg r = re_shift.match(line) 6997ec681f3Smrg is_shift = r is not None 7007ec681f3Smrg r = re_mask.match(line) if r is None else r 7017ec681f3Smrg if r is None: 7027ec681f3Smrg continue 7037ec681f3Smrg 7047ec681f3Smrg name = r.group('name') 7057ec681f3Smrg if name not in regs.keys(): 7067ec681f3Smrg continue 7077ec681f3Smrg 7087ec681f3Smrg field = r.group('field') 7097ec681f3Smrg value = int(r.group('value'), 0) 7107ec681f3Smrg assert not is_shift or value < 32 7117ec681f3Smrg 7127ec681f3Smrg d = shifts if is_shift else masks 7137ec681f3Smrg if name not in d: 7147ec681f3Smrg d[name] = {} 7157ec681f3Smrg d[name][field] = value 7167ec681f3Smrg 7177ec681f3Smrg 7187ec681f3Smrg # Parse the enum.h file 7197ec681f3Smrg re_enum_begin = re.compile(r'^typedef enum (?P<name>\w+) {\n') 7207ec681f3Smrg re_enum_entry = re.compile(r'\s*(?P<name>\w+)\s*=\s*(?P<value>\w+),?\n') 7217ec681f3Smrg re_enum_end = re.compile(r'^} \w+;\n') 7227ec681f3Smrg inside_enum = False 7237ec681f3Smrg name = None 7247ec681f3Smrg enums = enums_missing[gfx_version] if gfx_version in enums_missing else {} 7257ec681f3Smrg 7267ec681f3Smrg for line in files[3]: 7277ec681f3Smrg r = re_enum_begin.match(line) 7287ec681f3Smrg if r is not None: 7297ec681f3Smrg name = r.group('name') 7307ec681f3Smrg if name in enums: 7317ec681f3Smrg continue 7327ec681f3Smrg enums[name] = {'entries': []} 7337ec681f3Smrg inside_enum = True 7347ec681f3Smrg continue 7357ec681f3Smrg 7367ec681f3Smrg r = re_enum_end.match(line) 7377ec681f3Smrg if r is not None: 7387ec681f3Smrg inside_enum = False 7397ec681f3Smrg name = None 7407ec681f3Smrg continue 7417ec681f3Smrg 7427ec681f3Smrg if inside_enum: 7437ec681f3Smrg r = re_enum_entry.match(line) 7447ec681f3Smrg assert r 7457ec681f3Smrg enums[name]['entries'].append({ 7467ec681f3Smrg 'name': r.group('name'), 7477ec681f3Smrg 'value': int(r.group('value'), 0), 7487ec681f3Smrg }) 7497ec681f3Smrg 7507ec681f3Smrg 7517ec681f3Smrg # Assemble everything 7527ec681f3Smrg reg_types = {} 7537ec681f3Smrg reg_mappings = [] 7547ec681f3Smrg missing_fields = fields_missing[gfx_version] if gfx_version in fields_missing else {} 7557ec681f3Smrg 7567ec681f3Smrg for (name, reg) in regs.items(): 7577ec681f3Smrg type = {'fields': []} 7587ec681f3Smrg 7597ec681f3Smrg if name in shifts and name in masks: 7607ec681f3Smrg for (field, shift) in shifts[name].items(): 7617ec681f3Smrg if field not in masks[name]: 7627ec681f3Smrg continue 7637ec681f3Smrg 7647ec681f3Smrg new = { 7657ec681f3Smrg 'bits': [shift, shift + bitcount(masks[name][field]) - 1], 7667ec681f3Smrg 'name': field, 7677ec681f3Smrg } 7687ec681f3Smrg if field in enum_map: 7697ec681f3Smrg type_map = enum_map[field] 7707ec681f3Smrg type_name = None 7717ec681f3Smrg 7727ec681f3Smrg if len(type_map) == 1: 7737ec681f3Smrg type_name = type_map[0]; 7747ec681f3Smrg else: 7757ec681f3Smrg reg_index = type_map.index(name) if name in type_map else -1 7767ec681f3Smrg if reg_index >= 1 and reg_index % 2 == 1: 7777ec681f3Smrg type_name = type_map[reg_index - 1] 7787ec681f3Smrg 7797ec681f3Smrg if type_name is not None: 7807ec681f3Smrg if type_name not in enums: 7817ec681f3Smrg print('{0}: {1} type not found for {2}.{3}' 7827ec681f3Smrg .format(gfx_version, type_name, name, field), file=sys.stderr) 7837ec681f3Smrg else: 7847ec681f3Smrg new['enum_ref'] = type_name 7857ec681f3Smrg 7867ec681f3Smrg type['fields'].append(new) 7877ec681f3Smrg 7887ec681f3Smrg if name in missing_fields: 7897ec681f3Smrg fields = missing_fields[name] 7907ec681f3Smrg for f in fields: 7917ec681f3Smrg field = { 7927ec681f3Smrg 'bits': [f[1], f[2]], 7937ec681f3Smrg 'name': f[0], 7947ec681f3Smrg } 7957ec681f3Smrg if len(f) >= 4 and f[3] is not None and f[3] in enums: 7967ec681f3Smrg field['enum_ref'] = f[3] 7977ec681f3Smrg # missing_fields should replace overlapping fields if requested 7987ec681f3Smrg if len(f) >= 5 and f[4]: 7997ec681f3Smrg for f2 in type['fields']: 8007ec681f3Smrg if f2['bits'] == field['bits']: 8017ec681f3Smrg type['fields'].remove(f2) 8027ec681f3Smrg 8037ec681f3Smrg type['fields'].append(field) 8047ec681f3Smrg 8057ec681f3Smrg if len(type['fields']) > 0: 8067ec681f3Smrg reg_types[name] = type 8077ec681f3Smrg 8087ec681f3Smrg # Don't define types that have only one field covering all bits 8097ec681f3Smrg field0_bits = type['fields'][0]['bits']; 8107ec681f3Smrg if len(type['fields']) > 1 or field0_bits[0] != 0 or field0_bits[1] != 31: 8117ec681f3Smrg reg['type_ref'] = name 8127ec681f3Smrg 8137ec681f3Smrg reg_mappings.append(reg) 8147ec681f3Smrg 8157ec681f3Smrg 8167ec681f3Smrg # Generate and canonicalize json 8177ec681f3Smrg all = { 8187ec681f3Smrg 'enums': enums, 8197ec681f3Smrg 'register_mappings': reg_mappings, 8207ec681f3Smrg 'register_types': reg_types, 8217ec681f3Smrg } 8227ec681f3Smrg 8237ec681f3Smrg return json_canonicalize(io.StringIO(json.dumps(all, indent=1))) 8247ec681f3Smrg 8257ec681f3Smrg 8267ec681f3Smrgif __name__ == '__main__': 8277ec681f3Smrg if len(sys.argv) <= 1 or (sys.argv[1] not in gfx_versions and sys.argv[1] != 'all'): 8287ec681f3Smrg print('First parameter should be one of: all, ' + ', '.join(gfx_versions.keys()), file=sys.stderr) 8297ec681f3Smrg sys.exit(1) 8307ec681f3Smrg 8317ec681f3Smrg if len(sys.argv) <= 2: 8327ec681f3Smrg print('Second parameter should be the path to the amd/include directory.', file=sys.stderr) 8337ec681f3Smrg sys.exit(1) 8347ec681f3Smrg 8357ec681f3Smrg if sys.argv[1] == 'all': 8367ec681f3Smrg for gfx_version in gfx_versions.keys(): 8377ec681f3Smrg print(generate_json(gfx_version, sys.argv[2]), file=open(gfx_version + '.json', 'w')) 8387ec681f3Smrg sys.exit(0) 8397ec681f3Smrg 8407ec681f3Smrg print(generate_json(sys.argv[1], sys.argv[2])) 841