Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
douglas-raillard-arm committed Jan 8, 2024
1 parent 0962d2f commit 19b7c8c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tools/analysis/traceevent/src/cinterp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,13 @@ impl Expr {
.map_err(|_| EvalError::CannotConvertToSigned(x))
}

fn ptr_arith(pointee: Type, expr: Expr) -> Expr {
match pointee {
Type::Void | Type::U8 | Type::I8 => expr,
_ => Mul(Box::new(expr), Box::new(SizeofType(pointee))),
}
}

macro_rules! binop {
($ctor:path, $lhs:expr, $rhs:expr, $op:expr) => {{
let lhs = *$lhs;
Expand All @@ -1313,8 +1320,6 @@ impl Expr {
match (lhstyp, rhstyp) {
// Binary operation between two arithmetic types
(lhs, rhs) if lhs.is_arith() && rhs.is_arith() => {
let rhs2 = rhs.clone();
let lhs2 = lhs.clone();
let (_typ, conv_lhs, conv_rhs) = convert_arith_ops(abi, lhs, rhs)?;

Ok(new_dyn_evaluator(move |env| {
Expand Down Expand Up @@ -1346,7 +1351,7 @@ impl Expr {
Type::Pointer(_lhstyp.clone()),
Box::new($ctor(
Box::new(Cast(Type::U64, Box::new(lhs))),
Box::new(Mul(Box::new(rhs), Box::new(SizeofType(*_lhstyp)))),
Box::new(ptr_arith(*_lhstyp, rhs)),
))
)
)
Expand All @@ -1357,7 +1362,7 @@ impl Expr {
Cast(
Type::Pointer(_rhstyp.clone()),
Box::new($ctor(
Box::new(Mul(Box::new(lhs), Box::new(SizeofType(*_rhstyp)))),
Box::new(ptr_arith(*_rhstyp, lhs)),
Box::new(Cast(Type::U64, Box::new(rhs))),
))
)
Expand Down

0 comments on commit 19b7c8c

Please sign in to comment.