1 use std::collections::HashMap;
4 use cranelift::codegen::{
6 write::{FuncWriter, PlainWriter},
8 use cranelift::prelude::*;
10 pub struct CommentWriter(pub HashMap<Inst, String>);
12 impl FuncWriter for CommentWriter {
15 w: &mut dyn fmt::Write,
17 isa: Option<&dyn isa::TargetIsa>,
21 if let Some(comment) = self.0.get(&inst) {
22 writeln!(w, "; {}", comment.replace('\n', "\n; "))?;
24 PlainWriter.write_instruction(w, func, isa, inst, indent)
29 w: &mut dyn fmt::Write,
31 reg_info: Option<&isa::RegInfo>,
32 ) -> Result<bool, fmt::Error> {
33 PlainWriter.write_preamble(w, func, reg_info)