From ec84726858b9881b3e95e07e3eb61e38c0ed58c7 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 18 Feb 2015 09:56:07 -0700 Subject: [PATCH] py2llvm: support conversion of fractions to float --- artiq/py2llvm/fractions.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/artiq/py2llvm/fractions.py b/artiq/py2llvm/fractions.py index 1e0196ecb..c2a9730fa 100644 --- a/artiq/py2llvm/fractions.py +++ b/artiq/py2llvm/fractions.py @@ -153,6 +153,15 @@ class VFraction(VGeneric): r.auto_store(builder, builder.sdiv(a, b)) return r.o_intx(target_bits, builder) + def o_float(self, builder): + r = VFloat() + if builder is not None: + a, b = self._nd(builder) + af = builder.sitofp(a, r.get_llvm_type()) + bf = builder.sitofp(b, r.get_llvm_type()) + r.auto_store(builder, builder.fdiv(af, bf)) + return r + def _o_eq_inv(self, other, builder, ne): if not isinstance(other, (VInt, VFraction)): return NotImplemented