Questions tagged [compilers]

Questions about programs that read code in one language (source language) and translate it into an equivalent program in another language (target language).

A compiler is a program that transforms source code written in a programming language (the source language) into another language (the target language).

Example: A C++ compiler transforms your C++ code into equivalent Assembly Language or Machine Code.

A rough sketch of working of compilers

Source Program (or Code) → Compiler → Target Program (or executable code)


Compilers are more generally used to translate high-level code (like C#, C++, Java) into low level or machine code.

659 questions
58
votes
4 answers

Time complexity of a compiler

I am interested in the time complexity of a compiler. Clearly this is a very complicated question as there are many compilers, compiler options and variables to consider. Specifically, I am interested in LLVM but would be interested in any thoughts…
superbriggs
  • 705
  • 5
  • 6
29
votes
2 answers

What is a batch compiler?

I have the following quotation from my compiler's course (in the context of graph coloring): Because it is slow, graph coloring tends to be used in batch compilers, while linear scan tends to be used in JIT compilers. I couldn't find a clear…
user1868607
  • 2,194
  • 13
  • 23
22
votes
2 answers

How is a JIT compiler different from an ordinary compiler?

There's been a lot of hype about JIT compilers for languages like Java, Ruby, and Python. How are JIT compilers different from C/C++ compilers, and why are the compilers written for Java, Ruby or Python called JIT compilers, while C/C++ compilers…
Ken Li
  • 3,078
  • 3
  • 23
  • 38
9
votes
3 answers

Why would we want a self-hosting compiler?

I understand that a self-hosting compiler is a compiler which can compile the code of the language that it is written in into different language but I don't understand why we would want to do that. What are the benefits (and drawbacks) of a compiler…
Haych
  • 534
  • 5
  • 20
6
votes
0 answers

Alternatives to phi nodes in static single assignment

I have read somewhere about an alternative SSA representation that doesn't use phi nodes but instead uses parameterized basic blocks. Something like this in an SSA with phi: block_a: value_a = ... jump block_c block_b: value_b = ... …
oconnor0
  • 393
  • 1
  • 8
6
votes
3 answers

Why anyone learn compiler?

I am learning compiler in my Uni. I have been through all major compiler techniques like top-down parsing, bottom-up parsing, Lexical analyzer, Symbol table, etc. I have a good understanding of them, but I am still confused about the course. What…
AHF
  • 97
  • 1
  • 7
6
votes
1 answer

Why more and more handcraft lex do not use regular expression any more?

Recently I read the source code of Clang, and found that it just do the lex thing by reading characters one by one and manually do the matching. But both my teacher when I'm in college and the book "Compilers Principles, Techniques, and Tools" take…
ravenisadesk
  • 213
  • 1
  • 5
5
votes
0 answers

SSA Phi to Registers

I'm working on an LLVM-like kit for .Net - because this is something that's lacking in .Net and I really want to learn the more advanced compilation theory. I'm really struggling to find anything digestible for turning Phi into platform code (in…
5
votes
2 answers

How are the web based compilers designed?

Is it possible to design a compiler that can safely compile and run untrusted code? As a practical example, I want to know how the online compilers are designed/programmed?(Like the one on codepad.org) Are they similar to our traditional day-to-day…
Andy
  • 371
  • 1
  • 3
  • 6
5
votes
1 answer

Why more and more languages do not have link stage when compiling?

As far as I know, only C, C++, and Objective-C (in most used languages) need a linker when compiling, languages like Java and C# don't have one, and it seems more and more modern languages do not have a linking stage nowadays. Why? If there's no…
ravenisadesk
  • 213
  • 1
  • 5
4
votes
1 answer

What data-structure is best suited for escape analysis?

I'm making a compiler using LLVM and LLVM's shadow-stack. I thought I might easy the load of the GC by using escape analysis and allocate some variables on the stack. Can I use my typed AST for this algorithm, or must I use a graph data-structure?
Olle Härstedt
  • 375
  • 1
  • 9
4
votes
1 answer

Compiler backend generated from declarative description of the architecture

Is it possible, given a declarative description of an architecture's register layout and instruction semantics and machine code encodings, to autogenerate a compiler back-end? If so, has anyone ever done this?
J D
  • 221
  • 2
  • 5
4
votes
1 answer

Uses of irreducible control flow

What are some applications where irreducible control flow is required*? I'm particularly interested in programming language features that will be tricky to efficiently compile if the compile target does not permit irreducible control flow. For…
bshanks
  • 141
  • 2
3
votes
2 answers

Is it possible to tell if two sequences of assembly instructions are semantically equivalent?

In a modern instruction set like x86-64 there are many many many ways to accomplish the same task using a series of old simple instructions all the way up to the complex SIMD instructions. If one wanted to determine the semantic equivalence of a…
guidoism
  • 131
  • 3
3
votes
1 answer

interference graph: assigning variable to itself

I'm studying the theory behind compiler design, and was assigned with building an Interference graph for a certain code 3-address code. We were taught to first divide the code into blocks (according to GOTOs), and draw lines that represent a…
yoad w
  • 131
  • 3
1
2 3 4 5 6