Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Bindgen
pystencils
Commits
de250f5a
Commit
de250f5a
authored
6 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Add _print_address_of for address_of to cbackend
parent
50f27d79
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/backends/cbackend.py
+8
-3
8 additions, 3 deletions
pystencils/backends/cbackend.py
with
8 additions
and
3 deletions
pystencils/backends/cbackend.py
+
8
−
3
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
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment