]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_ssa/src/traits/asm.rs
Rollup merge of #93214 - ibraheemdev:issue-93210, r=davidtwco
[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 {
40     Const { string: String },
41 }
42
43 pub trait AsmBuilderMethods<'tcx>: BackendTypes {
44     /// Take an inline assembly expression and splat it out via LLVM
45     fn codegen_inline_asm(
46         &mut self,
47         template: &[InlineAsmTemplatePiece],
48         operands: &[InlineAsmOperandRef<'tcx, Self>],
49         options: InlineAsmOptions,
50         line_spans: &[Span],
51         instance: Instance<'_>,
52         dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>,
53     );
54 }
55
56 pub trait AsmMethods {
57     fn codegen_global_asm(
58         &self,
59         template: &[InlineAsmTemplatePiece],
60         operands: &[GlobalAsmOperandRef],
61         options: InlineAsmOptions,
62         line_spans: &[Span],
63     );
64 }