📓
Everything I Know
  • index
  • #
    • 3D Printing
  • A
    • Abandoned Spaces
    • ADHD
    • Aging
    • Algorithms & Data Structures
      • Array
      • Constraint Satisfaction Problem
      • Dynamic Programming
      • Graph
      • Hash Table
      • Heap
      • Linked List
      • Queue
      • Recursion
      • Set
      • Stack
      • Tree
      • Trie
      • Union Find
    • Amazon Web Services
    • Android
    • Anime, Comics & Manga
    • APIs
    • Artificial Intelligence
    • Assembly
      • ARM
      • MIPS
      • x86
    • Audio / Video Editing
    • Awesome
    • Azure
  • B
    • Board Games
    • Books
  • C
    • C (programming language)
    • C++
    • Cars
    • Cascading Style Sheets
    • Chess
    • Comedy
    • Command Line
      • Autotools
      • Awk
      • Bash scripting
      • Grep
      • Lsof
      • Sed
      • SSH
    • Competitive Programming
    • Compilers
    • Computer Graphics
      • OpenGL
      • Vulkan
      • WebGPU
    • Computer Networks
    • Computer Science
    • Concurrency
    • Continuous Integration / Delivery
    • Cooking
    • Cryptography
    • Cryptocurriencies
    • Curriculum Vitae
  • D
    • Databases
      • PostgreSQL
      • SQL
      • SQLite
    • Design Patterns
    • Digital Minimalism
    • Distributed Systems
    • Docker
    • Documentaries
    • Documentation
    • Domain Name System
    • Dopamine
    • Drawing
  • E
    • eCommerce
    • Electronics
      • Repairs
    • Engineering
    • Entrepreneurship
    • Events
  • F
    • Fashion
    • Fitness
      • Exercise
      • Nutrition
      • Weight Loss
    • Focus
    • Football
  • G
    • Game Development
      • Godot
      • LibGDX
      • Unity
      • Unreal Engine
    • Git
    • Goals
    • Guitar
  • H
    • Habits
    • Happiness
    • House
      • Tradespeople
      • Buying
      • Renting
  • I
    • Interviews
      • Behavioural Interviews
      • Coding Interviews
      • System Design Interviews
  • J
    • Java
    • JavaScript
      • Astro
      • Bun
      • Electron
      • Jest
      • Node.js
      • Nue.js
      • React.js
      • Redux
      • Vue.js
    • Journaling
  • K
    • Karting
    • Knots
    • Knowledge Bases
    • Kotlin
    • Kubernetes
  • L
    • LaTeX
    • Learning
      • Drawing
      • Languages
        • Certificate of Proficiency in English
        • Japanese
      • Piano
    • Legacy Code
    • LEGO
    • Lifestyle
    • Life Hacks
    • Linux
    • LISP
  • M
    • Machine Learning
      • Deep Learning
    • MacOS
    • Maths
    • Meditation
    • Movies
    • Music
      • Music Production
      • Music Theory
  • N
    • Negotiation
    • News
  • O
    • Operating Systems
      • Linux
  • P
    • Parenting
    • Personal Finance
      • ISAs
      • Pensions
    • PHP
    • Physics
    • Podcasts
    • Procrastination
    • Productivity
    • Programming
      • Functional Programming
      • Performance
    • Prometheus
    • Psychology
    • Public Speaking
    • Purpose
    • Puzzles
    • Python
      • Django
      • Pandas
  • Q
    • Quantum Computing
    • Quotes
  • R
    • Regular Expressions
    • Relationships
    • Reverse Engineering
    • Rust
      • Cargo
  • S
    • Security
      • Android
      • Binary Exploitation
      • CompTIA Security+ SYO-701
      • CTFs
      • Forensics
      • Linux
      • Web
      • Windows
    • Self Improvement
    • Shaving
    • Sitting
    • Sleep
    • Social Skills
    • Spring (framework)
    • Stoicism
    • Strength Training
      • Deadlifts
      • Push Ups
    • Success
    • System Design
      • Site Reliability Engineering
  • T
    • Table Tennis
    • Testing
    • Thinking
    • Touch Typing
    • Travel
      • Japan
        • Fukuoka
        • Hiroshima
        • Kyoto
        • Okinawa
        • Osaka
        • Tokyo
      • London
      • Rome
    • TV Series & Programmes
    • Twitch
    • TypeScript
    • Typography
  • V
    • Virtual Tours
    • Vim
    • Video Games
      • Emulation
      • Mods
      • Music
      • Speedrunning
      • Warzone
  • W
    • Web Apps
    • Web Cams
    • Web Development
      • Selenium
      • Web Assembly
    • Windows
      • Windows Development
    • Work
      • Freelancing
      • GitHub Profile
      • Interesting Companies
      • Job Boards
      • Remote Work
      • Startup
    • Writing
Powered by GitBook
On this page
  • Notes
  • Resources
  • Articles
  • Books
  • Courses
  • GitHub repositories
  • Websites
  • Wikipedia Articles
  • YouTube Playlists
  • YouTube Videos

Was this helpful?

  1. C

Compilers

Notes

  • The compiler is a program that takes your human-readable source code, analyses it, and produces a computer-readable binary code

  • The steps of processing involved in compilng are:

    • Preprocessing: reads the input file and substitutes specific macros, symbols and directives with their definitions;

    • Lexical analysis (or tokenization): split the input up character by character, and group them together to form words, identifiers, symbols, and more - these groups are called tokens;

    • Parsing: take the tokens, attempt to see if they're in certain patterns (usually defined by a grammar), then associate those patterns with expressions like calling functions, recalling variables, or math operations; the output of the parser is the abstract syntax tree (AST);

    • Optimisation: take the AST and try to evaluate constant expressions, remove unused variables or unreachable code, unroll loops if possible, etc.;

    • Generating code: take the AST and emit the equivalent in the assembly language in an object file (or other high-level programming languages in the case of a transpiler)

    • Linking: take all the object files and make an executable, a shared library, or a static library

  • The front end is responsible for taking in the source code and turning it into an intermediate representation.

  • The middle end is responsible for performing various optimizations on the intermediate representation.

    • these optimisations are independent of the target platform, so they are going to speed up the code regardless of what the back end does

    • some examples of optimisations are constant folding, reachability analysis and dead code elimination

  • The back end is responsible for taking the optimised intermediate representation and generating the machine code for the specific CPU architecture or generating bytecode.

Resources

Articles

  • Writing a C Compiler - Nora Sandler

Books

Courses

GitHub repositories

Websites

Wikipedia Articles

YouTube Playlists

YouTube Videos

PreviousCompetitive ProgrammingNextComputer Graphics

Last updated 1 month ago

Was this helpful?

- Stefanos Baziotis

- Divyanshu Shekhar

- Jack Crenshaw

- Luke I. Wilson

() - Luke I. Wilson

- Noah Gibbs, Shopify

- Integers

- Unary Operators

- Binary Operators

- Even More Binary Operators

- Local Variables

- Conditionals

- Compound Statements

- Loops

- Functions

- Global Variables

- Charles Fischer, Ron Cytron, Richard LeBlanc

- Robert Nystrom

- Keith D. Cooper, Linda Torczon

- Chris Lattner

- Nora Sandler

- Cornell University, Fall 2020

- Indiana University, Fall 2020

- Spencer Tipping

- Simple virtual machine which interprets bytecode

- John Regehr

- Pixeled

- Computerphile

- Omer Iqbal

- Gary Explains

- Gary Explains

Common Misconceptions about Compilers
Decoding C Compilation Process: From Source Code to Binary
Let's Build a Compiler
Making a Brainf*ck to C Compiler in Rust
Understanding Compilers - For Humans
v2
When is JIT Faster Than A Compiler?
Part 1
Part 2
Part 3
Part 4
Part 5
Part 6
Part 7
Part 8
Part 9
Part 10
Crafting A Compiler
Crafting Interpreters
Review by Chidi Williams
Engineering A Compiler
The Architecture of Open Source Applications
Chapter 11: LLVM
Writing a C Compiler
Advanced Compilers: The Self-Guided Online Course
Compilers
How to write a JIT compiler
simple.vm
AST Explorer
Compiler Explorer
Decompiler Explorer
The LLVM Compiler Infrastructure Project
A Tourist’s Guide to the LLVM Source Code
Shunting yard algorithm
Creating a Compiler
Just In Time (JIT) Compilers
So what's exactly a JIT Compiler?
The Shunting Yard Algorithm Demystified: Transform Expressions Like a Pro!
What is Reverse Polish Notation (AKA Postfix Notation)? Why is it Important?