Skip to content
Snippets Groups Projects

WIP: Assembly

Closed Markus Holzer requested to merge holzer/pystencils:assembly into master
2 unresolved threads
Files
7
@@ -628,6 +628,20 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
@@ -628,6 +628,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['-' + suffix] if sign == -1 else self.instruction_set['+' + suffix]
 
return func.format(summands[0].term, summands[1].term)
 
else:
 
elements = len(summands) // 2
 
if len(summands[:elements]) < 2:
 
func = self.instruction_set['-' + suffix] \
 
if summands[0].sign == -1 else self.instruction_set['+' + suffix]
 
return func.format(summands[0].term, visit(summands[elements:]))
 
else:
 
func = self.instruction_set['+' + suffix]
 
return func.format(visit(summands[:elements]), visit(summands[elements:]))
try:
try:
result = self._scalarFallback('_print_Add', expr)
result = self._scalarFallback('_print_Add', expr)
except Exception:
except Exception:
@@ -662,10 +676,13 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
@@ -662,10 +676,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['-' + suffix] if summand.sign == -1 else self.instruction_set['+' + suffix]
for summand in summands[1:]:
processed = func.format(processed, summand.term)
func = self.instruction_set['-' + suffix] if summand.sign == -1 else self.instruction_set['+' + suffix]
 
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