1*61046927SAndroid Build Coastguard WorkerISASPEC - XML Based ISA Specification 2*61046927SAndroid Build Coastguard Worker===================================== 3*61046927SAndroid Build Coastguard Worker 4*61046927SAndroid Build Coastguard Workerisaspec provides a mechanism to describe an instruction set in XML, and 5*61046927SAndroid Build Coastguard Workergenerate a disassembler and assembler. The intention is 6*61046927SAndroid Build Coastguard Workerto describe the instruction set more formally than hand-coded assembler 7*61046927SAndroid Build Coastguard Workerand disassembler, and better decouple the shader compiler from the 8*61046927SAndroid Build Coastguard Workerunderlying instruction encoding to simplify dealing with instruction 9*61046927SAndroid Build Coastguard Workerencoding differences between generations of GPU. 10*61046927SAndroid Build Coastguard Worker 11*61046927SAndroid Build Coastguard WorkerBenefits of a formal ISA description, compared to hand-coded assemblers 12*61046927SAndroid Build Coastguard Workerand disassemblers, include easier detection of new bit combinations that 13*61046927SAndroid Build Coastguard Workerwere not seen before in previous generations due to more rigorous 14*61046927SAndroid Build Coastguard Workerdescription of bits that are expect to be '0' or '1' or 'x' (dontcare) 15*61046927SAndroid Build Coastguard Workerand verification that different encodings don't have conflicting bits 16*61046927SAndroid Build Coastguard Worker(i.e. that the specification cannot result in more than one valid 17*61046927SAndroid Build Coastguard Workerinterpretation of any bit pattern). 18*61046927SAndroid Build Coastguard Worker 19*61046927SAndroid Build Coastguard WorkerThe isaspec tool and XML schema are intended to be generic (not specific 20*61046927SAndroid Build Coastguard Workerto ir3), although there are currently a couple limitations due to short- 21*61046927SAndroid Build Coastguard Workercuts taken to get things up and running (which are mostly not inherent to 22*61046927SAndroid Build Coastguard Workerthe XML schema, and should not be too difficult to remove from the py and 23*61046927SAndroid Build Coastguard Workerdecode/disasm utility): 24*61046927SAndroid Build Coastguard Worker 25*61046927SAndroid Build Coastguard Worker* Maximum "field" size is 64b 26*61046927SAndroid Build Coastguard Worker* Fixed instruction size 27*61046927SAndroid Build Coastguard Worker 28*61046927SAndroid Build Coastguard WorkerOften times, especially when new functionality is added in later gens 29*61046927SAndroid Build Coastguard Workerwhile retaining (or at least mostly retaining) backwards compatibility 30*61046927SAndroid Build Coastguard Workerwith encodings used in earlier generations, the actual encoding can be 31*61046927SAndroid Build Coastguard Workerrather messy to describe. To support this, isaspec provides many flexible 32*61046927SAndroid Build Coastguard Workermechanism, such as conditional overrides and derived fields. This not 33*61046927SAndroid Build Coastguard Workeronly allows for describing an irregular instruction encoding, but also 34*61046927SAndroid Build Coastguard Workerallows matching an existing disasm syntax (which might not have been 35*61046927SAndroid Build Coastguard Workerdesign around the idea of disassembly based on a formal ISA description). 36*61046927SAndroid Build Coastguard Worker 37*61046927SAndroid Build Coastguard WorkerBitsets 38*61046927SAndroid Build Coastguard Worker------- 39*61046927SAndroid Build Coastguard Worker 40*61046927SAndroid Build Coastguard WorkerThe fundamental concept of matching a bit-pattern to an instruction 41*61046927SAndroid Build Coastguard Workerdecoding/encoding is the concept of a hierarchical tree of bitsets. 42*61046927SAndroid Build Coastguard WorkerThis is intended to match how the HW decodes instructions, where certain 43*61046927SAndroid Build Coastguard Workerbits describe the instruction (and sub-encoding, and so on), and other 44*61046927SAndroid Build Coastguard Workerbits describe various operands to the instruction. 45*61046927SAndroid Build Coastguard Worker 46*61046927SAndroid Build Coastguard WorkerBitsets can also be used recursively as the type of a field described 47*61046927SAndroid Build Coastguard Workerin another bitset. 48*61046927SAndroid Build Coastguard Worker 49*61046927SAndroid Build Coastguard WorkerThe leaves of the tree of instruction bitsets represent every possible 50*61046927SAndroid Build Coastguard Workerinstruction. Deciding which instruction a bitpattern is amounts to: 51*61046927SAndroid Build Coastguard Worker 52*61046927SAndroid Build Coastguard Worker.. code-block:: c 53*61046927SAndroid Build Coastguard Worker 54*61046927SAndroid Build Coastguard Worker m = (val & bitsets[n]->mask) & ~bitsets[n]->dontcare; 55*61046927SAndroid Build Coastguard Worker 56*61046927SAndroid Build Coastguard Worker if (m == bitsets[n]->match) { 57*61046927SAndroid Build Coastguard Worker /* we've found the instruction description */ 58*61046927SAndroid Build Coastguard Worker } 59*61046927SAndroid Build Coastguard Worker 60*61046927SAndroid Build Coastguard WorkerFor example, the starting point to decode an ir3 instruction is a 64b 61*61046927SAndroid Build Coastguard Workerbitset: 62*61046927SAndroid Build Coastguard Worker 63*61046927SAndroid Build Coastguard Worker.. code-block:: xml 64*61046927SAndroid Build Coastguard Worker 65*61046927SAndroid Build Coastguard Worker <bitset name="#instruction" size="64"> 66*61046927SAndroid Build Coastguard Worker <doc> 67*61046927SAndroid Build Coastguard Worker Encoding of an ir3 instruction. All instructions are 64b. 68*61046927SAndroid Build Coastguard Worker </doc> 69*61046927SAndroid Build Coastguard Worker </bitset> 70*61046927SAndroid Build Coastguard Worker 71*61046927SAndroid Build Coastguard WorkerIn the first level of instruction encoding hierarchy, the high three bits 72*61046927SAndroid Build Coastguard Workergroup things into instruction "categories": 73*61046927SAndroid Build Coastguard Worker 74*61046927SAndroid Build Coastguard Worker.. code-block:: xml 75*61046927SAndroid Build Coastguard Worker 76*61046927SAndroid Build Coastguard Worker <bitset name="#instruction-cat2" extends="#instruction"> 77*61046927SAndroid Build Coastguard Worker <field name="DST" low="32" high="39" type="#reg-gpr"/> 78*61046927SAndroid Build Coastguard Worker <field name="REPEAT" low="40" high="41" type="#rptN"/> 79*61046927SAndroid Build Coastguard Worker <field name="SAT" pos="42" type="bool" display="(sat)"/> 80*61046927SAndroid Build Coastguard Worker <field name="SS" pos="44" type="bool" display="(ss)"/> 81*61046927SAndroid Build Coastguard Worker <field name="UL" pos="45" type="bool" display="(ul)"/> 82*61046927SAndroid Build Coastguard Worker <field name="DST_CONV" pos="46" type="bool"> 83*61046927SAndroid Build Coastguard Worker <doc> 84*61046927SAndroid Build Coastguard Worker Destination register is opposite precision as source, i.e. 85*61046927SAndroid Build Coastguard Worker if {FULL} is true then destination is half precision, and 86*61046927SAndroid Build Coastguard Worker visa versa. 87*61046927SAndroid Build Coastguard Worker </doc> 88*61046927SAndroid Build Coastguard Worker </field> 89*61046927SAndroid Build Coastguard Worker <derived name="DST_HALF" expr="#dest-half" type="bool" display="h"/> 90*61046927SAndroid Build Coastguard Worker <field name="EI" pos="47" type="bool" display="(ei)"/> 91*61046927SAndroid Build Coastguard Worker <field name="FULL" pos="52" type="bool"> 92*61046927SAndroid Build Coastguard Worker <doc>Full precision source registers</doc> 93*61046927SAndroid Build Coastguard Worker </field> 94*61046927SAndroid Build Coastguard Worker <field name="JP" pos="59" type="bool" display="(jp)"/> 95*61046927SAndroid Build Coastguard Worker <field name="SY" pos="60" type="bool" display="(sy)"/> 96*61046927SAndroid Build Coastguard Worker <pattern low="61" high="63">010</pattern> <!-- cat2 --> 97*61046927SAndroid Build Coastguard Worker <!-- 98*61046927SAndroid Build Coastguard Worker NOTE, both SRC1_R and SRC2_R are defined at this level because 99*61046927SAndroid Build Coastguard Worker SRC2_R is still a valid bit for (nopN) (REPEAT==0) for cat2 100*61046927SAndroid Build Coastguard Worker instructions with only a single src 101*61046927SAndroid Build Coastguard Worker --> 102*61046927SAndroid Build Coastguard Worker <field name="SRC1_R" pos="43" type="bool" display="(r)"/> 103*61046927SAndroid Build Coastguard Worker <field name="SRC2_R" pos="51" type="bool" display="(r)"/> 104*61046927SAndroid Build Coastguard Worker <derived name="ZERO" expr="#zero" type="bool" display=""/> 105*61046927SAndroid Build Coastguard Worker </bitset> 106*61046927SAndroid Build Coastguard Worker 107*61046927SAndroid Build Coastguard WorkerThe ``<pattern>`` elements are the part(s) that determine which leaf-node 108*61046927SAndroid Build Coastguard Workerbitset matches against a given bit pattern. The leaf node's match/mask/ 109*61046927SAndroid Build Coastguard Workerdontcare bitmasks are a combination of those defined at the leaf node and 110*61046927SAndroid Build Coastguard Workerrecursively each parent bitclass. 111*61046927SAndroid Build Coastguard Worker 112*61046927SAndroid Build Coastguard WorkerFor example, cat2 instructions (ALU instructions with up to two src 113*61046927SAndroid Build Coastguard Workerregisters) can have either one or two source registers: 114*61046927SAndroid Build Coastguard Worker 115*61046927SAndroid Build Coastguard Worker.. code-block:: xml 116*61046927SAndroid Build Coastguard Worker 117*61046927SAndroid Build Coastguard Worker <bitset name="#instruction-cat2-1src" extends="#instruction-cat2"> 118*61046927SAndroid Build Coastguard Worker <override expr="#cat2-cat3-nop-encoding"> 119*61046927SAndroid Build Coastguard Worker <display> 120*61046927SAndroid Build Coastguard Worker {SY}{SS}{JP}{SAT}(nop{NOP}) {UL}{NAME} {EI}{DST_HALF}{DST}, {SRC1} 121*61046927SAndroid Build Coastguard Worker </display> 122*61046927SAndroid Build Coastguard Worker <derived name="NOP" expr="#cat2-cat3-nop-value" type="uint"/> 123*61046927SAndroid Build Coastguard Worker <field name="SRC1" low="0" high="15" type="#multisrc"> 124*61046927SAndroid Build Coastguard Worker <param name="ZERO" as="SRC_R"/> 125*61046927SAndroid Build Coastguard Worker <param name="FULL"/> 126*61046927SAndroid Build Coastguard Worker </field> 127*61046927SAndroid Build Coastguard Worker </override> 128*61046927SAndroid Build Coastguard Worker <display> 129*61046927SAndroid Build Coastguard Worker {SY}{SS}{JP}{SAT}{REPEAT}{UL}{NAME} {EI}{DST_HALF}{DST}, {SRC1} 130*61046927SAndroid Build Coastguard Worker </display> 131*61046927SAndroid Build Coastguard Worker <pattern low="16" high="31">xxxxxxxxxxxxxxxx</pattern> 132*61046927SAndroid Build Coastguard Worker <pattern low="48" high="50">xxx</pattern> <!-- COND --> 133*61046927SAndroid Build Coastguard Worker <field name="SRC1" low="0" high="15" type="#multisrc"> 134*61046927SAndroid Build Coastguard Worker <param name="SRC1_R" as="SRC_R"/> 135*61046927SAndroid Build Coastguard Worker <param name="FULL"/> 136*61046927SAndroid Build Coastguard Worker </field> 137*61046927SAndroid Build Coastguard Worker </bitset> 138*61046927SAndroid Build Coastguard Worker 139*61046927SAndroid Build Coastguard Worker <bitset name="absneg.f" extends="#instruction-cat2-1src"> 140*61046927SAndroid Build Coastguard Worker <pattern low="53" high="58">000110</pattern> 141*61046927SAndroid Build Coastguard Worker </bitset> 142*61046927SAndroid Build Coastguard Worker 143*61046927SAndroid Build Coastguard WorkerIn this example, ``absneg.f`` is a concrete cat2 instruction (leaf node of 144*61046927SAndroid Build Coastguard Workerthe bitset inheritance tree) which has a single src register. At the 145*61046927SAndroid Build Coastguard Worker``#instruction-cat2-1src`` level, bits that are used for the 2nd src arg 146*61046927SAndroid Build Coastguard Workerand condition code (for cat2 instructions which use a condition code) are 147*61046927SAndroid Build Coastguard Workerdefined as 'x' (dontcare), which matches our understanding of the hardware 148*61046927SAndroid Build Coastguard Worker(but also lets the disassembler flag cases where '1' bits show up in places 149*61046927SAndroid Build Coastguard Workerwe don't expect, which may signal a new instruction (sub)encoding). 150*61046927SAndroid Build Coastguard Worker 151*61046927SAndroid Build Coastguard WorkerYou'll notice that ``SRC1`` refers back to a different bitset hierarchy 152*61046927SAndroid Build Coastguard Workerthat describes various different src register encoding (used for cat2 and 153*61046927SAndroid Build Coastguard Workercat4 instructions), i.e. GPR vs CONST vs relative GPR/CONST. For fields 154*61046927SAndroid Build Coastguard Workerwhich have bitset types, parameters can be "passed" in via ``<param>`` 155*61046927SAndroid Build Coastguard Workerelements, which can be referred to by the display template string, and/or 156*61046927SAndroid Build Coastguard Workerexpressions. For example, this helps to deal with cases where other fields 157*61046927SAndroid Build Coastguard Workeroutside of that bitset control the encoding/decoding, such as in the 158*61046927SAndroid Build Coastguard Worker``#multisrc`` example: 159*61046927SAndroid Build Coastguard Worker 160*61046927SAndroid Build Coastguard Worker.. code-block:: xml 161*61046927SAndroid Build Coastguard Worker 162*61046927SAndroid Build Coastguard Worker <bitset name="#multisrc" size="16"> 163*61046927SAndroid Build Coastguard Worker <doc> 164*61046927SAndroid Build Coastguard Worker Encoding for instruction source which can be GPR/CONST/IMMED 165*61046927SAndroid Build Coastguard Worker or relative GPR/CONST. 166*61046927SAndroid Build Coastguard Worker </doc> 167*61046927SAndroid Build Coastguard Worker </bitset> 168*61046927SAndroid Build Coastguard Worker 169*61046927SAndroid Build Coastguard Worker ... 170*61046927SAndroid Build Coastguard Worker 171*61046927SAndroid Build Coastguard Worker <bitset name="#multisrc-gpr" extends="#multisrc"> 172*61046927SAndroid Build Coastguard Worker <display> 173*61046927SAndroid Build Coastguard Worker {ABSNEG}{SRC_R}{HALF}{SRC} 174*61046927SAndroid Build Coastguard Worker </display> 175*61046927SAndroid Build Coastguard Worker <derived name="HALF" expr="#multisrc-half" type="bool" display="h"/> 176*61046927SAndroid Build Coastguard Worker <field name="SRC" low="0" high="7" type="#reg-gpr"/> 177*61046927SAndroid Build Coastguard Worker <pattern low="8" high="13">000000</pattern> 178*61046927SAndroid Build Coastguard Worker <field name="ABSNEG" low="14" high="15" type="#absneg"/> 179*61046927SAndroid Build Coastguard Worker </bitset> 180*61046927SAndroid Build Coastguard Worker 181*61046927SAndroid Build Coastguard WorkerAt some level in the bitset inheritance hierarchy, there is expected to be a 182*61046927SAndroid Build Coastguard Worker``<display>`` element specifying a template string used during bitset 183*61046927SAndroid Build Coastguard Workerdecoding. The display template consists of references to fields (which may 184*61046927SAndroid Build Coastguard Workerbe derived fields) specified as ``{FIELDNAME}`` and other characters 185*61046927SAndroid Build Coastguard Workerwhich are just echoed through to the resulting decoded bitset. 186*61046927SAndroid Build Coastguard Worker 187*61046927SAndroid Build Coastguard WorkerThe special field reference ``{NAME}`` prints the name of the bitset. This is 188*61046927SAndroid Build Coastguard Workeroften useful when the ``<display>`` element is at a higher level than the 189*61046927SAndroid Build Coastguard Workerleaves of the hierarchy, for example a whole class of similar instructions that 190*61046927SAndroid Build Coastguard Workeronly differ in opcode. 191*61046927SAndroid Build Coastguard Worker 192*61046927SAndroid Build Coastguard WorkerSometimes there may be multiple variants of an instruction that must be 193*61046927SAndroid Build Coastguard Workerdifferent bitsets, for example because they are so different that they must 194*61046927SAndroid Build Coastguard Workerderive from different bitsets, but they have the same name. Because bitset 195*61046927SAndroid Build Coastguard Workernames must be unique in the encoder, this can be a problem, but this can worked 196*61046927SAndroid Build Coastguard Workeraround with the ``displayname`` attribute on the ``bitset`` which changes how 197*61046927SAndroid Build Coastguard Worker``{NAME}`` is displayed but not the name used in the encoder. ``displayname`` 198*61046927SAndroid Build Coastguard Workeris only useful for leaf bitsets. 199*61046927SAndroid Build Coastguard Worker 200*61046927SAndroid Build Coastguard WorkerIt is possible to define a line column alignment value per field to influence 201*61046927SAndroid Build Coastguard Workerthe visual output. It needs to be specified as ``{FIELDNAME:align=xx}``. 202*61046927SAndroid Build Coastguard Worker 203*61046927SAndroid Build Coastguard WorkerThe ``<override>`` element will be described in the next section, but it 204*61046927SAndroid Build Coastguard Workerprovides for both different decoded instruction syntax/mnemonics (when 205*61046927SAndroid Build Coastguard Workersimply providing a different display template string) as well as instruction 206*61046927SAndroid Build Coastguard Workerencoding where different ranges of bits have a different meaning based on 207*61046927SAndroid Build Coastguard Workersome other bitfield (or combination of bitfields). In this example it is 208*61046927SAndroid Build Coastguard Workerused to cover the cases where ``SRCn_R`` has a different meaning and a 209*61046927SAndroid Build Coastguard Workerdifferent disassembly syntax depending on whether ``REPEAT`` equals zero. 210*61046927SAndroid Build Coastguard Worker 211*61046927SAndroid Build Coastguard WorkerThe ``<template>`` element can be used to represent a placeholder for a more 212*61046927SAndroid Build Coastguard Workercomplex ``<display>`` substring. 213*61046927SAndroid Build Coastguard Worker 214*61046927SAndroid Build Coastguard WorkerOverrides 215*61046927SAndroid Build Coastguard Worker--------- 216*61046927SAndroid Build Coastguard Worker 217*61046927SAndroid Build Coastguard WorkerIn many cases, a bitset is not convenient for describing the expected 218*61046927SAndroid Build Coastguard Workerdisasm syntax, and/or interpretation of some range of bits differs based 219*61046927SAndroid Build Coastguard Workeron some other field or combination of fields. These *could* be modeled 220*61046927SAndroid Build Coastguard Workeras different derived bitsets, at the expense of a combinatorial explosion 221*61046927SAndroid Build Coastguard Workerof the size of the bitset inheritance tree. For example, *every* cat2 222*61046927SAndroid Build Coastguard Worker(and cat3) instruction has both a ``(nopN)`` interpretation in addition to 223*61046927SAndroid Build Coastguard Workerthe ``(rptN`)`` interpretation. 224*61046927SAndroid Build Coastguard Worker 225*61046927SAndroid Build Coastguard WorkerAn ``<override>`` in a bitset allows to redefine the display string, and/or 226*61046927SAndroid Build Coastguard Workerfield definitions from the default case. If the override's expr(ession) 227*61046927SAndroid Build Coastguard Workerevaluates to non-zero, ``<display>``, ``<field>``, and ``<derived>`` 228*61046927SAndroid Build Coastguard Workerelements take precedence over what is defined in the top-level of the 229*61046927SAndroid Build Coastguard Workerbitset (i.e. the default case). 230*61046927SAndroid Build Coastguard Worker 231*61046927SAndroid Build Coastguard WorkerExpressions 232*61046927SAndroid Build Coastguard Worker----------- 233*61046927SAndroid Build Coastguard Worker 234*61046927SAndroid Build Coastguard WorkerBoth ``<override>`` and ``<derived>`` fields make use of ``<expr>`` elements, 235*61046927SAndroid Build Coastguard Workereither defined inline, or defined and named at the top level and referred to 236*61046927SAndroid Build Coastguard Workerby name in multiple other places. An expression is a simple 'C' expression 237*61046927SAndroid Build Coastguard Workerwhich can reference fields (including other derived fields) with the same 238*61046927SAndroid Build Coastguard Worker``{FIELDNAME}`` syntax as display template strings. For example: 239*61046927SAndroid Build Coastguard Worker 240*61046927SAndroid Build Coastguard Worker.. code-block:: xml 241*61046927SAndroid Build Coastguard Worker 242*61046927SAndroid Build Coastguard Worker <expr name="#cat2-cat3-nop-encoding"> 243*61046927SAndroid Build Coastguard Worker (({SRC1_R} != 0) || ({SRC2_R} != 0)) && ({REPEAT} == 0) 244*61046927SAndroid Build Coastguard Worker </expr> 245*61046927SAndroid Build Coastguard Worker 246*61046927SAndroid Build Coastguard WorkerIn the case of ``<override>`` elements, the override applies if the expression 247*61046927SAndroid Build Coastguard Workerevaluates to non-zero. In the case of ``<derived>`` fields, the expression 248*61046927SAndroid Build Coastguard Workerevaluates to the value of the derived field. 249*61046927SAndroid Build Coastguard Worker 250*61046927SAndroid Build Coastguard WorkerBranching 251*61046927SAndroid Build Coastguard Worker--------- 252*61046927SAndroid Build Coastguard Worker 253*61046927SAndroid Build Coastguard Workerisaspec supports a few special field types for printing branch destinations. If 254*61046927SAndroid Build Coastguard Worker``isaspec_decode_options::branch_labels`` is true, a pre-pass over the program 255*61046927SAndroid Build Coastguard Workerto be disassembled determines which instructions are branch destinations and 256*61046927SAndroid Build Coastguard Workerthen they are printed when disassembling, in addition to printing the name of 257*61046927SAndroid Build Coastguard Workerthe destination when printing the field itself. 258*61046927SAndroid Build Coastguard Worker 259*61046927SAndroid Build Coastguard WorkerThere are two different types, which affect how the destination is computed. If 260*61046927SAndroid Build Coastguard Workerthe field type is ``branch``, then the field is interpreted as a signed offset 261*61046927SAndroid Build Coastguard Workerfrom the current instruction. If the type is ``absbranch``, then it is 262*61046927SAndroid Build Coastguard Workerinterpreted as an offset from the first instruction to be disassembled. In 263*61046927SAndroid Build Coastguard Workereither case, the offset is multiplied by the instruction size. 264*61046927SAndroid Build Coastguard Worker 265*61046927SAndroid Build Coastguard WorkerFor example, here is what a signed-offset unconditional jump instruction might 266*61046927SAndroid Build Coastguard Workerlook like: 267*61046927SAndroid Build Coastguard Worker 268*61046927SAndroid Build Coastguard Worker.. code-block:: xml 269*61046927SAndroid Build Coastguard Worker 270*61046927SAndroid Build Coastguard Worker <bitset name="jump" extends="#instruction"> 271*61046927SAndroid Build Coastguard Worker <display> 272*61046927SAndroid Build Coastguard Worker jump #{OFFSET} 273*61046927SAndroid Build Coastguard Worker </display> 274*61046927SAndroid Build Coastguard Worker <pattern low="26" high="31">110010</pattern> <!-- opcode goes here --> 275*61046927SAndroid Build Coastguard Worker <field name="OFFSET" low="0" high="25" type="branch"/> 276*61046927SAndroid Build Coastguard Worker </bitset> 277*61046927SAndroid Build Coastguard Worker 278*61046927SAndroid Build Coastguard WorkerThis would produce a disassembly like ``jump #l42`` if the destination is 42 279*61046927SAndroid Build Coastguard Workerinstructions after the start of the disassembly. The destination would be 280*61046927SAndroid Build Coastguard Workerpreceded by a line with just ``l42:``. 281*61046927SAndroid Build Coastguard Worker 282*61046927SAndroid Build Coastguard Worker``branch`` and ``absbranch`` fields can additionally have a ``call="true"`` 283*61046927SAndroid Build Coastguard Workerattribute. For now, this just changes the disassembly. In particular the label 284*61046927SAndroid Build Coastguard Workerprefix is changed to ``fxn`` and an extra empty line before the destination is 285*61046927SAndroid Build Coastguard Workeradded to visually separate the disassembly into functions. So, for example, a 286*61046927SAndroid Build Coastguard Workercall instruction defined like this: 287*61046927SAndroid Build Coastguard Worker 288*61046927SAndroid Build Coastguard Worker.. code-block:: xml 289*61046927SAndroid Build Coastguard Worker 290*61046927SAndroid Build Coastguard Worker <bitset name="call" extends="#instruction"> 291*61046927SAndroid Build Coastguard Worker <display> 292*61046927SAndroid Build Coastguard Worker call #{OFFSET} 293*61046927SAndroid Build Coastguard Worker </display> 294*61046927SAndroid Build Coastguard Worker <pattern low="26" high="31">110010</pattern> <!-- opcode goes here --> 295*61046927SAndroid Build Coastguard Worker <field name="OFFSET" low="0" high="25" type="branch" call="true"/> 296*61046927SAndroid Build Coastguard Worker </bitset> 297*61046927SAndroid Build Coastguard Worker 298*61046927SAndroid Build Coastguard Workerwill disassemble to ``call #fxn42``. 299*61046927SAndroid Build Coastguard Worker 300*61046927SAndroid Build Coastguard WorkerFinally, users with special knowledge about where execution may start can define 301*61046927SAndroid Build Coastguard Worker"entrypoints" when disassembling which are printed like function call 302*61046927SAndroid Build Coastguard Workerdestinations, with an extra empty line, but with an arbitrary user-defined 303*61046927SAndroid Build Coastguard Workername. Names that are ``fxn`` or ``l`` followed by a number are discouraged 304*61046927SAndroid Build Coastguard Workerbecause they may clash with automatically-generated names. 305*61046927SAndroid Build Coastguard Worker 306*61046927SAndroid Build Coastguard WorkerEncoding 307*61046927SAndroid Build Coastguard Worker-------- 308*61046927SAndroid Build Coastguard Worker 309*61046927SAndroid Build Coastguard WorkerTo facilitate instruction encoding, ``<encode>`` elements can be provided 310*61046927SAndroid Build Coastguard Workerto teach the generated instruction packing code how to map from data structures 311*61046927SAndroid Build Coastguard Workerrepresenting the IR to fields. For example: 312*61046927SAndroid Build Coastguard Worker 313*61046927SAndroid Build Coastguard Worker.. code-block:: xml 314*61046927SAndroid Build Coastguard Worker 315*61046927SAndroid Build Coastguard Worker <bitset name="#instruction" size="64"> 316*61046927SAndroid Build Coastguard Worker <doc> 317*61046927SAndroid Build Coastguard Worker Encoding of an ir3 instruction. All instructions are 64b. 318*61046927SAndroid Build Coastguard Worker </doc> 319*61046927SAndroid Build Coastguard Worker <gen min="300"/> 320*61046927SAndroid Build Coastguard Worker <encode type="struct ir3_instruction *" case-prefix="OPC_"> 321*61046927SAndroid Build Coastguard Worker <!-- 322*61046927SAndroid Build Coastguard Worker Define mapping from encode src to individual fields, 323*61046927SAndroid Build Coastguard Worker which are common across all instruction categories 324*61046927SAndroid Build Coastguard Worker at the root instruction level 325*61046927SAndroid Build Coastguard Worker 326*61046927SAndroid Build Coastguard Worker Not all of these apply to all instructions, but we 327*61046927SAndroid Build Coastguard Worker can define mappings here for anything that is used 328*61046927SAndroid Build Coastguard Worker in more than one instruction category. For things 329*61046927SAndroid Build Coastguard Worker that are specific to a single instruction category, 330*61046927SAndroid Build Coastguard Worker mappings should be defined at that level instead. 331*61046927SAndroid Build Coastguard Worker --> 332*61046927SAndroid Build Coastguard Worker <map name="DST">src->regs[0]</map> 333*61046927SAndroid Build Coastguard Worker <map name="SRC1">src->regs[1]</map> 334*61046927SAndroid Build Coastguard Worker <map name="SRC2">src->regs[2]</map> 335*61046927SAndroid Build Coastguard Worker <map name="SRC3">src->regs[3]</map> 336*61046927SAndroid Build Coastguard Worker <map name="REPEAT">src->repeat</map> 337*61046927SAndroid Build Coastguard Worker <map name="SS">!!(src->flags & IR3_INSTR_SS)</map> 338*61046927SAndroid Build Coastguard Worker <map name="JP">!!(src->flags & IR3_INSTR_JP)</map> 339*61046927SAndroid Build Coastguard Worker <map name="SY">!!(src->flags & IR3_INSTR_SY)</map> 340*61046927SAndroid Build Coastguard Worker <map name="UL">!!(src->flags & IR3_INSTR_UL)</map> 341*61046927SAndroid Build Coastguard Worker <map name="EQ">0</map> <!-- We don't use this (yet) --> 342*61046927SAndroid Build Coastguard Worker <map name="SAT">!!(src->flags & IR3_INSTR_SAT)</map> 343*61046927SAndroid Build Coastguard Worker </encode> 344*61046927SAndroid Build Coastguard Worker </bitset> 345*61046927SAndroid Build Coastguard Worker 346*61046927SAndroid Build Coastguard WorkerThe ``type`` attribute specifies that the input to encoding an instruction 347*61046927SAndroid Build Coastguard Workeris a ``struct ir3_instruction *``. In the case of bitset hierarchies with 348*61046927SAndroid Build Coastguard Workermultiple possible leaf nodes, a ``case-prefix`` attribute should be supplied 349*61046927SAndroid Build Coastguard Workeralong with a function that maps the bitset encode source to an enum value 350*61046927SAndroid Build Coastguard Workerwith the specified prefix prepended to uppercased leaf node name. I.e. in 351*61046927SAndroid Build Coastguard Workerthis case, "add.f" becomes ``OPC_ADD_F``. 352*61046927SAndroid Build Coastguard Worker 353*61046927SAndroid Build Coastguard WorkerIndividual ``<map>`` elements teach the encoder how to map from the encode 354*61046927SAndroid Build Coastguard Workersource to fields in the encoded instruction. 355