aboutsummaryrefslogtreecommitdiff
path: root/src/ARMeilleure/IntermediateRepresentation/OperandType.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ARMeilleure/IntermediateRepresentation/OperandType.cs')
-rw-r--r--src/ARMeilleure/IntermediateRepresentation/OperandType.cs55
1 files changed, 26 insertions, 29 deletions
diff --git a/src/ARMeilleure/IntermediateRepresentation/OperandType.cs b/src/ARMeilleure/IntermediateRepresentation/OperandType.cs
index 81b22cf5..67ebdcde 100644
--- a/src/ARMeilleure/IntermediateRepresentation/OperandType.cs
+++ b/src/ARMeilleure/IntermediateRepresentation/OperandType.cs
@@ -9,7 +9,7 @@ namespace ARMeilleure.IntermediateRepresentation
I64,
FP32,
FP64,
- V128
+ V128,
}
static class OperandTypeExtensions
@@ -22,44 +22,41 @@ namespace ARMeilleure.IntermediateRepresentation
public static RegisterType ToRegisterType(this OperandType type)
{
- switch (type)
+ return type switch
{
- case OperandType.FP32: return RegisterType.Vector;
- case OperandType.FP64: return RegisterType.Vector;
- case OperandType.I32: return RegisterType.Integer;
- case OperandType.I64: return RegisterType.Integer;
- case OperandType.V128: return RegisterType.Vector;
- }
-
- throw new InvalidOperationException($"Invalid operand type \"{type}\".");
+ OperandType.FP32 => RegisterType.Vector,
+ OperandType.FP64 => RegisterType.Vector,
+ OperandType.I32 => RegisterType.Integer,
+ OperandType.I64 => RegisterType.Integer,
+ OperandType.V128 => RegisterType.Vector,
+ _ => throw new InvalidOperationException($"Invalid operand type \"{type}\"."),
+ };
}
public static int GetSizeInBytes(this OperandType type)
{
- switch (type)
+ return type switch
{
- case OperandType.FP32: return 4;
- case OperandType.FP64: return 8;
- case OperandType.I32: return 4;
- case OperandType.I64: return 8;
- case OperandType.V128: return 16;
- }
-
- throw new InvalidOperationException($"Invalid operand type \"{type}\".");
+ OperandType.FP32 => 4,
+ OperandType.FP64 => 8,
+ OperandType.I32 => 4,
+ OperandType.I64 => 8,
+ OperandType.V128 => 16,
+ _ => throw new InvalidOperationException($"Invalid operand type \"{type}\"."),
+ };
}
public static int GetSizeInBytesLog2(this OperandType type)
{
- switch (type)
+ return type switch
{
- case OperandType.FP32: return 2;
- case OperandType.FP64: return 3;
- case OperandType.I32: return 2;
- case OperandType.I64: return 3;
- case OperandType.V128: return 4;
- }
-
- throw new InvalidOperationException($"Invalid operand type \"{type}\".");
+ OperandType.FP32 => 2,
+ OperandType.FP64 => 3,
+ OperandType.I32 => 2,
+ OperandType.I64 => 3,
+ OperandType.V128 => 4,
+ _ => throw new InvalidOperationException($"Invalid operand type \"{type}\"."),
+ };
}
}
-} \ No newline at end of file
+}