1#!/usr/bin/env python 2 3# RISC-V multilib list generator. 4# Copyright (C) 2011-2019 Free Software Foundation, Inc. 5# Contributed by Andrew Waterman (andrew@sifive.com). 6# 7# This file is part of GCC. 8# 9# GCC is free software; you can redistribute it and/or modify 10# it under the terms of the GNU General Public License as published by 11# the Free Software Foundation; either version 3, or (at your option) 12# any later version. 13# 14# GCC is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License for more details. 18# 19# You should have received a copy of the GNU General Public License 20# along with GCC; see the file COPYING3. If not see 21# <http://www.gnu.org/licenses/>. 22 23# Each argument to this script is of the form 24# <primary arch>-<abi>-<additional arches>-<extensions> 25# For example, 26# rv32imafd-ilp32d-rv32g-c,v 27# means that, in addition to rv32imafd, these configurations can also use the 28# rv32imafd-ilp32d libraries: rv32imafdc, rv32imafdv, rv32g, rv32gc, rv32gv 29 30from __future__ import print_function 31import sys 32import collections 33 34arches = collections.OrderedDict() 35abis = collections.OrderedDict() 36required = [] 37reuse = [] 38 39for cfg in sys.argv[1:]: 40 (arch, abi, extra, ext) = cfg.split('-') 41 arches[arch] = 1 42 abis[abi] = 1 43 extra = list(filter(None, extra.split(','))) 44 ext = list(filter(None, ext.split(','))) 45 alts = sum([[x] + [x + y for y in ext] for x in [arch] + extra], []) 46 alts = alts + [x.replace('imafd', 'g') for x in alts if 'imafd' in x] 47 for alt in alts[1:]: 48 arches[alt] = 1 49 reuse.append('march.%s/mabi.%s=march.%s/mabi.%s' % (arch, abi, alt, abi)) 50 required.append('march=%s/mabi=%s' % (arch, abi)) 51 52arch_options = '/'.join(['march=%s' % x for x in arches.keys()]) 53arch_dirnames = ' \\\n'.join(arches.keys()) 54 55abi_options = '/'.join(['mabi=%s' % x for x in abis.keys()]) 56abi_dirnames = ' \\\n'.join(abis.keys()) 57 58prog = sys.argv[0].split('/')[-1] 59print('# This file was generated by %s with the command:' % prog) 60print('# %s' % ' '.join(sys.argv)) 61 62print('MULTILIB_OPTIONS = %s %s' % (arch_options, abi_options)) 63print('MULTILIB_DIRNAMES = %s %s' % (arch_dirnames, abi_dirnames)) 64print('MULTILIB_REQUIRED = %s' % ' \\\n'.join(required)) 65print('MULTILIB_REUSE = %s' % ' \\\n'.join(reuse)) 66