示例#1
0
        /// <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);
        }
示例#2
0
        /// <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);
        }
示例#4
0
        /// <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);
        }
示例#5
0
 /// <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);
 }
示例#6
0
 /// <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));
 }
示例#7
0
 /// <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));
 }
示例#8
0
        /// <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);
        }
示例#9
0
        /// <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);
        }
示例#10
0
 /// <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));
 }
示例#12
0
        /// <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);
        }