Skip to content

Instantly share code, notes, and snippets.

@inolen
Last active November 19, 2017 16:56
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 inolen/8ee108ab7fdaf140f8affaf8719f5b99 to your computer and use it in GitHub Desktop.
Save inolen/8ee108ab7fdaf140f8affaf8719f5b99 to your computer and use it in GitHub Desktop.
void x64_backend_mov_value(struct x64_backend *backend, const Xbyak::Reg &rd,
const struct ir_value *v) {
auto &e = *backend->codegen;
if (ir_is_constant(v)) {
e.mov(rd, ir_zext_constant(v));
return;
}
Xbyak::Reg ra = x64_backend_reg(backend, v);
if (rd.isBit(64) && ra.isBit(64)) {
e.mov(rd, ra);
} else if (rd.isBit(64) && ra.isBit(32)) {
/* mov will automatically zero fill the upper 32-bits */
e.mov(rd.cvt32(), ra);
} else {
e.movzx(rd, ra);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment