Hey everyone,
I am currently trying to add a runtime call to a library I have created. I am working on a system that will add some type soundness and need to check reference count variables I am keeping track of. The issue I am having is that I need the runtime call inserted before every variable assignment. Looking into the compiler I see three possible areas that I could change to make this work:
- Adding new AST node before the Assignment AST nodes (OP=OAS)
- Creating SSA value for my runtime call when generating SSA for assignments
- When finally generating machine code for assignments, throw in my runtime call
Ideally, I think option 1 would be best. Earlier in the chain seems like the right move. However, I have no idea how to progress in either of these options. If anyone has any input I would like to hear it. I have mainly attempted option 2 as it seemed easiest calling something along the lines of “s.newValue1A(ssa.OpStaticCall, types.TypeMem, myFunction, s.mem())” with my runtime call information but it just breaks the compiler in different ways and I don’t understand why. Specifically I’ll ask this:
- How to create an extra AST node and correctly insert it in the tree at that stage? or
- How to generate a SSA value for my runtime call?
I am new to this forum so please let me know if this is too much or if I should break it down a little more. Thanks!