diff --git a/package/src/Transpiler.jl b/package/src/Transpiler.jl index 9ba416c..83742bd 100644 --- a/package/src/Transpiler.jl +++ b/package/src/Transpiler.jl @@ -100,32 +100,6 @@ end # Note: Maybe make an additional function that transpiles and executed the code. This would then be the function the user calls # -# TODO: I guess I need to move this to different module because it seems like I can't access inner functions -let registers = Dict() # stores the count of the register already used. - global get_next_free_register - global get_used_registers - - # By convention these names correspond to the following types: - # - p -> pred - # - f32 -> float32 - # - b32 -> 32 bit - # - var -> float32 - # - param -> float32 !! although, they might get inserted as fixed number and not be sent to gpu? - function get_next_free_register(name::String)::String - if haskey(registers, name) - registers[name] += 1 - else - registers[name] = 1 - end - - return String(["%", name, registers[name]]) - end - - function get_used_registers() - return pairs(registers) - end -end - # To increase performance, it would probably be best for all helper functions to return their IO Buffer and not a string const exitJumpLocationMarker = "\$L__BB0_2" function transpile(expression::ExpressionProcessing.PostfixType)::String @@ -297,7 +271,30 @@ function get_ptx_operator(operator::Operator)::String end end +let registers = Dict() # stores the count of the register already used. + global get_next_free_register + global get_used_registers + # By convention these names correspond to the following types: + # - p -> pred + # - f32 -> float32 + # - b32 -> 32 bit + # - var -> float32 + # - param -> float32 !! although, they might get inserted as fixed number and not be sent to gpu? + function get_next_free_register(name::String)::String + if haskey(registers, name) + registers[name] += 1 + else + registers[name] = 1 + end + + return string("%", name, registers[name]) + end + + function get_used_registers() + return pairs(registers) + end +end end