GCC, GNU compiler collection

3,135 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
3,135
On SlideShare
0
From Embeds
0
Number of Embeds
429
Actions
Shares
0
Downloads
108
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

GCC, GNU compiler collection

  1. 1. GCC : GNU compilers collection Alberto Bustamante Reyes ( www.albertobustamante.com ) Author:
  2. 2. Brief introduction <ul><li>Compiler system developed by GNU Project
  3. 3. Distributed by FSF under GPL License
  4. 4. Written in C / C++
  5. 5. Default compiler for Unix and Mac OS X
  6. 6. Also ported to Windows (MinGW) </li></ul>
  7. 7. Brief introduction <ul><li>Originally developed for C language
  8. 8. Several front-ends added to support different languages: </li></ul><ul><ul><li>C / C++ (gcc / g++)
  9. 9. Java (gcj)
  10. 10. Objective-C / Objective-C++ (gobjc / gobjc++ )
  11. 11. Fortran (gfortran) </li></ul></ul>
  12. 12. Structure <ul><li>Generic compiler: </li></ul><ul><ul><li>Front end
  13. 13. Back end </li></ul></ul><ul><li>GCC compiler: </li></ul><ul><ul><li>Front end
  14. 14. Middle end
  15. 15. Back end </li></ul></ul>
  16. 16. Structure <ul><li>GCC Compiler (before 2005) </li></ul>Source code AST RTL RTL Object code FRONT END BACK END
  17. 17. Structure <ul><li>GCC Compiler (before 2005) </li></ul>Source code AST RTL RTL Object code FRONT END BACK END
  18. 18. Structure <ul><li>GCC Compiler (before 2005) </li></ul>Source code AST RTL RTL Object code FRONT END BACK END SSA Tree project: OPTIMIZATIONS
  19. 19. Structure <ul><li>GCC Compiler (after 2005) </li></ul>Source code AST GENERIC GIMPLE RTL FRONT END
  20. 20. Structure <ul><li>GCC Compiler (after 2005) </li></ul>Source code AST GENERIC GIMPLE RTL FRONT END Language dependent Language independent
  21. 21. Structure <ul><li>GCC Compiler (after 2005) </li></ul>Source code AST GENERIC GIMPLE RTL FRONT END Language dependent Language independent MIDDLE END
  22. 22. Structure: GENERIC & GIMPLE <ul><li>Why two kinds of trees? </li></ul><ul><ul><li>GIMPLE is a simplified subset of GENERIC </li></ul></ul>GIMPLE GENERIC
  23. 23. Structure: GENERIC & GIMPLE <ul><li>GENERIC -> (Gimplifier) -> GIMPLE </li></ul>GIMPLIFIER if (foo ( a + b, c)) c = b ++ / a end if return c t1 = a +b t2 = foo (t1, c) If (t2 != 0 ) <L1, L2> L1: t3 = b b = b + 1 c = t3 / a goto L3 L2: L3: return c
  24. 24. Structure: GENERIC & GIMPLE <ul><li>Developed by SSA Tree Project
  25. 25. SSA </li></ul><ul><ul><li>Developed by IBM in 1980
  26. 26. Single Static Assignment
  27. 27. Example: </li></ul></ul>y := 1 y := 2 x := y y1 := 1 y2 := 2 x1 := y2
  28. 28. Structure: Middle end GIMPLE Tree SSA Optimizer RTL
  29. 29. Structure:Middle end <ul><li>SSA Tree Optimization </li></ul><ul><ul><li>Dead code elimination </li></ul></ul>y := 1 y := 2 x := y y1 := 1 y2 := 2 x1 := y2
  30. 30. Structure:Middle end <ul><li>SSA Tree Optimization </li></ul><ul><ul><li>Dead code elimination
  31. 31. Partial redundancy elimination </li></ul></ul>if (some_condition) { // some code y = x + 4; }else { // other code } z = x + 4; if (some_condition) { // some code y = x + 4; t = y; }else { // other code t = x + 4; } z = t;
  32. 32. Structure:Middle end <ul><li>SSA Tree Optimization </li></ul><ul><ul><li>Dead code elimination
  33. 33. Partial redundancy elimination
  34. 34. Global value numbering </li></ul></ul>w := 3 x := 3 y := x + 4 z := w + 4 w := 3 x := w y := w + 4 z := y
  35. 35. Structure:Middle end <ul><li>SSA Tree Optimization </li></ul><ul><ul><li>Dead code elimination
  36. 36. Partial redundancy elimination
  37. 37. Global value numbering
  38. 38. Sparse conditional constant propagation </li></ul></ul>
  39. 39. Structure:Middle end <ul><li>SSA Tree Optimization </li></ul><ul><ul><li>Dead code elimination
  40. 40. Partial redundancy elimination
  41. 41. Global value numbering
  42. 42. Sparse conditional constant propagation
  43. 43. Scalar replacement of aggregates </li></ul></ul>
  44. 44. Structure: RTL <ul><li>Output of the Middle End
  45. 45. Processor dependent
  46. 46. Looks like Lisp S-expressions: </li></ul>(set:SI (reg:SI 140) (plus:SI (reg:SI 138) (reg:SI 139)))
  47. 47. Structure: summary Source code AST GENERIC GIMPLE Tree SSA Optimizer RTL Optimized RTL Object code FRONT END MIDDLE END BACK END
  48. 48. Advantages of using GCC <ul><li>Reliable </li></ul><ul><ul><li>Suppported by GNU & FSF
  49. 49. Active and noumerous developer team
  50. 50. One of the most popular compilers
  51. 51. Lots of test cases (users) </li></ul></ul><ul><li>Several front ends
  52. 52. Free!! </li></ul>
  53. 53. More information available at… <ul><li>GCC : http://gcc.gnu.org
  54. 54. GCC Wiki : http://gcc.gnu.org/wiki
  55. 55. SSA Tree Project: http://gcc.gnu.org/projects/tree-ssa/
  56. 56. GNU : http://www.gnu.org
  57. 57. Free Software Foundation : http://www.fsf.org
  58. 58. MinGW: http://www.mingw.org </li></ul>
  59. 59. The End Thanks for watching
  60. 60. GCC : GNU compilers collection Alberto Bustamante Reyes ( www.albertobustamante.com ) Author:

×