rustc_codegen_ssa/traits/
asm.rs1use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
2use rustc_hir::def_id::DefId;
3use rustc_middle::ty::Instance;
4use rustc_span::Span;
5use rustc_target::asm::InlineAsmRegOrRegClass;
6
7use super::BackendTypes;
8use crate::mir::operand::OperandRef;
9use crate::mir::place::PlaceRef;
10
11#[derive(Debug)]
12pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> {
13 In {
14 reg: InlineAsmRegOrRegClass,
15 value: OperandRef<'tcx, B::Value>,
16 },
17 Out {
18 reg: InlineAsmRegOrRegClass,
19 late: bool,
20 place: Option<PlaceRef<'tcx, B::Value>>,
21 },
22 InOut {
23 reg: InlineAsmRegOrRegClass,
24 late: bool,
25 in_value: OperandRef<'tcx, B::Value>,
26 out_place: Option<PlaceRef<'tcx, B::Value>>,
27 },
28 Const {
29 string: String,
30 },
31 SymFn {
32 instance: Instance<'tcx>,
33 },
34 SymStatic {
35 def_id: DefId,
36 },
37 Label {
38 label: B::BasicBlock,
39 },
40}
41
42#[derive(Debug)]
43pub enum GlobalAsmOperandRef<'tcx> {
44 Const { string: String },
45 SymFn { instance: Instance<'tcx> },
46 SymStatic { def_id: DefId },
47}
48
49pub trait AsmBuilderMethods<'tcx>: BackendTypes {
50 fn codegen_inline_asm(
52 &mut self,
53 template: &[InlineAsmTemplatePiece],
54 operands: &[InlineAsmOperandRef<'tcx, Self>],
55 options: InlineAsmOptions,
56 line_spans: &[Span],
57 instance: Instance<'_>,
58 dest: Option<Self::BasicBlock>,
59 catch_funclet: Option<(Self::BasicBlock, Option<&Self::Funclet>)>,
60 );
61}
62
63pub trait AsmCodegenMethods<'tcx> {
64 fn codegen_global_asm(
65 &self,
66 template: &[InlineAsmTemplatePiece],
67 operands: &[GlobalAsmOperandRef<'tcx>],
68 options: InlineAsmOptions,
69 line_spans: &[Span],
70 );
71
72 fn mangled_name(&self, instance: Instance<'tcx>) -> String;
78}