LLVM Auto-Generated GLSL Code Formatting

Anyone know of any labour-saving automatic script or tool for making GLSL code generated by LLVM human-readable. For those who haven’t seen it, it produces this kind of thing:


(z_318)=((xyMiddle)+(vec2(((((vec2((((((z_318)-(xyMiddle))[0])*((vec2((((_zoom)[0])/(float((pow((length(_zoom)), (2.000000)))))), ((-((_zoom)[1]))/(float((pow((length(_zoom)), (2.000000))))))))[0]))-((((z_318)-(xyMiddle))[1])*((vec2((((_zoom)[0])/(float((pow((length(_zoom)), (2.000000)))))), ((-((_zoom)[1]))/(float((pow((length(_zoom)), (2.000000))))))))[1]))), (((((z_318)-(xyMiddle))[0])*((vec2((((_zoom)[0])/(float((pow((length(_zoom)), (2.000000)))))), ((-((_zoom)[1]))/(float((pow((length(_zoom)), (2.000000))))))))[1]))+((((z_318)-(xyMiddle))[1])*((vec2((((_zoom)[0])/(float((pow((length(_zoom)), (2.000000)))))), ((-((_zoom)[1]))/(float((pow((length(_zoom)), (2.000000))))))))[0])))))[0])*((vec2(((exp((vec2((((-0.000000)*((_rotate)[0]))-((-1.000000)*((_rotate)[1]))), (((-0.000000)*((_rotate)[1]))+((-1.000000)*((_rotate)[0])))))[0]))*(cos((...

SO, basically, I just need to get rid of all the extraneous brackets. Doing it manually is harder than you might think though, especially when you’ve got a lot of lines to work through.

Anyone any ideas?

a|x
http://machinesdontcare.wordpress.com

Sorry, I’m not being able to help for the bracket removal - but I was wondering how/where/when are you making LLVM generate GLSL ?! Is there a GLSL backend ? :confused:

Afaik Mesa has LLVM backend.
Also I think Apple uses LLVM for GLSL in OpenGL 3.x driver in Snow Leopard.

Yep. I knew that, but the OP seems to use LLVM to generate GLSL code, not GLSL to generate LLVM IR code - which surprised me ! Tonebust, could you shed light on me ?

Hi Nicolas,

I must admit, I’m vague on the nuts and bolts.
I was under the impression LLVM was used on MacOS X Leopard (10.5) machines too, to negotiate software-fallback rendering etc. but as I said, I’m hazy on the details.

In fact, the whole LLVM thing might be a false lead. The code in question was extracted from the application ‘OpenGL Profiler’, and actually came from Adobe’s Pixel Bender toolkit, running a particular filter. I guess it’s more likely that Pixel Bender Toolkit generated the code itself.

Still leaves me with the problem of getting rid of all those extra brackets, though…

a|x