Skip to content

Commit

Permalink
add RenameInterrupts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dirbaio committed Nov 14, 2024
1 parent cedad40 commit 0b2cebe
Show file tree
Hide file tree
Showing 2 changed files with 26 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 @@ -255,4 +255,5 @@ transforms!(
make_block::MakeBlock,
modify_byte_offset::ModifyByteOffset,
fix_register_bit_sizes::FixRegisterBitSizes,
rename_interrupts::RenameInterrupts,
);
25 changes: 25 additions & 0 deletions src/transform/rename_interrupts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use serde::{Deserialize, Serialize};

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

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

impl RenameInterrupts {
pub fn run(&self, ir: &mut IR) -> anyhow::Result<()> {
let re = make_regex(&self.from)?;

for d in ir.devices.values_mut() {
for i in &mut d.interrupts {
if let Some(name) = match_expand(&i.name, &re, &self.to) {
i.name = name;
}
}
}
Ok(())
}
}

0 comments on commit 0b2cebe

Please sign in to comment.