aboutsummaryrefslogtreecommitdiff
path: root/Spv.Generator/Instruction.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Spv.Generator/Instruction.cs')
-rw-r--r--Spv.Generator/Instruction.cs15
1 files changed, 15 insertions, 0 deletions
diff --git a/Spv.Generator/Instruction.cs b/Spv.Generator/Instruction.cs
index 27190f05..8ecfe683 100644
--- a/Spv.Generator/Instruction.cs
+++ b/Spv.Generator/Instruction.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@@ -228,5 +229,19 @@ namespace Spv.Generator
{
return obj is Instruction instruction && Equals(instruction);
}
+
+ private static readonly Dictionary<Specification.Op, string[]> _operandLabels = new()
+ {
+ { Specification.Op.OpConstant, new [] { "Value" } },
+ { Specification.Op.OpTypeInt, new [] { "Width", "Signed" } },
+ { Specification.Op.OpTypeFloat, new [] { "Width" } }
+ };
+
+ public override string ToString()
+ {
+ var labels = _operandLabels.TryGetValue(Opcode, out var opLabels) ? opLabels : Array.Empty<string>();
+ var result = _resultType == null ? string.Empty : $"{_resultType} ";
+ return $"{result}{Opcode}{_operands.ToString(labels)}";
+ }
}
}