Skip to content

Commit

Permalink
Allow ont creating fieldsets in FixRegisterBitSizes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Aug 11, 2024
1 parent a269e20 commit 5e98229
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions src/transform/fix_register_bit_sizes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use serde::{Deserialize, Serialize};
use crate::ir::*;

#[derive(Debug, Serialize, Deserialize)]
pub struct FixRegisterBitSizes {}
pub struct FixRegisterBitSizes {
pub create_fieldsets: bool,
}

impl FixRegisterBitSizes {
pub fn run(&self, ir: &mut IR) -> anyhow::Result<()> {
Expand All @@ -22,23 +24,25 @@ impl FixRegisterBitSizes {
r.bit_size = good_bit_size;
match &r.fieldset {
None => {
// create a new fieldset, with a single field with the original bit size.
r.fieldset = Some(i.name.clone());
let fs = FieldSet {
bit_size: good_bit_size,
fields: vec![Field {
name: "val".to_string(),
bit_offset: BitOffset::Regular(0),
bit_size: orig_bit_size,
if self.create_fieldsets {
// create a new fieldset, with a single field with the original bit size.
r.fieldset = Some(i.name.clone());
let fs = FieldSet {
bit_size: good_bit_size,
fields: vec![Field {
name: "val".to_string(),
bit_offset: BitOffset::Regular(0),
bit_size: orig_bit_size,
description: None,
enumm: None,
array: None,
}],
description: None,
enumm: None,
array: None,
}],
description: None,
extends: None,
};
if ir.fieldsets.insert(i.name.clone(), fs).is_some() {
panic!("dup fieldset {}", i.name);
extends: None,
};
if ir.fieldsets.insert(i.name.clone(), fs).is_some() {
panic!("dup fieldset {}", i.name);
}
}
}
Some(fs) => {
Expand Down

0 comments on commit 5e98229

Please sign in to comment.