Skip to content

Commit

Permalink
fmt + clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpal committed May 27, 2024
1 parent 77aac8c commit 9afc66b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 15 deletions.
2 changes: 1 addition & 1 deletion brilift/src/translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ impl CompileEnv<'_> {
let thn = builder.use_var(self.vars[&args[1]]);
let els = builder.use_var(self.vars[&args[2]]);
let res = builder.ins().select(cond, thn, els);
builder.def_var(self.vars[dest], res);
builder.def_var(self.vars[dest], res);
}
bril::ValueOps::Smax => {
let a = builder.use_var(self.vars[&args[0]]);
Expand Down
2 changes: 1 addition & 1 deletion brilirs/src/basic_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl BBProgram {
.collect::<Result<Vec<BBFunction>, InterpError>>()?;

let bb = Self {
index_of_main: func_map.get(&"main".to_string()).copied(),
index_of_main: func_map.get("main").copied(),
func_index,
};
if func_map.len() == num_funcs {
Expand Down
13 changes: 6 additions & 7 deletions brilirs/src/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use crate::{
};
use bril_rs::{ConstOps, EffectOps, Instruction, Type, ValueOps};

use clap::ValueEnum;
use fxhash::FxHashMap;

const fn check_num_args(expected: usize, args: &[String]) -> Result<(), InterpError> {
Expand Down Expand Up @@ -184,25 +183,25 @@ fn type_check_instruction<'a>(
args,
funcs,
labels,
pos: _
pos: _,
} => {
check_num_args(3, args)?;
check_num_funcs(0, funcs)?;
check_num_labels(0, labels)?;
check_asmt_type(&Type::Bool, get_type(env, 0, args)?)?;
check_asmt_type(&op_type, get_type(env, 1, args)?)?;
check_asmt_type(&op_type, get_type(env, 2, args)?)?;
check_asmt_type(op_type, get_type(env, 1, args)?)?;
check_asmt_type(op_type, get_type(env, 2, args)?)?;
update_env(env, dest, op_type)
}
Instruction::Value {
Instruction::Value {
op: ValueOps::Smax | ValueOps::Smin,
dest,
op_type,
args,
funcs,
labels,
pos: _
} => {
pos: _,
} => {
check_num_args(2, args)?;
check_num_funcs(0, funcs)?;
check_num_labels(0, labels)?;
Expand Down
12 changes: 6 additions & 6 deletions brilirs/src/interp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,8 @@ fn execute_value_op<T: std::io::Write>(
) -> Result<(), InterpError> {
use bril_rs::ValueOps::{
Add, Alloc, And, Call, Ceq, Cge, Cgt, Char2int, Cle, Clt, Div, Eq, Fadd, Fdiv, Feq, Fge, Fgt,
Fle, Flt, Fmul, Fsub, Ge, Gt, Id, Int2char, Le, Load, Lt, Mul, Not, Or, Phi, PtrAdd, Sub, Select,
Smax, Smin
Fle, Flt, Fmul, Fsub, Ge, Gt, Id, Int2char, Le, Load, Lt, Mul, Not, Or, Phi, PtrAdd, Select,
Smax, Smin, Sub,
};
match op {
Add => {
Expand Down Expand Up @@ -402,18 +402,18 @@ fn execute_value_op<T: std::io::Write>(
let res = if arg0 { arg1 } else { arg2 };
state.env.set(dest, res);
}
Smax => {
Smax => {
let arg0 = get_arg::<i64>(&state.env, 0, args);
let arg1 = get_arg::<i64>(&state.env, 1, args);
let res = if arg0 > arg1 { arg0 } else { arg1 };
state.env.set(dest, Value::Int(res));
}
Smin => {
}
Smin => {
let arg0 = get_arg::<i64>(&state.env, 0, args);
let arg1 = get_arg::<i64>(&state.env, 1, args);
let res = if arg0 < arg1 { arg0 } else { arg1 };
state.env.set(dest, Value::Int(res));
}
}
Fadd => {
let arg0 = get_arg::<f64>(&state.env, 0, args);
let arg1 = get_arg::<f64>(&state.env, 1, args);
Expand Down

0 comments on commit 9afc66b

Please sign in to comment.