import unittest
-from bigint_presentation_code.compiler_ir import (GPR_SIZE_IN_BYTES, SSAGPR, VL, FixedGPRRangeType, Fn,
- GlobalMem, GPRRange,
- GPRRangeType, OpCopy,
- OpFuncArg, OpInputMem,
- OpSetVLImm, OpStore, PreRASimState, SSAGPRRange, XERBit,
- generate_assembly)
-from bigint_presentation_code.register_allocator import allocate_registers
+from bigint_presentation_code.compiler_ir2 import (GPR_SIZE_IN_BYTES, Fn,
+ GenAsmState, OpKind,
+ PreRASimState)
+from bigint_presentation_code.register_allocator2 import allocate_registers
from bigint_presentation_code.toom_cook import ToomCookInstance, simple_mul
-from bigint_presentation_code.util import FMap
class SimpleMul192x192:
def __init__(self):
+ super().__init__()
self.fn = fn = Fn()
- self.mem_in = mem = OpInputMem(fn).out
- self.dest_ptr_in = OpFuncArg(fn, FixedGPRRangeType(GPRRange(3))).out
- self.lhs_in = OpFuncArg(fn, FixedGPRRangeType(GPRRange(4, 3))).out
- self.rhs_in = OpFuncArg(fn, FixedGPRRangeType(GPRRange(7, 3))).out
- dest_ptr = OpCopy(fn, self.dest_ptr_in, GPRRangeType()).dest
- vl = OpSetVLImm(fn, 3).out
- lhs = OpCopy(fn, self.lhs_in, GPRRangeType(3), vl=vl).dest
- rhs = OpCopy(fn, self.rhs_in, GPRRangeType(3), vl=vl).dest
- retval = simple_mul(fn, lhs, rhs)
- vl = OpSetVLImm(fn, 6).out
- self.mem_out = OpStore(fn, RS=retval, RA=dest_ptr, offset=0,
- mem_in=mem, vl=vl).mem_out
+ self.dest_offset = 0
+ self.lhs_offset = 48 + self.dest_offset
+ self.rhs_offset = 24 + self.lhs_offset
+ self.ptr_in = fn.append_new_op(kind=OpKind.FuncArgR3,
+ name="ptr_in").outputs[0]
+ setvl3 = fn.append_new_op(kind=OpKind.SetVLI, immediates=[3],
+ maxvl=3, name="setvl3")
+ load_lhs = fn.append_new_op(
+ kind=OpKind.SvLd, immediates=[self.lhs_offset],
+ input_vals=[self.ptr_in, setvl3.outputs[0]],
+ name="load_lhs", maxvl=3)
+ load_rhs = fn.append_new_op(
+ kind=OpKind.SvLd, immediates=[self.rhs_offset],
+ input_vals=[self.ptr_in, setvl3.outputs[0]],
+ name="load_rhs", maxvl=3)
+ retval = simple_mul(fn, load_lhs.outputs[0], load_rhs.outputs[0])
+ setvl6 = fn.append_new_op(kind=OpKind.SetVLI, immediates=[6],
+ maxvl=6, name="setvl6")
+ fn.append_new_op(
+ kind=OpKind.SvStd,
+ input_vals=[retval, self.ptr_in, setvl6.outputs[0]],
+ immediates=[self.dest_offset], maxvl=6, name="store_dest")
class TestToomCook(unittest.TestCase):
# == int.from_bytes(b"arbitrary 192x192->384-bit multiplication test",
# 'little')
code = SimpleMul192x192()
- dest_ptr = 0x100
- state = PreRASimState(
- gprs={}, VLs={}, CAs={}, global_mems={code.mem_in: FMap()},
- stack_slots={}, fixed_gprs={
- code.dest_ptr_in: (dest_ptr,),
- code.lhs_in: (0x821a2342132c5b57, 0x4c6b5f2b19e1a53e,
- 0x000191acb262e15b),
- code.rhs_in: (0x208a49071aeec507, 0xcf1f597598194ae6,
- 0x4a37c0567bcbab53)
- })
+ ptr_in = 0x100
+ dest_ptr = ptr_in + code.dest_offset
+ lhs_ptr = ptr_in + code.lhs_offset
+ rhs_ptr = ptr_in + code.rhs_offset
+ state = PreRASimState(ssa_vals={code.ptr_in: (ptr_in,)}, memory={})
+ state.store(lhs_ptr, 0x821a2342132c5b57)
+ state.store(lhs_ptr + 8, 0x4c6b5f2b19e1a53e)
+ state.store(lhs_ptr + 16, 0x000191acb262e15b)
+ state.store(rhs_ptr, 0x208a49071aeec507)
+ state.store(rhs_ptr + 8, 0xcf1f597598194ae6)
+ state.store(rhs_ptr + 16, 0x4a37c0567bcbab53)
code.fn.pre_ra_sim(state)
expected_bytes = b"arbitrary 192x192->384-bit multiplication test"
OUT_BYTE_COUNT = 6 * GPR_SIZE_IN_BYTES
expected_bytes = expected_bytes.ljust(OUT_BYTE_COUNT, b'\0')
- mem_out = state.global_mems[code.mem_out]
out_bytes = bytes(
- mem_out.get(dest_ptr + i, 0) for i in range(OUT_BYTE_COUNT))
+ state.load_byte(dest_ptr + i) for i in range(OUT_BYTE_COUNT))
self.assertEqual(out_bytes, expected_bytes)
def test_simple_mul_192x192_ops(self):
code = SimpleMul192x192()
fn = code.fn
self.assertEqual([repr(v) for v in fn.ops], [
- 'OpInputMem(#0, <#0.out: GlobalMemType()>)',
- 'OpFuncArg(#1, <#1.out: <fixed(<r3>)>>)',
- 'OpFuncArg(#2, <#2.out: <fixed(<r4..len=3>)>>)',
- 'OpFuncArg(#3, <#3.out: <fixed(<r7..len=3>)>>)',
- 'OpCopy(#4, <#4.dest: <gpr_ty[1]>>, src=<#1.out: <fixed(<r3>)>>, '
- 'vl=None)',
- 'OpSetVLImm(#5, <#5.out: KnownVLType(length=3)>)',
- 'OpCopy(#6, <#6.dest: <gpr_ty[3]>>, '
- 'src=<#2.out: <fixed(<r4..len=3>)>>, '
- 'vl=<#5.out: KnownVLType(length=3)>)',
- 'OpCopy(#7, <#7.dest: <gpr_ty[3]>>, '
- 'src=<#3.out: <fixed(<r7..len=3>)>>, '
- 'vl=<#5.out: KnownVLType(length=3)>)',
- 'OpSplit(#8, results=(<#8.results[0]: <gpr_ty[1]>>, '
- '<#8.results[1]: <gpr_ty[1]>>, <#8.results[2]: <gpr_ty[1]>>), '
- 'src=<#7.dest: <gpr_ty[3]>>)',
- 'OpSetVLImm(#9, <#9.out: KnownVLType(length=3)>)',
- 'OpLI(#10, <#10.out: <gpr_ty[1]>>, value=0, vl=None)',
- 'OpBigIntMulDiv(#11, <#11.RT: <gpr_ty[3]>>, '
- 'RA=<#6.dest: <gpr_ty[3]>>, RB=<#8.results[0]: <gpr_ty[1]>>, '
- 'RC=<#10.out: <gpr_ty[1]>>, <#11.RS: <gpr_ty[1]>>, is_div=False, '
- 'vl=<#9.out: KnownVLType(length=3)>)',
- 'OpConcat(#12, <#12.dest: <gpr_ty[4]>>, sources=('
- '<#11.RT: <gpr_ty[3]>>, <#11.RS: <gpr_ty[1]>>))',
- 'OpBigIntMulDiv(#13, <#13.RT: <gpr_ty[3]>>, '
- 'RA=<#6.dest: <gpr_ty[3]>>, RB=<#8.results[1]: <gpr_ty[1]>>, '
- 'RC=<#10.out: <gpr_ty[1]>>, <#13.RS: <gpr_ty[1]>>, is_div=False, '
- 'vl=<#9.out: KnownVLType(length=3)>)',
- 'OpSplit(#14, results=(<#14.results[0]: <gpr_ty[1]>>, '
- '<#14.results[1]: <gpr_ty[3]>>), src=<#12.dest: <gpr_ty[4]>>)',
- 'OpSetCA(#15, <#15.out: CAType()>, value=False)',
- 'OpBigIntAddSub(#16, <#16.out: <gpr_ty[3]>>, '
- 'lhs=<#13.RT: <gpr_ty[3]>>, rhs=<#14.results[1]: <gpr_ty[3]>>, '
- 'CA_in=<#15.out: CAType()>, <#16.CA_out: CAType()>, is_sub=False, '
- 'vl=<#9.out: KnownVLType(length=3)>)',
- 'OpBigIntAddSub(#17, <#17.out: <gpr_ty[1]>>, '
- 'lhs=<#13.RS: <gpr_ty[1]>>, rhs=<#10.out: <gpr_ty[1]>>, '
- 'CA_in=<#16.CA_out: CAType()>, <#17.CA_out: CAType()>, '
- 'is_sub=False, vl=None)',
- 'OpConcat(#18, <#18.dest: <gpr_ty[5]>>, sources=('
- '<#14.results[0]: <gpr_ty[1]>>, <#16.out: <gpr_ty[3]>>, '
- '<#17.out: <gpr_ty[1]>>))',
- 'OpBigIntMulDiv(#19, <#19.RT: <gpr_ty[3]>>, '
- 'RA=<#6.dest: <gpr_ty[3]>>, RB=<#8.results[2]: <gpr_ty[1]>>, '
- 'RC=<#10.out: <gpr_ty[1]>>, <#19.RS: <gpr_ty[1]>>, is_div=False, '
- 'vl=<#9.out: KnownVLType(length=3)>)',
- 'OpSplit(#20, results=(<#20.results[0]: <gpr_ty[2]>>, '
- '<#20.results[1]: <gpr_ty[3]>>), src=<#18.dest: <gpr_ty[5]>>)',
- 'OpSetCA(#21, <#21.out: CAType()>, value=False)',
- 'OpBigIntAddSub(#22, <#22.out: <gpr_ty[3]>>, '
- 'lhs=<#19.RT: <gpr_ty[3]>>, rhs=<#20.results[1]: <gpr_ty[3]>>, '
- 'CA_in=<#21.out: CAType()>, <#22.CA_out: CAType()>, is_sub=False, '
- 'vl=<#9.out: KnownVLType(length=3)>)',
- 'OpBigIntAddSub(#23, <#23.out: <gpr_ty[1]>>, '
- 'lhs=<#19.RS: <gpr_ty[1]>>, rhs=<#10.out: <gpr_ty[1]>>, '
- 'CA_in=<#22.CA_out: CAType()>, <#23.CA_out: CAType()>, '
- 'is_sub=False, vl=None)',
- 'OpConcat(#24, <#24.dest: <gpr_ty[6]>>, sources=('
- '<#20.results[0]: <gpr_ty[2]>>, <#22.out: <gpr_ty[3]>>, '
- '<#23.out: <gpr_ty[1]>>))',
- 'OpSetVLImm(#25, <#25.out: KnownVLType(length=6)>)',
- 'OpStore(#26, RS=<#24.dest: <gpr_ty[6]>>, '
- 'RA=<#4.dest: <gpr_ty[1]>>, offset=0, '
- 'mem_in=<#0.out: GlobalMemType()>, '
- '<#26.mem_out: GlobalMemType()>, '
- 'vl=<#25.out: KnownVLType(length=6)>)'
+ "Op(kind=OpKind.FuncArgR3, "
+ "input_vals=[], "
+ "input_uses=(), immediates=[], "
+ "outputs=(<ptr_in.outputs[0]: <I64>>,), "
+ "name='ptr_in')",
+ "Op(kind=OpKind.SetVLI, "
+ "input_vals=[], "
+ "input_uses=(), immediates=[3], "
+ "outputs=(<setvl3.outputs[0]: <VL_MAXVL>>,), "
+ "name='setvl3')",
+ "Op(kind=OpKind.SvLd, "
+ "input_vals=[<ptr_in.outputs[0]: <I64>>, "
+ "<setvl3.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<load_lhs.input_uses[0]: <I64>>, "
+ "<load_lhs.input_uses[1]: <VL_MAXVL>>), immediates=[48], "
+ "outputs=(<load_lhs.outputs[0]: <I64*3>>,), "
+ "name='load_lhs')",
+ "Op(kind=OpKind.SvLd, "
+ "input_vals=[<ptr_in.outputs[0]: <I64>>, "
+ "<setvl3.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<load_rhs.input_uses[0]: <I64>>, "
+ "<load_rhs.input_uses[1]: <VL_MAXVL>>), immediates=[72], "
+ "outputs=(<load_rhs.outputs[0]: <I64*3>>,), "
+ "name='load_rhs')",
+ "Op(kind=OpKind.SetVLI, "
+ "input_vals=[], "
+ "input_uses=(), immediates=[3], "
+ "outputs=(<rhs_setvl.outputs[0]: <VL_MAXVL>>,), "
+ "name='rhs_setvl')",
+ "Op(kind=OpKind.Spread, "
+ "input_vals=[<load_rhs.outputs[0]: <I64*3>>, "
+ "<rhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<rhs_spread.input_uses[0]: <I64*3>>, "
+ "<rhs_spread.input_uses[1]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<rhs_spread.outputs[0]: <I64>>, "
+ "<rhs_spread.outputs[1]: <I64>>, "
+ "<rhs_spread.outputs[2]: <I64>>), "
+ "name='rhs_spread')",
+ "Op(kind=OpKind.SetVLI, "
+ "input_vals=[], "
+ "input_uses=(), immediates=[3], "
+ "outputs=(<lhs_setvl.outputs[0]: <VL_MAXVL>>,), "
+ "name='lhs_setvl')",
+ "Op(kind=OpKind.LI, "
+ "input_vals=[], "
+ "input_uses=(), immediates=[0], "
+ "outputs=(<zero.outputs[0]: <I64>>,), "
+ "name='zero')",
+ "Op(kind=OpKind.SvMAddEDU, "
+ "input_vals=[<load_lhs.outputs[0]: <I64*3>>, "
+ "<rhs_spread.outputs[0]: <I64>>, "
+ "<zero.outputs[0]: <I64>>, "
+ "<lhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<mul0.input_uses[0]: <I64*3>>, "
+ "<mul0.input_uses[1]: <I64>>, "
+ "<mul0.input_uses[2]: <I64>>, "
+ "<mul0.input_uses[3]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<mul0.outputs[0]: <I64*3>>, "
+ "<mul0.outputs[1]: <I64>>), "
+ "name='mul0')",
+ "Op(kind=OpKind.Spread, "
+ "input_vals=[<mul0.outputs[0]: <I64*3>>, "
+ "<lhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<mul0_rt_spread.input_uses[0]: <I64*3>>, "
+ "<mul0_rt_spread.input_uses[1]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<mul0_rt_spread.outputs[0]: <I64>>, "
+ "<mul0_rt_spread.outputs[1]: <I64>>, "
+ "<mul0_rt_spread.outputs[2]: <I64>>), "
+ "name='mul0_rt_spread')",
+ "Op(kind=OpKind.SvMAddEDU, "
+ "input_vals=[<load_lhs.outputs[0]: <I64*3>>, "
+ "<rhs_spread.outputs[1]: <I64>>, "
+ "<zero.outputs[0]: <I64>>, "
+ "<lhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<mul1.input_uses[0]: <I64*3>>, "
+ "<mul1.input_uses[1]: <I64>>, "
+ "<mul1.input_uses[2]: <I64>>, "
+ "<mul1.input_uses[3]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<mul1.outputs[0]: <I64*3>>, "
+ "<mul1.outputs[1]: <I64>>), "
+ "name='mul1')",
+ "Op(kind=OpKind.Concat, "
+ "input_vals=[<mul0_rt_spread.outputs[1]: <I64>>, "
+ "<mul0_rt_spread.outputs[2]: <I64>>, "
+ "<mul0.outputs[1]: <I64>>, "
+ "<lhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<add1_rb_concat.input_uses[0]: <I64>>, "
+ "<add1_rb_concat.input_uses[1]: <I64>>, "
+ "<add1_rb_concat.input_uses[2]: <I64>>, "
+ "<add1_rb_concat.input_uses[3]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<add1_rb_concat.outputs[0]: <I64*3>>,), "
+ "name='add1_rb_concat')",
+ "Op(kind=OpKind.ClearCA, "
+ "input_vals=[], "
+ "input_uses=(), immediates=[], "
+ "outputs=(<clear_ca1.outputs[0]: <CA>>,), "
+ "name='clear_ca1')",
+ "Op(kind=OpKind.SvAddE, "
+ "input_vals=[<mul1.outputs[0]: <I64*3>>, "
+ "<add1_rb_concat.outputs[0]: <I64*3>>, "
+ "<clear_ca1.outputs[0]: <CA>>, "
+ "<lhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<add1.input_uses[0]: <I64*3>>, "
+ "<add1.input_uses[1]: <I64*3>>, "
+ "<add1.input_uses[2]: <CA>>, "
+ "<add1.input_uses[3]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<add1.outputs[0]: <I64*3>>, "
+ "<add1.outputs[1]: <CA>>), "
+ "name='add1')",
+ "Op(kind=OpKind.Spread, "
+ "input_vals=[<add1.outputs[0]: <I64*3>>, "
+ "<lhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<add1_rt_spread.input_uses[0]: <I64*3>>, "
+ "<add1_rt_spread.input_uses[1]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<add1_rt_spread.outputs[0]: <I64>>, "
+ "<add1_rt_spread.outputs[1]: <I64>>, "
+ "<add1_rt_spread.outputs[2]: <I64>>), "
+ "name='add1_rt_spread')",
+ "Op(kind=OpKind.AddZE, "
+ "input_vals=[<mul1.outputs[1]: <I64>>, "
+ "<add1.outputs[1]: <CA>>], "
+ "input_uses=(<add_hi1.input_uses[0]: <I64>>, "
+ "<add_hi1.input_uses[1]: <CA>>), immediates=[], "
+ "outputs=(<add_hi1.outputs[0]: <I64>>, "
+ "<add_hi1.outputs[1]: <CA>>), "
+ "name='add_hi1')",
+ "Op(kind=OpKind.SvMAddEDU, "
+ "input_vals=[<load_lhs.outputs[0]: <I64*3>>, "
+ "<rhs_spread.outputs[2]: <I64>>, "
+ "<zero.outputs[0]: <I64>>, "
+ "<lhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<mul2.input_uses[0]: <I64*3>>, "
+ "<mul2.input_uses[1]: <I64>>, "
+ "<mul2.input_uses[2]: <I64>>, "
+ "<mul2.input_uses[3]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<mul2.outputs[0]: <I64*3>>, "
+ "<mul2.outputs[1]: <I64>>), "
+ "name='mul2')",
+ "Op(kind=OpKind.Concat, "
+ "input_vals=[<add1_rt_spread.outputs[1]: <I64>>, "
+ "<add1_rt_spread.outputs[2]: <I64>>, "
+ "<add_hi1.outputs[0]: <I64>>, "
+ "<lhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<add2_rb_concat.input_uses[0]: <I64>>, "
+ "<add2_rb_concat.input_uses[1]: <I64>>, "
+ "<add2_rb_concat.input_uses[2]: <I64>>, "
+ "<add2_rb_concat.input_uses[3]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<add2_rb_concat.outputs[0]: <I64*3>>,), "
+ "name='add2_rb_concat')",
+ "Op(kind=OpKind.ClearCA, "
+ "input_vals=[], "
+ "input_uses=(), immediates=[], "
+ "outputs=(<clear_ca2.outputs[0]: <CA>>,), "
+ "name='clear_ca2')",
+ "Op(kind=OpKind.SvAddE, "
+ "input_vals=[<mul2.outputs[0]: <I64*3>>, "
+ "<add2_rb_concat.outputs[0]: <I64*3>>, "
+ "<clear_ca2.outputs[0]: <CA>>, "
+ "<lhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<add2.input_uses[0]: <I64*3>>, "
+ "<add2.input_uses[1]: <I64*3>>, "
+ "<add2.input_uses[2]: <CA>>, "
+ "<add2.input_uses[3]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<add2.outputs[0]: <I64*3>>, "
+ "<add2.outputs[1]: <CA>>), "
+ "name='add2')",
+ "Op(kind=OpKind.Spread, "
+ "input_vals=[<add2.outputs[0]: <I64*3>>, "
+ "<lhs_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<add2_rt_spread.input_uses[0]: <I64*3>>, "
+ "<add2_rt_spread.input_uses[1]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<add2_rt_spread.outputs[0]: <I64>>, "
+ "<add2_rt_spread.outputs[1]: <I64>>, "
+ "<add2_rt_spread.outputs[2]: <I64>>), "
+ "name='add2_rt_spread')",
+ "Op(kind=OpKind.AddZE, "
+ "input_vals=[<mul2.outputs[1]: <I64>>, "
+ "<add2.outputs[1]: <CA>>], "
+ "input_uses=(<add_hi2.input_uses[0]: <I64>>, "
+ "<add_hi2.input_uses[1]: <CA>>), immediates=[], "
+ "outputs=(<add_hi2.outputs[0]: <I64>>, "
+ "<add_hi2.outputs[1]: <CA>>), "
+ "name='add_hi2')",
+ "Op(kind=OpKind.SetVLI, "
+ "input_vals=[], "
+ "input_uses=(), immediates=[6], "
+ "outputs=(<retval_setvl.outputs[0]: <VL_MAXVL>>,), "
+ "name='retval_setvl')",
+ "Op(kind=OpKind.Concat, "
+ "input_vals=[<mul0_rt_spread.outputs[0]: <I64>>, "
+ "<add1_rt_spread.outputs[0]: <I64>>, "
+ "<add2_rt_spread.outputs[0]: <I64>>, "
+ "<add2_rt_spread.outputs[1]: <I64>>, "
+ "<add2_rt_spread.outputs[2]: <I64>>, "
+ "<add_hi2.outputs[0]: <I64>>, "
+ "<retval_setvl.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<concat_retval.input_uses[0]: <I64>>, "
+ "<concat_retval.input_uses[1]: <I64>>, "
+ "<concat_retval.input_uses[2]: <I64>>, "
+ "<concat_retval.input_uses[3]: <I64>>, "
+ "<concat_retval.input_uses[4]: <I64>>, "
+ "<concat_retval.input_uses[5]: <I64>>, "
+ "<concat_retval.input_uses[6]: <VL_MAXVL>>), immediates=[], "
+ "outputs=(<concat_retval.outputs[0]: <I64*6>>,), "
+ "name='concat_retval')",
+ "Op(kind=OpKind.SetVLI, "
+ "input_vals=[], "
+ "input_uses=(), immediates=[6], "
+ "outputs=(<setvl6.outputs[0]: <VL_MAXVL>>,), "
+ "name='setvl6')",
+ "Op(kind=OpKind.SvStd, "
+ "input_vals=[<concat_retval.outputs[0]: <I64*6>>, "
+ "<ptr_in.outputs[0]: <I64>>, "
+ "<setvl6.outputs[0]: <VL_MAXVL>>], "
+ "input_uses=(<store_dest.input_uses[0]: <I64*6>>, "
+ "<store_dest.input_uses[1]: <I64>>, "
+ "<store_dest.input_uses[2]: <VL_MAXVL>>), immediates=[0], "
+ "outputs=(), "
+ "name='store_dest')",
])
# FIXME: register allocator currently allocates wrong registers
def test_simple_mul_192x192_reg_alloc(self):
code = SimpleMul192x192()
fn = code.fn
- assigned_registers = allocate_registers(fn.ops)
+ assigned_registers = allocate_registers(fn)
self.assertEqual(assigned_registers, {
- fn.ops[13].RS: GPRRange(9), # type: ignore
- fn.ops[14].results[0]: GPRRange(6), # type: ignore
- fn.ops[14].results[1]: GPRRange(7, length=3), # type: ignore
- fn.ops[15].out: XERBit.CA, # type: ignore
- fn.ops[16].out: GPRRange(7, length=3), # type: ignore
- fn.ops[16].CA_out: XERBit.CA, # type: ignore
- fn.ops[17].out: GPRRange(10), # type: ignore
- fn.ops[17].CA_out: XERBit.CA, # type: ignore
- fn.ops[18].dest: GPRRange(6, length=5), # type: ignore
- fn.ops[19].RT: GPRRange(3, length=3), # type: ignore
- fn.ops[19].RS: GPRRange(9), # type: ignore
- fn.ops[20].results[0]: GPRRange(6, length=2), # type: ignore
- fn.ops[20].results[1]: GPRRange(8, length=3), # type: ignore
- fn.ops[21].out: XERBit.CA, # type: ignore
- fn.ops[22].out: GPRRange(8, length=3), # type: ignore
- fn.ops[22].CA_out: XERBit.CA, # type: ignore
- fn.ops[23].out: GPRRange(11), # type: ignore
- fn.ops[23].CA_out: XERBit.CA, # type: ignore
- fn.ops[24].dest: GPRRange(6, length=6), # type: ignore
- fn.ops[25].out: VL.VL_MAXVL, # type: ignore
- fn.ops[26].mem_out: GlobalMem.GlobalMem, # type: ignore
- fn.ops[0].out: GlobalMem.GlobalMem, # type: ignore
- fn.ops[1].out: GPRRange(3), # type: ignore
- fn.ops[2].out: GPRRange(4, length=3), # type: ignore
- fn.ops[3].out: GPRRange(7, length=3), # type: ignore
- fn.ops[4].dest: GPRRange(12), # type: ignore
- fn.ops[5].out: VL.VL_MAXVL, # type: ignore
- fn.ops[6].dest: GPRRange(17, length=3), # type: ignore
- fn.ops[7].dest: GPRRange(14, length=3), # type: ignore
- fn.ops[8].results[0]: GPRRange(14), # type: ignore
- fn.ops[8].results[1]: GPRRange(15), # type: ignore
- fn.ops[8].results[2]: GPRRange(16), # type: ignore
- fn.ops[9].out: VL.VL_MAXVL, # type: ignore
- fn.ops[10].out: GPRRange(9), # type: ignore
- fn.ops[11].RT: GPRRange(6, length=3), # type: ignore
- fn.ops[11].RS: GPRRange(9), # type: ignore
- fn.ops[12].dest: GPRRange(6, length=4), # type: ignore
- fn.ops[13].RT: GPRRange(3, length=3) # type: ignore
})
self.fail("register allocator currently allocates wrong registers")
# FIXME: register allocator currently allocates wrong registers
@unittest.expectedFailure
def test_simple_mul_192x192_asm(self):
+ self.skipTest("WIP")
code = SimpleMul192x192()
- asm = generate_assembly(code.fn.ops)
- self.assertEqual(asm, [
- 'or 12, 3, 3',
- 'setvl 0, 0, 3, 0, 1, 1',
- 'sv.or *17, *4, *4',
- 'sv.or *14, *7, *7',
- 'setvl 0, 0, 3, 0, 1, 1',
- 'addi 9, 0, 0',
- 'sv.maddedu *6, *17, 14, 9',
- 'sv.maddedu *3, *17, 15, 9',
- 'addic 0, 0, 0',
- 'sv.adde *7, *3, *7',
- 'adde 10, 9, 9',
- 'sv.maddedu *3, *17, 16, 9',
- 'addic 0, 0, 0',
- 'sv.adde *8, *3, *8',
- 'adde 11, 9, 9',
- 'setvl 0, 0, 6, 0, 1, 1',
- 'sv.std *6, 0(12)',
- 'bclr 20, 0, 0'
+ fn = code.fn
+ assigned_registers = allocate_registers(fn)
+ gen_asm_state = GenAsmState(assigned_registers)
+ fn.gen_asm(gen_asm_state)
+ self.assertEqual(gen_asm_state.output, [
])
self.fail("register allocator currently allocates wrong registers")