@@ -40,28 +40,100 @@ pub(crate) type InstructionId = Id<Instruction>;
40
40
/// source code and must be processed by the IR.
41
41
#[ derive( Debug , Copy , Clone , PartialEq , Eq , Hash , Serialize , Deserialize ) ]
42
42
pub enum Intrinsic {
43
+ /// ArrayLen - returns the length of the input array
44
+ /// argument: array (value id)
45
+ /// result: length of the array, panic if the input is not an array
43
46
ArrayLen ,
47
+ /// ArrayAsStrUnchecked - Converts a byte array of type `[u8; N]` to a string
48
+ /// argument: array (value id)
49
+ /// result: str
44
50
ArrayAsStrUnchecked ,
51
+ /// AsSlice
52
+ /// argument: value id
53
+ /// result: a slice containing the elements of the argument. Panic if the value id does not correspond to an `array` type
45
54
AsSlice ,
55
+ /// AssertConstant - Enforce the argument to be a constant value, at compile time.
56
+ /// argument: value id
57
+ /// result: (), panic if the argument does not resolve to a constant value
46
58
AssertConstant ,
59
+ /// StaticAssert - Enforce the first argument to be true, at compile time
60
+ /// arguments: boolean (value id), ...message. The message can be a `format string` of several arguments
61
+ /// result: (), panic if the arguments do not resolve to constant values or if the first one is false.
47
62
StaticAssert ,
63
+ /// SlicePushBack - Add elements at the end of a slice
64
+ /// arguments: slice length, slice contents, ...elements_to_push
65
+ /// result: a slice containing `slice contents,..elements_to_push`
48
66
SlicePushBack ,
67
+ /// SlicePushFront - Add elements at the start of a slice
68
+ /// arguments: slice length, slice contents, ...elements_to_push
69
+ /// result: a slice containing `..elements_to_push, slice contents`
49
70
SlicePushFront ,
71
+ /// SlicePopBack - Removes the last element of a slice
72
+ /// arguments: slice length, slice contents
73
+ /// result: a slice without the last element of `slice contents`
50
74
SlicePopBack ,
75
+ /// SlicePopFront - Removes the first element of a slice
76
+ /// arguments: slice length, slice contents
77
+ /// result: a slice without the first element of `slice contents`
51
78
SlicePopFront ,
79
+ /// SliceInsert - Insert elements inside a slice.
80
+ /// arguments: slice length, slice contents, insert index, ...elements_to_insert
81
+ /// result: a slice with ...elements_to_insert inserted at the `insert index`
52
82
SliceInsert ,
83
+ /// SliceRemove - Removes an element from a slice
84
+ /// arguments: slice length, slice contents, remove index
85
+ /// result: a slice with without the element at `remove index`
53
86
SliceRemove ,
87
+ /// ApplyRangeConstraint - Enforces the `bit size` of the first argument via a range check.
88
+ /// arguments: value id, bit size (constant)
89
+ /// result: applies a range check constraint to the input. It is replaced by a RangeCheck instruction during simplification.
54
90
ApplyRangeConstraint ,
91
+ /// StrAsBytes - Convert a `str` into a byte array of type `[u8; N]`
92
+ /// arguments: value id
93
+ /// result: the argument. Internally a `str` is a byte array.
55
94
StrAsBytes ,
95
+ /// ToBits(Endian) - Computes the bit decomposition of the argument.
96
+ /// argument: a field element (value id)
97
+ /// result: an array whose elements are the bit decomposition of the argument, in the endian order depending on the chosen variant.
98
+ /// The type of the result gives the number of limbs to use for the decomposition.
56
99
ToBits ( Endian ) ,
100
+ /// ToRadix(Endian) - Decompose the first argument over the `radix` base
101
+ /// arguments: a field element (value id), the radix to use (constant, a power of 2 between 2 and 256)
102
+ /// result: an array whose elements are the decomposition of the argument into the `radix` base, in the endian order depending on the chosen variant.
103
+ /// The type of the result gives the number of limbs to use for the decomposition.
57
104
ToRadix ( Endian ) ,
105
+ /// BlackBox(BlackBoxFunc) - Calls a blackbox function. More details can be found here: [acvm-repo::acir::::circuit::opcodes::BlackBoxFuncCall]
58
106
BlackBox ( BlackBoxFunc ) ,
107
+ /// Hint(Hint) - Avoid its arguments to be removed by DIE.
108
+ /// arguments: ... value id
109
+ /// result: the arguments. Hint does not layout any constraint but avoid its arguments to be simplified out during SSA transformations
59
110
Hint ( Hint ) ,
111
+ /// AsWitness - Adds a new witness constrained to be equal to the argument
112
+ /// arguments: value id
113
+ /// result: the argument
60
114
AsWitness ,
115
+ /// IsUnconstrained - Indicates if the execution context is constrained or unconstrained
116
+ /// argument: ()
117
+ /// result: true if execution is under unconstrained context, false else.
61
118
IsUnconstrained ,
119
+ /// DerivePedersenGenerators - Computes the Pedersen generators
120
+ /// arguments: domain_separator_string (constant string), starting_index (constant)
121
+ /// result: array of elliptic curve points (Grumpkin) containing the generators.
122
+ /// The type of the result gives the number of generators to compute.
62
123
DerivePedersenGenerators ,
124
+ /// FieldLessThan - Compare the arguments: `lhs` < `rhs`
125
+ /// arguments: lhs, rhs. Field elements
126
+ /// result: true if `lhs` mod p < `rhs` mod p (p being the field characteristic), false else
63
127
FieldLessThan ,
128
+ /// ArrayRefCount - Gives the reference count of the array
129
+ /// argument: array (value id)
130
+ /// result: reference count of `array`. In unconstrained context, the reference count is stored alongside the array.
131
+ /// in constrained context, it will be 0.
64
132
ArrayRefCount ,
133
+ /// SliceRefCount - Gives the reference count of the slice
134
+ /// argument: slice (value id)
135
+ /// result: reference count of `slice`. In unconstrained context, the reference count is stored alongside the slice.
136
+ /// in constrained context, it will be 0.
65
137
SliceRefCount ,
66
138
}
67
139
0 commit comments