/// <summary cref="IValueVisitor.Visit(Predicate)"/> public void Visit(Predicate predicate) { var condition = LoadPrimitive(predicate.Condition); var trueValue = Load(predicate.TrueValue); var falseValue = Load(predicate.FalseValue); var targetRegister = Allocate(predicate); EmitComplexCommand( PTXInstructions.GetSelectValueOperation(predicate.BasicValueType), new PredicateEmitter(condition), targetRegister, trueValue, falseValue); }
/// <summary cref="IBackendCodeGenerator.GenerateCode(IfPredicate)"/> public void GenerateCode(IfPredicate predicate) { var condition = LoadPrimitive(predicate.Condition); var trueValue = Load(predicate.TrueValue); var falseValue = Load(predicate.FalseValue); var targetRegister = Allocate(predicate); if (predicate.BasicValueType == BasicValueType.Int1) { // We need a specific sequence of instructions for predicate registers var conditionRegister = EnsureHardwareRegister(condition); using (var statement1 = BeginMove( new PredicateConfiguration(conditionRegister, true))) { statement1.AppendSuffix(BasicValueType.Int1); statement1.AppendArgument(targetRegister as PrimitiveRegister); statement1.AppendArgument(trueValue as PrimitiveRegister); } using var statement2 = BeginMove( new PredicateConfiguration(conditionRegister, false)); statement2.AppendSuffix(BasicValueType.Int1); statement2.AppendArgument(targetRegister as PrimitiveRegister); statement2.AppendArgument(falseValue as PrimitiveRegister); } else { EmitComplexCommand( PTXInstructions.GetSelectValueOperation(predicate.BasicValueType), new PredicateEmitter(condition), targetRegister, trueValue, falseValue); } }
/// <summary> /// Gets the actual select command. /// </summary> public string AdjustCommand(string command, PrimitiveRegister[] registers) => PTXInstructions.GetSelectValueOperation(registers[0].BasicValueType);