]> git.proxmox.com Git - rustc.git/blob - src/librustc_codegen_ssa/traits/asm.rs
New upstream version 1.47.0~beta.2+dfsg1
[rustc.git] / src / librustc_codegen_ssa / 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::{GlobalAsm, 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 pub trait AsmBuilderMethods<'tcx>: BackendTypes {
40 /// Take an inline assembly expression and splat it out via LLVM
41 fn codegen_llvm_inline_asm(
42 &mut self,
43 ia: &LlvmInlineAsmInner,
44 outputs: Vec<PlaceRef<'tcx, Self::Value>>,
45 inputs: Vec<Self::Value>,
46 span: Span,
47 ) -> bool;
48
49 /// Take an inline assembly expression and splat it out via LLVM
50 fn codegen_inline_asm(
51 &mut self,
52 template: &[InlineAsmTemplatePiece],
53 operands: &[InlineAsmOperandRef<'tcx, Self>],
54 options: InlineAsmOptions,
55 line_spans: &[Span],
56 );
57 }
58
59 pub trait AsmMethods {
60 fn codegen_global_asm(&self, ga: &GlobalAsm);
61 }