]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_ssa/src/traits/asm.rs
Rollup merge of #104286 - ozkanonur:fix-doc-bootstrap-recompilation, r=jyn514
[rust.git] / compiler / rustc_codegen_ssa / src / traits / asm.rs
1 use super::BackendTypes;
2 use crate::mir::operand::OperandRef;
3 use crate::mir::place::PlaceRef;
4 use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
5 use rustc_hir::def_id::DefId;
6 use rustc_middle::ty::Instance;
7 use rustc_span::Span;
8 use rustc_target::asm::InlineAsmRegOrRegClass;
9
10 #[derive(Debug)]
11 pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> {
12     In {
13         reg: InlineAsmRegOrRegClass,
14         value: OperandRef<'tcx, B::Value>,
15     },
16     Out {
17         reg: InlineAsmRegOrRegClass,
18         late: bool,
19         place: Option<PlaceRef<'tcx, B::Value>>,
20     },
21     InOut {
22         reg: InlineAsmRegOrRegClass,
23         late: bool,
24         in_value: OperandRef<'tcx, B::Value>,
25         out_place: Option<PlaceRef<'tcx, B::Value>>,
26     },
27     Const {
28         string: String,
29     },
30     SymFn {
31         instance: Instance<'tcx>,
32     },
33     SymStatic {
34         def_id: DefId,
35     },
36 }
37
38 #[derive(Debug)]
39 pub enum GlobalAsmOperandRef<'tcx> {
40     Const { string: String },
41     SymFn { instance: Instance<'tcx> },
42     SymStatic { def_id: DefId },
43 }
44
45 pub trait AsmBuilderMethods<'tcx>: BackendTypes {
46     /// Take an inline assembly expression and splat it out via LLVM
47     fn codegen_inline_asm(
48         &mut self,
49         template: &[InlineAsmTemplatePiece],
50         operands: &[InlineAsmOperandRef<'tcx, Self>],
51         options: InlineAsmOptions,
52         line_spans: &[Span],
53         instance: Instance<'_>,
54         dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>,
55     );
56 }
57
58 pub trait AsmMethods<'tcx> {
59     fn codegen_global_asm(
60         &self,
61         template: &[InlineAsmTemplatePiece],
62         operands: &[GlobalAsmOperandRef<'tcx>],
63         options: InlineAsmOptions,
64         line_spans: &[Span],
65     );
66 }