[llvm-commits] [llvm] r144253 - in /llvm/trunk: lib/Target/ lib/Target/ARM/ lib/Target/CBackend/ lib/Target/CellSPU/ lib/Target/CppBackend/ lib/Target/MBlaze/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PTX/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/X86/ lib/Target/XCore/ utils/llvm-build/llvmbuild/

Daniel Dunbar daniel at zuster.org
Wed Nov 9 16:50:07 PST 2011


Author: ddunbar
Date: Wed Nov  9 18:50:07 2011
New Revision: 144253

URL: http://llvm.org/viewvc/llvm-project?rev=144253&view=rev
Log:
llvm-build: Add --native-target and --enable-targets options, and add logic to
handle defining the "magic" target related components (like native,
nativecodegen, and engine).
 - We still require these components to be in the project (currently in
   lib/Target) so that we have a place to document them and hopefully make it
   more obvious that they are "magic".

Modified:
    llvm/trunk/lib/Target/ARM/LLVMBuild.txt
    llvm/trunk/lib/Target/CBackend/LLVMBuild.txt
    llvm/trunk/lib/Target/CellSPU/LLVMBuild.txt
    llvm/trunk/lib/Target/CppBackend/LLVMBuild.txt
    llvm/trunk/lib/Target/LLVMBuild.txt
    llvm/trunk/lib/Target/MBlaze/LLVMBuild.txt
    llvm/trunk/lib/Target/MSP430/LLVMBuild.txt
    llvm/trunk/lib/Target/Mips/LLVMBuild.txt
    llvm/trunk/lib/Target/PTX/LLVMBuild.txt
    llvm/trunk/lib/Target/PowerPC/LLVMBuild.txt
    llvm/trunk/lib/Target/Sparc/LLVMBuild.txt
    llvm/trunk/lib/Target/X86/LLVMBuild.txt
    llvm/trunk/lib/Target/XCore/LLVMBuild.txt
    llvm/trunk/utils/llvm-build/llvmbuild/componentinfo.py
    llvm/trunk/utils/llvm-build/llvmbuild/main.py

Modified: llvm/trunk/lib/Target/ARM/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/ARM/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = ARM
 parent = Target
-add_to_library_groups = all-targets
 has_jit = 1
 
 [component_1]

Modified: llvm/trunk/lib/Target/CBackend/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CBackend/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CBackend/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/CBackend/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = CBackend
 parent = Target
-add_to_library_groups = all-targets
 
 [component_1]
 type = Library

Modified: llvm/trunk/lib/Target/CellSPU/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CellSPU/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/CellSPU/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = CellSPU
 parent = Target
-add_to_library_groups = all-targets
 
 [component_1]
 type = Library

Modified: llvm/trunk/lib/Target/CppBackend/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/CppBackend/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/CppBackend/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = CppBackend
 parent = Target
-add_to_library_groups = all-targets
 
 [component_1]
 type = Library

Modified: llvm/trunk/lib/Target/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -21,20 +21,32 @@
 parent = Libraries
 required_libraries = Core MC Support
 
+; This is a convenient group we define (and expect targets to add to) which
+; makes it easy for tools to include every target.
 [component_1]
 type = LibraryGroup
 name = all-targets
 parent = Libraries
 
+; This is a special group whose required libraries are extended (by llvm-build)
+; with the configured native target, if any.
 [component_2]
 type = LibraryGroup
-name = native
+name = Native
 parent = Libraries
-required_libraries = X86
 
+; This is a special group whose required libraries are extended (by llvm-build)
+; with the configured native code generator, if any.
 [component_3]
 type = LibraryGroup
-name = nativecodegen
+name = NativeCodeGen
+parent = Libraries
+
+; This is a special group whose required libraries are extended (by llvm-build)
+; with the best execution engine (the native JIT, if available, or the
+; interpreter).
+[component_4]
+type = LibraryGroup
+name = Engine
 parent = Libraries
-required_libraries = X86CodeGen
 

Modified: llvm/trunk/lib/Target/MBlaze/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MBlaze/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/MBlaze/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = MBlaze
 parent = Target
-add_to_library_groups = all-targets
 
 [component_1]
 type = Library

Modified: llvm/trunk/lib/Target/MSP430/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MSP430/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/MSP430/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/MSP430/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = MSP430
 parent = Target
-add_to_library_groups = all-targets
 
 [component_1]
 type = Library

Modified: llvm/trunk/lib/Target/Mips/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/Mips/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = Mips
 parent = Target
-add_to_library_groups = all-targets
 has_jit = 1
 
 [component_1]

Modified: llvm/trunk/lib/Target/PTX/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PTX/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/PTX/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = PTX
 parent = Target
-add_to_library_groups = all-targets
 
 [component_1]
 type = Library

Modified: llvm/trunk/lib/Target/PowerPC/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/PowerPC/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = PowerPC
 parent = Target
-add_to_library_groups = all-targets
 has_jit = 1
 
 [component_1]

Modified: llvm/trunk/lib/Target/Sparc/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/Sparc/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = Sparc
 parent = Target
-add_to_library_groups = all-targets
 
 [component_1]
 type = Library

Modified: llvm/trunk/lib/Target/X86/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/X86/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = X86
 parent = Target
-add_to_library_groups = all-targets
 has_jit = 1
 
 [component_1]

Modified: llvm/trunk/lib/Target/XCore/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/XCore/LLVMBuild.txt?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/lib/Target/XCore/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/XCore/LLVMBuild.txt Wed Nov  9 18:50:07 2011
@@ -19,7 +19,6 @@
 type = TargetGroup
 name = XCore
 parent = Target
-add_to_library_groups = all-targets
 
 [component_1]
 type = Library

Modified: llvm/trunk/utils/llvm-build/llvmbuild/componentinfo.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/llvm-build/llvmbuild/componentinfo.py?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/utils/llvm-build/llvmbuild/componentinfo.py (original)
+++ llvm/trunk/utils/llvm-build/llvmbuild/componentinfo.py Wed Nov  9 18:50:07 2011
@@ -215,6 +215,10 @@
         # Whether or not this target supports the JIT.
         self.has_jit = bool(has_jit)
 
+        # Whether or not this target is enabled. This is set in response to
+        # configuration parameters.
+        self.enabled = False
+
     def get_component_references(self):
         for r in ComponentInfo.get_component_references(self):
             yield r

Modified: llvm/trunk/utils/llvm-build/llvmbuild/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/llvm-build/llvmbuild/main.py?rev=144253&r1=144252&r2=144253&view=diff
==============================================================================
--- llvm/trunk/utils/llvm-build/llvmbuild/main.py (original)
+++ llvm/trunk/utils/llvm-build/llvmbuild/main.py Wed Nov  9 18:50:07 2011
@@ -498,6 +498,105 @@
 
         f.close()
 
+def add_magic_target_components(parser, project, opts):
+    """add_magic_target_components(project, opts) -> None
+
+    Add the "magic" target based components to the project, which can only be
+    determined based on the target configuration options.
+
+    This currently is responsible for populating the required_libraries list of
+    the "Native", "NativeCodeGen", and "Engine" components.
+    """
+
+    # Determine the available targets.
+    available_targets = dict((ci.name,ci)
+                             for ci in project.component_infos
+                             if ci.type_name == 'TargetGroup')
+
+    # Find the configured native target.
+
+    # We handle a few special cases of target names here for historical
+    # reasons, as these are the names configure currently comes up with.
+    native_target_name = { 'x86' : 'X86',
+                           'x86_64' : 'X86',
+                           'Unknown' : None }.get(opts.native_target,
+                                                  opts.native_target)
+    if native_target_name is None:
+        native_target = None
+    else:
+        native_target = available_targets.get(native_target_name)
+        if native_target is None:
+            parser.error("invalid native target: %r (not in project)" % (
+                    opts.native_target,))
+        if native_target.type_name != 'TargetGroup':
+            parser.error("invalid native target: %r (not a target)" % (
+                    opts.native_target,))
+
+    # Find the list of targets to enable.
+    if opts.enable_targets is None:
+        enable_targets = available_targets.values()
+    else:
+        enable_targets = []
+        for name in opts.enable_targets.split():
+            target = available_targets.get(name)
+            if target is None:
+                parser.error("invalid target to enable: %r (not in project)" % (
+                        name,))
+            if target.type_name != 'TargetGroup':
+                parser.error("invalid target to enable: %r (not a target)" % (
+                        name,))
+            enable_targets.append(target)
+
+    # Find the special library groups we are going to populate. We enforce that
+    # these appear in the project (instead of just adding them) so that they at
+    # least have an explicit representation in the project LLVMBuild files (and
+    # comments explaining how they are populated).
+    def find_special_group(name):
+        info = info_map.get(name)
+        if info is None:
+            fatal("expected project to contain special %r component" % (
+                    name,))
+
+        if info.type_name != 'LibraryGroup':
+            fatal("special component %r should be a LibraryGroup" % (
+                    name,))
+
+        if info.required_libraries:
+            fatal("special component %r must have empty %r list" % (
+                    name, 'required_libraries'))
+        if info.add_to_library_groups:
+            fatal("special component %r must have empty %r list" % (
+                    name, 'add_to_library_groups'))
+
+        return info
+
+    info_map = dict((ci.name, ci) for ci in project.component_infos)
+    all_targets = find_special_group('all-targets')
+    native_group = find_special_group('Native')
+    native_codegen_group = find_special_group('NativeCodeGen')
+    engine_group = find_special_group('Engine')
+
+    # Set the enabled bit in all the target groups, and append to the
+    # all-targets list.
+    for ci in enable_targets:
+        all_targets.required_libraries.append(ci.name)
+        ci.enabled = True
+
+    # If we have a native target, then that defines the native and
+    # native_codegen libraries.
+    if native_target and native_target.enabled:
+        native_group.required_libraries.append(native_target.name)
+        native_codegen_group.required_libraries.append(
+            '%sCodeGen' % native_target.name)
+
+    # If we have a native target with a JIT, use that for the engine. Otherwise,
+    # use the interpreter.
+    if native_target and native_target.enabled and native_target.has_jit:
+        engine_group.required_libraries.append('JIT')
+        engine_group.required_libraries.append(native_group.name)
+    else:
+        engine_group.required_libraries.append('Interpreter')
+
 def main():
     from optparse import OptionParser, OptionGroup
     parser = OptionParser("usage: %prog [options]")
@@ -533,6 +632,17 @@
                      help="Write the Makefile project information to PATH",
                      action="store", default=None)
     parser.add_option_group(group)
+
+    group = OptionGroup(parser, "Configuration Options")
+    group.add_option("", "--native-target",
+                      dest="native_target", metavar="NAME",
+                      help=("Treat the named target as the 'native' one, if "
+                            "given [%default]"),
+                      action="store", default=None)
+    group.add_option("", "--enable-targets",
+                      dest="enable_targets", metavar="NAMES",
+                      help=("Enable the given space separated list of targets, "
+                            "or all targets if not present"),
                       action="store", default=None)
     parser.add_option_group(group)
 
@@ -558,6 +668,9 @@
     project_info = LLVMProjectInfo.load_from_path(
         source_root, llvmbuild_source_root)
 
+    # Add the magic target based components.
+    add_magic_target_components(parser, project_info, opts)
+
     # Validate the project component info.
     project_info.validate_components()
 





More information about the llvm-commits mailing list