示例#1
0
        /// <summary cref="ILBackend.GenerateLocals{TEmitter}(EntryPoint, TEmitter, KernelGenerationData, ImmutableArray{FieldInfo}, ILLocal)"/>
        protected override void GenerateLocals <TEmitter>(
            EntryPoint entryPoint,
            TEmitter emitter,
            KernelGenerationData kernelData,
            ImmutableArray <FieldInfo> taskArgumentMapping,
            ILLocal task)
        {
            // Cache all fields in local variables
            var taskArgumentLocals = ImmutableArray.CreateBuilder <ILLocal>(taskArgumentMapping.Length);

            for (int i = 0, e = taskArgumentMapping.Length; i < e; ++i)
            {
                var taskArgument     = taskArgumentMapping[i];
                var taskArgumentType = taskArgument.FieldType;

                // Load instance field i
                emitter.Emit(LocalOperation.Load, task);
                emitter.Emit(OpCodes.Ldfld, taskArgumentMapping[i]);

                // Declare local
                taskArgumentLocals.Add(emitter.DeclareLocal(taskArgumentType));

                // Cache field value in local variable
                emitter.Emit(LocalOperation.Store, taskArgumentLocals[i]);
            }
            kernelData.SetupUniforms(taskArgumentLocals.MoveToImmutable());
        }
示例#2
0
        /// <summary cref="IILEmitter.DeclareLocal(Type)"/>
        public ILLocal DeclareLocal(Type type)
        {
            var result = new ILLocal(locals.Count, type);

            locals.Add(result);
            return(result);
        }
示例#3
0
        /// <summary>
        /// Declares a locally internal type.
        /// </summary>
        /// <param name="type">The allocation type.</param>
        /// <returns>The allocated local.</returns>
        private ILLocal DeclareLocalInternal(Type type)
        {
            var result = new ILLocal(locals.Count, type);

            locals.Add(result);
            return(result);
        }
示例#4
0
        public ILLocal DeclareLocal(Type type)
        {
            var local  = Generator.DeclareLocal(type);
            var result = new ILLocal(declaredLocals.Count, type);

            declaredLocals.Add(local);
            return(result);
        }
示例#5
0
        private ILLocal DeclareLocalInternal(Type type, bool pinned)
        {
            var local  = Generator.DeclareLocal(type);
            var result = new ILLocal(declaredLocals.Count, type);

            declaredLocals.Add(local);
            return(result);
        }
示例#6
0
        /// <summary cref="IILEmitter.Emit(LocalOperation, ILLocal)"/>
        public void Emit(LocalOperation operation, ILLocal local)
        {
            EmitPrefix();
            switch (operation)
            {
            case LocalOperation.Load:
                Writer.Write("ldloc ");
                break;

            case LocalOperation.LoadAddress:
                Writer.Write("ldloca ");
                break;

            default:
                Writer.Write("stloc ");
                break;
            }
            Writer.WriteLine(local.Index);
        }
示例#7
0
        public void Emit(LocalOperation operation, ILLocal local)
        {
            var localBuilder = declaredLocals[local.Index];

            switch (operation)
            {
            case LocalOperation.Load:
                Generator.Emit(OpCodes.Ldloc, localBuilder);
                break;

            case LocalOperation.LoadAddress:
                Generator.Emit(OpCodes.Ldloca, localBuilder);
                break;

            default:
                Generator.Emit(OpCodes.Stloc, localBuilder);
                break;
            }
        }
示例#8
0
 /// <summary cref="IILEmitter.Emit(LocalOperation, ILLocal)"/>
 public void Emit(LocalOperation operation, ILLocal local)
 {
 }