1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5// Defines the functions understood by the value-numbering system.
6// ValueNumFuncDef(<name of function>, <arity (1-4)>, <is-commutative (for arity = 2)>, <non-null (for gc functions)>,
7// <is-shared-static>)
8
9// clang-format off
10ValueNumFuncDef(MapStore, 3, false, false, false)
11ValueNumFuncDef(MapSelect, 2, false, false, false)
12
13ValueNumFuncDef(FieldSeq, 2, false, false, false) // Sequence (VN of null == empty) of (VN's of) field handles.
14ValueNumFuncDef(NotAField, 0, false, false, false) // Value number function for FieldSeqStore::NotAField.
15ValueNumFuncDef(ZeroMap, 0, false, false, false) // The "ZeroMap": indexing at any index yields "zero of the desired type".
16
17ValueNumFuncDef(PtrToLoc, 2, false, false, false) // Pointer (byref) to a local variable. Args: VN's of: 0: var num, 1: FieldSeq.
18ValueNumFuncDef(PtrToArrElem, 4, false, false, false) // Pointer (byref) to an array element. Args: 0: array elem type eq class var_types value, VN's of: 1: array, 2: index, 3: FieldSeq.
19ValueNumFuncDef(PtrToStatic, 1, false, false, false) // Pointer (byref) to a static variable (or possibly a field thereof, if the static variable is a struct). Args: 0: FieldSeq, first element
20 // of which is the static var.
21ValueNumFuncDef(Phi, 2, false, false, false) // A phi function. Only occurs as arg of PhiDef or PhiMemoryDef. Arguments are SSA numbers of var being defined.
22ValueNumFuncDef(PhiDef, 3, false, false, false) // Args: 0: local var # (or -1 for memory), 1: SSA #, 2: VN of definition.
23// Wouldn't need this if I'd made memory a regular local variable...
24ValueNumFuncDef(PhiMemoryDef, 2, false, false, false) // Args: 0: VN for basic block pointer, 1: VN of definition
25ValueNumFuncDef(InitVal, 1, false, false, false) // An input arg, or init val of a local Args: 0: a constant VN.
26
27
28
29ValueNumFuncDef(Cast, 2, false, false, false) // VNF_Cast: Cast Operation changes the representations size and unsigned-ness.
30 // Args: 0: Source for the cast operation.
31 // 1: Constant integer representing the operation .
32 // Use VNForCastOper() to construct.
33ValueNumFuncDef(CastOvf, 2, false, false, false) // Same as a VNF_Cast but also can throw an overflow exception, currently we don't try to constant fold this
34
35ValueNumFuncDef(CastClass, 2, false, false, false) // Args: 0: Handle of class being cast to, 1: object being cast.
36ValueNumFuncDef(IsInstanceOf, 2, false, false, false) // Args: 0: Handle of class being queried, 1: object being queried.
37ValueNumFuncDef(ReadyToRunCastClass, 2, false, false, false) // Args: 0: Helper stub address, 1: object being cast.
38ValueNumFuncDef(ReadyToRunIsInstanceOf, 2, false, false, false) // Args: 0: Helper stub address, 1: object being queried.
39ValueNumFuncDef(TypeHandleToRuntimeType, 1, false, false, false) // Args: 0: TypeHandle to translate
40ValueNumFuncDef(TypeHandleToRuntimeTypeHandle, 1, false, false, false) // Args: 0: TypeHandle to translate
41
42ValueNumFuncDef(AreTypesEquivalent, 2, false, false, false) // Args: 0: first TypeHandle, 1: second TypeHandle
43
44ValueNumFuncDef(LdElemA, 3, false, false, false) // Args: 0: array value; 1: index value; 2: type handle of element.
45
46ValueNumFuncDef(ByrefExposedLoad, 3, false, false, false) // Args: 0: type handle/id, 1: pointer value; 2: ByrefExposed heap value
47
48ValueNumFuncDef(GetRefanyVal, 2, false, false, false) // Args: 0: type handle; 1: typedref value. Returns the value (asserting that the type is right).
49
50ValueNumFuncDef(GetClassFromMethodParam, 1, false, true, false) // Args: 0: method generic argument.
51ValueNumFuncDef(GetSyncFromClassHandle, 1, false, true, false) // Args: 0: class handle.
52ValueNumFuncDef(LoopCloneChoiceAddr, 0, false, true, false)
53
54// How we represent values of expressions with exceptional side effects:
55ValueNumFuncDef(ValWithExc, 2, false, false, false) // Args: 0: value number from normal execution; 1: VN for set of possible exceptions.
56ValueNumFuncDef(ExcSetCons, 2, false, false, false) // Args: 0: exception; 1: exception set (including EmptyExcSet). Invariant: "car"s are always in ascending order.
57
58// Various functions that are used to indicate that an exceptions may occur
59// Curremtly when the execution is always thrown, the value VNForVoid() is used as Arg0 by OverflowExc and DivideByZeroExc
60//
61ValueNumFuncDef(NullPtrExc, 1, false, false, false) // Null pointer exception check. Args: 0: address value, throws when it is null
62ValueNumFuncDef(ArithmeticExc, 2, false, false, false) // Arithmetic exception check, ckfinite and integer division overflow, Args: 0: expression value,
63ValueNumFuncDef(OverflowExc, 1, false, false, false) // Integer overflow check. used for checked add,sub and mul Args: 0: expression value, throws when it overflows
64ValueNumFuncDef(ConvOverflowExc, 2, false, false, false) // Cast conversion overflow check. Args: 0: input value; 1: var_types of the target type
65 // - (shifted left one bit; low bit encode whether source is unsigned.)
66ValueNumFuncDef(DivideByZeroExc, 1, false, false, false) // Division by zero check. Args: 0: divisor value, throws when it is zero
67ValueNumFuncDef(IndexOutOfRangeExc, 2, false, false, false) // Array bounds check, Args: 0: array length; 1: index value, throws when the bounds check fails.
68ValueNumFuncDef(InvalidCastExc, 2, false, false, false) // CastClass check, Args: 0: ref value being cast; 1: handle of type being cast to, throws when the cast fails.
69ValueNumFuncDef(NewArrOverflowExc, 1, false, false, false) // Raises Integer overflow when Arg 0 is negative
70ValueNumFuncDef(HelperMultipleExc, 0, false, false, false) // Represents one or more different exceptions that could be thrown by a Jit Helper method
71
72ValueNumFuncDef(Lng2Dbl, 1, false, false, false)
73ValueNumFuncDef(ULng2Dbl, 1, false, false, false)
74ValueNumFuncDef(Dbl2Int, 1, false, false, false)
75ValueNumFuncDef(Dbl2UInt, 1, false, false, false)
76ValueNumFuncDef(Dbl2Lng, 1, false, false, false)
77ValueNumFuncDef(Dbl2ULng, 1, false, false, false)
78ValueNumFuncDef(FltRound, 1, false, false, false)
79ValueNumFuncDef(DblRound, 1, false, false, false)
80
81ValueNumFuncDef(Sin, 1, false, false, false)
82ValueNumFuncDef(Cos, 1, false, false, false)
83ValueNumFuncDef(Cbrt, 1, false, false, false)
84ValueNumFuncDef(Sqrt, 1, false, false, false)
85ValueNumFuncDef(Abs, 1, false, false, false)
86ValueNumFuncDef(RoundDouble, 1, false, false, false)
87ValueNumFuncDef(RoundFloat, 1, false, false, false)
88ValueNumFuncDef(RoundInt, 1, false, false, false)
89ValueNumFuncDef(Cosh, 1, false, false, false)
90ValueNumFuncDef(Sinh, 1, false, false, false)
91ValueNumFuncDef(Tan, 1, false, false, false)
92ValueNumFuncDef(Tanh, 1, false, false, false)
93ValueNumFuncDef(Asin, 1, false, false, false)
94ValueNumFuncDef(Asinh, 1, false, false, false)
95ValueNumFuncDef(Acos, 1, false, false, false)
96ValueNumFuncDef(Acosh, 1, false, false, false)
97ValueNumFuncDef(Atan, 1, false, false, false)
98ValueNumFuncDef(Atan2, 2, false, false, false)
99ValueNumFuncDef(Atanh, 1, false, false, false)
100ValueNumFuncDef(Log10, 1, false, false, false)
101ValueNumFuncDef(Pow, 2, false, false, false)
102ValueNumFuncDef(Exp, 1, false, false, false)
103ValueNumFuncDef(Ceiling, 1, false, false, false)
104ValueNumFuncDef(Floor, 1, false, false, false)
105
106ValueNumFuncDef(ManagedThreadId, 0, false, false, false)
107
108ValueNumFuncDef(ObjGetType, 1, false, false, false)
109ValueNumFuncDef(GetgenericsGcstaticBase, 1, false, true, true)
110ValueNumFuncDef(GetgenericsNongcstaticBase, 1, false, true, true)
111ValueNumFuncDef(GetsharedGcstaticBase, 2, false, true, true)
112ValueNumFuncDef(GetsharedNongcstaticBase, 2, false, true, true)
113ValueNumFuncDef(GetsharedGcstaticBaseNoctor, 1, false, true, true)
114ValueNumFuncDef(GetsharedNongcstaticBaseNoctor, 1, false, true, true)
115ValueNumFuncDef(ReadyToRunStaticBase, 1, false, true, true)
116ValueNumFuncDef(ReadyToRunGenericStaticBase, 2, false, true, true)
117ValueNumFuncDef(GetsharedGcstaticBaseDynamicclass, 2, false, true, true)
118ValueNumFuncDef(GetsharedNongcstaticBaseDynamicclass, 2, false, true, true)
119ValueNumFuncDef(GetgenericsGcthreadstaticBase, 1, false, true, true)
120ValueNumFuncDef(GetgenericsNongcthreadstaticBase, 1, false, true, true)
121ValueNumFuncDef(GetsharedGcthreadstaticBase, 2, false, true, true)
122ValueNumFuncDef(GetsharedNongcthreadstaticBase, 2, false, true, true)
123ValueNumFuncDef(GetsharedGcthreadstaticBaseNoctor, 2, false, true, true)
124ValueNumFuncDef(GetsharedNongcthreadstaticBaseNoctor, 2, false, true, true)
125ValueNumFuncDef(GetsharedGcthreadstaticBaseDynamicclass, 2, false, true, true)
126ValueNumFuncDef(GetsharedNongcthreadstaticBaseDynamicclass, 2, false, true, true)
127
128ValueNumFuncDef(ClassinitSharedDynamicclass, 2, false, false, false)
129ValueNumFuncDef(RuntimeHandleMethod, 2, false, true, false)
130ValueNumFuncDef(RuntimeHandleClass, 2, false, true, false)
131
132ValueNumFuncDef(GetStaticAddrContext, 1, false, true, false)
133ValueNumFuncDef(GetStaticAddrTLS, 1, false, true, false)
134
135ValueNumFuncDef(JitNew, 2, false, true, false)
136ValueNumFuncDef(JitNewArr, 3, false, true, false)
137ValueNumFuncDef(JitReadyToRunNew, 2, false, true, false)
138ValueNumFuncDef(JitReadyToRunNewArr, 3, false, true, false)
139ValueNumFuncDef(Box, 3, false, false, false)
140ValueNumFuncDef(BoxNullable, 3, false, false, false)
141
142ValueNumFuncDef(StrCns, 2, false, true, false)
143ValueNumFuncDef(Unbox, 2, false, true, false)
144
145ValueNumFuncDef(LT_UN, 2, false, false, false) // unsigned or unordered comparisons
146ValueNumFuncDef(LE_UN, 2, false, false, false)
147ValueNumFuncDef(GE_UN, 2, false, false, false)
148ValueNumFuncDef(GT_UN, 2, false, false, false)
149
150ValueNumFuncDef(MUL64_UN, 2, true, false, false) // unsigned multiplication (used by 32-bit targets)
151
152// currently we won't constant fold the next six
153
154ValueNumFuncDef(ADD_OVF, 2, true, false, false) // overflow checking operations
155ValueNumFuncDef(SUB_OVF, 2, false, false, false)
156ValueNumFuncDef(MUL_OVF, 2, true, false, false)
157
158ValueNumFuncDef(ADD_UN_OVF, 2, true, false, false) // unsigned overflow checking operations
159ValueNumFuncDef(SUB_UN_OVF, 2, false, false, false)
160ValueNumFuncDef(MUL_UN_OVF, 2, true, false, false)
161
162// clang-format on
163
164#undef ValueNumFuncDef
165