コード例 #1
0
        /// <summary cref="CompilerDeviceFunctions.MakeWarp(InvocationContext, WarpIntrinsicKind)"/>
        protected override Value?MakeWarp(InvocationContext context, WarpIntrinsicKind kind)
        {
            var          builder = context.Builder;
            LLVMValueRef value;

            switch (kind)
            {
            case WarpIntrinsicKind.WarpSize:
                value = MakeWarpSize(builder);
                break;

            case WarpIntrinsicKind.LaneIdx:
                value = BuildCall(builder, GetLaneId.Value);
                break;

            default:
                KeyValuePair <Lazy <LLVMValueRef>, bool> shuffleKey;
                if (!ShuffleLookup.TryGetValue(kind, out shuffleKey))
                {
                    throw context.CompilationContext.GetNotSupportedException(
                              ErrorMessages.NotSupportedWarpIntrinsic, kind);
                }
                // Create final mask
                var args = context.GetLLVMArgs();
                args[2] = BuildWarpShuffleMask(context.Unit, builder, args[2], shuffleKey.Value);
                // Build desired shuffle instruction
                value = BuildCall(builder, shuffleKey.Key.Value, args);
                break;
            }
            return(new Value(typeof(int), value));
        }
コード例 #2
0
        /// <summary>
        /// Builds the actual invocation of the built-in assertion-failed method.
        /// </summary>
        /// <param name="context">The current invocation context.</param>
        /// <returns>Null.</returns>
        private Value?MakeAssertFailed(InvocationContext context)
        {
            var llvmContext = context.LLVMContext;
            var builder     = context.Builder;
            var args        = context.GetLLVMArgs();

            // Convert to void*
            var voidPtrType = llvmContext.VoidPtrType;

            args[0] = BuildBitCast(builder, args[0], voidPtrType, string.Empty);
            args[1] = BuildBitCast(builder, args[1], voidPtrType, string.Empty);
            args[3] = BuildBitCast(builder, args[3], voidPtrType, string.Empty);
            // Convert to size_t
            args[4] = BuildIntCast(builder, args[4], context.Unit.NativeIntPtrType, string.Empty);

            BuildCall(builder, AssertFailedMethod.Value, args);

            return(null);
        }