Scaffolding for defining settings.
Settings can be defined globally or per-ISA. They are available to code through a generated Settings struct with accessor methods per setting.
This commit is contained in:
@@ -25,6 +25,45 @@ The main driver for this source code generation process is the
|
||||
:file:`meta/build.py` script which is invoked as part of the build process if
|
||||
anything in the :file:`meta` directory has changed since the last build.
|
||||
|
||||
|
||||
Settings
|
||||
========
|
||||
|
||||
Settings are used by the environment embedding Cretonne to control the details
|
||||
of code generation. Each setting is defined in the meta language so a compact
|
||||
and consistent Rust representation can be generated. Shared settings are defined
|
||||
in the :mod:`cretonne.settings` module. Some settings are specific to a target
|
||||
ISA, and defined in a `settings` module under the appropriate :file:`meta/isa/*`
|
||||
directory.
|
||||
|
||||
Settings can take boolean on/off values, small numbers, or explicitly enumerated
|
||||
symbolic values. Each type is represented by a sub-class of :class:`Setting`:
|
||||
|
||||
.. inheritance-diagram:: Setting BoolSetting NumSetting EnumSetting
|
||||
:parts: 1
|
||||
|
||||
.. autoclass:: Setting
|
||||
.. autoclass:: BoolSetting
|
||||
.. autoclass:: NumSetting
|
||||
.. autoclass:: EnumSetting
|
||||
|
||||
All settings must belong to a *group*, represented by a :class:`SettingGroup`
|
||||
object.
|
||||
|
||||
.. autoclass:: SettingGroup
|
||||
|
||||
Normally, a setting group corresponds to all settings defined in a module. Such
|
||||
a module looks like this::
|
||||
|
||||
group = SettingGroup('example')
|
||||
|
||||
foo = BoolSetting('use the foo')
|
||||
bar = BoolSetting('enable bars', True)
|
||||
opt = EnumSetting('optimization level', 'Debug', 'Release')
|
||||
|
||||
group.close(globals())
|
||||
|
||||
|
||||
Instruction descriptions
|
||||
========================
|
||||
|
||||
|
||||
@@ -13,5 +13,6 @@ pub mod write;
|
||||
pub mod cfg;
|
||||
pub mod dominator_tree;
|
||||
pub mod entity_map;
|
||||
pub mod settings;
|
||||
|
||||
#[cfg(test)]pub mod test_utils;
|
||||
|
||||
7
cranelift/src/libcretonne/settings.rs
Normal file
7
cranelift/src/libcretonne/settings.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
//! Shared settings module.
|
||||
//!
|
||||
//! This module defines data structures to access the settings defined in the meta language.
|
||||
|
||||
// Include code generated by `meta/gen_settings.py`. This file contains a public `Settings` struct
|
||||
// with an impl for all of the settings defined in `meta/cretonne/settings.py`.
|
||||
include!(concat!(env!("OUT_DIR"), "/settings.rs"));
|
||||
Reference in New Issue
Block a user