-
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.
Auto merge of #109224 - oli-obk:smir, r=pnkfelix
Stable MIR: Add basic MIR body datastructures At this point it will panic on most useful MIR, but you can do basic assignments r? `@pnkfelix`
- Loading branch information
Showing
6 changed files
with
239 additions
and
11 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
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,3 @@ | ||
mod body; | ||
|
||
pub use body::*; |
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,69 @@ | ||
#[derive(Clone, Debug)] | ||
pub struct Body { | ||
pub blocks: Vec<BasicBlock>, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct BasicBlock { | ||
pub statements: Vec<Statement>, | ||
pub terminator: Terminator, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum Terminator { | ||
Goto { | ||
target: usize, | ||
}, | ||
SwitchInt { | ||
discr: Operand, | ||
targets: Vec<SwitchTarget>, | ||
otherwise: usize, | ||
}, | ||
Resume, | ||
Abort, | ||
Return, | ||
Unreachable, | ||
Drop { | ||
place: Place, | ||
target: usize, | ||
unwind: Option<usize>, | ||
}, | ||
Call { | ||
func: Operand, | ||
args: Vec<Operand>, | ||
destination: Place, | ||
target: Option<usize>, | ||
cleanup: Option<usize>, | ||
}, | ||
Assert { | ||
cond: Operand, | ||
expected: bool, | ||
msg: String, | ||
target: usize, | ||
cleanup: Option<usize>, | ||
}, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum Statement { | ||
Assign(Place, Operand), | ||
Nop, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub enum Operand { | ||
Copy(Place), | ||
Move(Place), | ||
Constant(String), | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Place { | ||
pub local: usize, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct SwitchTarget { | ||
pub value: u128, | ||
pub target: usize, | ||
} |
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