1use core::fmt::Display;
2
3use enumset::{EnumSet, EnumSetType};
4
5use crate::{Instruction, Operation, TypeHash};
6
7use crate::{OperationCode, OperationReflect};
8
9use super::Value;
10
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
16#[derive(Debug, Clone, TypeHash, PartialEq, Eq, Hash, OperationCode)]
17#[operation(opcode_name = MarkerOpCode)]
18pub enum Marker {
19 Free(Value),
21 #[operation(pure)]
22 DummyRead(Value),
23}
24
25impl OperationReflect for Marker {
26 type OpCode = MarkerOpCode;
27
28 fn op_code(&self) -> Self::OpCode {
29 self.__match_opcode()
30 }
31
32 fn sanitize_args(&mut self, _: &crate::Scope) {}
33}
34
35impl Display for Marker {
36 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
37 match self {
38 Marker::Free(val) => write!(f, "free({val})"),
39 Marker::DummyRead(value) => write!(f, "mark_read({value})"),
40 }
41 }
42}
43
44impl From<Marker> for Instruction {
45 fn from(value: Marker) -> Self {
46 Instruction::no_out(Operation::Marker(value))
47 }
48}
49
50#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
53#[derive(Debug, Hash, TypeHash, EnumSetType)]
54pub enum FastMath {
55 NotNaN,
57 NotInf,
60 UnsignedZero,
62 AllowReciprocal,
64 AllowContraction,
67 AllowReassociation,
69 AllowTransform,
72 ReducedPrecision,
74}
75
76impl FastMath {
77 pub const fn all() -> EnumSet<FastMath> {
78 EnumSet::all()
79 }
80}