Add basic inline asm support for x86_64
This commit is contained in:
parent
35701d8caa
commit
726e329f46
6 changed files with 243 additions and 15 deletions
29
src/base.rs
29
src/base.rs
|
|
@ -36,6 +36,7 @@ pub(crate) fn trans_fn<'tcx, B: Backend + 'static>(
|
|||
let mut fx = FunctionCx {
|
||||
tcx,
|
||||
module: &mut cx.module,
|
||||
global_asm: &mut cx.global_asm,
|
||||
pointer_type,
|
||||
|
||||
instance,
|
||||
|
|
@ -307,24 +308,26 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) {
|
|||
TerminatorKind::InlineAsm {
|
||||
template,
|
||||
operands,
|
||||
options: _,
|
||||
options,
|
||||
destination,
|
||||
line_spans: _,
|
||||
} => {
|
||||
match template {
|
||||
&[] => {
|
||||
assert_eq!(operands, &[]);
|
||||
match *destination {
|
||||
Some(destination) => {
|
||||
let destination_block = fx.get_block(destination);
|
||||
fx.bcx.ins().jump(destination_block, &[]);
|
||||
}
|
||||
None => bug!(),
|
||||
}
|
||||
crate::inline_asm::codegen_inline_asm(
|
||||
fx,
|
||||
bb_data.terminator().source_info.span,
|
||||
template,
|
||||
operands,
|
||||
*options,
|
||||
);
|
||||
|
||||
// Black box
|
||||
match *destination {
|
||||
Some(destination) => {
|
||||
let destination_block = fx.get_block(destination);
|
||||
fx.bcx.ins().jump(destination_block, &[]);
|
||||
}
|
||||
None => {
|
||||
crate::trap::trap_unreachable(fx, "[corruption] Returned from noreturn inline asm");
|
||||
}
|
||||
_ => fx.tcx.sess.span_fatal(bb_data.terminator().source_info.span, "Inline assembly is not supported"),
|
||||
}
|
||||
}
|
||||
TerminatorKind::Resume | TerminatorKind::Abort => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue