public IOEmitter( PointerType targetType, PrimitiveRegister addressRegister) { TargetType = targetType; AddressRegister = addressRegister; }
public IOEmitter( PointerType sourceType, PrimitiveRegister addressRegister) { SourceType = sourceType; AddressRegister = addressRegister; }
/// <summary> /// Emits a new parameter load operation that converts generic address- /// space pointers into a specialized address space. /// </summary> public readonly void Emit( PTXCodeGenerator codeGenerator, string command, PrimitiveRegister primitiveRegister, int offset) { // Load into the temporary register in the case of a pointer type if (primitiveRegister.Type is AddressSpaceType addressSpaceType && addressSpaceType.AddressSpace != MemoryAddressSpace.Generic) { primitiveRegister.AssertNotNull(TempRegister); using (var commandEmitter = BeginEmitLoad( codeGenerator, command, TempRegister)) { commandEmitter.AppendRawValue(ParamName, offset); } // Convert the source value into the specialized address space // using the previously allocated temp register codeGenerator.CreateAddressSpaceCast( TempRegister, primitiveRegister as HardwareRegister, MemoryAddressSpace.Generic, addressSpaceType.AddressSpace); }
/// <summary> /// Creates a set of instructions to realize a generic lea operation. /// </summary> /// <param name="sourceType">The source address type (pointer or view).</param> /// <param name="elementIndex">The current element index (the offset).</param> /// <param name="targetAddressRegister">The allocated target pointer register to write to.</param> /// <param name="address">The source address.</param> private void MakeLoadElementAddress( AddressSpaceType sourceType, PrimitiveRegister elementIndex, PrimitiveRegister targetAddressRegister, PrimitiveRegister address) { var elementSize = ABI.GetSizeOf(sourceType.ElementType); var offsetRegister = AllocatePlatformRegister(out RegisterDescription _); using (var command = BeginCommand( PTXInstructions.GetLEAMulOperation(ABI.PointerArithmeticType))) { command.AppendArgument(offsetRegister); command.AppendArgument(elementIndex); command.AppendConstant(elementSize); } using (var command = BeginCommand( PTXInstructions.GetArithmeticOperation( BinaryArithmeticKind.Add, ABI.PointerArithmeticType, false))) { command.AppendArgument(targetAddressRegister); command.AppendArgument(address); command.AppendArgument(offsetRegister); } FreeRegister(offsetRegister); }
/// <summary> /// Append the value given register argument. /// </summary> /// <param name="argument">The register argument.</param> public void AppendArgumentValue(PrimitiveRegister argument) { AppendArgument(); stringBuilder.Append('['); stringBuilder.Append('%'); stringBuilder.Append(GetStringRepresentation(argument)); stringBuilder.Append(']'); }
internal ViewImplementationRegister( ViewType viewType, PrimitiveRegister pointer, PrimitiveRegister length) : base(viewType) { Pointer = pointer; Length = length; }
public PredicateScope(PrimitiveRegister predicateRegister) { Debug.Assert(predicateRegister != null, "Invalid register allocator"); Debug.Assert( predicateRegister.Kind == PTXRegisterKind.Predicate, "Invalid predicate register"); RegisterAllocator = null; PredicateRegister = predicateRegister; }
public void Emit( PTXCodeGenerator codeGenerator, string command, PrimitiveRegister primitiveRegister, int offset) => codeGenerator.EmitIOLoad( Emitter, command, primitiveRegister as HardwareRegister, offset);
/// <summary> /// Constructs a new predicate configuration. /// </summary> /// <param name="predicateRegister">The predicate register to test.</param> /// <param name="isTrue">Branch if the predicate register is true.</param> public PredicateConfiguration( PrimitiveRegister predicateRegister, bool isTrue) { Debug.Assert( predicateRegister.Kind == PTXRegisterKind.Predicate, "Invalid predicate register"); PredicateRegister = predicateRegister; IsTrue = isTrue; }
public void Emit( PTXCodeGenerator codeGenerator, string command, PrimitiveRegister register, int offset) => codeGenerator.EmitIOStore( Emitter, command, register, offset);
public void Emit( PTXCodeGenerator codeGenerator, string command, PrimitiveRegister primitiveRegister, int offset) { using var commandEmitter = codeGenerator.BeginCommand(command); commandEmitter.AppendSuffix(primitiveRegister.BasicValueType); commandEmitter.AppendRawValue(ParamName, offset); commandEmitter.AppendArgument(primitiveRegister); }
/// <summary> /// Append the given register argument. /// </summary> /// <param name="argument">The register argument.</param> public void AppendArgument(PrimitiveRegister argument) { if (argument is ConstantRegister constantRegister) { AppendArgument(constantRegister); } else { AppendArgument(argument as HardwareRegister); } }
public void Emit( PTXCodeGenerator codeGenerator, string command, PrimitiveRegister register, int offset) { using var commandEmitter = codeGenerator.BeginCommand(command); commandEmitter.AppendAddressSpace(TargetType.AddressSpace); commandEmitter.AppendSuffix(register.BasicValueType); commandEmitter.AppendArgumentValue(AddressRegister, offset); commandEmitter.AppendArgument(register); }
private static CommandEmitter BeginEmitLoad( PTXCodeGenerator codeGenerator, string command, PrimitiveRegister sourceRegister) { var commandEmitter = codeGenerator.BeginCommand(command); commandEmitter.AppendSuffix( ResolveParameterBasicValueType( sourceRegister.BasicValueType)); commandEmitter.AppendArgument(sourceRegister); return(commandEmitter); }
/// <summary> /// Creates an address-space cast conversion. /// </summary> /// <param name="sourceRegister">The source register.</param> /// <param name="targetRegister">The target register.</param> /// <param name="sourceAddressSpace">The source address space.</param> /// <param name="targetAddressSpace">The target address space.</param> private void CreateAddressSpaceCast( PrimitiveRegister sourceRegister, HardwareRegister targetRegister, MemoryAddressSpace sourceAddressSpace, MemoryAddressSpace targetAddressSpace) { var toGeneric = targetAddressSpace == MemoryAddressSpace.Generic; var addressSpaceOperation = PTXInstructions.GetAddressSpaceCast(toGeneric); var addressSpaceOperationSuffix = PTXInstructions.GetAddressSpaceCastSuffix(Backend); using var command = BeginCommand(addressSpaceOperation); command.AppendAddressSpace( toGeneric ? sourceAddressSpace : targetAddressSpace); command.AppendSuffix(addressSpaceOperationSuffix); command.AppendArgument(targetRegister); command.AppendArgument(sourceRegister); }
public PredicateEmitter(PrimitiveRegister predicateRegister) { PredicateRegister = predicateRegister; }
/// <summary> /// Converts the underlying predicate register to a /// default target register. /// </summary> /// <param name="codeGenerator">The target code generator.</param> /// <param name="targetRegister">The target register to write to.</param> public void ConvertToValue( PTXCodeGenerator codeGenerator, PrimitiveRegister targetRegister) => codeGenerator.ConvertPredicateToValue( PredicateRegister, targetRegister);
public StoreEmitter( PointerType targetType, PrimitiveRegister addressRegister) { Emitter = new IOEmitter(targetType, addressRegister); }
public LoadEmitter( PointerType sourceType, PrimitiveRegister addressRegister) { Emitter = new IOEmitter(sourceType, addressRegister); }
/// <summary> /// Frees the given register. /// </summary> /// <param name="register">The register to free.</param> public abstract void FreeRegister(PrimitiveRegister register);