-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recursion in ShyvyC #119
Comments
Hi @rolex20 , it does support recursive function calls although it appears you’re right there’s currently no test for that. Feel free to add one in the general tests directory. |
Thank you, I will and thank you very much for writing this compiler, I think Its great. As a hobby project, I am trying to adapt it to produce assember code for a CASIO PB-1000 from the 80's. I know there was no C compiler for it. There was a Pascal compiler that almost no one was able to buy and my goal is to beat this Pascal compiler although after my initial experiments it looks like the Pascal compiler had common subexpression elimination and that is where it beats me. Initially I wrote a C compiler on my own using Java but without AST, cyclic register allocation, and lots of peephole optimizations but it doesn't support recursion. My compiler written java generated code that took 11 seconds for a sieve program. The pascal compiler takes 7 seconds for the same program. A hand written translation from the Intel assembler generated by ShyvyC takes 10 seconds but I have hopes that it should be possible doing the subexpression elimination in ShyvyC but not in my compiler that has no AST. If I do the subexpression elimination by hand, my compiler written in java generates code that takes 6 seconds (beating Pascal) and ShyvyC would take 5 seconds or maybe less. So I am pretty sure this is what is missing. For example, this code extract:
would need to be "rewritten by the compiler" as
Any pointers you could offer would be greatly appreciated or even better if you decide to add those common expression elimination improvement :) and also regarding where to add the modifications to generate code for a different architecture, right now I think I would have to change a lot of code in a lot of places so perhaps it would be easier just to write a translator after ShyvyC has produced the assembler, which is what I am preparing to do but it sounds ugly but it would make it easier to integrate against any improvements you decide to make in the future. Another point where I would really appreciate your help is if you can tell me how can I force ShyvyC to flush the registers to memory because I need to call an internal ROM routine that will completely overwrite pretty much all registers (for example the Internal putch() ROM routine uses all registers, the internal IMUL and IDIV overwrites about 6 of the 16 available 16-bit registers) And if you are curious about the PB-1000, people loved it so much, there are open source emulators for it, and almost all their secrets and architecture have been documented (I still have the real thing and it works as new). Please let my know if you are interested in any of this, kind regards |
does ShyvyC was designed to support recursion? I couldn't find test cases for it
The text was updated successfully, but these errors were encountered: