Merge commit '48d60ab7c5' into libgccjit-codegen

This commit is contained in:
Antoni Boucher 2021-09-17 17:52:40 -04:00
commit df487317d0
24 changed files with 774 additions and 387 deletions

View file

@ -62,5 +62,92 @@ fn main() {
}
assert_eq!(x, 43);
// check inout(reg_class) x
let mut x: u64 = 42;
unsafe {
asm!("add {0}, {0}",
inout(reg) x
);
}
assert_eq!(x, 84);
// check inout("reg") x
let mut x: u64 = 42;
unsafe {
asm!("add r11, r11",
inout("r11") x
);
}
assert_eq!(x, 84);
// check a mix of
// in("reg")
// inout(class) x => y
// inout (class) x
let x: u64 = 702;
let y: u64 = 100;
let res: u64;
let mut rem: u64 = 0;
unsafe {
asm!("div r11",
in("r11") y,
inout("eax") x => res,
inout("edx") rem,
);
}
assert_eq!(res, 7);
assert_eq!(rem, 2);
// check const
let mut x: u64 = 42;
unsafe {
asm!("add {}, {}",
inout(reg) x,
const 1
);
}
assert_eq!(x, 43);
// check const (ATT syntax)
let mut x: u64 = 42;
unsafe {
asm!("add {}, {}",
const 1,
inout(reg) x,
options(att_syntax)
);
}
assert_eq!(x, 43);
// check sym fn
extern "C" fn foo() -> u64 { 42 }
let x: u64;
unsafe {
asm!("call {}", sym foo, lateout("rax") x);
}
assert_eq!(x, 42);
// check sym fn (ATT syntax)
let x: u64;
unsafe {
asm!("call {}", sym foo, lateout("rax") x, options(att_syntax));
}
assert_eq!(x, 42);
// check sym static
static FOO: u64 = 42;
let x: u64;
unsafe {
asm!("mov {1}, qword ptr [rip + {0}]", sym FOO, lateout(reg) x);
}
assert_eq!(x, 42);
// check sym static (ATT syntax)
let x: u64;
unsafe {
asm!("movq {0}(%rip), {1}", sym FOO, lateout(reg) x, options(att_syntax));
}
assert_eq!(x, 42);
assert_eq!(unsafe { add_asm(40, 2) }, 42);
}