Parse basic blocks and instructions.

Create map entries for ebbs and values as they are defined, but leave ebb and
value operands unresolved on instructions as they are parsed. Instruction
operands can refer to ebbs and values that may not have been defined yet.

Don't infer or check result types yet.
This commit is contained in:
Jakob Stoklund Olesen
2016-05-17 11:54:46 -07:00
parent 2dc15b78ae
commit 1dcac579fb
4 changed files with 371 additions and 16 deletions

View File

@@ -105,6 +105,12 @@ pub enum ExpandedValue {
}
impl Value {
pub fn direct_from_number(n: u32) -> Value {
let encoding = n * 2;
assert!(encoding < u32::MAX);
Value(encoding)
}
pub fn new_direct(i: Inst) -> Value {
let encoding = i.index() * 2;
assert!(encoding < u32::MAX as usize);

View File

@@ -19,6 +19,9 @@ pub struct Function {
/// Signature of this function.
signature: Signature,
/// The entry block.
pub entry_block: Ebb,
/// Stack slots allocated in this function.
stack_slots: Vec<StackSlotData>,
@@ -45,6 +48,7 @@ impl Function {
Function {
name: name,
signature: sig,
entry_block: NO_EBB,
stack_slots: Vec::new(),
instructions: Vec::new(),
extended_basic_blocks: Vec::new(),