예제 #1
0
파일: Transformer.cs 프로젝트: linhdh/ILGPU
        internal void Transform <THandler>(
            IRContext context,
            THandler handler)
            where THandler : ITransformerHandler
        {
            Debug.Assert(context != null, "Invalid conext");

            var toTransform = context.GetMethodCollection(
                new MethodPredicate(Configuration.RequiredFlags));

            if (toTransform.TotalNumMethods < 1)
            {
                return;
            }

            // Apply all transformations
            foreach (var transform in Transformations)
            {
                handler.BeforeTransformation(
                    context,
                    transform);
                transform.Transform(toTransform);
                handler.AfterTransformation(
                    context,
                    transform);
            }

            // Apply final flags
            foreach (var entry in toTransform)
            {
                entry.AddTransformationFlags(Configuration.TransformationFlags);
            }

            if (Configuration.FinalGC)
            {
                context.GC();
            }
        }