コード例 #1
0
        /// <summary cref="IValueVisitor.Visit(GenericAtomic)"/>
        public void Visit(GenericAtomic atomic)
        {
            var target = LoadIntrinsic(atomic.Target);
            var value  = LoadIntrinsic(atomic.Value);

            var atomicOperation = CLInstructions.GetAtomicOperation(atomic.Kind);

            StatementEmitter statement;

            if (atomic.Kind == AtomicKind.Exchange)
            {
                var result = AllocateIntrinsic(atomic);
                statement = BeginStatement(result, atomicOperation);
            }
            else
            {
                statement = BeginStatement(atomicOperation);
            }

            statement.BeginArguments();
            statement.AppendAtomicCast(atomic.ArithmeticBasicValueType);
            statement.AppendArgument(target);
            statement.AppendArgument(value);
            statement.EndArguments();

            statement.Dispose();
        }
コード例 #2
0
        /// <summary cref="IBackendCodeGenerator.GenerateCode(GenericAtomic)"/>
        public void GenerateCode(GenericAtomic atomic)
        {
            var target = Load(atomic.Target);
            var value  = Load(atomic.Value);
            var result = Allocate(atomic);

            var atomicOperation = CLInstructions.GetAtomicOperation(atomic.Kind);

            using var statement = BeginStatement(result, atomicOperation);
            statement.BeginArguments();
            statement.AppendAtomicCast(atomic.ArithmeticBasicValueType);
            statement.AppendArgument(target);
            statement.AppendArgument(value);
            statement.EndArguments();
        }