Skip to content
Snippets Groups Projects

WIP: Assembly

Closed Markus Holzer requested to merge holzer/pystencils:assembly into master
1 file
+ 21
4
Compare changes
  • Side-by-side
  • Inline
@@ -609,6 +609,20 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
@@ -609,6 +609,20 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
return result
return result
def _print_Add(self, expr, order=None):
def _print_Add(self, expr, order=None):
 
def visit(summands):
 
if len(summands) == 2:
 
sign = summands[0].sign * summands[1].sign
 
func = self.instruction_set['-'] if sign == -1 else self.instruction_set['+']
 
return func.format(summands[0].term, summands[1].term)
 
else:
 
elements = len(summands) // 2
 
if len(summands[:elements]) < 2:
 
func = self.instruction_set['-'] if summands[0].sign == -1 else self.instruction_set['+']
 
return func.format(summands[0].term, visit(summands[elements:]))
 
else:
 
func = self.instruction_set['+']
 
return func.format(visit(summands[:elements]), visit(summands[elements:]))
 
result = self._scalarFallback('_print_Add', expr)
result = self._scalarFallback('_print_Add', expr)
if result:
if result:
return result
return result
@@ -628,10 +642,13 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
@@ -628,10 +642,13 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
summands.insert(0, self.SummandInfo(1, "0"))
summands.insert(0, self.SummandInfo(1, "0"))
assert len(summands) >= 2
assert len(summands) >= 2
processed = summands[0].term
if len(summands) < 10:
for summand in summands[1:]:
processed = summands[0].term
func = self.instruction_set['-'] if summand.sign == -1 else self.instruction_set['+']
for summand in summands[1:]:
processed = func.format(processed, summand.term)
func = self.instruction_set['-'] if summand.sign == -1 else self.instruction_set['+']
 
processed = func.format(processed, summand.term)
 
else:
 
processed = visit(summands)
return processed
return processed
def _print_Pow(self, expr):
def _print_Pow(self, expr):
Loading