GlslDecompiler.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Globalization;
  4. using System.Linq;
  5. using System.Text;
  6. namespace Ryujinx.Graphics.Gal.Shader
  7. {
  8. class GlslDecompiler
  9. {
  10. private delegate string GetInstExpr(ShaderIrOp Op);
  11. private Dictionary<ShaderIrInst, GetInstExpr> InstsExpr;
  12. private enum OperType
  13. {
  14. Bool,
  15. F32,
  16. I32
  17. }
  18. private const string IdentationStr = " ";
  19. private static string[] ElemTypes = new string[] { "float", "vec2", "vec3", "vec4" };
  20. private GlslDecl Decl;
  21. private StringBuilder SB;
  22. public GlslDecompiler()
  23. {
  24. InstsExpr = new Dictionary<ShaderIrInst, GetInstExpr>()
  25. {
  26. { ShaderIrInst.And, GetAndExpr },
  27. { ShaderIrInst.Asr, GetAsrExpr },
  28. { ShaderIrInst.Band, GetBandExpr },
  29. { ShaderIrInst.Bnot, GetBnotExpr },
  30. { ShaderIrInst.Clt, GetCltExpr },
  31. { ShaderIrInst.Ceq, GetCeqExpr },
  32. { ShaderIrInst.Cle, GetCleExpr },
  33. { ShaderIrInst.Cgt, GetCgtExpr },
  34. { ShaderIrInst.Cne, GetCneExpr },
  35. { ShaderIrInst.Cge, GetCgeExpr },
  36. { ShaderIrInst.Exit, GetExitExpr },
  37. { ShaderIrInst.Fabs, GetFabsExpr },
  38. { ShaderIrInst.Fadd, GetFaddExpr },
  39. { ShaderIrInst.Fcos, GetFcosExpr },
  40. { ShaderIrInst.Fex2, GetFex2Expr },
  41. { ShaderIrInst.Ffma, GetFfmaExpr },
  42. { ShaderIrInst.Flg2, GetFlg2Expr },
  43. { ShaderIrInst.Fmul, GetFmulExpr },
  44. { ShaderIrInst.Fneg, GetFnegExpr },
  45. { ShaderIrInst.Frcp, GetFrcpExpr },
  46. { ShaderIrInst.Frsq, GetFrsqExpr },
  47. { ShaderIrInst.Fsin, GetFsinExpr },
  48. { ShaderIrInst.Ipa, GetIpaExpr },
  49. { ShaderIrInst.Kil, GetKilExpr },
  50. { ShaderIrInst.Lsr, GetLsrExpr },
  51. { ShaderIrInst.Not, GetNotExpr },
  52. { ShaderIrInst.Or, GetOrExpr },
  53. { ShaderIrInst.Stof, GetStofExpr },
  54. { ShaderIrInst.Utof, GetUtofExpr },
  55. { ShaderIrInst.Texr, GetTexrExpr },
  56. { ShaderIrInst.Texg, GetTexgExpr },
  57. { ShaderIrInst.Texb, GetTexbExpr },
  58. { ShaderIrInst.Texa, GetTexaExpr },
  59. { ShaderIrInst.Xor, GetXorExpr },
  60. };
  61. }
  62. public GlslProgram Decompile(int[] Code, GalShaderType ShaderType)
  63. {
  64. ShaderIrBlock Block = ShaderDecoder.DecodeBasicBlock(Code, 0, ShaderType);
  65. ShaderIrNode[] Nodes = Block.GetNodes();
  66. Decl = new GlslDecl(Nodes, ShaderType);
  67. SB = new StringBuilder();
  68. SB.AppendLine("#version 330 core");
  69. PrintDeclTextures();
  70. PrintDeclUniforms();
  71. PrintDeclInAttributes();
  72. PrintDeclOutAttributes();
  73. PrintDeclGprs();
  74. PrintDeclPreds();
  75. PrintBlockScope("void main()", 1, Nodes);
  76. string GlslCode = SB.ToString();
  77. return new GlslProgram(
  78. GlslCode,
  79. Decl.Textures.Values,
  80. Decl.Uniforms.Values);
  81. }
  82. private void PrintDeclTextures()
  83. {
  84. PrintDecls(Decl.Textures, "uniform sampler2D");
  85. }
  86. private void PrintDeclUniforms()
  87. {
  88. foreach (ShaderDeclInfo DeclInfo in Decl.Uniforms.Values.OrderBy(DeclKeySelector))
  89. {
  90. SB.AppendLine($"uniform {GetDecl(DeclInfo)};");
  91. }
  92. if (Decl.Uniforms.Count > 0)
  93. {
  94. SB.AppendLine();
  95. }
  96. }
  97. private void PrintDeclInAttributes()
  98. {
  99. PrintDeclAttributes(Decl.InAttributes.Values, "in");
  100. }
  101. private void PrintDeclOutAttributes()
  102. {
  103. PrintDeclAttributes(Decl.OutAttributes.Values, "out");
  104. }
  105. private void PrintDeclAttributes(IEnumerable<ShaderDeclInfo> Decls, string InOut)
  106. {
  107. int Count = 0;
  108. foreach (ShaderDeclInfo DeclInfo in Decls.OrderBy(DeclKeySelector))
  109. {
  110. if (DeclInfo.Index >= 0)
  111. {
  112. SB.AppendLine($"layout (location = {DeclInfo.Index}) {InOut} {GetDecl(DeclInfo)};");
  113. Count++;
  114. }
  115. }
  116. if (Count > 0)
  117. {
  118. SB.AppendLine();
  119. }
  120. }
  121. private void PrintDeclGprs()
  122. {
  123. PrintDecls(Decl.Gprs);
  124. }
  125. private void PrintDeclPreds()
  126. {
  127. PrintDecls(Decl.Preds, "bool");
  128. }
  129. private void PrintDecls(IReadOnlyDictionary<int, ShaderDeclInfo> Dict, string CustomType = null)
  130. {
  131. foreach (ShaderDeclInfo DeclInfo in Dict.Values.OrderBy(DeclKeySelector))
  132. {
  133. string Name;
  134. if (CustomType != null)
  135. {
  136. Name = CustomType + " " + DeclInfo.Name + ";";
  137. }
  138. else if (DeclInfo.Name == GlslDecl.FragmentOutputName)
  139. {
  140. Name = "layout (location = 0) out " + GetDecl(DeclInfo) + ";";
  141. }
  142. else
  143. {
  144. Name = GetDecl(DeclInfo) + ";";
  145. }
  146. SB.AppendLine(Name);
  147. }
  148. if (Dict.Count > 0)
  149. {
  150. SB.AppendLine();
  151. }
  152. }
  153. private int DeclKeySelector(ShaderDeclInfo DeclInfo)
  154. {
  155. return DeclInfo.Cbuf << 24 | DeclInfo.Index;
  156. }
  157. private string GetDecl(ShaderDeclInfo DeclInfo)
  158. {
  159. return ElemTypes[DeclInfo.Size - 1] + " " + DeclInfo.Name;
  160. }
  161. private void PrintBlockScope(string ScopeName, int IdentationLevel, params ShaderIrNode[] Nodes)
  162. {
  163. string Identation = string.Empty;
  164. for (int Index = 0; Index < IdentationLevel - 1; Index++)
  165. {
  166. Identation += IdentationStr;
  167. }
  168. if (ScopeName != string.Empty)
  169. {
  170. ScopeName += " ";
  171. }
  172. SB.AppendLine(Identation + ScopeName + "{");
  173. string LastLine = Identation + "}";
  174. if (IdentationLevel > 0)
  175. {
  176. Identation += IdentationStr;
  177. }
  178. for (int Index = 0; Index < Nodes.Length; Index++)
  179. {
  180. ShaderIrNode Node = Nodes[Index];
  181. if (Node is ShaderIrCond Cond)
  182. {
  183. string SubScopeName = "if (" + GetSrcExpr(Cond.Pred, true) + ")";
  184. PrintBlockScope(SubScopeName, IdentationLevel + 1, Cond.Child);
  185. }
  186. else if (Node is ShaderIrAsg Asg && IsValidOutOper(Asg.Dst))
  187. {
  188. string Expr = GetSrcExpr(Asg.Src, true);
  189. Expr = GetExprWithCast(Asg.Dst, Asg.Src, Expr);
  190. SB.AppendLine(Identation + GetDstOperName(Asg.Dst) + " = " + Expr + ";");
  191. }
  192. else if (Node is ShaderIrOp Op)
  193. {
  194. SB.AppendLine(Identation + GetSrcExpr(Op, true) + ";");
  195. }
  196. else
  197. {
  198. throw new InvalidOperationException();
  199. }
  200. }
  201. SB.AppendLine(LastLine);
  202. }
  203. private bool IsValidOutOper(ShaderIrNode Node)
  204. {
  205. if (Node is ShaderIrOperGpr Gpr && Gpr.IsConst)
  206. {
  207. return false;
  208. }
  209. else if (Node is ShaderIrOperPred Pred && Pred.IsConst)
  210. {
  211. return false;
  212. }
  213. return true;
  214. }
  215. private string GetDstOperName(ShaderIrNode Node)
  216. {
  217. if (Node is ShaderIrOperAbuf Abuf)
  218. {
  219. return GetOutAbufName(Abuf);
  220. }
  221. else if (Node is ShaderIrOperGpr Gpr)
  222. {
  223. return GetName(Gpr);
  224. }
  225. else if (Node is ShaderIrOperPred Pred)
  226. {
  227. return GetName(Pred);
  228. }
  229. throw new ArgumentException(nameof(Node));
  230. }
  231. private string GetSrcExpr(ShaderIrNode Node, bool Entry = false)
  232. {
  233. switch (Node)
  234. {
  235. case ShaderIrOperAbuf Abuf: return GetName (Abuf);
  236. case ShaderIrOperCbuf Cbuf: return GetName (Cbuf);
  237. case ShaderIrOperGpr Gpr: return GetName (Gpr);
  238. case ShaderIrOperImm Imm: return GetValue(Imm);
  239. case ShaderIrOperImmf Immf: return GetValue(Immf);
  240. case ShaderIrOperPred Pred: return GetName (Pred);
  241. case ShaderIrOp Op:
  242. string Expr;
  243. if (InstsExpr.TryGetValue(Op.Inst, out GetInstExpr GetExpr))
  244. {
  245. Expr = GetExpr(Op);
  246. }
  247. else
  248. {
  249. throw new NotImplementedException(Op.Inst.ToString());
  250. }
  251. if (!Entry && NeedsParentheses(Op))
  252. {
  253. Expr = "(" + Expr + ")";
  254. }
  255. return Expr;
  256. default: throw new ArgumentException(nameof(Node));
  257. }
  258. }
  259. private static bool NeedsParentheses(ShaderIrOp Op)
  260. {
  261. switch (Op.Inst)
  262. {
  263. case ShaderIrInst.Frcp:
  264. return true;
  265. case ShaderIrInst.Ipa:
  266. case ShaderIrInst.Texr:
  267. case ShaderIrInst.Texg:
  268. case ShaderIrInst.Texb:
  269. case ShaderIrInst.Texa:
  270. return false;
  271. }
  272. return Op.OperandB != null ||
  273. Op.OperandC != null;
  274. }
  275. private string GetName(ShaderIrOperCbuf Cbuf)
  276. {
  277. if (!Decl.Uniforms.TryGetValue((Cbuf.Index, Cbuf.Offs), out ShaderDeclInfo DeclInfo))
  278. {
  279. throw new InvalidOperationException();
  280. }
  281. return DeclInfo.Name;
  282. }
  283. private string GetOutAbufName(ShaderIrOperAbuf Abuf)
  284. {
  285. return GetName(Decl.OutAttributes, Abuf);
  286. }
  287. private string GetName(ShaderIrOperAbuf Abuf)
  288. {
  289. if (Abuf.Offs == GlslDecl.GlPositionWAttr && Decl.ShaderType == GalShaderType.Fragment)
  290. {
  291. return "(1f / gl_FragCoord.w)";
  292. }
  293. if (Abuf.Offs == GlslDecl.VertexIdAttr)
  294. {
  295. return "gl_VertexID";
  296. }
  297. return GetName(Decl.InAttributes, Abuf);
  298. }
  299. private string GetName(IReadOnlyDictionary<int, ShaderDeclInfo> Dict, ShaderIrOperAbuf Abuf)
  300. {
  301. int Index = Abuf.Offs >> 4;
  302. int Elem = (Abuf.Offs >> 2) & 3;
  303. if (!Dict.TryGetValue(Index, out ShaderDeclInfo DeclInfo))
  304. {
  305. throw new InvalidOperationException();
  306. }
  307. return DeclInfo.Size > 1 ? DeclInfo.Name + "." + GetAttrSwizzle(Elem) : DeclInfo.Name;
  308. }
  309. private string GetName(ShaderIrOperGpr Gpr)
  310. {
  311. return Gpr.IsConst ? "0" : GetNameWithSwizzle(Decl.Gprs, Gpr.Index);
  312. }
  313. private string GetValue(ShaderIrOperImm Imm)
  314. {
  315. //Only use hex is the value is too big and would likely be hard to read as int.
  316. if (Imm.Value > 0xfff ||
  317. Imm.Value < -0xfff)
  318. {
  319. return "0x" + Imm.Value.ToString("x8", CultureInfo.InvariantCulture);
  320. }
  321. else
  322. {
  323. return Imm.Value.ToString(CultureInfo.InvariantCulture);
  324. }
  325. }
  326. private string GetValue(ShaderIrOperImmf Immf)
  327. {
  328. return Immf.Value.ToString(CultureInfo.InvariantCulture) + "f";
  329. }
  330. private string GetName(ShaderIrOperPred Pred)
  331. {
  332. return Pred.IsConst ? "true" : GetNameWithSwizzle(Decl.Preds, Pred.Index);
  333. }
  334. private string GetNameWithSwizzle(IReadOnlyDictionary<int, ShaderDeclInfo> Dict, int Index)
  335. {
  336. int VecIndex = Index >> 2;
  337. if (Dict.TryGetValue(VecIndex, out ShaderDeclInfo DeclInfo))
  338. {
  339. if (DeclInfo.Size > 1 && Index < VecIndex + DeclInfo.Size)
  340. {
  341. return DeclInfo.Name + "." + GetAttrSwizzle(Index & 3);
  342. }
  343. }
  344. if (!Dict.TryGetValue(Index, out DeclInfo))
  345. {
  346. throw new InvalidOperationException();
  347. }
  348. return DeclInfo.Name;
  349. }
  350. private string GetAttrSwizzle(int Elem)
  351. {
  352. return "xyzw".Substring(Elem, 1);
  353. }
  354. private string GetAndExpr(ShaderIrOp Op) => GetBinaryExpr(Op, "&");
  355. private string GetAsrExpr(ShaderIrOp Op) => GetBinaryExpr(Op, ">>");
  356. private string GetBandExpr(ShaderIrOp Op) => GetBinaryExpr(Op, "&&");
  357. private string GetBnotExpr(ShaderIrOp Op) => GetUnaryExpr(Op, "!");
  358. private string GetCltExpr(ShaderIrOp Op) => GetBinaryExpr(Op, "<");
  359. private string GetCeqExpr(ShaderIrOp Op) => GetBinaryExpr(Op, "==");
  360. private string GetCleExpr(ShaderIrOp Op) => GetBinaryExpr(Op, "<=");
  361. private string GetCgtExpr(ShaderIrOp Op) => GetBinaryExpr(Op, ">");
  362. private string GetCneExpr(ShaderIrOp Op) => GetBinaryExpr(Op, "!=");
  363. private string GetCgeExpr(ShaderIrOp Op) => GetBinaryExpr(Op, ">=");
  364. private string GetExitExpr(ShaderIrOp Op) => "return";
  365. private string GetFabsExpr(ShaderIrOp Op) => GetUnaryCall(Op, "abs");
  366. private string GetFaddExpr(ShaderIrOp Op) => GetBinaryExpr(Op, "+");
  367. private string GetFcosExpr(ShaderIrOp Op) => GetUnaryCall(Op, "cos");
  368. private string GetFex2Expr(ShaderIrOp Op) => GetUnaryCall(Op, "exp2");
  369. private string GetFfmaExpr(ShaderIrOp Op) => GetTernaryExpr(Op, "*", "+");
  370. private string GetFlg2Expr(ShaderIrOp Op) => GetUnaryCall(Op, "log2");
  371. private string GetFmulExpr(ShaderIrOp Op) => GetBinaryExpr(Op, "*");
  372. private string GetFnegExpr(ShaderIrOp Op) => GetUnaryExpr(Op, "-");
  373. private string GetFrcpExpr(ShaderIrOp Op) => GetUnaryExpr(Op, "1f / ");
  374. private string GetFrsqExpr(ShaderIrOp Op) => GetUnaryCall(Op, "inversesqrt");
  375. private string GetFsinExpr(ShaderIrOp Op) => GetUnaryCall(Op, "sin");
  376. private string GetIpaExpr(ShaderIrOp Op) => GetSrcExpr(Op.OperandA);
  377. private string GetKilExpr(ShaderIrOp Op) => "discard";
  378. private string GetLsrExpr(ShaderIrOp Op)
  379. {
  380. return "int(uint(" + GetOperExpr(Op, Op.OperandA) + ") >> " +
  381. GetOperExpr(Op, Op.OperandB) + ")";
  382. }
  383. private string GetNotExpr(ShaderIrOp Op) => GetUnaryExpr(Op, "~");
  384. private string GetOrExpr(ShaderIrOp Op) => GetBinaryExpr(Op, "|");
  385. private string GetStofExpr(ShaderIrOp Op)
  386. {
  387. return "float(" + GetOperExpr(Op, Op.OperandA) + ")";
  388. }
  389. private string GetUtofExpr(ShaderIrOp Op)
  390. {
  391. return "float(uint(" + GetOperExpr(Op, Op.OperandA) + "))";
  392. }
  393. private string GetXorExpr(ShaderIrOp Op) => GetBinaryExpr(Op, "^");
  394. private string GetUnaryCall(ShaderIrOp Op, string FuncName)
  395. {
  396. return FuncName + "(" + GetOperExpr(Op, Op.OperandA) + ")";
  397. }
  398. private string GetUnaryExpr(ShaderIrOp Op, string Opr)
  399. {
  400. return Opr + GetOperExpr(Op, Op.OperandA);
  401. }
  402. private string GetBinaryExpr(ShaderIrOp Op, string Opr)
  403. {
  404. return GetOperExpr(Op, Op.OperandA) + " " + Opr + " " +
  405. GetOperExpr(Op, Op.OperandB);
  406. }
  407. private string GetTernaryExpr(ShaderIrOp Op, string Opr1, string Opr2)
  408. {
  409. return GetOperExpr(Op, Op.OperandA) + " " + Opr1 + " " +
  410. GetOperExpr(Op, Op.OperandB) + " " + Opr2 + " " +
  411. GetOperExpr(Op, Op.OperandC);
  412. }
  413. private string GetTexrExpr(ShaderIrOp Op) => GetTexExpr(Op, 'r');
  414. private string GetTexgExpr(ShaderIrOp Op) => GetTexExpr(Op, 'g');
  415. private string GetTexbExpr(ShaderIrOp Op) => GetTexExpr(Op, 'b');
  416. private string GetTexaExpr(ShaderIrOp Op) => GetTexExpr(Op, 'a');
  417. private string GetTexExpr(ShaderIrOp Op, char Ch)
  418. {
  419. return $"texture({GetTexSamplerName(Op)}, {GetTexSamplerCoords(Op)}).{Ch}";
  420. }
  421. private string GetTexSamplerName(ShaderIrOp Op)
  422. {
  423. ShaderIrOperImm Node = (ShaderIrOperImm)Op.OperandC;
  424. int Handle = ((ShaderIrOperImm)Op.OperandC).Value;
  425. if (!Decl.Textures.TryGetValue(Handle, out ShaderDeclInfo DeclInfo))
  426. {
  427. throw new InvalidOperationException();
  428. }
  429. return DeclInfo.Name;
  430. }
  431. private string GetTexSamplerCoords(ShaderIrOp Op)
  432. {
  433. return "vec2(" + GetOperExpr(Op, Op.OperandA) + ", " +
  434. GetOperExpr(Op, Op.OperandB) + ")";
  435. }
  436. private string GetOperExpr(ShaderIrOp Op, ShaderIrNode Oper)
  437. {
  438. return GetExprWithCast(Op, Oper, GetSrcExpr(Oper));
  439. }
  440. private static string GetExprWithCast(ShaderIrNode Dst, ShaderIrNode Src, string Expr)
  441. {
  442. //Note: The "DstType" (of the cast) is the type that the operation
  443. //uses on the source operands, while the "SrcType" is the destination
  444. //type of the operand result (if it is a operation) or just the type
  445. //of the variable for registers/uniforms/attributes.
  446. OperType DstType = GetSrcNodeType(Dst);
  447. OperType SrcType = GetDstNodeType(Src);
  448. if (DstType != SrcType)
  449. {
  450. //Check for invalid casts
  451. //(like bool to int/float and others).
  452. if (SrcType != OperType.F32 &&
  453. SrcType != OperType.I32)
  454. {
  455. throw new InvalidOperationException();
  456. }
  457. //For integer immediates being used as float,
  458. //it's better (for readability) to just return the float value.
  459. if (Src is ShaderIrOperImm Imm && DstType == OperType.F32)
  460. {
  461. float Value = BitConverter.Int32BitsToSingle(Imm.Value);
  462. return Value.ToString(CultureInfo.InvariantCulture) + "f";
  463. }
  464. switch (DstType)
  465. {
  466. case OperType.F32: Expr = "intBitsToFloat(" + Expr + ")"; break;
  467. case OperType.I32: Expr = "floatBitsToInt(" + Expr + ")"; break;
  468. }
  469. }
  470. return Expr;
  471. }
  472. private static OperType GetDstNodeType(ShaderIrNode Node)
  473. {
  474. if (Node is ShaderIrOp Op)
  475. {
  476. switch (Op.Inst)
  477. {
  478. case ShaderIrInst.Stof: return OperType.F32;
  479. case ShaderIrInst.Utof: return OperType.F32;
  480. }
  481. }
  482. return GetSrcNodeType(Node);
  483. }
  484. private static OperType GetSrcNodeType(ShaderIrNode Node)
  485. {
  486. switch (Node)
  487. {
  488. case ShaderIrOperAbuf Abuf:
  489. return Abuf.Offs == GlslDecl.VertexIdAttr
  490. ? OperType.I32
  491. : OperType.F32;
  492. case ShaderIrOperCbuf Cbuf: return OperType.F32;
  493. case ShaderIrOperGpr Gpr: return OperType.F32;
  494. case ShaderIrOperImm Imm: return OperType.I32;
  495. case ShaderIrOperImmf Immf: return OperType.F32;
  496. case ShaderIrOperPred Pred: return OperType.Bool;
  497. case ShaderIrOp Op:
  498. if (Op.Inst > ShaderIrInst.B_Start &&
  499. Op.Inst < ShaderIrInst.B_End)
  500. {
  501. return OperType.Bool;
  502. }
  503. else if (Op.Inst > ShaderIrInst.F_Start &&
  504. Op.Inst < ShaderIrInst.F_End)
  505. {
  506. return OperType.F32;
  507. }
  508. else if (Op.Inst > ShaderIrInst.I_Start &&
  509. Op.Inst < ShaderIrInst.I_End)
  510. {
  511. return OperType.I32;
  512. }
  513. break;
  514. }
  515. throw new ArgumentException(nameof(Node));
  516. }
  517. }
  518. }