C code after preprocessor and constant propagation

I want to get **C** code after going through preprocessor **AND** constant propagation and simple code analysis. Here is what I mean. I use gcc's `-E` option to get the code after preprocessor. However, the code I am getting is really hard to understand and a simple pass of local constant propagation would make it much easier to read. Here is an example of just one line of **C** code generated by the preprocessor. (b1[0] = (kp + 1 * 4)[0] ^ ( t_fn[0][(((( 0 == 0 ? ( 0 == 0 ? b0[0] : 0 == 1 ? b0[1] : 0 == 2 ? b0[2] : b0[3]) : 0 == 1 ? ( 0 == 0 ? b0[1] : 0 == 1 ? b0[2] : 0 == 2 ? b0[3] : b0[0]) : 0 == 2 ? ( 0 == 0 ? b0[2] : 0 == 1 ? b0[3] : 0 == 2 ? b0[0] : b0[1]) : ( 0 == 0 ? b0[3] : 0 == 1 ? b0[0] : 0 == 2 ? b0[1] : b0[2]))) >> (8 * ((0)))) & 0xff)] ^ t_fn[1][(((( 1 == 0 ? ( 0 == 0 ? b0[0] : 0 == 1 ? b0[1] : 0 == 2 ? b0[2] : b0[3]) : 1 == 1 ? ( 0 == 0 ? b0[1] : 0 == 1 ? b0[2] : 0 == 2 ? b0[3] : b0[0]) : 1 == 2 ? ( 0 == 0 ? b0[2] : 0 == 1 ? b0[3] : 0 == 2 ? b0[0] : b0[1]) : ( 0 == 0 ? b0[3] : 0 == 1 ? b0[0] : 0 == 2 ? b0[1] : b0[2]))) >> (8 * ((1)))) & 0xff)] ^ t_fn[2][(((( 2 == 0 ? ( 0 == 0 ? b0[0] : 0 == 1 ? b0[1] : 0 == 2 ? b0[2] : b0[3]) : 2 == 1 ? ( 0 == 0 ? b0[1] : 0 == 1 ? b0[2] : 0 == 2 ? b0[3] : b0[0]) : 2 == 2 ? ( 0 == 0 ? b0[2] : 0 == 1 ? b0[3] : 0 == 2 ? b0[0] : b0[1]) : ( 0 == 0 ? b0[3] : 0 == 1 ? b0[0] : 0 == 2 ? b0[1] : b0[2]))) >> (8 * ((2)))) & 0xff)] ^ t_fn[3][(((( 3 == 0 ? ( 0 == 0 ? b0[0] : 0 == 1 ? b0[1] : 0 == 2 ? b0[2] : b0[3]) : 3 == 1 ? ( 0 == 0 ? b0[1] : 0 == 1 ? b0[2] : 0 == 2 ? b0[3] : b0[0]) : 3 == 2 ? ( 0 == 0 ? b0[2] : 0 == 1 ? b0[3] : 0 == 2 ? b0[0] : b0[1]) : ( 0 == 0 ? b0[3] : 0 == 1 ? b0[0] : 0 == 2 ? b0[1] : b0[2]))) >> (8 * ((3)))) & 0xff)])); pieces like `0 == 0 ? X : Y` and `8*2` can be easily transformed to simpler forms. Now there is tons of such lines in my code and this is a real headache. So it would be great if I could get a simpler **C** code by just doing a simple local constant propagation and code analysis?
I have a C/C++ source code analysis toolkit and maybe I can help you. Unfortunately it is not really clear what do you want. Can you be more specific?

以上就是C code after preprocessor and constant propagation的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏