llvm-build: Add an explicit component type to represent targets.
authorDaniel Dunbar <daniel@zuster.org>
Thu, 10 Nov 2011 00:49:51 +0000 (00:49 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 10 Nov 2011 00:49:51 +0000 (00:49 +0000)
 - Gives us a place to hang target specific metadata (like whether the target has a JIT).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144250 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
docs/LLVMBuild.html
lib/Target/ARM/LLVMBuild.txt
lib/Target/CBackend/LLVMBuild.txt
lib/Target/CellSPU/LLVMBuild.txt
lib/Target/CppBackend/LLVMBuild.txt
lib/Target/MBlaze/LLVMBuild.txt
lib/Target/MSP430/LLVMBuild.txt
lib/Target/Mips/LLVMBuild.txt
lib/Target/PTX/LLVMBuild.txt
lib/Target/PowerPC/LLVMBuild.txt
lib/Target/Sparc/LLVMBuild.txt
lib/Target/X86/LLVMBuild.txt
lib/Target/XCore/LLVMBuild.txt
utils/llvm-build/llvmbuild/componentinfo.py
utils/llvm-build/llvmbuild/main.py

index bb1883a12c56f4e74f01dda0382b3e8e5ce2d3b4..1616b2d4593d4760ee5834dc11c504183c32b42e 100644 (file)
@@ -134,7 +134,7 @@ $ROOT of project trees for things which can be checked out separately. -->
 </div>
 
 <!-- *********************************************************************** -->
-<h2><a name="formatref">LLVMBuild Format Reference</a></h2>
+<h2><a name="formatreference">LLVMBuild Format Reference</a></h2>
 <!-- *********************************************************************** -->
 
 <div>
@@ -151,11 +151,12 @@ $ROOT of project trees for things which can be checked out separately. -->
 
 <i>; Properties are declared using '=' and are contained in the previous section.
 ;
-; We support simple scalar values and list values, where items are separated by
-; spaces. There is no support for quoting, and so property values may not contain
-; spaces.</i>
+; We support simple string and boolean scalar values and list values, where
+; items are separated by spaces. There is no support for quoting, and so
+; property values may not contain spaces.</i>
 property_name = property_value
 list_property_name = value_1 value_2 <em>...</em> value_n
+boolean_property_name = 1 <em>(or 0)</em>
 </pre>
   </div>
 
@@ -281,6 +282,21 @@ required_libraries = Archive BitReader Core Support TransformUtils
       </ul>
     </li>
 
+    <li><i>type = TargetGroup</i>
+      <p>TargetGroup components are an extension of LibraryGroups, specifically
+      for defining LLVM targets (which are handled specially in a few
+      places).</p>
+
+      <p>The name of the component should always be the name of the target.</p>
+
+      <p>Components with this type use the LibraryGroup properties in addition
+      to:</p>
+      <ul>
+        <li><i>has_jit</i> <b>[optional]</b> <b>[boolean]</b>
+          <p>Whether this target supports JIT compilation.</p></li>
+      </ul>
+    </li>
+
     <li><i>type = Tool</i>
       <p>Tool components define standalone command line tools which should be
       built from the source code in the component directory and linked.</p>
index a7f209cf6e6d74c7d7d0324aefe30e4a63530b7a..cfac6ac51ba2c8f82921d2f228161f39f1d5d82b 100644 (file)
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = ARM
 parent = Target
 add_to_library_groups = all-targets
+has_jit = 1
 
 [component_1]
 type = Library
index 1bc5ea1070aa0adcce0298802201a10735245716..7cd420bfe026f97ec4a48fa300230a61c5048ace 100644 (file)
@@ -16,7 +16,7 @@
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = CBackend
 parent = Target
 add_to_library_groups = all-targets
index 03e592cd7af76b6c1d495419e8e6d35dfcecf40d..e8db9f3f84da5838caad666e07eb1577905ea026 100644 (file)
@@ -16,7 +16,7 @@
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = CellSPU
 parent = Target
 add_to_library_groups = all-targets
index 9602f57f9ef4a29ba8290ddffd8f5b6e5f56885e..447795f3b88a5bbc9260e8626362c64a1819f564 100644 (file)
@@ -16,7 +16,7 @@
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = CppBackend
 parent = Target
 add_to_library_groups = all-targets
index 7bea2687612ff83b66fcbf69e5b94dd3436d150d..b953e3df305662c9a0c464089e418cee19b13bd3 100644 (file)
@@ -16,7 +16,7 @@
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = MBlaze
 parent = Target
 add_to_library_groups = all-targets
index 3081146e68f8d83277fa4babc1439c152d077801..8b0b1f6534d4a429a8af2cd6cba1150c7bca5035 100644 (file)
@@ -16,7 +16,7 @@
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = MSP430
 parent = Target
 add_to_library_groups = all-targets
index b9d9abf93663d4e57ae9c805a5c46fbd17f8648c..bcec4a9661f866aa96842849ecc18a1470b3b31f 100644 (file)
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = Mips
 parent = Target
 add_to_library_groups = all-targets
+has_jit = 1
 
 [component_1]
 type = Library
index 2d24524d2e2861001d2b77f47d541241712f26dc..27119c2a3e7ea13c3d366ea6b67464f1a106b804 100644 (file)
@@ -16,7 +16,7 @@
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = PTX
 parent = Target
 add_to_library_groups = all-targets
index 4a93587bdc776ccffa45b5adbf91ff2c9729e7dd..3c439f37738547cccd4274b249deeb3445f42d1e 100644 (file)
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = PowerPC
 parent = Target
 add_to_library_groups = all-targets
+has_jit = 1
 
 [component_1]
 type = Library
index 21cd91fa0b83293ae63104f14309175e45d10179..f59cc2eec422df171e60191e34e3c1745a215a02 100644 (file)
@@ -16,7 +16,7 @@
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = Sparc
 parent = Target
 add_to_library_groups = all-targets
index b0958f3825e803c48a88cc6867a97f87dae9d5ef..7f48a9e485cfa1e39df88d3de099db00e6455ca2 100644 (file)
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = X86
 parent = Target
 add_to_library_groups = all-targets
+has_jit = 1
 
 [component_1]
 type = Library
index 321f25fa292f7d911fc360238c8fe48f06a6ff80..41943c3690604d3f81689cbf339a91d3f17354ec 100644 (file)
@@ -16,7 +16,7 @@
 ;===------------------------------------------------------------------------===;
 
 [component_0]
-type = LibraryGroup
+type = TargetGroup
 name = XCore
 parent = Target
 add_to_library_groups = all-targets
index fb455710b6ad899862627e749d4c622ca6789fc7..00b8ac52a94537a4dfc26e296bca652dc00b189f 100644 (file)
@@ -188,6 +188,60 @@ class LibraryGroupComponentInfo(ComponentInfo):
     def get_llvmconfig_component_name(self):
         return self.name.lower()
 
+class TargetGroupComponentInfo(ComponentInfo):
+    type_name = 'TargetGroup'
+
+    @staticmethod
+    def parse(subpath, items):
+        kwargs = ComponentInfo.parse_items(items, has_dependencies = False)
+        kwargs['required_libraries'] = items.get_list('required_libraries')
+        kwargs['add_to_library_groups'] = items.get_list(
+            'add_to_library_groups')
+        kwargs['has_jit'] = items.get_optional_bool('has_jit', False)
+        return TargetGroupComponentInfo(subpath, **kwargs)
+
+    def __init__(self, subpath, name, parent, required_libraries = [],
+                 add_to_library_groups = [], has_jit = False):
+        ComponentInfo.__init__(self, subpath, name, [], parent)
+
+        # The names of the library components which are required when linking
+        # with this component.
+        self.required_libraries = list(required_libraries)
+
+        # The names of the library group components this component should be
+        # considered part of.
+        self.add_to_library_groups = list(add_to_library_groups)
+
+        # Whether or not this target supports the JIT.
+        self.has_jit = bool(has_jit)
+
+    def get_component_references(self):
+        for r in ComponentInfo.get_component_references(self):
+            yield r
+        for r in self.required_libraries:
+            yield ('required library', r)
+        for r in self.add_to_library_groups:
+            yield ('library group', r)
+
+    def get_llvmbuild_fragment(self):
+        result = StringIO.StringIO()
+        print >>result, 'type = %s' % self.type_name
+        print >>result, 'name = %s' % self.name
+        print >>result, 'parent = %s' % self.parent
+        if self.required_libraries:
+            print >>result, 'required_libraries = %s' % ' '.join(
+                self.required_libraries)
+        if self.add_to_library_groups:
+            print >>result, 'add_to_library_groups = %s' % ' '.join(
+                self.add_to_library_groups)
+        if self.has_jit:
+            print >>result, 'has_jit = %s' % ' '.join(
+                int(self.has_jit))
+        return result.getvalue()
+
+    def get_llvmconfig_component_name(self):
+        return self.name.lower()
+
 class ToolComponentInfo(ComponentInfo):
     type_name = 'Tool'
 
@@ -255,11 +309,27 @@ class IniFormatParser(dict):
             raise ParseError("missing value for required string: %r" % key)
         return value
 
+    def get_optional_bool(self, key, default = None):
+        value = self.get_optional_string(key)
+        if not value:
+            return default
+        if value not in ('0', '1'):
+            raise ParseError("invalid value(%r) for boolean property: %r" % (
+                    value, key))
+        return bool(int(value))
+
+    def get_bool(self, key):
+        value = self.get_optional_bool(key)
+        if value is None:
+            raise ParseError("missing value for required boolean: %r" % key)
+        return value
+
 _component_type_map = dict(
     (t.type_name, t)
     for t in (GroupComponentInfo,
               LibraryComponentInfo, LibraryGroupComponentInfo,
-              ToolComponentInfo, BuildToolComponentInfo))
+              ToolComponentInfo, BuildToolComponentInfo,
+              TargetGroupComponentInfo))
 def load_from_path(path, subpath):
     # Load the LLVMBuild.txt file as an .ini format file.
     parser = ConfigParser.RawConfigParser()
index 2a9ef5d9073dc16f5de623fd8b63fc7e35093acc..cc4617d9b99ad7e8605b83b07936ab52bc7c9d4d 100644 (file)
@@ -242,8 +242,8 @@ class LLVMProjectInfo(object):
         # dependencies for added library groups.
         entries = {}
         for c in self.ordered_component_infos:
-            # Only Library and LibraryGroup components are in the table.
-            if c.type_name not in ('Library', 'LibraryGroup'):
+            # Only certain components are in the table.
+            if c.type_name not in ('Library', 'LibraryGroup', 'TargetGroup'):
                 continue
 
             # Compute the llvm-config "component name". For historical reasons,
@@ -251,10 +251,10 @@ class LLVMProjectInfo(object):
             llvmconfig_component_name = c.get_llvmconfig_component_name()
             
             # Get the library name, or None for LibraryGroups.
-            if c.type_name == 'LibraryGroup':
-                library_name = None
-            else:
+            if c.type_name == 'Library':
                 library_name = c.get_library_name()
+            else:
+                library_name = None
 
             # Get the component names of all the required libraries.
             required_llvmconfig_component_names = [