Add info about disjoint local indices to values.
This commit is contained in:
parent
8a7a65f94c
commit
3e21bb7411
|
@ -129,6 +129,7 @@ fn parse_body<'a, 'b>(
|
||||||
builder.body.values.push(ValueDef {
|
builder.body.values.push(ValueDef {
|
||||||
kind: ValueKind::Arg(arg_idx),
|
kind: ValueKind::Arg(arg_idx),
|
||||||
ty: arg_ty,
|
ty: arg_ty,
|
||||||
|
local: Some(local_idx),
|
||||||
});
|
});
|
||||||
trace!("defining local {} to value {}", local_idx, value);
|
trace!("defining local {} to value {}", local_idx, value);
|
||||||
builder.locals.insert(local_idx, (arg_ty, value));
|
builder.locals.insert(local_idx, (arg_ty, value));
|
||||||
|
@ -149,8 +150,6 @@ fn parse_body<'a, 'b>(
|
||||||
Ok(ret)
|
Ok(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
type LocalId = u32;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct FunctionBodyBuilder<'a, 'b> {
|
struct FunctionBodyBuilder<'a, 'b> {
|
||||||
module: &'b Module<'a>,
|
module: &'b Module<'a>,
|
||||||
|
@ -315,6 +314,7 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> {
|
||||||
self.body.values.push(ValueDef {
|
self.body.values.push(ValueDef {
|
||||||
ty,
|
ty,
|
||||||
kind: ValueKind::Inst(block, inst, 0),
|
kind: ValueKind::Inst(block, inst, 0),
|
||||||
|
local: Some(*local_index),
|
||||||
});
|
});
|
||||||
value
|
value
|
||||||
} else {
|
} else {
|
||||||
|
@ -887,6 +887,7 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> {
|
||||||
self.body.values.push(ValueDef {
|
self.body.values.push(ValueDef {
|
||||||
kind: ValueKind::BlockParam(block, block_param_num),
|
kind: ValueKind::BlockParam(block, block_param_num),
|
||||||
ty,
|
ty,
|
||||||
|
local: None,
|
||||||
});
|
});
|
||||||
self.op_stack.push((ty, value_id));
|
self.op_stack.push((ty, value_id));
|
||||||
block_param_num += 1;
|
block_param_num += 1;
|
||||||
|
@ -901,6 +902,7 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> {
|
||||||
self.body.values.push(ValueDef {
|
self.body.values.push(ValueDef {
|
||||||
kind: ValueKind::BlockParam(block, block_param_num),
|
kind: ValueKind::BlockParam(block, block_param_num),
|
||||||
ty,
|
ty,
|
||||||
|
local: Some(local_id),
|
||||||
});
|
});
|
||||||
block_param_num += 1;
|
block_param_num += 1;
|
||||||
self.locals.insert(local_id, (ty, value_id));
|
self.locals.insert(local_id, (ty, value_id));
|
||||||
|
@ -936,6 +938,7 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> {
|
||||||
self.body.values.push(ValueDef {
|
self.body.values.push(ValueDef {
|
||||||
kind: ValueKind::Inst(block, inst, i),
|
kind: ValueKind::Inst(block, inst, i),
|
||||||
ty: output_ty,
|
ty: output_ty,
|
||||||
|
local: None,
|
||||||
});
|
});
|
||||||
self.op_stack.push((output_ty, val));
|
self.op_stack.push((output_ty, val));
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ pub type FuncId = usize;
|
||||||
pub type BlockId = usize;
|
pub type BlockId = usize;
|
||||||
pub type InstId = usize;
|
pub type InstId = usize;
|
||||||
pub type ValueId = usize;
|
pub type ValueId = usize;
|
||||||
|
pub type LocalId = u32;
|
||||||
|
|
||||||
pub const NO_VALUE: ValueId = usize::MAX;
|
pub const NO_VALUE: ValueId = usize::MAX;
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ pub struct FunctionBody<'a> {
|
||||||
pub struct ValueDef {
|
pub struct ValueDef {
|
||||||
pub kind: ValueKind,
|
pub kind: ValueKind,
|
||||||
pub ty: Type,
|
pub ty: Type,
|
||||||
|
pub local: Option<LocalId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|
Loading…
Reference in a new issue