コード例 #1
0
        /// <summary>
        /// Lowers set field operations into separate SSA values.
        /// </summary>
        private static void Lower(
            RewriterContext context,
            TypeLowering <ViewType> _,
            SubViewValue value)
        {
            var builder  = context.Builder;
            var location = value.Location;
            var pointer  = builder.CreateGetField(
                location,
                value.Source,
                new FieldSpan(0));
            var newPointer = builder.CreateLoadElementAddress(
                location,
                pointer,
                value.Offset);

            var length = value.Length;

            if (length.BasicValueType != BasicValueType.Int64)
            {
                length = builder.CreateConvertToInt64(
                    value.Location,
                    length);
            }
            var subView = builder.CreateDynamicStructure(
                location,
                newPointer,
                length);

            context.ReplaceAndRemove(value, subView);
        }
コード例 #2
0
        /// <summary cref="IValueVisitor.Visit(SubViewValue)"/>
        public void Visit(SubViewValue value)
        {
            var viewType = value.Type as ViewType;
            var source   = LoadAs <ViewVariable>(value.Source);
            var offset   = LoadAs <PrimitiveVariable>(value.Offset);
            var length   = LoadAs <PrimitiveVariable>(value.Length);

            var target = AllocatePointerType(viewType.ElementType, viewType.AddressSpace);

            MakeLoadElementAddress(
                offset,
                target,
                source.Pointer);

            var newSubView = new ViewVariable(
                viewType,
                target,
                length);

            Bind(value, newSubView);
        }
コード例 #3
0
        /// <summary cref="IValueVisitor.Visit(SubViewValue)"/>
        public void Visit(SubViewValue value)
        {
            var viewType = value.Type as ViewType;
            var source   = LoadAs <ViewImplementationRegister>(value.Source);
            var offset   = LoadPrimitive(value.Offset);
            var length   = LoadPrimitive(value.Length);

            var targetAddressRegister = AllocatePlatformRegister(value, out RegisterDescription _);

            MakeLoadElementAddress(
                viewType,
                offset,
                targetAddressRegister,
                source.Pointer);

            var newSubView = new ViewImplementationRegister(
                viewType,
                targetAddressRegister,
                length);

            Bind(value, newSubView);
        }
コード例 #4
0
        /// <summary cref="IValueVisitor.Visit(SubViewValue)"/>
        public void Visit(SubViewValue value)
        {
            var source = LoadView(value.Source);
            var offset = LoadAs <PrimitiveVariable>(value.Offset);
            var length = LoadAs <PrimitiveVariable>(value.Length);
            var target = AllocateView(value);

            // Declare view
            Declare(target);

            // Assign pointer
            using (var statement = BeginStatement(target, target.PointerFieldIndex))
            {
                statement.AppendCommand(CLInstructions.AddressOfOperation);
                statement.Append(source);
                statement.AppendField(target.PointerFieldIndex);
                statement.AppendIndexer(offset);
            }

            // Assign length
            using (var statement = BeginStatement(target, target.LengthFieldIndex))
                statement.Append(length);
        }
コード例 #5
0
 public void Visit(SubViewValue value)
 {
 }
コード例 #6
0
 /// <summary cref="IValueVisitor.Visit(SubViewValue)"/>
 public void Visit(SubViewValue value) =>
 throw new InvalidCodeGenerationException();