Skip to content

Commit

Permalink
add RenamePeripherals
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Jan 2, 2025
1 parent e09c27d commit 26983da
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,5 @@ transforms!(
modify_byte_offset::ModifyByteOffset,
fix_register_bit_sizes::FixRegisterBitSizes,
rename_interrupts::RenameInterrupts,
rename_peripherals::RenamePeripherals,
);
23 changes: 23 additions & 0 deletions src/transform/rename_peripherals.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use serde::{Deserialize, Serialize};

use super::common::*;
use crate::ir::*;

#[derive(Debug, Serialize, Deserialize)]
pub struct RenamePeripherals {
pub from: RegexSet,
pub to: String,
}

impl RenamePeripherals {
pub fn run(&self, ir: &mut IR) -> anyhow::Result<()> {
for d in ir.devices.values_mut() {
for p in &mut d.peripherals {
if let Some(name) = match_expand(&p.name, &self.from, &self.to) {
p.name = name;
}
}
}
Ok(())
}
}

0 comments on commit 26983da

Please sign in to comment.