Exemplo n.º 1
0
        /// <summary cref="IValueVisitor.Visit(GenericAtomic)"/>
        public void Visit(GenericAtomic atomic)
        {
            var target = LoadPrimitive(atomic.Target);
            var value  = LoadPrimitive(atomic.Value);

            var requiresResult  = atomic.Uses.HasAny || atomic.Kind == AtomicKind.Exchange;
            var atomicOperation = PTXInstructions.GetAtomicOperation(
                atomic.Kind,
                requiresResult);
            var suffix = PTXInstructions.GetAtomicOperationSuffix(
                atomic.Kind,
                atomic.ArithmeticBasicValueType);

            var targetRegister = requiresResult ? AllocatePrimitive(atomic) : default;

            using (var command = BeginCommand(atomicOperation))
            {
                command.AppendNonLocalAddressSpace(
                    (atomic.Target.Type as AddressSpaceType).AddressSpace);
                command.AppendSuffix(suffix);
                if (requiresResult)
                {
                    command.AppendArgument(targetRegister);
                }
                command.AppendArgumentValue(target);
                command.AppendArgument(value);
            }
        }