Skip to content

Instantly share code, notes, and snippets.

@pervognsen
Last active October 23, 2022 10:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pervognsen/05b6ba468c3e28e2b18e30eb873cbc7a to your computer and use it in GitHub Desktop.
Save pervognsen/05b6ba468c3e28e2b18e30eb873cbc7a to your computer and use it in GitHub Desktop.
// semantic analysis, called by parser
void do_mul(Value *dest, Value *src) {
promote_arith(dest, src);
if (isint(dest)) {
if (isconst2(dest, src)) {
dest->ival *= src->ival;
} else {
gen_mul(dest, src);
}
} else {
assert(isfloat(dest));
if (isconst2(dest, src)) {
dest->fval *= src->fval;
} else {
gen_fmul(dest, src);
}
}
gen_kill(src);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment