2018-11-24 16:30:29 +01:00
|
|
|
use super::BackendTypes;
|
2020-02-17 21:36:01 +00:00
|
|
|
use crate::mir::operand::OperandRef;
|
2019-02-09 23:31:47 +09:00
|
|
|
use crate::mir::place::PlaceRef;
|
2020-04-27 23:26:11 +05:30
|
|
|
use rustc_ast::{InlineAsmOptions, InlineAsmTemplatePiece};
|
2020-02-17 21:36:01 +00:00
|
|
|
use rustc_hir::def_id::DefId;
|
|
|
|
use rustc_middle::ty::Instance;
|
2019-12-31 20:15:40 +03:00
|
|
|
use rustc_span::Span;
|
2020-05-06 14:46:01 +01:00
|
|
|
use rustc_target::asm::InlineAsmRegOrRegClass;
|
2020-02-17 21:36:01 +00:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum InlineAsmOperandRef<'tcx, B: BackendTypes + ?Sized> {
|
|
|
|
In {
|
|
|
|
reg: InlineAsmRegOrRegClass,
|
|
|
|
value: OperandRef<'tcx, B::Value>,
|
|
|
|
},
|
|
|
|
Out {
|
|
|
|
reg: InlineAsmRegOrRegClass,
|
|
|
|
late: bool,
|
|
|
|
place: Option<PlaceRef<'tcx, B::Value>>,
|
|
|
|
},
|
|
|
|
InOut {
|
|
|
|
reg: InlineAsmRegOrRegClass,
|
|
|
|
late: bool,
|
|
|
|
in_value: OperandRef<'tcx, B::Value>,
|
|
|
|
out_place: Option<PlaceRef<'tcx, B::Value>>,
|
|
|
|
},
|
|
|
|
Const {
|
|
|
|
string: String,
|
|
|
|
},
|
|
|
|
SymFn {
|
|
|
|
instance: Instance<'tcx>,
|
|
|
|
},
|
|
|
|
SymStatic {
|
|
|
|
def_id: DefId,
|
|
|
|
},
|
2023-12-27 04:08:04 +00:00
|
|
|
Label {
|
|
|
|
label: B::BasicBlock,
|
|
|
|
},
|
2020-02-17 21:36:01 +00:00
|
|
|
}
|
2018-09-20 15:47:22 +02:00
|
|
|
|
2021-04-11 20:51:28 +01:00
|
|
|
#[derive(Debug)]
|
2022-03-01 00:53:25 +00:00
|
|
|
pub enum GlobalAsmOperandRef<'tcx> {
|
2021-04-11 20:51:28 +01:00
|
|
|
Const { string: String },
|
2022-03-01 00:53:25 +00:00
|
|
|
SymFn { instance: Instance<'tcx> },
|
|
|
|
SymStatic { def_id: DefId },
|
2021-04-11 20:51:28 +01:00
|
|
|
}
|
|
|
|
|
2018-11-24 16:30:29 +01:00
|
|
|
pub trait AsmBuilderMethods<'tcx>: BackendTypes {
|
2020-02-17 21:36:01 +00:00
|
|
|
/// Take an inline assembly expression and splat it out via LLVM
|
|
|
|
fn codegen_inline_asm(
|
|
|
|
&mut self,
|
|
|
|
template: &[InlineAsmTemplatePiece],
|
|
|
|
operands: &[InlineAsmOperandRef<'tcx, Self>],
|
|
|
|
options: InlineAsmOptions,
|
2020-05-26 20:07:59 +01:00
|
|
|
line_spans: &[Span],
|
2021-10-21 04:56:36 +09:00
|
|
|
instance: Instance<'_>,
|
2023-12-27 04:08:04 +00:00
|
|
|
dest: Option<Self::BasicBlock>,
|
|
|
|
catch_funclet: Option<(Self::BasicBlock, Option<&Self::Funclet>)>,
|
2020-02-17 21:36:01 +00:00
|
|
|
);
|
2018-09-20 15:47:22 +02:00
|
|
|
}
|
|
|
|
|
2022-03-01 00:53:25 +00:00
|
|
|
pub trait AsmMethods<'tcx> {
|
2021-04-11 20:51:28 +01:00
|
|
|
fn codegen_global_asm(
|
|
|
|
&self,
|
|
|
|
template: &[InlineAsmTemplatePiece],
|
2022-03-01 00:53:25 +00:00
|
|
|
operands: &[GlobalAsmOperandRef<'tcx>],
|
2021-04-11 20:51:28 +01:00
|
|
|
options: InlineAsmOptions,
|
|
|
|
line_spans: &[Span],
|
|
|
|
);
|
2018-09-20 15:47:22 +02:00
|
|
|
}
|