Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion compiler/rustc_smir/src/rustc_smir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,27 @@ fn rustc_generator_to_generator(
}
}

fn rustc_inline_asm_operand_to_inline_asm_operand(
operand: &rustc_middle::mir::InlineAsmOperand<'_>,
) -> stable_mir::mir::InlineAsmOperand {
use rustc_middle::mir::InlineAsmOperand;

let (in_value, out_place) = match operand {
InlineAsmOperand::In { value, .. } => (Some(rustc_op_to_op(value)), None),
InlineAsmOperand::Out { place, .. } => {
(None, place.map(|place| rustc_place_to_place(&place)))
}
InlineAsmOperand::InOut { in_value, out_place, .. } => {
(Some(rustc_op_to_op(in_value)), out_place.map(|place| rustc_place_to_place(&place)))
}
InlineAsmOperand::Const { .. }
| InlineAsmOperand::SymFn { .. }
| InlineAsmOperand::SymStatic { .. } => (None, None),
};

stable_mir::mir::InlineAsmOperand { in_value, out_place, raw_rpr: format!("{:?}", operand) }
}

fn rustc_terminator_to_terminator(
terminator: &rustc_middle::mir::Terminator<'_>,
) -> stable_mir::mir::Terminator {
Expand Down Expand Up @@ -330,7 +351,19 @@ fn rustc_terminator_to_terminator(
target: target.as_usize(),
unwind: rustc_unwind_to_unwind(unwind),
},
InlineAsm { .. } => todo!(),
InlineAsm { template, operands, options, line_spans, destination, unwind } => {
Terminator::InlineAsm {
template: format!("{:?}", template),
operands: operands
.iter()
.map(|operand| rustc_inline_asm_operand_to_inline_asm_operand(operand))
.collect(),
options: format!("{:?}", options),
line_spans: format!("{:?}", line_spans),
destination: destination.map(|d| d.as_usize()),
unwind: rustc_unwind_to_unwind(unwind),
}
}
Yield { .. } | GeneratorDrop | FalseEdge { .. } | FalseUnwind { .. } => unreachable!(),
}
}
17 changes: 17 additions & 0 deletions compiler/rustc_smir/src/stable_mir/mir/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,23 @@ pub enum Terminator {
unwind: UnwindAction,
},
GeneratorDrop,
InlineAsm {
template: String,
operands: Vec<InlineAsmOperand>,
options: String,
line_spans: String,
destination: Option<usize>,
unwind: UnwindAction,
},
}

#[derive(Clone, Debug)]
pub struct InlineAsmOperand {
pub in_value: Option<Operand>,
pub out_place: Option<Place>,
// This field has a raw debug representation of MIR's InlineAsmOperand.
// For now we care about place/operand + the rest in a debug format.
pub raw_rpr: String,
}

#[derive(Clone, Debug)]
Expand Down