mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Add Assume custom MIR.
This commit is contained in:
parent
ef71f1047e
commit
161c674ef0
@ -20,6 +20,10 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
|
||||
@call(mir_storage_dead, args) => {
|
||||
Ok(StatementKind::StorageDead(self.parse_local(args[0])?))
|
||||
},
|
||||
@call(mir_assume, args) => {
|
||||
let op = self.parse_operand(args[0])?;
|
||||
Ok(StatementKind::Intrinsic(Box::new(NonDivergingIntrinsic::Assume(op))))
|
||||
},
|
||||
@call(mir_deinit, args) => {
|
||||
Ok(StatementKind::Deinit(Box::new(self.parse_place(args[0])?)))
|
||||
},
|
||||
|
@ -1027,6 +1027,7 @@ symbols! {
|
||||
minnumf32,
|
||||
minnumf64,
|
||||
mips_target_feature,
|
||||
mir_assume,
|
||||
mir_basic_block,
|
||||
mir_call,
|
||||
mir_cast_transmute,
|
||||
|
@ -357,6 +357,8 @@ define!("mir_unwind_resume",
|
||||
|
||||
define!("mir_storage_live", fn StorageLive<T>(local: T));
|
||||
define!("mir_storage_dead", fn StorageDead<T>(local: T));
|
||||
#[cfg(not(bootstrap))]
|
||||
define!("mir_assume", fn Assume(operand: bool));
|
||||
define!("mir_deinit", fn Deinit<T>(place: T));
|
||||
define!("mir_checked", fn Checked<T>(binop: T) -> (T, bool));
|
||||
define!("mir_len", fn Len<T>(place: T) -> usize);
|
||||
|
@ -0,0 +1,10 @@
|
||||
// MIR for `assume_constant` after built
|
||||
|
||||
fn assume_constant() -> () {
|
||||
let mut _0: ();
|
||||
|
||||
bb0: {
|
||||
assume(const true);
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
// MIR for `assume_local` after built
|
||||
|
||||
fn assume_local(_1: bool) -> () {
|
||||
let mut _0: ();
|
||||
|
||||
bb0: {
|
||||
assume(_1);
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
// MIR for `assume_place` after built
|
||||
|
||||
fn assume_place(_1: (bool, u8)) -> () {
|
||||
let mut _0: ();
|
||||
|
||||
bb0: {
|
||||
assume((_1.0: bool));
|
||||
return;
|
||||
}
|
||||
}
|
44
tests/mir-opt/building/custom/assume.rs
Normal file
44
tests/mir-opt/building/custom/assume.rs
Normal file
@ -0,0 +1,44 @@
|
||||
// skip-filecheck
|
||||
#![feature(custom_mir, core_intrinsics)]
|
||||
|
||||
extern crate core;
|
||||
use core::intrinsics::mir::*;
|
||||
|
||||
// EMIT_MIR assume.assume_local.built.after.mir
|
||||
#[custom_mir(dialect = "built")]
|
||||
fn assume_local(x: bool) {
|
||||
mir!(
|
||||
{
|
||||
Assume(x);
|
||||
Return()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// EMIT_MIR assume.assume_place.built.after.mir
|
||||
#[custom_mir(dialect = "built")]
|
||||
fn assume_place(p: (bool, u8)) {
|
||||
mir!(
|
||||
{
|
||||
Assume(p.0);
|
||||
Return()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
// EMIT_MIR assume.assume_constant.built.after.mir
|
||||
#[custom_mir(dialect = "built")]
|
||||
fn assume_constant() {
|
||||
mir!(
|
||||
{
|
||||
Assume(true);
|
||||
Return()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fn main() {
|
||||
assume_local(true);
|
||||
assume_place((true, 50));
|
||||
assume_constant();
|
||||
}
|
Loading…
Reference in New Issue
Block a user