/// <summary cref="IBackendCodeGenerator.GenerateCode(PrimitiveValue)"/> public void GenerateCode(PrimitiveValue value) { // Check whether we are loading an FP16 value. In this case, we have to // move the resulting constant into a register since the PTX compiler // expects a converted FP16 value in the scope of a register. var description = ResolveRegisterDescription(value.Type); var register = new ConstantRegister(description, value); if (value.BasicValueType == BasicValueType.Float16) { Bind(value, EnsureHardwareRegister(register)); } else { Bind(value, register); } }
/// <summary> /// Append the given register argument. /// </summary> /// <param name="argument">The register argument.</param> public void AppendArgument(ConstantRegister argument) { var value = argument.Value; switch (argument.BasicValueType) { case BasicValueType.Int1: AppendConstant(value.Int1Value ? 1 : 0); break; case BasicValueType.Int8: AppendConstant(value.UInt8Value); break; case BasicValueType.Int16: AppendConstant(value.UInt16Value); break; case BasicValueType.Int32: AppendConstant(value.UInt32Value); break; case BasicValueType.Int64: AppendConstant(value.UInt64Value); break; case BasicValueType.Float16: // Use the raw UInt16 value that will be moved into a 16bit // hardware register to be interpreted as a FP16 value. AppendConstant(value.UInt16Value); break; case BasicValueType.Float32: AppendConstant(value.Float32Value); break; case BasicValueType.Float64: AppendConstant(value.Float64Value); break; default: throw new InvalidCodeGenerationException(); } }
/// <summary> /// Append the given register argument. /// </summary> /// <param name="argument">The register argument.</param> public void AppendArgument(ConstantRegister argument) { var value = argument.Value; switch (argument.BasicValueType) { case BasicValueType.Int1: AppendConstant(value.Int1Value ? 1 : 0); break; case BasicValueType.Int8: AppendConstant(value.UInt8Value); break; case BasicValueType.Int16: AppendConstant(value.UInt16Value); break; case BasicValueType.Int32: AppendConstant(value.UInt32Value); break; case BasicValueType.Int64: AppendConstant(value.UInt64Value); break; case BasicValueType.Float32: AppendConstant(value.Float32Value); break; case BasicValueType.Float64: AppendConstant(value.Float64Value); break; default: throw new InvalidCodeGenerationException(); } }