From ea6f170475dc460d8ba49b512270fddf17ae4ec2 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Sat, 30 Oct 2021 11:26:31 +0100 Subject: [PATCH] add setmodule function to SimdScope --- src/ieee754/part/simd_scope.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ieee754/part/simd_scope.py b/src/ieee754/part/simd_scope.py index 290c83e6..680fea32 100644 --- a/src/ieee754/part/simd_scope.py +++ b/src/ieee754/part/simd_scope.py @@ -50,18 +50,22 @@ class SimdScope: def __init__(self, module, elwid, vec_el_counts, scalar=False): + self.elwid = elwid + self.vec_el_counts = vec_el_counts + self.scalar = scalar + self.set_module(module) + + def set_module(self, module): # in SIMD mode, must establish module as part of context and inform # the module to operate under "SIMD" Type 1 (AST) casting rules, # not the # default "Value.cast" rules. - if not scalar: - self.module = module - from ieee754.part.partsig import SimdSignal + if self.scalar: + return + self.module = module + from ieee754.part.partsig import SimdSignal + if module is not None: module._setAstTypeCastFn(SimdSignal.cast) - self.elwid = elwid - self.vec_el_counts = vec_el_counts - self.scalar = scalar - def __repr__(self): return (f"SimdScope(\n" f" elwid={self.elwid},\n" -- 2.30.2