public op io
This commit is contained in:
parent
1878db1c1d
commit
c3705d8186
|
@ -1674,8 +1674,8 @@ impl<'a, 'b> FunctionBodyBuilder<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit(&mut self, op: Operator, loc: SourceLoc) -> Result<()> {
|
fn emit(&mut self, op: Operator, loc: SourceLoc) -> Result<()> {
|
||||||
let inputs = op_inputs(self.module, &self.op_stack[..], &op)?;
|
let inputs = op_inputs(self.module, Some(&self.op_stack[..]), &op)?;
|
||||||
let outputs = op_outputs(self.module, &self.op_stack[..], &op)?;
|
let outputs = op_outputs(self.module, Some(&self.op_stack[..]), &op)?;
|
||||||
|
|
||||||
log::trace!(
|
log::trace!(
|
||||||
"emit into block {:?}: op {:?} inputs {:?}",
|
"emit into block {:?}: op {:?} inputs {:?}",
|
||||||
|
|
|
@ -11,7 +11,7 @@ pub mod entity;
|
||||||
mod errors;
|
mod errors;
|
||||||
mod frontend;
|
mod frontend;
|
||||||
mod ir;
|
mod ir;
|
||||||
mod op_traits;
|
pub mod op_traits;
|
||||||
mod ops;
|
mod ops;
|
||||||
pub mod passes;
|
pub mod passes;
|
||||||
pub mod pool;
|
pub mod pool;
|
||||||
|
|
|
@ -7,7 +7,7 @@ use std::borrow::Cow;
|
||||||
|
|
||||||
pub fn op_inputs(
|
pub fn op_inputs(
|
||||||
module: &Module,
|
module: &Module,
|
||||||
op_stack: &[(Type, Value)],
|
op_stack: Option<&[(Type, Value)]>,
|
||||||
op: &Operator,
|
op: &Operator,
|
||||||
) -> Result<Cow<'static, [Type]>> {
|
) -> Result<Cow<'static, [Type]>> {
|
||||||
match op {
|
match op {
|
||||||
|
@ -24,6 +24,9 @@ pub fn op_inputs(
|
||||||
}
|
}
|
||||||
|
|
||||||
&Operator::Select => {
|
&Operator::Select => {
|
||||||
|
let Some(op_stack) = op_stack else{
|
||||||
|
anyhow::bail!("selects cannot be typed with no stack");
|
||||||
|
};
|
||||||
let val_ty = op_stack[op_stack.len() - 2].0;
|
let val_ty = op_stack[op_stack.len() - 2].0;
|
||||||
Ok(vec![val_ty, val_ty, Type::I32].into())
|
Ok(vec![val_ty, val_ty, Type::I32].into())
|
||||||
}
|
}
|
||||||
|
@ -226,7 +229,7 @@ pub fn op_inputs(
|
||||||
|
|
||||||
pub fn op_outputs(
|
pub fn op_outputs(
|
||||||
module: &Module,
|
module: &Module,
|
||||||
op_stack: &[(Type, Value)],
|
op_stack: Option<&[(Type, Value)]>,
|
||||||
op: &Operator,
|
op: &Operator,
|
||||||
) -> Result<Cow<'static, [Type]>> {
|
) -> Result<Cow<'static, [Type]>> {
|
||||||
match op {
|
match op {
|
||||||
|
@ -241,6 +244,9 @@ pub fn op_outputs(
|
||||||
}
|
}
|
||||||
|
|
||||||
&Operator::Select => {
|
&Operator::Select => {
|
||||||
|
let Some(op_stack) = op_stack else{
|
||||||
|
anyhow::bail!("selects cannot be typed with no stack");
|
||||||
|
};
|
||||||
let val_ty = op_stack[op_stack.len() - 2].0;
|
let val_ty = op_stack[op_stack.len() - 2].0;
|
||||||
Ok(vec![val_ty].into())
|
Ok(vec![val_ty].into())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue