gcc, gnu compiler collection

Download GCC, GNU compiler collection

If you can't read please download the document

Upload: alberto-bustamante-reyes

Post on 25-May-2015

1.976 views

Category:

Technology


2 download

TRANSCRIPT

  • 1. GCC : GNU compilers collection Alberto Bustamante Reyes (www.albertobustamante.com) Author:

2. Brief introduction

  • Compiler system developed by GNU Project

3. Distributed by FSF under GPL License 4. Written in C / C++ 5. Default compiler for Unix and Mac OS X 6. Also ported to Windows (MinGW) 7. Brief introduction

  • Originally developed for C language

8. Several front-ends added to support different languages:

    • C / C++(gcc / g++)
  • 9. Java(gcj)

10. Objective-C / Objective-C++(gobjc / gobjc++ ) 11. Fortran(gfortran) 12. Structure

  • Generic compiler:
    • Front end
  • 13. Back end
  • GCC compiler:
    • Front end
  • 14. Middle end

15. Back end 16. Structure

  • GCC Compiler (before 2005)

Source code AST RTL RTL Object code FRONT END BACK END 17. Structure

  • GCC Compiler (before 2005)

Source code AST RTL RTL Object code FRONT END BACK END 18. Structure

  • GCC Compiler (before 2005)

Source code AST RTL RTL Object code FRONT END BACK END SSA Tree project: OPTIMIZATIONS 19. Structure

  • GCC Compiler (after 2005)

Source code AST GENERIC GIMPLE RTL FRONT END 20. Structure

  • GCC Compiler (after 2005)

Source code AST GENERIC GIMPLE RTL FRONT END Language dependent Language independent 21. Structure

  • GCC Compiler (after 2005)

Source code AST GENERIC GIMPLE RTL FRONT END Language dependent Language independent MIDDLE END 22. Structure: GENERIC & GIMPLE

  • Why two kinds of trees?
    • GIMPLE is a simplified subset of GENERIC

GIMPLE GENERIC 23. Structure: GENERIC & GIMPLE

  • GENERIC -> (Gimplifier) -> GIMPLE

GIMPLIFIER if (foo ( a + b, c)) c = b ++ / a end if return c t1 = a +b t2 = foo (t1, c) If (t2 != 0 ) L1: t3 = b b = b + 1 c = t3 / a goto L3 L2: L3: return c 24. Structure: GENERIC & GIMPLE

  • Developed by SSA Tree Project

25. SSA

    • Developed by IBM in 1980
  • 26. Single Static Assignment

27. Example: y := 1 y := 2 x := y y1 := 1 y2 := 2 x1 := y2 28. Structure: Middle end GIMPLETree SSA OptimizerRTL 29. Structure:Middle end

  • SSA Tree Optimization
    • Dead code elimination

y := 1 y := 2 x := y y1 := 1 y2 := 2 x1 := y2 30. Structure:Middle end

  • SSA Tree Optimization
    • Dead code elimination
  • 31. Partial redundancy elimination

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. Structure:Middle end

  • SSA Tree Optimization
    • Dead code elimination
  • 33. Partial redundancy elimination

34. Global value numbering w := 3 x := 3 y := x + 4 z := w + 4 w := 3 x := w y := w + 4 z := y 35. Structure:Middle end

  • SSA Tree Optimization
    • Dead code elimination
  • 36. Partial redundancy elimination

37. Global value numbering 38. Sparse conditional constant propagation 39. Structure:Middle end

  • SSA Tree Optimization
    • Dead code elimination
  • 40. Partial redundancy elimination

41. Global value numbering 42. Sparse conditional constant propagation 43. Scalar replacement of aggregates 44. Structure: RTL

  • Output of the Middle End

45. Processor dependent 46. Looks like Lisp S-expressions: (set:SI (reg:SI 140) (plus:SI (reg:SI 138) (reg:SI 139))) 47. Structure: summary Source code AST GENERIC GIMPLETree SSA Optimizer RTL Optimized RTLObject code FRONT END MIDDLE END BACK END 48. Advantages of using GCC

  • Reliable
    • Suppported by GNU & FSF
  • 49. Active and noumerous developer team

50. One of the most popular compilers 51. Lots of test cases (users)

  • Several front ends

52. Free!! 53. More information available at

  • GCC :http://gcc.gnu.org

54. GCC Wiki :http://gcc.gnu.org/wiki 55. SSA Tree Project:http://gcc.gnu.org/projects/tree-ssa/ 56. GNU :http://www.gnu.org 57. Free Software Foundation :http://www.fsf.org 58. MinGW:http://www.mingw.org 59. The End Thanks for watching 60. GCC : GNU compilers collection Alberto Bustamante Reyes (www.albertobustamante.com) Author: