OSDN Git Service

Subzero, MIPS32: Encoding of FP comparison instructions
[android-x86/external-swiftshader.git] / tests_lit / lit.cfg
1 # -*- Python -*-
2 # Taken from utils/lit/tests in the LLVM tree and hacked together to support
3 # our tests.
4 #
5 # Note: This configuration has simple commands to run Subzero's translator.
6 # They have the form %X2i (i.e. %p2i, %l2i, and %lc2i) where X is defined
7 # as follows:
8 #
9 #   p : Run Subzero's translator, building ICE from PNaCl bitcode directly.
10 #   l : Run Subzero's translator, converting the .ll file to a PNaCl bitcode
11 #       file, reading in the bitcode file and generating LLVM IR, and
12 #       then convert LLVM IR to ICE IR.
13 #   lc : Run Subzero's translator, directly parsing the .ll file into LLVM IR,
14 #        and then convert it to ICE IR.
15 #
16 # These commands can be used in RUN lines by FileCheck. If the Subzero
17 # build being tested lacks any required attributes (e.g., the ability
18 # to parse .ll files), the command will simply return successfully,
19 # generating no output. This allows translation tests to be able to
20 # conditionally test the translator, based on the translator built.
21 #
22 # This conditional handling of translation introduces potential problems
23 # when the output is piped to another command on a RUN line. Executables
24 # like FileCheck expect non-empty input.
25 #
26 # To handle the problem that the pipe is conditional, any command that
27 # doesn't accept empty input should be prefixed by a corresponding
28 # %ifX (i.e. %p2i, %ifl, or %ifpc). Note: %p2i should always work, and
29 # hence %ifp is not necessary (i.e. it is a nop).
30 #
31 # If you need to check other build attributes (other than the
32 # existence of %l2i and %lc2i), you can use the %if command (which is
33 # a short hand for using pydir/ifatts.py).
34
35 import os
36 import re
37 import sys
38
39 import lit.formats
40
41 sys.path.insert(0, 'pydir')
42 from utils import FindBaseNaCl, shellcmd
43
44 # name: The name of this test suite.
45 config.name = 'subzero'
46
47 # testFormat: The test format to use to interpret tests.
48 config.test_format = lit.formats.ShTest()
49
50 # suffixes: A list of file extensions to treat as test files.
51 config.suffixes = ['.ll', '.test']
52
53 # test_source_root: The root path where tests are located.
54 config.test_source_root = os.path.dirname(__file__)
55 config.test_exec_root = config.test_source_root
56 config.target_triple = '(unused)'
57
58 src_root = os.path.join(FindBaseNaCl(), 'toolchain_build/src/subzero')
59 bin_root = src_root
60 config.substitutions.append(('%{src_root}', src_root))
61 config.substitutions.append(('%{python}', sys.executable))
62
63 pydir = os.path.join(bin_root, 'pydir')
64
65 # Finding PNaCl binary tools. Tools used in the tests must be listed in the
66 # pnaclbintools list.
67 pnaclbinpath = os.path.abspath(os.environ.get('PNACL_BIN_PATH'))
68
69 # Define the location of the pnacl-sz tool.
70 pnacl_sz_tool = os.path.join(bin_root, 'pnacl-sz')
71 pnacl_sz_atts = shellcmd(' '.join([pnacl_sz_tool, '--build-atts']),
72                         echo=False).split()
73
74 # Add build attributes of pnacl-sz tool to the set of available features.
75 config.available_features.update(pnacl_sz_atts)
76
77 def if_cond_flag(Value):
78   return '--cond=true' if Value else '--cond=false'
79
80 # shell conditional commands.
81 if_atts = [os.path.join(pydir, 'if.py')]
82 if_atts_cmd = if_atts + ['--have=' + att for att in pnacl_sz_atts]
83 ifl2i_atts_cmd = if_atts + [if_cond_flag('allow_llvm_ir' in pnacl_sz_atts),
84                             '--command']
85 iflc2i_atts_cmd = if_atts + [if_cond_flag('allow_llvm_ir_as_input'
86                                           in pnacl_sz_atts), '--command']
87
88 # Base command for running pnacl-sz
89 pnacl_sz_cmd = [os.path.join(pydir, 'run-pnacl-sz.py'),
90                 '--echo-cmd',
91                 '--pnacl-sz', pnacl_sz_tool,
92                 '--pnacl-bin-path', pnaclbinpath]
93 if 'FORCEASM' in lit_config.params:
94   pnacl_sz_cmd += ['--forceasm']
95
96 # Run commands only if corresponding build attributes apply, including
97 # for each compiler setup.
98 config.substitutions.append(('%ifp', ' '))
99 config.substitutions.append(('%iflc', ' '.join(iflc2i_atts_cmd)))
100 config.substitutions.append(('%ifl', ' '.join(ifl2i_atts_cmd)))
101 config.substitutions.append(('%if', ' '.join(if_atts_cmd)))
102
103 # Translate LLVM source for each compiler setup.
104 config.substitutions.append(('%p2i', ' '.join(pnacl_sz_cmd)))
105 config.substitutions.append(('%l2i', ' '.join(ifl2i_atts_cmd + pnacl_sz_cmd
106                                               + ['--llvm'])))
107 config.substitutions.append(('%lc2i', ' '.join(iflc2i_atts_cmd + pnacl_sz_cmd
108                                                + ['--llvm-source'])))
109
110 config.substitutions.append(('%pnacl_sz', pnacl_sz_tool))
111
112 pnaclbintools = [r'\b' + x + r'\b' for x in
113                  ['FileCheck',
114                   'llvm-as',
115                   'llvm-mc',
116                   'llvm-readobj',
117                   'not',
118                   'pnacl-bcdis',
119                   'pnacl-bcfuzz',
120                   'pnacl-freeze']]
121
122 for tool in pnaclbintools:
123   # The re.sub() line is adapted from one of LLVM's lit.cfg files.
124   # Extract the tool name from the pattern.  This relies on the tool
125   # name being surrounded by \b word match operators.  If the
126   # pattern starts with "| ", include it in the string to be
127   # substituted.
128   substitution = re.sub(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_]+)\\b\W*$",
129                         r"\2" + pnaclbinpath + "/" + r"\4",
130                         tool)
131   config.substitutions.append((tool, substitution))
132
133 # Add a feature to detect the Python version.
134 config.available_features.add("python%d.%d" % (sys.version_info[0],
135                                                sys.version_info[1]))
136
137 # Debugging output
138 def dbg(s):
139   print '[DBG] %s' % s
140
141 dbg('bin_root = %s' % bin_root)
142 dbg('pnaclbinpath = %s' % pnaclbinpath)
143 dbg("Build attributes = %s" % pnacl_sz_atts)