public void Visit(UnaryArithmeticValue value) { if (Get <UnaryArithmeticValue>().Kind != value.Kind) { Fail(); } }
/// <summary cref="IValueVisitor.Visit(UnaryArithmeticValue)"/> public void Visit(UnaryArithmeticValue value) { var argument = Load(value.Value); var target = Allocate(value, value.ArithmeticBasicValueType); using (var statement = BeginStatement(target)) { statement.AppendCast(value.ArithmeticBasicValueType); var operation = CLInstructions.GetArithmeticOperation( value.Kind, value.BasicValueType.IsFloat(), out bool isFunction); if (isFunction) { statement.AppendCommand(operation); } statement.BeginArguments(); if (!isFunction) { statement.AppendCommand(operation); } statement.AppendCast(value.ArithmeticBasicValueType); statement.AppendArgument(argument); statement.EndArguments(); } }
/// <summary cref="IBackendCodeGenerator.GenerateCode(UnaryArithmeticValue)"/> public void GenerateCode(UnaryArithmeticValue value) { var argument = Load(value.Value); var target = Allocate( value, value.BasicValueType == BasicValueType.Int1 ? ArithmeticBasicValueType.UInt1 : value.ArithmeticBasicValueType); using var statement = BeginStatement(target); if (value.BasicValueType != BasicValueType.Int1) { statement.AppendCast(value.ArithmeticBasicValueType); } var operation = CLInstructions.GetArithmeticOperation( value.Kind, value.ArithmeticBasicValueType, out bool isFunction); if (isFunction) { statement.AppendCommand(operation); } statement.BeginArguments(); if (!isFunction) { statement.AppendCommand(operation); } statement.AppendCast(value.ArithmeticBasicValueType); statement.AppendArgument(argument); statement.EndArguments(); }
/// <summary cref="IBackendCodeGenerator.GenerateCode(UnaryArithmeticValue)"/> public void GenerateCode(UnaryArithmeticValue value) { var argument = LoadPrimitive(value.Value); var targetRegister = AllocateHardware(value); using var command = BeginCommand( PTXInstructions.GetArithmeticOperation( value.Kind, value.ArithmeticBasicValueType, FastMath)); command.AppendArgument(targetRegister); command.AppendArgument(argument); }
/// <summary cref="IValueVisitor.Visit(UnaryArithmeticValue)"/> public void Visit(UnaryArithmeticValue value) => CodeGenerator.GenerateCode(value);
/// <summary> /// Tries to determine power of 2 information for the given unary operation. /// </summary> /// <param name="unary">The unary operation to analyze.</param> /// <returns>The power of 2 value (if any).</returns> private static int?TryGetPowerOf2(UnaryArithmeticValue unary) => unary.Kind switch {