-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom mir: Add support for some remaining, easy to support constructs
- Loading branch information
1 parent
e187f88
commit d7f59e9
Showing
8 changed files
with
68 additions
and
6 deletions.
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
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
14 changes: 14 additions & 0 deletions
14
tests/mir-opt/building/custom/arrays.arrays.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,14 @@ | ||
// MIR for `arrays` after built | ||
|
||
fn arrays() -> usize { | ||
let mut _0: usize; // return place in scope 0 at $DIR/arrays.rs:+0:32: +0:37 | ||
let mut _1: [i32; C]; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL | ||
let mut _2: usize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL | ||
|
||
bb0: { | ||
_1 = [const 5_i32; C]; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL | ||
_2 = Len(_1); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL | ||
_0 = _2; // scope 0 at $DIR/arrays.rs:+4:9: +4:16 | ||
return; // scope 0 at $DIR/arrays.rs:+5:9: +5:17 | ||
} | ||
} |
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,19 @@ | ||
#![feature(custom_mir, core_intrinsics, inline_const)] | ||
|
||
extern crate core; | ||
use core::intrinsics::mir::*; | ||
|
||
// EMIT_MIR arrays.arrays.built.after.mir | ||
#[custom_mir(dialect = "built")] | ||
fn arrays<const C: usize>() -> usize { | ||
mir!({ | ||
let x = [5_i32; C]; | ||
let c = Len(x); | ||
RET = c; | ||
Return() | ||
}) | ||
} | ||
|
||
fn main() { | ||
assert_eq!(arrays::<20>(), 20); | ||
} |
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
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
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
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