Add a wasmtime settings command to print Cranelift settings.
This commit adds the `wasmtime settings` command to print out available Cranelift settings for a target (defaults to the host). The compile command has been updated to remove the Cranelift ISA options in favor of encouraging users to use `wasmtime settings` to discover what settings are available. This will reduce the maintenance cost for syncing the compile command with Cranelift ISA flags.
This commit is contained in:
@@ -20,6 +20,7 @@ pub(crate) enum SpecificSetting {
|
||||
#[derive(Hash, PartialEq, Eq)]
|
||||
pub(crate) struct Setting {
|
||||
pub name: &'static str,
|
||||
pub description: &'static str,
|
||||
pub comment: &'static str,
|
||||
pub specific: SpecificSetting,
|
||||
pub byte_offset: u8,
|
||||
@@ -88,6 +89,7 @@ impl Into<PresetType> for PresetIndex {
|
||||
#[derive(Hash, PartialEq, Eq)]
|
||||
pub(crate) struct Preset {
|
||||
pub name: &'static str,
|
||||
pub description: &'static str,
|
||||
values: Vec<BoolSettingIndex>,
|
||||
}
|
||||
|
||||
@@ -169,6 +171,7 @@ pub(crate) enum ProtoSpecificSetting {
|
||||
/// This is the information provided during building for a setting.
|
||||
struct ProtoSetting {
|
||||
name: &'static str,
|
||||
description: &'static str,
|
||||
comment: &'static str,
|
||||
specific: ProtoSpecificSetting,
|
||||
}
|
||||
@@ -251,11 +254,13 @@ impl SettingGroupBuilder {
|
||||
fn add_setting(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
description: &'static str,
|
||||
comment: &'static str,
|
||||
specific: ProtoSpecificSetting,
|
||||
) {
|
||||
self.settings.push(ProtoSetting {
|
||||
name,
|
||||
description,
|
||||
comment,
|
||||
specific,
|
||||
})
|
||||
@@ -264,6 +269,7 @@ impl SettingGroupBuilder {
|
||||
pub fn add_bool(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
description: &'static str,
|
||||
comment: &'static str,
|
||||
default: bool,
|
||||
) -> BoolSettingIndex {
|
||||
@@ -271,28 +277,55 @@ impl SettingGroupBuilder {
|
||||
self.predicates.is_empty(),
|
||||
"predicates must be added after the boolean settings"
|
||||
);
|
||||
self.add_setting(name, comment, ProtoSpecificSetting::Bool(default));
|
||||
self.add_setting(
|
||||
name,
|
||||
description,
|
||||
comment,
|
||||
ProtoSpecificSetting::Bool(default),
|
||||
);
|
||||
BoolSettingIndex(self.settings.len() - 1)
|
||||
}
|
||||
|
||||
pub fn add_enum(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
description: &'static str,
|
||||
comment: &'static str,
|
||||
values: Vec<&'static str>,
|
||||
) {
|
||||
self.add_setting(name, comment, ProtoSpecificSetting::Enum(values));
|
||||
self.add_setting(
|
||||
name,
|
||||
description,
|
||||
comment,
|
||||
ProtoSpecificSetting::Enum(values),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn add_num(&mut self, name: &'static str, comment: &'static str, default: u8) {
|
||||
self.add_setting(name, comment, ProtoSpecificSetting::Num(default));
|
||||
pub fn add_num(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
description: &'static str,
|
||||
comment: &'static str,
|
||||
default: u8,
|
||||
) {
|
||||
self.add_setting(
|
||||
name,
|
||||
description,
|
||||
comment,
|
||||
ProtoSpecificSetting::Num(default),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn add_predicate(&mut self, name: &'static str, node: PredicateNode) {
|
||||
self.predicates.push(ProtoPredicate { name, node });
|
||||
}
|
||||
|
||||
pub fn add_preset(&mut self, name: &'static str, args: Vec<PresetType>) -> PresetIndex {
|
||||
pub fn add_preset(
|
||||
&mut self,
|
||||
name: &'static str,
|
||||
description: &'static str,
|
||||
args: Vec<PresetType>,
|
||||
) -> PresetIndex {
|
||||
let mut values = Vec::new();
|
||||
for arg in args {
|
||||
match arg {
|
||||
@@ -302,7 +335,11 @@ impl SettingGroupBuilder {
|
||||
PresetType::BoolSetting(index) => values.push(index),
|
||||
}
|
||||
}
|
||||
self.presets.push(Preset { name, values });
|
||||
self.presets.push(Preset {
|
||||
name,
|
||||
description,
|
||||
values,
|
||||
});
|
||||
PresetIndex(self.presets.len() - 1)
|
||||
}
|
||||
|
||||
@@ -347,6 +384,7 @@ impl SettingGroupBuilder {
|
||||
|
||||
group.settings.push(Setting {
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
comment: s.comment,
|
||||
byte_offset,
|
||||
specific,
|
||||
@@ -367,6 +405,7 @@ impl SettingGroupBuilder {
|
||||
};
|
||||
group.settings.push(Setting {
|
||||
name: s.name,
|
||||
description: s.description,
|
||||
comment: s.comment,
|
||||
byte_offset: byte_offset + predicate_number / 8,
|
||||
specific: SpecificSetting::Bool(BoolSetting {
|
||||
|
||||
Reference in New Issue
Block a user