Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Tom Harke
pystencils
Commits
de250f5a
Commit
de250f5a
authored
Mar 30, 2019
by
Stephan Seitz
Browse files
Add _print_address_of for address_of to cbackend
parent
50f27d79
Changes
1
Show whitespace changes
Inline
Side-by-side
pystencils/backends/cbackend.py
View file @
de250f5a
...
...
@@ -5,7 +5,11 @@ from typing import Set
from
sympy.printing.ccode
import
C89CodePrinter
from
pystencils.cpu.vectorization
import
vec_any
,
vec_all
from
pystencils.fast_approximation
import
fast_division
,
fast_sqrt
,
fast_inv_sqrt
from
pystencils.data_types
import
(
PointerType
,
VectorType
,
address_of
,
cast_func
,
create_type
,
reinterpret_cast_func
,
get_type_of_expression
,
vector_memory_access
)
from
pystencils.fast_approximation
import
fast_division
,
fast_inv_sqrt
,
fast_sqrt
try
:
from
sympy.printing.ccode
import
C99CodePrinter
as
CCodePrinter
...
...
@@ -15,8 +19,6 @@ except ImportError:
from
pystencils.integer_functions
import
bitwise_xor
,
bit_shift_right
,
bit_shift_left
,
bitwise_and
,
\
bitwise_or
,
modulo_ceil
,
int_div
,
int_power_of_2
from
pystencils.astnodes
import
Node
,
KernelFunction
from
pystencils.data_types
import
create_type
,
PointerType
,
get_type_of_expression
,
VectorType
,
cast_func
,
\
vector_memory_access
,
reinterpret_cast_func
__all__
=
[
'generate_c'
,
'CustomCodeNode'
,
'PrintNode'
,
'get_headers'
,
'CustomSympyPrinter'
]
...
...
@@ -276,6 +278,9 @@ class CustomSympyPrinter(CCodePrinter):
if
isinstance
(
expr
,
reinterpret_cast_func
):
arg
,
data_type
=
expr
.
args
return
"*((%s)(& %s))"
%
(
PointerType
(
data_type
,
restrict
=
False
),
self
.
_print
(
arg
))
elif
isinstance
(
expr
,
address_of
):
assert
len
(
expr
.
args
)
==
1
,
"address_of must only have one argument"
return
"&(%s)"
%
self
.
_print
(
expr
.
args
[
0
])
elif
isinstance
(
expr
,
cast_func
):
arg
,
data_type
=
expr
.
args
if
isinstance
(
arg
,
sp
.
Number
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment