llvm.org GIT mirror llvm / c352caf
llvm-build: Add an explicit component type to represent targets. - 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 Daniel Dunbar 7 years ago
15 changed file(s) with 112 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
133133
134134
135135
136

LLVMBuild Format Reference

136

LLVMBuild Format Reference

137137
138138
139139
150150
151151 ; Properties are declared using '=' and are contained in the previous section.
152152 ;
153 ; We support simple scalar values and list values, where items are separated by
154 ; spaces. There is no support for quoting, and so property values may not contain
155 ; spaces.
153 ; We support simple string and boolean scalar values and list values, where
154 ; items are separated by spaces. There is no support for quoting, and so
155 ; property values may not contain spaces.
156156 property_name = property_value
157157 list_property_name = value_1 value_2 ... value_n
158 boolean_property_name = 1 (or 0)
158159
159160
160161
280281
281282
282283
284
  • type = TargetGroup
  • 285

    TargetGroup components are an extension of LibraryGroups, specifically

    286 for defining LLVM targets (which are handled specially in a few
    287 places).

    288
    289

    The name of the component should always be the name of the target.

    290
    291

    Components with this type use the LibraryGroup properties in addition

    292 to:

    293
    294
  • has_jit [optional] [boolean]
  • 295

    Whether this target supports JIT compilation.

    296
    297
    298
    283299
  • type = Tool
  • 284300

    Tool components define standalone command line tools which should be

    285301 built from the source code in the component directory and linked.

    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = ARM
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    22 has_jit = 1
    2223
    2324 [component_1]
    2425 type = Library
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = CBackend
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = CellSPU
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = CppBackend
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = MBlaze
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = MSP430
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = Mips
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    22 has_jit = 1
    2223
    2324 [component_1]
    2425 type = Library
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = PTX
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = PowerPC
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    22 has_jit = 1
    2223
    2324 [component_1]
    2425 type = Library
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = Sparc
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = X86
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    22 has_jit = 1
    2223
    2324 [component_1]
    2425 type = Library
    1515 ;===------------------------------------------------------------------------===;
    1616
    1717 [component_0]
    18 type = LibraryGroup
    18 type = TargetGroup
    1919 name = XCore
    2020 parent = Target
    2121 add_to_library_groups = all-targets
    187187 def get_llvmconfig_component_name(self):
    188188 return self.name.lower()
    189189
    190 class TargetGroupComponentInfo(ComponentInfo):
    191 type_name = 'TargetGroup'
    192
    193 @staticmethod
    194 def parse(subpath, items):
    195 kwargs = ComponentInfo.parse_items(items, has_dependencies = False)
    196 kwargs['required_libraries'] = items.get_list('required_libraries')
    197 kwargs['add_to_library_groups'] = items.get_list(
    198 'add_to_library_groups')
    199 kwargs['has_jit'] = items.get_optional_bool('has_jit', False)
    200 return TargetGroupComponentInfo(subpath, **kwargs)
    201
    202 def __init__(self, subpath, name, parent, required_libraries = [],
    203 add_to_library_groups = [], has_jit = False):
    204 ComponentInfo.__init__(self, subpath, name, [], parent)
    205
    206 # The names of the library components which are required when linking
    207 # with this component.
    208 self.required_libraries = list(required_libraries)
    209
    210 # The names of the library group components this component should be
    211 # considered part of.
    212 self.add_to_library_groups = list(add_to_library_groups)
    213
    214 # Whether or not this target supports the JIT.
    215 self.has_jit = bool(has_jit)
    216
    217 def get_component_references(self):
    218 for r in ComponentInfo.get_component_references(self):
    219 yield r
    220 for r in self.required_libraries:
    221 yield ('required library', r)
    222 for r in self.add_to_library_groups:
    223 yield ('library group', r)
    224
    225 def get_llvmbuild_fragment(self):
    226 result = StringIO.StringIO()
    227 print >>result, 'type = %s' % self.type_name
    228 print >>result, 'name = %s' % self.name
    229 print >>result, 'parent = %s' % self.parent
    230 if self.required_libraries:
    231 print >>result, 'required_libraries = %s' % ' '.join(
    232 self.required_libraries)
    233 if self.add_to_library_groups:
    234 print >>result, 'add_to_library_groups = %s' % ' '.join(
    235 self.add_to_library_groups)
    236 if self.has_jit:
    237 print >>result, 'has_jit = %s' % ' '.join(
    238 int(self.has_jit))
    239 return result.getvalue()
    240
    241 def get_llvmconfig_component_name(self):
    242 return self.name.lower()
    243
    190244 class ToolComponentInfo(ComponentInfo):
    191245 type_name = 'Tool'
    192246
    254308 raise ParseError("missing value for required string: %r" % key)
    255309 return value
    256310
    311 def get_optional_bool(self, key, default = None):
    312 value = self.get_optional_string(key)
    313 if not value:
    314 return default
    315 if value not in ('0', '1'):
    316 raise ParseError("invalid value(%r) for boolean property: %r" % (
    317 value, key))
    318 return bool(int(value))
    319
    320 def get_bool(self, key):
    321 value = self.get_optional_bool(key)
    322 if value is None:
    323 raise ParseError("missing value for required boolean: %r" % key)
    324 return value
    325
    257326 _component_type_map = dict(
    258327 (t.type_name, t)
    259328 for t in (GroupComponentInfo,
    260329 LibraryComponentInfo, LibraryGroupComponentInfo,
    261 ToolComponentInfo, BuildToolComponentInfo))
    330 ToolComponentInfo, BuildToolComponentInfo,
    331 TargetGroupComponentInfo))
    262332 def load_from_path(path, subpath):
    263333 # Load the LLVMBuild.txt file as an .ini format file.
    264334 parser = ConfigParser.RawConfigParser()
    241241 # dependencies for added library groups.
    242242 entries = {}
    243243 for c in self.ordered_component_infos:
    244 # Only Library and LibraryGroup components are in the table.
    245 if c.type_name not in ('Library', 'LibraryGroup'):
    244 # Only certain components are in the table.
    245 if c.type_name not in ('Library', 'LibraryGroup', 'TargetGroup'):
    246246 continue
    247247
    248248 # Compute the llvm-config "component name". For historical reasons,
    250250 llvmconfig_component_name = c.get_llvmconfig_component_name()
    251251
    252252 # Get the library name, or None for LibraryGroups.
    253 if c.type_name == 'LibraryGroup':
    253 if c.type_name == 'Library':
    254 library_name = c.get_library_name()
    255 else:
    254256 library_name = None
    255 else:
    256 library_name = c.get_library_name()
    257257
    258258 # Get the component names of all the required libraries.
    259259 required_llvmconfig_component_names = [