예제 #1
0
        /// <summary>
        /// Realizes a convert instruction.
        /// </summary>
        /// <param name="block">The current basic block.</param>
        /// <param name="builder">The current builder.</param>
        /// <param name="targetType">The target type.</param>
        /// <param name="instructionFlags">The instruction flags.</param>
        private static void MakeConvert(
            Block block,
            IRBuilder builder,
            Type targetType,
            ILInstructionFlags instructionFlags)
        {
            var value        = block.Pop();
            var convertFlags = ConvertFlags.None;

            if (instructionFlags.HasFlags(ILInstructionFlags.Unsigned))
            {
                convertFlags |= ConvertFlags.SourceUnsigned;
            }
            if (instructionFlags.HasFlags(ILInstructionFlags.Overflow))
            {
                convertFlags |= ConvertFlags.Overflow;
            }
            if (targetType.IsUnsignedInt())
            {
                convertFlags |= ConvertFlags.SourceUnsigned;
                convertFlags |= ConvertFlags.TargetUnsigned;
            }
            var type           = targetType.GetBasicValueType();
            var targetTypeNode = block.Builder.GetPrimitiveType(type);

            block.Push(CreateConversion(
                           builder,
                           value,
                           targetTypeNode,
                           convertFlags));
        }
예제 #2
0
        /// <summary>
        /// Realizes a convert instruction.
        /// </summary>
        /// <param name="targetType">The target type.</param>
        /// <param name="instructionFlags">The instruction flags.</param>
        private void MakeConvert(
            Type targetType,
            ILInstructionFlags instructionFlags)
        {
            var value        = Block.Pop();
            var convertFlags = ConvertFlags.None;

            if (instructionFlags.HasFlags(ILInstructionFlags.Unsigned))
            {
                convertFlags |= ConvertFlags.SourceUnsigned;
            }
            if (instructionFlags.HasFlags(ILInstructionFlags.Overflow))
            {
                convertFlags |= ConvertFlags.Overflow;
            }
            if (targetType.IsUnsignedInt())
            {
                convertFlags |= ConvertFlags.SourceUnsigned;
                convertFlags |= ConvertFlags.TargetUnsigned;
            }
            var targetTypeNode = Builder.CreateType(targetType);

            Block.Push(CreateConversion(
                           value,
                           targetTypeNode,
                           convertFlags));
        }
예제 #3
0
파일: Compare.cs 프로젝트: saimarpaka/ILGPU
        /// <summary>
        /// Creates a compare instruction of the given type.
        /// </summary>
        /// <param name="compareKind">The comparison kind.</param>
        /// <param name="instructionFlags">The instruction flags.</param>
        private Value CreateCompare(
            CompareKind compareKind,
            ILInstructionFlags instructionFlags)
        {
            var compareFlags = CompareFlags.None;

            if (instructionFlags.HasFlags(ILInstructionFlags.Unsigned))
            {
                compareFlags |= CompareFlags.UnsignedOrUnordered;
            }
            return(CreateCompare(compareKind, compareFlags));
        }
예제 #4
0
        /// <summary>
        /// Creates a compare instruction of the given type.
        /// </summary>
        /// <param name="block">The current basic block.</param>
        /// <param name="builder">The current builder.</param>
        /// <param name="compareKind">The comparison kind.</param>
        /// <param name="instructionFlags">The instruction flags.</param>
        private static Value CreateCompare(
            Block block,
            IRBuilder builder,
            CompareKind compareKind,
            ILInstructionFlags instructionFlags)
        {
            var compareFlags = CompareFlags.None;

            if (instructionFlags.HasFlags(ILInstructionFlags.Unsigned))
            {
                compareFlags |= CompareFlags.UnsignedOrUnordered;
            }
            return(CreateCompare(block, builder, compareKind, compareFlags));
        }