/// <summary> /// Constructs a new cast value. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="value">The value to convert.</param> /// <param name="targetType">The target type to convert the value to.</param> internal BaseAddressSpaceCast( BasicBlock basicBlock, ValueReference value, AddressSpaceType targetType) : base(basicBlock, value, targetType) { }
/// <summary> /// Constructs a new cast value. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="value">The value to convert.</param> /// <param name="targetType">The target type to convert the value to.</param> internal CastValue( BasicBlock basicBlock, ValueReference value, TypeNode targetType) : base(basicBlock, targetType) { Seal(ImmutableArray.Create(value)); }
/// <summary> /// Constructs a view property. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="initialType">The initial node type.</param> /// <param name="view">The underlying view.</param> internal ViewPropertyValue( BasicBlock basicBlock, ValueReference view, TypeNode initialType) : base(basicBlock, initialType) { Seal(ImmutableArray.Create(view)); }
/// <summary> /// Constructs a new cast value. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="source">The view to cast.</param> /// <param name="targetType">The primitive target type.</param> internal BitCast( BasicBlock basicBlock, ValueReference source, PrimitiveType targetType) : base(basicBlock, source, targetType) { Debug.Assert(source.Type.IsPrimitiveType, "Invalid primitive type"); TargetPrimitiveType = targetType; }
/// <summary> /// Constructs a view. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="pointer">The underlying pointer.</param> /// <param name="length">The number of elements.</param> internal NewView( IRContext context, BasicBlock basicBlock, ValueReference pointer, ValueReference length) : base(basicBlock, ComputeType(context, pointer.Type)) { Debug.Assert(length.BasicValueType == BasicValueType.Int32, "Invalid length"); Seal(ImmutableArray.Create(pointer, length)); }
/// <summary> /// Constructs a new return terminator. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="returnValue">The current return value.</param> internal ReturnTerminator( BasicBlock basicBlock, ValueReference returnValue) : base( basicBlock, ImmutableArray <BasicBlock> .Empty, ComputeType(returnValue.Type)) { Seal(ImmutableArray.Create(returnValue)); }
/// <summary> /// Constructs a new view length property. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicblock">The parent basic block.</param> /// <param name="view">The underlying view.</param> internal GetViewLength( IRContext context, BasicBlock basicblock, ValueReference view) : base( basicblock, view, ComputeType(context)) { }
/// <summary> /// Constructs a new field load. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="structValue">The structure value.</param> /// <param name="fieldIndex">The structure field index.</param> internal GetField( BasicBlock basicBlock, ValueReference structValue, int fieldIndex) : base( basicBlock, ComputeType(structValue, fieldIndex), fieldIndex) { Seal(ImmutableArray.Create(structValue)); }
/// <summary> /// Constructs a new element load. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="arrayValue">The array value.</param> /// <param name="arrayIndex">The array index.</param> internal GetElement( BasicBlock basicBlock, ValueReference arrayValue, ValueReference arrayIndex) : base(ValueKind.GetElement, basicBlock, ComputeType(arrayValue)) { Debug.Assert( arrayIndex.BasicValueType == BasicValueType.Int32, "Invalid array index"); Seal(ImmutableArray.Create(arrayValue, arrayIndex)); }
/// <summary> /// Constructs a new address value. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="sourceView">The source address.</param> /// <param name="elementIndex">The address of the referenced element.</param> internal LoadElementAddress( IRContext context, BasicBlock basicBlock, ValueReference sourceView, ValueReference elementIndex) : base( basicBlock, ComputeType(context, sourceView)) { Seal(ImmutableArray.Create(sourceView, elementIndex)); }
/// <summary> /// Constructs a new shuffle operation. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="variable">The source variable value.</param> /// <param name="origin">The shuffle origin.</param> /// <param name="kind">The operation kind.</param> internal WarpShuffle( BasicBlock basicBlock, ValueReference variable, ValueReference origin, ShuffleKind kind) : base( basicBlock, ImmutableArray.Create(variable, origin), kind) { }
/// <summary> /// Constructs a new sub-view computation. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="source">The source view.</param> /// <param name="offset">The offset.</param> /// <param name="length">The length.</param> internal SubViewValue( BasicBlock basicBlock, ValueReference source, ValueReference offset, ValueReference length) : base( basicBlock, ComputeType(source)) { Seal(ImmutableArray.Create(source, offset, length)); }
/// <summary> /// Constructs a new store operation. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="target">The target view.</param> /// <param name="value">The value to store.</param> internal Store( IRContext context, BasicBlock basicBlock, ValueReference target, ValueReference value) : base( basicBlock, ImmutableArray.Create(target, value), ComputeType(context)) { }
/// <summary> /// Constructs a new load operation. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="source">The source view.</param> internal Load( IRContext context, BasicBlock basicBlock, ValueReference source) : base( basicBlock, ImmutableArray.Create(source), ComputeType(context, source.Type)) { InvalidateType(); }
/// <summary> /// Constructs a new cast value. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="sourceView">The view to cast.</param> /// <param name="targetElementType">The target element type.</param> internal ViewCast( IRContext context, BasicBlock basicBlock, ValueReference sourceView, TypeNode targetElementType) : base( basicBlock, sourceView, ComputeType(context, sourceView.Type, targetElementType)) { TargetElementType = targetElementType; }
/// <summary> /// Constructs a new convert value. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="value">The value to convert.</param> /// <param name="targetElementType">The target element type.</param> internal PointerCast( IRContext context, BasicBlock basicBlock, ValueReference value, TypeNode targetElementType) : base( basicBlock, value, ComputeType(context, value.Type, targetElementType)) { TargetElementType = targetElementType; }
/// <summary> /// Constructs a new convert value. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="value">The value to convert.</param> /// <param name="targetType">The target type to convert the value to.</param> /// <param name="flags">The operation flags.</param> internal ConvertValue( BasicBlock basicBlock, ValueReference value, TypeNode targetType, ConvertFlags flags) : base(ValueKind.Convert, basicBlock, ComputeType(targetType)) { ConvertType = targetType; Flags = flags; Seal(ImmutableArray.Create(value)); }
/// <summary> /// Constructs a new debug operation. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="kind">The operation kind.</param> /// <param name="message">The debug message.</param> internal DebugOperation( IRContext context, BasicBlock basicBlock, DebugKind kind, ValueReference message) : base( ValueKind.Debug, basicBlock, ImmutableArray.Create(message), ComputeType(context)) { }
/// <summary> /// Constructs a new address value. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="source">The source address.</param> /// <param name="fieldIndex">The structure field index.</param> internal LoadFieldAddress( IRContext context, BasicBlock basicBlock, ValueReference source, int fieldIndex) : base( basicBlock, ComputeType(context, source, fieldIndex)) { FieldIndex = fieldIndex; Seal(ImmutableArray.Create(source)); }
/// <summary> /// Constructs a new field store. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="structValue">The structure value.</param> /// <param name="fieldIndex">The structure field index.</param> /// <param name="value">The value to store.</param> internal SetField( BasicBlock basicBlock, ValueReference structValue, int fieldIndex, ValueReference value) : base( ValueKind.SetField, basicBlock, ComputeType(structValue), fieldIndex) { Seal(ImmutableArray.Create(structValue, value)); }
/// <summary> /// Constructs a new shuffle operation. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="variable">The source variable value.</param> /// <param name="origin">The shuffle origin.</param> /// <param name="width">The sub-warp width.</param> /// <param name="kind">The operation kind.</param> internal SubWarpShuffle( BasicBlock basicBlock, ValueReference variable, ValueReference origin, ValueReference width, ShuffleKind kind) : base( ValueKind.SubWarpShuffle, basicBlock, ImmutableArray.Create(variable, origin, width), kind) { }
/// <summary> /// Constructs a new broadcast operation. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="value">The value to broadcast.</param> /// <param name="origin">The source thread index within the group or warp..</param> /// <param name="broadcastKind">The operation kind.</param> internal Broadcast( BasicBlock basicBlock, ValueReference value, ValueReference origin, BroadcastKind broadcastKind) : base( ValueKind.Broadcast, basicBlock, ImmutableArray.Create(value, origin), ComputeType(value.Type)) { Kind = broadcastKind; }
/// <summary> /// Constructs a new abstract atomic value. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="target">The target.</param> /// <param name="value">The value to store.</param> /// <param name="arguments">Additional arguments.</param> /// <param name="flags">The operation flags.</param> internal AtomicValue( BasicBlock basicBlock, ValueReference target, ValueReference value, ImmutableArray <ValueReference> arguments, AtomicFlags flags) : base( basicBlock, ImmutableArray.Create(target, value).AddRange(arguments), ComputeType(value)) { Flags = flags; }
/// <summary> /// Constructs a new compare value. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="left">The left operand.</param> /// <param name="right">The right operand.</param> /// <param name="kind">The operation kind.</param> /// <param name="flags">The operation flags.</param> internal CompareValue( IRContext context, BasicBlock basicBlock, ValueReference left, ValueReference right, CompareKind kind, CompareFlags flags) : base(ValueKind.Compare, basicBlock, ComputeType(context)) { Kind = kind; Flags = flags; Seal(ImmutableArray.Create(left, right)); }
/// <summary> /// Constructs a new unary arithmetic operation. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="value">The operand.</param> /// <param name="kind">The operation kind.</param> /// <param name="flags">The operation flags.</param> internal UnaryArithmeticValue( IRContext context, BasicBlock basicBlock, ValueReference value, UnaryArithmeticKind kind, ArithmeticFlags flags) : base( basicBlock, ImmutableArray.Create(value), flags, ComputeType(context, value, kind)) { Kind = kind; }
private static TypeNode ComputeType( IRContext context, ValueReference source) { var sourceType = source.Type as AddressSpaceType; if (sourceType is PointerType) { return(sourceType); } return(context.CreatePointerType( sourceType.ElementType, sourceType.AddressSpace)); }
/// <summary> /// Constructs a new convert value. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="value">The value to convert.</param> /// <param name="targetAddressSpace">The target address space.</param> internal AddressSpaceCast( IRContext context, BasicBlock basicBlock, ValueReference value, MemoryAddressSpace targetAddressSpace) : base( basicBlock, value, ComputeType(context, value.Type, targetAddressSpace)) { Debug.Assert( value.Type.IsViewOrPointerType && (value.Type as AddressSpaceType).AddressSpace != targetAddressSpace, "Invalid target address space"); }
/// <summary> /// Constructs a new predicate. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="condition">The condition.</param> /// <param name="trueValue">The true value.</param> /// <param name="falseValue">The false value.</param> internal Predicate( BasicBlock basicBlock, ValueReference condition, ValueReference trueValue, ValueReference falseValue) : base( basicBlock, condition, ImmutableArray.Create(trueValue, falseValue)) { Debug.Assert( condition.Type.IsPrimitiveType && condition.Type.BasicValueType == BasicValueType.Int1, "Invalid boolean predicate"); }
/// <summary> /// Constructs a new predicate barrier. /// </summary> /// <param name="context">The parent IR context.</param> /// <param name="basicBlock">The parent basic block.</param> /// <param name="predicate">The predicate value.</param> /// <param name="kind">The operation kind.</param> internal PredicateBarrier( IRContext context, BasicBlock basicBlock, ValueReference predicate, PredicateBarrierKind kind) : base( basicBlock, ImmutableArray.Create(predicate), ComputeType(context, kind)) { Debug.Assert( predicate.BasicValueType == BasicValueType.Int1, "Invalid predicate"); Kind = kind; }
/// <summary> /// Constructs a new cast value. /// </summary> /// <param name="basicBlock">The parent basic block.</param> /// <param name="source">The view to cast.</param> /// <param name="targetType">The primitive target type.</param> internal IntAsFloatCast( BasicBlock basicBlock, ValueReference source, PrimitiveType targetType) : base(basicBlock, source, targetType) { var basicValueType = source.Type.BasicValueType; Debug.Assert( basicValueType == BasicValueType.Int32 || basicValueType == BasicValueType.Int64, "Invalid primitive type"); Debug.Assert( targetType.BasicValueType == BasicValueType.Float32 || targetType.BasicValueType == BasicValueType.Float64, "Invalid primitive type"); }