コード例 #1
0
        /// <summary cref="IValueVisitor.Visit(WarpShuffle)"/>
        public void Visit(WarpShuffle shuffle)
        {
            if (!CLInstructions.TryGetShuffleOperation(
                    Backend.Vendor,
                    shuffle.Kind,
                    out string operation))
            {
                throw new InvalidCodeGenerationException();
            }

            var source = Load(shuffle.Variable);
            var origin = Load(shuffle.Origin);
            var target = Allocate(shuffle);

            using (var statement = BeginStatement(target))
            {
                statement.AppendCommand(operation);
                statement.BeginArguments();

                statement.AppendArgument(source);
                // TODO: create a generic version that does not need this switch
                switch (shuffle.Kind)
                {
                case ShuffleKind.Down:
                case ShuffleKind.Up:
                    statement.AppendArgument(source);
                    break;
                }
                statement.AppendArgument(origin);

                statement.EndArguments();
            }
        }