File: pipeline_generator.py

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (47 lines) | stat: -rwxr-xr-x 1,618 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3

import argparse
import json
import os
import sys
import textwrap

# Append the src dir
sys.path.append(os.path.join(os.path.dirname(
    os.path.dirname(os.path.abspath(__file__))), 'src'))

import pass_pipeline_library  # noqa (E402 module level import not at top of file)

import passes                 # noqa (E402)

normal_pipeline = list(pass_pipeline_library.normal_passpipelines())
pass_pipelines = [x.identifier for x in normal_pipeline]

parser = argparse.ArgumentParser(description=textwrap.dedent("""
Generate pass pipelines based off of the normal swift pipeline.
"""))

parser.add_argument('--disable-pass', nargs='*', help='Disable this pass',
                    choices=[x.name for x in passes.PASSES], action='append',
                    default=[])
parser.add_argument('--disable-passpipeline', nargs='*',
                    help='Disable this pass list', choices=pass_pipelines,
                    default=[], action='append')

args = parser.parse_args()

disabled_passes = sum(args.disable_pass, [])
disabled_passpipelines = sum(args.disable_passpipeline, [])

# First filter out pipelines.
normal_pipeline_generated = [x.generate()
                             for x in normal_pipeline
                             if x.identifier not in disabled_passpipelines]

# Then filter out specific passes.
for i in range(len(normal_pipeline_generated)):
    normal_pipeline_generated[i] = [
        x for x in normal_pipeline_generated[i] if x not in disabled_passes]

json.dump(normal_pipeline_generated, sys.stdout,
          sort_keys=True, indent=4, separators=(',', ': '))