Skip to content

Instantly share code, notes, and snippets.

@Amanieu
Created May 22, 2018 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Amanieu/5f7d923437a25d3b87ff2a79af04718c to your computer and use it in GitHub Desktop.
Save Amanieu/5f7d923437a25d3b87ff2a79af04718c to your computer and use it in GitHub Desktop.
Instruction::SMLAW_16(fields) => {
if trans.config().strict_unpredictable {
if fields.Rd() == 15 || fields.Rm() == 15 || fields.Rn() == 15 {
return translate_unpredictable(trans);
}
}
let n = trans.get_reg(fields.Rn());
let m = trans.get_reg(fields.Rm());
let a = if fields.Ra() == 15 {
trans.gp().const32(0)
} else {
trans.get_reg(fields.Ra())
};
let n = trans.gp().sbfx(Width::X, n, 0, 32);
let m = if fields.M() {
trans.gp().sbfx(Width::X, m, 16, 16)
} else {
trans.gp().sbfx(Width::X, m, 0, 16)
};
let result = trans.gp().mul(Width::X, n, m);
let result = trans.gp().ubfx(Width::X, result, 16, 32);
let (result, flags) = trans.gp().add(Width::W, result, a);
trans.set_reg(fields.Rd(), result);
trans.if_(
BranchHint::False(BranchWeight::Unpredictable),
Predicate::Cond {
cond: Cond::VS,
flags,
},
|trans| {
let one = trans.gp().const32(1);
trans.set_q(one);
},
|_| {},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment