add sign/zero extension operations

This commit is contained in:
Quentin Carbonneaux 2015-08-17 19:00:51 -04:00
parent 5668e93147
commit 40d0582ee0
5 changed files with 23 additions and 2 deletions

View file

@ -130,6 +130,8 @@ eins(Ins i, Fn *fn, FILE *f)
[OSub] = "sub",
[OMul] = "imul",
[OAnd] = "and",
[OSext] = "movslq",
[OZext] = "movzlq",
[OLoad] = "mov",
[OLoadss] = "movsw",
[OLoadus] = "movzw",
@ -182,6 +184,13 @@ eins(Ins i, Fn *fn, FILE *f)
eop("mov", i.arg[0], i.to, fn, f);
eop(otoa[i.op], i.arg[1], i.to, fn, f);
break;
case OSext:
case OZext:
if (rtype(i.to) != RTmp || i.to.val >= EAX
|| (rtype(i.arg[0]) == RTmp && i.arg[0].val < EAX))
diag("emit: invalid extension");
eop(otoa[i.op], i.arg[0], i.to, fn, f);
break;
case OCopy:
if (req(i.to, R))
break;