Skip to content

Commit

Permalink
Merge pull request #158 from edwin7026/march_mabi_gen
Browse files Browse the repository at this point in the history
Added function that returns the march and mabi for gcc from a given ISA
  • Loading branch information
neelgala authored Jan 1, 2024
2 parents 829f875 + b9d9147 commit e9a2ca2
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.15.0] - 2024-01-01
- Added function that returns the march and mabi for gcc from a given ISA

## [3.14.3] - 2023-12-01
- Add support for Zimop extension
Expand Down
2 changes: 1 addition & 1 deletion riscv_config/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pkgutil import extend_path
__path__ = extend_path(__path__, __name__)
__version__ = '3.14.3'
__version__ = '3.15.0'

75 changes: 75 additions & 0 deletions riscv_config/isa_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,79 @@ def get_extension_list(isa):

return (extension_list, err, err_list)

def get_march_mabi (isa : str):
'''
This function returns the corresponding march and mabi argument values
for RISC-V GCC
arguments:
isa: (string) this is the isa string in canonical order
returns:
march: (string) this is the string to be passed to -march to gcc for a given isa
mabi: (string) this is the string to be passed to -mabi for given isa
march_list: (list) gives march as a list of all extensions as elements
None: if ISA validation throws error
'''

# march generation

march = 'rv32' if '32' in isa else 'rv64'
march_list = []
march_list.append(march)

# get extension list
(ext_list, err, err_list) = get_extension_list(isa)

# if isa validation throws errors, return None
if err:
return None

# extensions to be nullified
null_ext = [
# privilege modes
'U',
'S',

# rnmi
'Smrnmi',

# debug mode
'Sdext',

# performance counter
'Zicntr',
'Zihpm',

# unratified Zb* extensions
'Zbe',
'Zbf',
'Zbm',
'Zbr',
]

# add Zbp and Zbt to null_ext if Zbpbo is present
if 'Zbpbo' in ext_list:
null_ext += ['Zbp', 'Zbt']
# construct march
for ext in ext_list:
if ext not in null_ext:
march_list.append(ext.lower())
# suffix multicharacter extensions with '_'
if len(ext) == 1:
march += ext.lower()
else:
# suffix multiline extensions with '_'
march = march + '_' + ext.lower()

# mabi generation
mabi = 'ilp32'
if 'F' in ext_list and 'D' in ext_list:
mabi += 'd'
elif 'F' in ext_list:
mabi += 'f'

if 'rv64' in march:
mabi = mabi.replace('ilp32', 'lp64')

return (march, mabi, march_list)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 3.14.3
current_version = 3.15.0
commit = True
tag = True

Expand Down

0 comments on commit e9a2ca2

Please sign in to comment.