Added support for functions to accept symbolic variables#2331
Added support for functions to accept symbolic variables#2331certik merged 5 commits intolcompilers:mainfrom
Conversation
|
An example for reference |
|
Can you add a test for this? |
|
I think so maybe we would need a Where we are passing |
|
Just add a test for the feature you implemented in this PR, and later once you implement |
|
Yes, I think so I can implement the case for |
|
Also I am not sure why do we get an error through the The C backend works perfectly @Thirumalai-Shaktivel would you mind helping me out here. Once this is fixed the failing |
|
I think you have to cast the second argument from i32 to i64. As you can see, declare void @integer_set_si(void*, i64)
...
%3 = load i32, i32* %i, align 4
call void @integer_set_si(void* %2, i32 %3)
...In C, I think there might be an implicit cast for i32 to i64, so it works. |
Oops, sorry I think so I overlooked this. Thanks for the help ! |
|
I have a few doubts regarding few corner cases, hence converting to draft. |
|
I think this is ready now. |
certik
left a comment
There was a problem hiding this comment.
I think that this is good. Thanks!
Now that we have started porting sympy functions to LPython, I realized that there are some errors while trying to have symbolic parameters. Consider the following program
If we look at the C code generated for this.
But this would end up giving a segmentation fault, we don't need to apply the transformations which we apply on local variables (
ain this case) to the parameterized variable (xin this case). Something as simple as the following would do the job.Hence the changes introduced are the following
x: Sis being changed tox: CPtrto replicate the void pointer (printsym(void* x))Here
ashould be freed but freeing ofxhas been taken care inmain0