Path: blob/21.2-virgl/src/freedreno/isa/ir3-common.xml
4565 views
<?xml version="1.0" encoding="UTF-8"?>1<!--2Copyright © 2020 Google, Inc.34Permission is hereby granted, free of charge, to any person obtaining a5copy of this software and associated documentation files (the "Software"),6to deal in the Software without restriction, including without limitation7the rights to use, copy, modify, merge, publish, distribute, sublicense,8and/or sell copies of the Software, and to permit persons to whom the9Software is furnished to do so, subject to the following conditions:1011The above copyright notice and this permission notice (including the next12paragraph) shall be included in all copies or substantial portions of the13Software.1415THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL18THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,20OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE21SOFTWARE.22-->2324<isa>2526<!--27Helpers for cat2/cat3 nop encoding, which re-uses the SRC1_R/SRC2_R28fields to encode a # of nop delay slots following the instruction.29-->3031<expr name="#cat2-cat3-nop-encoding">32(({SRC1_R} != 0) || ({SRC2_R} != 0)) && ({REPEAT} == 0)33</expr>3435<expr name="#cat2-cat3-nop-value">36{SRC1_R} | ({SRC2_R} << 1)37</expr>3839<!--40Source/Dest gpr encoding. In the gpr case, this handles the special41cases (p0.x/a0.x)42-->4344<expr name="#reg-gpr-a0">45{GPR} == 61 /* a0.* */46</expr>4748<expr name="#reg-gpr-p0">49{GPR} == 62 /* p0.x */50</expr>5152<bitset name="#reg-gpr" size="8">53<override expr="#reg-gpr-a0">54<display>55a0.{SWIZ}56</display>57<assert low="2" high="7">111101</assert>58</override>59<override expr="#reg-gpr-p0">60<display>61p0.{SWIZ}62</display>63<assert low="2" high="7">111110</assert>64</override>65<display>66r{GPR}.{SWIZ}67</display>68<field name="SWIZ" low="0" high="1" type="#swiz"/>69<field name="GPR" low="2" high="7" type="uint"/>70<encode type="struct ir3_register *">71<map name="GPR">src->num >> 2</map>72<map name="SWIZ">src->num & 0x3</map>73</encode>74</bitset>7576<bitset name="#reg-const" size="11">77<display>78c{CONST}.{SWIZ}79</display>80<field name="SWIZ" low="0" high="1" type="#swiz"/>81<field name="CONST" low="2" high="10" type="uint"/>82<encode type="struct ir3_register *">83<map name="CONST">src->num >> 2</map>84<map name="SWIZ">src->num & 0x3</map>85</encode>86</bitset>8788<expr name="#offset-zero">89{OFFSET} == 090</expr>9192<bitset name="#reg-relative-gpr" size="10">93<override expr="#offset-zero">94<display>95r<a0.x>96</display>97</override>98<display>99r<a0.x + {OFFSET}>100</display>101<field name="OFFSET" low="0" high="9" type="int"/>102<encode type="struct ir3_register *">103<map name="OFFSET">src->array.offset</map>104</encode>105</bitset>106107<bitset name="#reg-relative-const" size="10">108<override expr="#offset-zero">109<display>110c<a0.x>111</display>112</override>113<display>114c<a0.x + {OFFSET}>115</display>116<field name="OFFSET" low="0" high="9" type="int"/>117<encode type="struct ir3_register *">118<map name="OFFSET">src->array.offset</map>119</encode>120</bitset>121122<!--123Source Register encoding, used in cat2 and cat4 where a src can be124either gpr/const/relative125-->126127<bitset name="#multisrc" size="16">128<doc>129Encoding for instruction source which can be GPR/CONST/IMMED130or relative GPR/CONST.131</doc>132<encode type="struct ir3_register *" case-prefix="REG_">133<map name="ABSNEG">extract_ABSNEG(src)</map>134<map name="SRC">src</map>135</encode>136</bitset>137138<bitset name="#mulitsrc-immed" extends="#multisrc">139<override expr="#multisrc-half">140<display>141{ABSNEG}{SRC_R}h({IMMED})142</display>143</override>144<display>145{ABSNEG}{SRC_R}{IMMED}146</display>147<field name="IMMED" low="0" high="10" type="int"/>148<pattern low="11" high="13">100</pattern>149<field name="ABSNEG" low="14" high="15" type="#absneg"/>150<encode>151<map name="IMMED">src->uim_val</map>152</encode>153</bitset>154155<bitset name="#mulitsrc-immed-flut" extends="#multisrc">156<doc>157Immediate with int->float lookup table:1581590 -> 0.01601 -> 0.51612 -> 1.01623 -> 2.01634 -> e1645 -> pi1656 -> 1/pi1667 -> 1/log2(e)1678 -> log2(e)1689 -> 1/log2(10)16910 -> log2(10)17011 -> 4.0171172</doc>173<field name="IMMED" low="0" high="9" type="#flut"/>174<pattern low="11" high="13">101</pattern>175<field name="ABSNEG" low="14" high="15" type="#absneg"/>176<encode>177<map name="IMMED">src->uim_val</map>178</encode>179</bitset>180181<bitset name="#multisrc-immed-flut-full" extends="#mulitsrc-immed-flut">182<display>183{ABSNEG}{SRC_R}{IMMED}184</display>185<pattern pos="10">0</pattern>186</bitset>187188<bitset name="#multisrc-immed-flut-half" extends="#mulitsrc-immed-flut">189<display>190{ABSNEG}{SRC_R}h{IMMED}191</display>192<pattern pos="10">1</pattern>193</bitset>194195<expr name="#multisrc-half">196!{FULL}197</expr>198199<bitset name="#multisrc-gpr" extends="#multisrc">200<display>201{ABSNEG}{SRC_R}{HALF}{SRC}202</display>203<derived name="HALF" expr="#multisrc-half" type="bool" display="h"/>204<field name="SRC" low="0" high="7" type="#reg-gpr"/>205<pattern low="8" high="13">000000</pattern>206<field name="ABSNEG" low="14" high="15" type="#absneg"/>207</bitset>208209<bitset name="#multisrc-const" extends="#multisrc">210<display>211{ABSNEG}{SRC_R}{HALF}{SRC}212</display>213<derived name="HALF" expr="#multisrc-half" type="bool" display="h"/>214<field name="SRC" low="0" high="10" type="#reg-const"/>215<pattern low="11" high="13">x10</pattern>216<field name="ABSNEG" low="14" high="15" type="#absneg"/>217</bitset>218219<bitset name="#multisrc-relative" extends="#multisrc">220<pattern low="11" high="13">001</pattern>221<field name="ABSNEG" low="14" high="15" type="#absneg"/>222</bitset>223224<bitset name="#multisrc-relative-gpr" extends="#multisrc-relative">225<display>226{ABSNEG}{SRC_R}{HALF}{SRC}227</display>228<derived name="HALF" expr="#multisrc-half" type="bool" display="h"/>229<field name="SRC" low="0" high="9" type="#reg-relative-gpr"/>230<pattern pos="10">0</pattern>231</bitset>232233<bitset name="#multisrc-relative-const" extends="#multisrc-relative">234<display>235{ABSNEG}{SRC_R}{HALF}{SRC}236</display>237<derived name="HALF" expr="#multisrc-half" type="bool" display="h"/>238<field name="SRC" low="0" high="9" type="#reg-relative-const"/>239<pattern pos="10">1</pattern>240</bitset>241242<!--243For cat2/cat4, the dst reg is full precision if {FULL} == {DEST_CONV}244In addition, for cat2 instructions that can write p0.x (cmps.*, and.b,245xor.b, etc), p0.x is never half (DEST_CONV is ignored)246-->247<expr name="#dest-half">248({FULL} == {DST_CONV}) && ({DST} <= 0xf7 /* p0.x */)249</expr>250251<expr name="#true">2521253</expr>254255<expr name="#false">2560257</expr>258259<!-- These make #true/#false a bit redundant, but I guess keep them for clarity -->260<expr name="#zero">2610262</expr>263<expr name="#one">2641265</expr>266<expr name="#two">2672268</expr>269270<!--271Enums used in various places:272-->273274<enum name="#rptN">275<value val="0" display=""/>276<value val="1" display="(rpt1)"/>277<value val="2" display="(rpt2)"/>278<value val="3" display="(rpt3)"/>279<value val="4" display="(rpt4)"/>280<value val="5" display="(rpt5)"/>281</enum>282283<enum name="#cond">284<value val="0" display="lt"/>285<value val="1" display="le"/>286<value val="2" display="gt"/>287<value val="3" display="ge"/>288<value val="4" display="eq"/>289<value val="5" display="ne"/>290</enum>291292<enum name="#swiz">293<value val="0" display="x"/>294<value val="1" display="y"/>295<value val="2" display="z"/>296<value val="3" display="w"/>297</enum>298299<enum name="#type">300<value val="0" display="f16"/>301<value val="1" display="f32"/>302<value val="2" display="u16"/>303<value val="3" display="u32"/>304<value val="4" display="s16"/>305<value val="5" display="s32"/>306<value val="6" display="u8"/>307<value val="7" display="s8"/>308</enum>309310<enum name="#absneg">311<value val="0" display=""/>312<value val="1" display="(neg)"/>313<value val="2" display="(abs)"/>314<value val="3" display="(absneg)"/>315</enum>316317<enum name="#flut">318<doc>int to float lookup table</doc>319<value val="0" display="(0.0)"/>320<value val="1" display="(0.5)"/>321<value val="2" display="(1.0)"/>322<value val="3" display="(2.0)"/>323<value val="4" display="(e)"/>324<value val="5" display="(pi)"/>325<value val="6" display="(1/pi)"/>326<value val="7" display="(1/log2(e))"/>327<value val="8" display="(log2(e))"/>328<value val="9" display="(1/log2(10))"/>329<value val="10" display="(log2(10))"/>330<value val="11" display="(4.0)"/>331</enum>332333<enum name="#wrmask">334<value val="0" display=""/>335<value val="1" display="x"/>336<value val="2" display="y"/>337<value val="3" display="xy"/>338<value val="4" display="z"/>339<value val="5" display="zx"/>340<value val="6" display="zy"/>341<value val="7" display="xyz"/>342<value val="8" display="w"/>343<value val="9" display="xw"/>344<value val="10" display="yw"/>345<value val="11" display="xyw"/>346<value val="12" display="zw"/>347<value val="13" display="xzw"/>348<value val="14" display="yzw"/>349<value val="15" display="xyzw"/>350</enum>351352</isa>353354355