-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
tests/mir-opt/building/custom/as_cast.float_to_int.built.after.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// MIR for `float_to_int` after built | ||
|
||
fn float_to_int(_1: f32) -> i32 { | ||
let mut _0: i32; // return place in scope 0 at $DIR/as_cast.rs:+0:28: +0:31 | ||
|
||
bb0: { | ||
_0 = _1 as i32 (FloatToInt); // scope 0 at $DIR/as_cast.rs:+3:13: +3:27 | ||
return; // scope 0 at $DIR/as_cast.rs:+4:13: +4:21 | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/mir-opt/building/custom/as_cast.int_to_int.built.after.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// MIR for `int_to_int` after built | ||
|
||
fn int_to_int(_1: u32) -> i32 { | ||
let mut _0: i32; // return place in scope 0 at $DIR/as_cast.rs:+0:26: +0:29 | ||
|
||
bb0: { | ||
_0 = _1 as i32 (IntToInt); // scope 0 at $DIR/as_cast.rs:+3:13: +3:27 | ||
return; // scope 0 at $DIR/as_cast.rs:+4:13: +4:21 | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/mir-opt/building/custom/as_cast.int_to_ptr.built.after.mir
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// MIR for `int_to_ptr` after built | ||
|
||
fn int_to_ptr(_1: usize) -> *const i32 { | ||
let mut _0: *const i32; // return place in scope 0 at $DIR/as_cast.rs:+0:28: +0:38 | ||
|
||
bb0: { | ||
_0 = _1 as *const i32 (PointerFromExposedAddress); // scope 0 at $DIR/as_cast.rs:+3:13: +3:34 | ||
return; // scope 0 at $DIR/as_cast.rs:+4:13: +4:21 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#![feature(custom_mir, core_intrinsics)] | ||
|
||
extern crate core; | ||
use core::intrinsics::mir::*; | ||
|
||
// EMIT_MIR as_cast.int_to_int.built.after.mir | ||
#[custom_mir(dialect = "built")] | ||
fn int_to_int(x: u32) -> i32 { | ||
mir!( | ||
{ | ||
RET = x as i32; | ||
Return() | ||
} | ||
) | ||
} | ||
|
||
// EMIT_MIR as_cast.float_to_int.built.after.mir | ||
#[custom_mir(dialect = "built")] | ||
fn float_to_int(x: f32) -> i32 { | ||
mir!( | ||
{ | ||
RET = x as i32; | ||
Return() | ||
} | ||
) | ||
} | ||
|
||
// EMIT_MIR as_cast.int_to_ptr.built.after.mir | ||
#[custom_mir(dialect = "built")] | ||
fn int_to_ptr(x: usize) -> *const i32 { | ||
mir!( | ||
{ | ||
RET = x as *const i32; | ||
Return() | ||
} | ||
) | ||
} | ||
|
||
fn main() { | ||
assert_eq!(int_to_int(5), 5); | ||
assert_eq!(float_to_int(5.), 5); | ||
assert_eq!(int_to_ptr(0), std::ptr::null()); | ||
} |