/// <summary> /// Initializes all rewriter patterns. /// </summary> static LowerArrays() { AddRewriters(Rewriter); Rewriter.Add <NewArray>(Register, Lower); Rewriter.Add <LoadArrayElementAddress>(Register, Lower); Rewriter.Add <GetArrayLength>(Register, Lower); Rewriter.Add <ArrayToViewCast>(Register, Lower); }
/// <summary> /// Registers all rewriting patterns. /// </summary> static AcceleratorSpecializer() { Rewriter.Add <AcceleratorTypeValue>(Specialize); Rewriter.Add <WarpSizeValue>(Specialize); Rewriter.Add <WriteToOutput>(Specialize); Rewriter.Add <IntAsPointerCast>(CanSpecialize, Specialize); Rewriter.Add <PointerAsIntCast>(CanSpecialize, Specialize); }
/// <summary> /// Registers all conversion patterns. /// </summary> static InferAddressSpaces() { // Rewrites address space casts that are not required. Rewriter.Add <AddressSpaceCast>( IsRedundant, (context, cast) => context.ReplaceAndRemove(cast, cast.Value)); // Invalidate types of affected values Rewriter.Add <PointerCast>(InvalidateType); Rewriter.Add <LoadFieldAddress>(InvalidateType); Rewriter.Add <LoadElementAddress>(InvalidateType); }
/// <summary> /// Initializes all rewriter patterns. /// </summary> static LowerArrays() { AddRewriters(Rewriter); Rewriter.Add <ArrayValue>(Register, Lower); Rewriter.Add <GetArrayExtent>(Register, Lower); Rewriter.Add <GetArrayElement>(Register, Lower); Rewriter.Add <SetArrayElement>(Register, Lower); Rewriter.Add <LoadElementAddress>( (converter, value) => value.IsArrayAccesss && Register(converter, value), Lower); }
/// <summary> /// Adds all internal type rewriters to the given rewriter instance. /// </summary> /// <param name="rewriter">The rewriter to extent.</param> protected static void AddRewriters(Rewriter <TypeLowering <TType> > rewriter) { rewriter.Add <NullValue>(IsTypeDependent, Lower); rewriter.Add <StructureValue>(IsTypeDependent, Lower); rewriter.Add <GetField>( (typeConverter, value) => IsTypeDependent(typeConverter, value, value.StructureType), Lower); rewriter.Add <SetField>(IsTypeDependent, Lower); rewriter.Add <Alloca>( (typeConverter, value) => IsTypeDependent(typeConverter, value, value.AllocaType), Lower); rewriter.Add <PointerCast>( (typeConverter, value) => IsTypeDependent(typeConverter, value, value.TargetType), Lower); rewriter.Add <LoadFieldAddress>( (typeConverter, value) => IsTypeDependent(typeConverter, value, value.StructureType), Lower); rewriter.Add <PhiValue>( (typeConverter, value) => IsTypeDependent(typeConverter, value, value.PhiType), Lower); }
/// <summary> /// Registers all rewriting patterns. /// </summary> static LowerThreadIntrinsics() { Rewriter.Add <Broadcast>( broadcast => !broadcast.IsBuiltIn, (context, value) => Lower <Broadcast, BroadcastLowering>(context, value)); Rewriter.Add <WarpShuffle>( shuffle => !shuffle.IsBuiltIn, (context, value) => Lower <WarpShuffle, WarpShuffleLowering>(context, value)); Rewriter.Add <SubWarpShuffle>( shuffle => !shuffle.IsBuiltIn, (context, value) => Lower <SubWarpShuffle, SubWarpShuffleLowering>(context, value)); }
/// <summary> /// Registers all conversion patterns. /// </summary> static InferAddressSpaces() { // Rewrites address space casts that are not required. Rewriter.Add <AddressSpaceCast>( IsRedundant, (context, cast) => context.ReplaceAndRemove(cast, cast.Value)); }
/// <summary> /// Adds a set of rewriters specialized for a general view-type lowering. /// </summary> protected static void AddRewriters( Rewriter <TypeLowering <ViewType> > rewriter, RewriteConverter < TypeLowering <ViewType>, NewView> newViewConverter, RewriteConverter < TypeLowering <ViewType>, GetViewLength> getViewLengthConverter, RewriteConverter < TypeLowering <ViewType>, SubViewValue> subViewConverter, RewriteConverter < TypeLowering <ViewType>, AddressSpaceCast> addressSpaceCastConverter, RewriteConverter < TypeLowering <ViewType>, ViewCast> viewCastConverter, RewriteConverter < TypeLowering <ViewType>, LoadElementAddress> leaConverter, RewriteConverter < TypeLowering <ViewType>, AlignViewTo> alignToConverter) { AddRewriters(rewriter); rewriter.Add(Register, newViewConverter); rewriter.Add(Register, getViewLengthConverter); rewriter.Add(Register, subViewConverter); rewriter.Add( (converter, value) => value.IsViewCast && Register(converter, value), addressSpaceCastConverter); rewriter.Add( (converter, value) => Register(converter, value, value.SourceType), viewCastConverter); rewriter.Add( (converter, value) => value.IsViewAccess && Register(converter, value), leaConverter); rewriter.Add( (converter, value) => Register(converter, value, value.View.Type), alignToConverter); }
/// <summary> /// Registers all rewriting patterns. /// </summary> static AcceleratorSpecializer() { Rewriter.Add <AcceleratorTypeValue>(Specialize); Rewriter.Add <WarpSizeValue>(Specialize); Rewriter.Add <DebugAssertOperation>(Specialize); Rewriter.Add <WriteToOutput>(Specialize); Rewriter.Add <AsAligned>( (data, _) => data.Specializer.EnableAssertions, Specialize); Rewriter.Add <IntAsPointerCast>(CanSpecialize, Specialize); Rewriter.Add <PointerAsIntCast>(CanSpecialize, Specialize); }
/// <summary> /// Registers all rewriting patterns. /// </summary> static AcceleratorSpecializer() { Rewriter.Add <AcceleratorTypeValue>(Specialize); Rewriter.Add <WarpSizeValue>(Specialize); Rewriter.Add <IntAsPointerCast>(Specialize); }
/// <summary> /// Registers all rewriting patterns. /// </summary> static UnreachableCodeElimination() { Rewriter.Add <PhiValue>((context, mapper, phiValue) => phiValue.RemapArguments(context.Builder, mapper)); }
/// <summary> /// Adds all internal type rewriters to the given rewriter instance. /// </summary> /// <param name="rewriter">The rewriter to extent.</param> protected static void AddRewriters(Rewriter <TypeLowering <TType> > rewriter) { rewriter.Add <NullValue>(IsTypeDependent, Lower); rewriter.Add <StructureValue>(IsTypeDependent, Lower); rewriter.Add <GetField>( (typeConverter, value) => IsTypeDependent(typeConverter, value, value.StructureType), Lower); rewriter.Add <SetField>(IsTypeDependent, Lower); rewriter.Add <Alloca>( (typeConverter, value) => IsTypeDependent(typeConverter, value, value.AllocaType), Lower); rewriter.Add <Load>(IsTypeDependent, InvalidateType); rewriter.Add <AddressSpaceCast>(IsTypeDependent, InvalidateType); rewriter.Add <PointerCast>( (typeConverter, value) => IsTypeDependent(typeConverter, value, value.TargetType), Lower); rewriter.Add <LoadFieldAddress>( (typeConverter, value) => IsTypeDependent(typeConverter, value, value.StructureType), Lower); rewriter.Add <PhiValue>( (typeConverter, value) => IsTypeDependent(typeConverter, value, value.PhiType), Lower); rewriter.Add <Broadcast>(IsTypeDependent, InvalidateType); rewriter.Add <WarpShuffle>(IsTypeDependent, InvalidateType); rewriter.Add <SubWarpShuffle>(IsTypeDependent, InvalidateType); rewriter.Add <Predicate>(IsTypeDependent, InvalidateType); rewriter.Add <MethodCall>(IsTypeDependent, InvalidateType); rewriter.Add <ReturnTerminator>(IsTypeDependent, InvalidateType); }