# Shell execution
if platform.system() not in ['Windows'] or lit.getBashPath() != '':
config.available_features.add('shell')
+
+# Registered Targets
+import subprocess
+import re
+import os
+
+def getRegisteredTargets(tool):
+ set_of_targets = set()
+
+ cmd = subprocess.Popen([tool, '-version'], stdout=subprocess.PIPE)
+
+ # Parse the stdout to get the list of registered targets.
+ parse_targets = False
+ for line in cmd.stdout:
+ if parse_targets:
+ m = re.match( r'(.*) - ', line)
+ if m is not None:
+ set_of_targets.add(m.group(1).strip() + '-registered-target')
+ else:
+ break
+ elif "Registered Targets:" in line:
+ parse_targets = True
+
+ return set_of_targets
+
+registered_targets = getRegisteredTargets(os.path.join(llvm_tools_dir, 'llc'))
+if len(registered_targets) > 0:
+ config.available_features.update(registered_targets)
+else:
+ lit.fatal('No Targets Registered with the LLVM Tools!')