Skip to content

Commit c869907

Browse files
committed
Document almost all modules
Fixes #1082
1 parent 934d56a commit c869907

36 files changed

+145
-66
lines changed

src/abi/comments.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Annotate the clif ir with comments describing how arguments are passed into the current function
2+
//! and where all locals are stored.
3+
14
use std::borrow::Cow;
25

36
use rustc_middle::mir;

src/abi/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Handling of everything related to the calling convention. Also fills `fx.local_map`.
2+
13
#[cfg(debug_assertions)]
24
mod comments;
35
mod pass_mode;
@@ -325,6 +327,7 @@ impl<'tcx, B: Backend + 'static> FunctionCx<'_, 'tcx, B> {
325327
}
326328
}
327329

330+
/// Make a [`CPlace`] capable of holding value of the specified type.
328331
fn make_local_place<'tcx>(
329332
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
330333
local: Local,

src/abi/pass_mode.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Argument passing
2+
13
use crate::prelude::*;
24

35
pub(super) use EmptySinglePair::*;
@@ -118,6 +120,7 @@ pub(super) fn get_pass_mode<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>)
118120
}
119121
}
120122

123+
/// Get a set of values to be passed as function arguments.
121124
pub(super) fn adjust_arg_for_abi<'tcx>(
122125
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
123126
arg: CValue<'tcx>,
@@ -136,6 +139,8 @@ pub(super) fn adjust_arg_for_abi<'tcx>(
136139
}
137140
}
138141

142+
/// Create a [`CValue`] containing the value of a function parameter adding clif function parameters
143+
/// as necessary.
139144
pub(super) fn cvalue_for_param<'tcx>(
140145
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
141146
start_block: Block,

src/abi/returning.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
//! Return value handling
2+
13
use crate::abi::pass_mode::*;
24
use crate::prelude::*;
35

46
fn return_layout<'a, 'tcx>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> TyAndLayout<'tcx> {
57
fx.layout_of(fx.monomorphize(&fx.mir.local_decls[RETURN_PLACE].ty))
68
}
79

10+
/// Can the given type be returned into an ssa var or does it need to be returned on the stack.
811
pub(crate) fn can_return_to_ssa_var<'tcx>(
912
tcx: TyCtxt<'tcx>,
1013
dest_layout: TyAndLayout<'tcx>,
@@ -16,6 +19,8 @@ pub(crate) fn can_return_to_ssa_var<'tcx>(
1619
}
1720
}
1821

22+
/// Return a place where the return value of the current function can be written to. If necessary
23+
/// this adds an extra parameter pointing to where the return value needs to be stored.
1924
pub(super) fn codegen_return_param<'tcx>(
2025
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
2126
ssa_analyzed: &rustc_index::vec::IndexVec<Local, crate::analyze::SsaKind>,
@@ -59,6 +64,8 @@ pub(super) fn codegen_return_param<'tcx>(
5964
ret_place
6065
}
6166

67+
/// Invokes the closure with if necessary a value representing the return pointer. When the closure
68+
/// returns the call return value(s) if any are written to the correct place.
6269
pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>(
6370
fx: &mut FunctionCx<'_, 'tcx, B>,
6471
fn_sig: FnSig<'tcx>,
@@ -102,6 +109,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx, B: Backend, T>(
102109
(call_inst, meta)
103110
}
104111

112+
/// Codegen a return instruction with the right return value(s) if any.
105113
pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, impl Backend>) {
106114
match get_pass_mode(fx.tcx, return_layout(fx)) {
107115
PassMode::NoPass | PassMode::ByRef { size: Some(_) } => {

src/allocator.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
1-
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2-
// file at the top-level directory of this distribution and at
3-
// http://rust-lang.org/COPYRIGHT.
4-
//
5-
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6-
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7-
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8-
// option. This file may not be copied, modified, or distributed
9-
// except according to those terms.
1+
//! Allocator shim
2+
// Adapted from rustc
103

114
use crate::prelude::*;
125

src/analyze.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! SSA analysis
2+
13
use crate::prelude::*;
24

35
use rustc_index::vec::IndexVec;

src/archive.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Creation of ar archives like for the lib and staticlib crate type
2+
13
use std::collections::BTreeMap;
24
use std::fs::File;
35
use std::path::{Path, PathBuf};

src/backend.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Abstraction around the object writing crate
2+
13
use std::convert::{TryFrom, TryInto};
24

35
use rustc_data_structures::fx::FxHashMap;

src/base.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Codegen of a single function
2+
13
use rustc_index::vec::IndexVec;
24
use rustc_middle::ty::adjustment::PointerCast;
35

src/cast.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Various number casting functions
2+
13
use crate::prelude::*;
24

35
pub(crate) fn clif_intcast(

0 commit comments

Comments
 (0)