]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_codegen_ssa/src/traits/asm.rs
New upstream version 1.57.0+dfsg1
[rustc.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_hir::LlvmInlineAsmInner;
7 use rustc_middle::ty::Instance;
8 use rustc_span::Span;
9 use rustc_target::asm::InlineAsmRegOrRegClass;
10
11 #[derive(Debug)]
12 pub 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 }
38
39 #[derive(Debug)]
40 pub enum GlobalAsmOperandRef {
41 Const { string: String },
42 }
43
44 pub trait AsmBuilderMethods<'tcx>: BackendTypes {
45 /// Take an inline assembly expression and splat it out via LLVM
46 fn codegen_llvm_inline_asm(
47 &mut self,
48 ia: &LlvmInlineAsmInner,
49 outputs: Vec<PlaceRef<'tcx, Self::Value>>,
50 inputs: Vec<Self::Value>,
51 span: Span,
52 ) -> bool;
53
54 /// Take an inline assembly expression and splat it out via LLVM
55 fn codegen_inline_asm(
56 &mut self,
57 template: &[InlineAsmTemplatePiece],
58 operands: &[InlineAsmOperandRef<'tcx, Self>],
59 options: InlineAsmOptions,
60 line_spans: &[Span],
61 );
62 }
63
64 pub trait AsmMethods {
65 fn codegen_global_asm(
66 &self,
67 template: &[InlineAsmTemplatePiece],
68 operands: &[GlobalAsmOperandRef],
69 options: InlineAsmOptions,
70 line_spans: &[Span],
71 );
72 }