示例#1
0
 /// <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)
 {
 }
示例#2
0
 /// <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));
 }
示例#3
0
 /// <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));
 }
示例#4
0
 /// <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;
 }
示例#5
0
 /// <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));
 }
示例#6
0
 /// <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));
 }
示例#7
0
 /// <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))
 {
 }
示例#8
0
 /// <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));
 }
示例#9
0
 /// <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));
 }
示例#10
0
 /// <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));
 }
示例#11
0
 /// <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)
 {
 }
示例#12
0
 /// <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));
 }
示例#13
0
 /// <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))
 {
 }
示例#14
0
 /// <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();
 }
示例#15
0
 /// <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;
 }
示例#16
0
 /// <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;
 }
示例#17
0
        /// <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));
        }
示例#18
0
 /// <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))
 {
 }
示例#19
0
 /// <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));
 }
示例#20
0
 /// <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));
 }
示例#21
0
 /// <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)
 {
 }
示例#22
0
 /// <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;
 }
示例#23
0
        /// <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;
        }
示例#24
0
文件: Compare.cs 项目: linhdh/ILGPU
        /// <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));
        }
示例#25
0
 /// <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;
 }
示例#26
0
        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));
        }
示例#27
0
 /// <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");
 }
示例#28
0
 /// <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");
 }
示例#29
0
 /// <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;
 }
示例#30
0
        /// <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");
        }