Index: tests_lit/lit.cfg |
diff --git a/tests_lit/lit.cfg b/tests_lit/lit.cfg |
index 825f7d2b3051d4bc366080b71cdbb696fc540b91..1233a76d4fbf7e8d0ebbe2b2af7096320e0c0819 100644 |
--- a/tests_lit/lit.cfg |
+++ b/tests_lit/lit.cfg |
@@ -1,7 +1,36 @@ |
+# -*- Python -*- |
# Taken from utils/lit/tests in the LLVM tree and hacked together to support |
# our tests. |
- |
-# -*- Python -*- |
+# |
+# Note: This configuration has simple commands to run Subzero's translator. |
+# They have the form %X2i (i.e. %p2i, %l2i, and %lc2i) where X is defined |
+# as follows: |
+# |
+# p : Run Subzero's translator, building ICE from PNaCl bitcode directly. |
+# l : Run Subzero's translator, converting the .ll file to a PNaCl bitcode |
+# file, reading in the bitcode file and generating LLVM IR, and |
+# then convert LLVM IR to ICE IR. |
+# lc : Run Subzero's translator, directly parsing the .ll file into LLVM IR, |
+# and then convert it to ICE IR. |
+# |
+# These commands can be used in RUN lines by FileCheck. If the Subzero |
+# build being tested lacks any required attributes (e.g., the ability |
+# to parse .ll files), the command will simply return successfully, |
+# generating no output. This allows translation tests to be able to |
+# conditionally test the translator, based on the translator built. |
+# |
+# This conditional handling of translation introduces potential problems |
+# when the output is piped to another command on a RUN line. Executables |
+# like FileCheck expect non-empty input. |
+# |
+# To handle the problem that the pipe is conditional, any command that |
+# doesn't accept empty input should be prefixed by a corresponding |
+# %ifX (i.e. %p2i, %ifl, or %ifpc). Note: %p2i should always work, and |
+# hence %ifp is not necessary (i.e. it is a nop). |
+# |
+# If you need to check other build attributes (other than the |
+# existence of %l2i and %lc2i), you can use the %if command (which is |
+# a short hand for using pydir/ifatts.py). |
import os |
import re |
@@ -11,6 +40,7 @@ import lit.formats |
sys.path.insert(0, 'pydir') |
from utils import FindBaseNaCl |
+from ifatts import GetFileAttributes |
# name: The name of this test suite. |
config.name = 'subzero' |
@@ -37,34 +67,39 @@ pydir = os.path.join(bin_root, 'pydir') |
# the llvmbintools list. |
llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH')) |
-# Finding Subzero tools |
+# Define the location of the llvm2ice tool. |
llvm2icetool = os.path.join(bin_root, 'llvm2ice') |
- |
-# Convert LLVM source to PNaCl bitcode, read using the |
-# Subzero bitcode reader, and then translate. |
-config.substitutions.append( |
- ('%p2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'), |
- '--llvm2ice', llvm2icetool, |
- '--llvm-bin-path', llvmbinpath |
- ]))) |
- |
-# Convert LLVM source to PNaCl bitcode, read using the PNaCl bitcode reader, |
-# convert to ICE using the ICE Converter, and then translate. |
-# TODO(kschimpf) Deprecated, remove once p2i working. |
-config.substitutions.append( |
- ('%l2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'), |
- '--llvm', '--llvm2ice', llvm2icetool, |
- '--llvm-bin-path', llvmbinpath |
- ]))) |
- |
-# Read LLVM source, convert to ICE using the ICE converter, and then translate. |
-# Note: l2i is preferred over lc2i, since it uses PNaCl bitcode. |
-# TODO(kschimpf) Deprecated, remove once p2i working. |
-config.substitutions.append( |
- ('%lc2i', ' '.join([os.path.join(pydir, 'run-llvm2ice.py'), |
- '--llvm-source', '--llvm2ice', llvm2icetool, |
- '--llvm-bin-path', llvmbinpath |
- ]))) |
+llvm2icetoolatts = os.path.join(bin_root, 'llvm2ice.build_atts') |
+ |
+# Add build attributes of llvm2ice tool to the set of available features. |
+config.available_features.update(GetFileAttributes(llvm2icetoolatts)) |
+ |
+# Base command for testing build attributes |
+if_atts_base = [os.path.join(pydir, 'ifatts.py'), llvm2icetoolatts] |
+if_atts_cmd = if_atts_base + ['--command'] |
+ifl2i_atts_cmd = if_atts_base + ['--att=allow_llvm_ir', '--command'] |
+iflc2i_atts_cmd = if_atts_base + ['--att=allow_llvm_ir', |
+ '--att=allow_llvm_ir_as_input', |
+ '--command'] |
+ |
+# Base command for running llvm2ice |
+llvm2ice_cmd = [os.path.join(pydir, 'run-llvm2ice.py'), |
+ '--llvm2ice', llvm2icetool, |
+ '--llvm-bin-path', llvmbinpath] |
+ |
+# Run commands only if corresponding build attributes apply, including |
+# for each compiler setup. |
+config.substitutions.append(('%ifp', ' ')) |
+config.substitutions.append(('%iflc', ' '.join(iflc2i_atts_cmd))) |
+config.substitutions.append(('%ifl', ' '.join(ifl2i_atts_cmd))) |
+config.substitutions.append(('%if', ' '.join(if_atts_cmd))) |
+ |
+# Translate LLVM source for each compiler setup. |
+config.substitutions.append(('%p2i', ' '.join(llvm2ice_cmd))) |
+config.substitutions.append(('%l2i', ' '.join(ifl2i_atts_cmd + llvm2ice_cmd |
+ + ['--llvm']))) |
+config.substitutions.append(('%lc2i', ' '.join(iflc2i_atts_cmd + llvm2ice_cmd |
+ + ['--llvm-source']))) |
config.substitutions.append(('%llvm2ice', llvm2icetool)) |
config.substitutions.append(('%szdiff', os.path.join(pydir, 'szdiff.py'))) |