Skip to content

Commit 55cfcd5

Browse files
authored
Rollup merge of #80323 - camelid:codegen-base-docs, r=nagisa
Update and improve `rustc_codegen_{llvm,ssa}` docs Fixes #75342. These docs were very out of date and misleading. They even said that they codegen'd the *AST*! For some reason, the `rustc_codegen_ssa::base` docs were exactly identical to the `rustc_codegen_llvm::base` docs. They didn't really make sense, because they had LLVM-specific information even though `rustc_codegen_ssa` is supposed to be somewhat generic. So I removed them as they were misleading. r? ``@pnkfelix`` maybe?
2 parents 44e3daf + 5b32ab6 commit 55cfcd5

File tree

3 files changed

+9
-25
lines changed

3 files changed

+9
-25
lines changed

compiler/rustc_codegen_llvm/src/base.rs

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
//! Codegen the completed AST to the LLVM IR.
2-
//!
3-
//! Some functions here, such as codegen_block and codegen_expr, return a value --
4-
//! the result of the codegen to LLVM -- while others, such as codegen_fn
5-
//! and mono_item, are called only for the side effect of adding a
6-
//! particular definition to the LLVM IR output we're producing.
1+
//! Codegen the MIR to the LLVM IR.
72
//!
83
//! Hopefully useful general knowledge about codegen:
94
//!
10-
//! * There's no way to find out the `Ty` type of a Value. Doing so
5+
//! * There's no way to find out the [`Ty`] type of a [`Value`]. Doing so
116
//! would be "trying to get the eggs out of an omelette" (credit:
12-
//! pcwalton). You can, instead, find out its `llvm::Type` by calling `val_ty`,
13-
//! but one `llvm::Type` corresponds to many `Ty`s; for instance, `tup(int, int,
14-
//! int)` and `rec(x=int, y=int, z=int)` will have the same `llvm::Type`.
7+
//! pcwalton). You can, instead, find out its [`llvm::Type`] by calling [`val_ty`],
8+
//! but one [`llvm::Type`] corresponds to many [`Ty`]s; for instance, `tup(int, int,
9+
//! int)` and `rec(x=int, y=int, z=int)` will have the same [`llvm::Type`].
10+
//!
11+
//! [`Ty`]: rustc_middle::ty::Ty
12+
//! [`val_ty`]: common::val_ty
1513
1614
use super::ModuleLlvm;
1715

compiler/rustc_codegen_llvm/src/common.rs

+1
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
314314
}
315315
}
316316

317+
/// Get the [LLVM type][Type] of a [`Value`].
317318
pub fn val_ty(v: &Value) -> &Type {
318319
unsafe { llvm::LLVMTypeOf(v) }
319320
}

compiler/rustc_codegen_ssa/src/base.rs

-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
1-
//! Codegen the completed AST to the LLVM IR.
2-
//!
3-
//! Some functions here, such as `codegen_block` and `codegen_expr`, return a value --
4-
//! the result of the codegen to LLVM -- while others, such as `codegen_fn`
5-
//! and `mono_item`, are called only for the side effect of adding a
6-
//! particular definition to the LLVM IR output we're producing.
7-
//!
8-
//! Hopefully useful general knowledge about codegen:
9-
//!
10-
//! * There's no way to find out the `Ty` type of a `Value`. Doing so
11-
//! would be "trying to get the eggs out of an omelette" (credit:
12-
//! pcwalton). You can, instead, find out its `llvm::Type` by calling `val_ty`,
13-
//! but one `llvm::Type` corresponds to many `Ty`s; for instance, `tup(int, int,
14-
//! int)` and `rec(x=int, y=int, z=int)` will have the same `llvm::Type`.
15-
161
use crate::back::write::{
172
compute_per_cgu_lto_type, start_async_codegen, submit_codegened_module_to_llvm,
183
submit_post_lto_module_to_llvm, submit_pre_lto_module_to_llvm, ComputedLtoType, OngoingCodegen,

0 commit comments

Comments
 (0)