/// <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()); }
/// <summary cref="IILEmitter.DeclareLocal(Type)"/> public ILLocal DeclareLocal(Type type) { var result = new ILLocal(locals.Count, type); locals.Add(result); return(result); }
/// <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); }
public ILLocal DeclareLocal(Type type) { var local = Generator.DeclareLocal(type); var result = new ILLocal(declaredLocals.Count, type); declaredLocals.Add(local); return(result); }
private ILLocal DeclareLocalInternal(Type type, bool pinned) { var local = Generator.DeclareLocal(type); var result = new ILLocal(declaredLocals.Count, type); declaredLocals.Add(local); return(result); }
/// <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); }
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; } }
/// <summary cref="IILEmitter.Emit(LocalOperation, ILLocal)"/> public void Emit(LocalOperation operation, ILLocal local) { }