Skip to content

Commit 02fd7f6

Browse files
committed
there are 3 backends now
1 parent 1e7fe14 commit 02fd7f6

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

Diff for: src/part-5-intro.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ will finally take the MIR and produce some executable machine code.
1313

1414
> NOTE: This part of a compiler is often called the _backend_. The term is a bit
1515
> overloaded because in the compiler source, it usually refers to the "codegen
16-
> backend" (i.e. LLVM or Cranelift). Usually, when you see the word "backend"
16+
> backend" (i.e. LLVM, Cranelift, or GCC). Usually, when you see the word "backend"
1717
> in this part, we are referring to the "codegen backend".
1818
1919
So what do we need to do?
@@ -26,29 +26,27 @@ So what do we need to do?
2626
collecting all the concrete types is called _monomorphization collection_.
2727
1. Next, we need to actually lower the MIR to a codegen IR
2828
(usually LLVM IR) for each concrete type we collected.
29-
2. Finally, we need to invoke LLVM or Cranelift, which runs a bunch of
29+
2. Finally, we need to invoke the codegen backend, which runs a bunch of
3030
optimization passes, generates executable code, and links together an
3131
executable binary.
3232

3333
[codegen1]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/base/fn.codegen_crate.html
3434

3535
The code for codegen is actually a bit complex due to a few factors:
3636

37-
- Support for multiple codegen backends (LLVM and Cranelift). We try to share as much
37+
- Support for multiple codegen backends (LLVM, Cranelift, and GCC). We try to share as much
3838
backend code between them as possible, so a lot of it is generic over the
3939
codegen implementation. This means that there are often a lot of layers of
4040
abstraction.
4141
- Codegen happens asynchronously in another thread for performance.
42-
- The actual codegen is done by a third-party library (either LLVM or Cranelift).
42+
- The actual codegen is done by a third-party library (either of the 3 backends).
4343

44-
Generally, the [`rustc_codegen_ssa`][ssa] crate contains backend-agnostic code
45-
(i.e. independent of LLVM or Cranelift), while the [`rustc_codegen_llvm`][llvm]
46-
crate contains code specific to LLVM codegen.
44+
Generally, the [`rustc_codegen_ssa`][ssa] crate contains backend-agnostic code,
45+
while the [`rustc_codegen_llvm`][llvm] crate contains code specific to LLVM codegen.
4746

4847
[ssa]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_ssa/index.html
4948
[llvm]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_codegen_llvm/index.html
5049

5150
At a very high level, the entry point is
5251
[`rustc_codegen_ssa::base::codegen_crate`][codegen1]. This function starts the
5352
process discussed in the rest of this chapter.
54-

0 commit comments

Comments
 (0)