Example #1
0
 /// <summary>
 /// Resolves an unary arithmetic operation.
 /// </summary>
 /// <param name="kind">The arithmetic kind.</param>
 /// <param name="isFloat">True, if this is a floating-point operation.</param>
 /// <param name="isFunction">True, if the resolved operation is a function call.</param>
 /// <returns>The resolved arithmetic operation.</returns>
 public static string GetArithmeticOperation(
     UnaryArithmeticKind kind,
     bool isFloat,
     out bool isFunction)
 {
     if (!UnaryArithmeticOperations.TryGetValue((kind, isFloat), out var operation))
     {
         throw new NotSupportedIntrinsicException(kind.ToString());
     }
     isFunction = operation.Item2;
     return(operation.Item1);
 }
Example #2
0
 /// <summary>
 /// Resolves an unary arithmetic operation.
 /// </summary>
 /// <param name="kind">The arithmetic kind.</param>
 /// <param name="basicValueType">The arithmetic basic value type.</param>
 /// <param name="isFunction">
 /// True, if the resolved operation is a function call.
 /// </param>
 /// <returns>The resolved arithmetic operation.</returns>
 public static string GetArithmeticOperation(
     UnaryArithmeticKind kind,
     ArithmeticBasicValueType basicValueType,
     out bool isFunction)
 {
     if (!UnaryCategoryLookup.TryGetValue(basicValueType, out var category) ||
         !UnaryArithmeticOperations.TryGetValue((kind, category), out var operation))
     {
         throw new NotSupportedIntrinsicException(kind.ToString());
     }
     isFunction = operation.Item2;
     return(operation.Item1);
 }
Example #3
0
        /// <summary>
        /// Resolves an unary arithmetic operation.
        /// </summary>
        /// <param name="kind">The arithmetic kind.</param>
        /// <param name="type">The operation type.</param>
        /// <param name="fastMath">True, to use a fast-math operation.</param>
        /// <returns>The resolved arithmetic operation.</returns>
        public static string GetArithmeticOperation(
            UnaryArithmeticKind kind,
            ArithmeticBasicValueType type,
            bool fastMath)
        {
            var key = (kind, type);

            if (fastMath &&
                UnaryArithmeticOperationsFastMath.TryGetValue(key, out string operation) ||
                UnaryArithmeticOperations.TryGetValue(key, out operation))
            {
                return(operation);
            }
            throw new NotSupportedIntrinsicException(kind.ToString());
        }