Add Intel legalization for division and multiplication.

These operations need custom legalization in order to use Intel's div
and idiv instructions.
This commit is contained in:
Jakob Stoklund Olesen
2017-07-28 08:46:45 -07:00
parent 6609d7baf4
commit be8331d0a0
7 changed files with 134 additions and 16 deletions

View File

@@ -14,6 +14,8 @@ from .instructions import band, bor, bxor, isplit, iconcat
from .instructions import bnot, band_not, bor_not, bxor_not
from .instructions import icmp, icmp_imm
from .instructions import iconst, bint
from .instructions import ishl, ishl_imm, sshr, sshr_imm, ushr, ushr_imm
from .instructions import rotl, rotl_imm, rotr, rotr_imm
from cdsl.ast import Var
from cdsl.xform import Rtl, XFormGroup
@@ -153,6 +155,20 @@ expand.legalize(
a << iadd(x, a1)
))
# Rotates and shifts.
for inst_imm, inst in [
(rotl_imm, rotl),
(rotr_imm, rotr),
(ishl_imm, ishl),
(sshr_imm, sshr),
(ushr_imm, ushr)]:
expand.legalize(
a << inst_imm(x, y),
Rtl(
a1 << iconst.i32(y),
a << inst(x, a1)
))
expand.legalize(
a << icmp_imm(cc, x, y),
Rtl(