Modify comments for cargo doc

This commit is contained in:
Minseong Jang
2022-02-27 22:39:21 +09:00
parent 9ea9eb8f4e
commit 6f0df5a4b8
4 changed files with 31 additions and 16 deletions

View File

@@ -22,14 +22,16 @@ pub struct TranslationUnit {
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub struct Section<T> { pub struct Section<T> {
/// Section Headers provice size, offset, type, alignment and flags of the sections /// Section Headers provice size, offset, type, alignment and flags of the sections
/// https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#section-header ///
/// For more details: <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#section-header>
pub header: Vec<Directive>, pub header: Vec<Directive>,
pub body: T, pub body: T,
} }
/// An object file is made up of multiple sections, with each section corresponding to /// An object file is made up of multiple sections, with each section corresponding to
/// distinct types of executable code or data. /// distinct types of executable code or data.
/// https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#sections ///
/// For more details: <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#sections>
impl<T> Section<T> { impl<T> Section<T> {
pub fn new(header: Vec<Directive>, body: T) -> Self { pub fn new(header: Vec<Directive>, body: T) -> Self {
Self { header, body } Self { header, body }
@@ -76,7 +78,8 @@ impl Block {
/// The assembler implements a number of directives that control the assembly of instructions /// The assembler implements a number of directives that control the assembly of instructions
/// into an object file. /// into an object file.
/// https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#assembler-directives ///
/// For more details: <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#assembler-directives>
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum Directive { pub enum Directive {
/// .align integer /// .align integer
@@ -129,7 +132,8 @@ pub enum SymbolType {
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum Instruction { pub enum Instruction {
/// R-type instruction format /// R-type instruction format
/// https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf (104p) ///
/// For more details: <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (104p)
RType { RType {
instr: RType, instr: RType,
rd: Register, rd: Register,
@@ -137,7 +141,8 @@ pub enum Instruction {
rs2: Option<Register>, rs2: Option<Register>,
}, },
/// I-type instruction format /// I-type instruction format
/// https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf (104p) ///
/// For more details: <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (104p)
IType { IType {
instr: IType, instr: IType,
rd: Register, rd: Register,
@@ -145,7 +150,8 @@ pub enum Instruction {
imm: Immediate, imm: Immediate,
}, },
/// S-type instruction format /// S-type instruction format
/// https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf (104p) ///
/// For more details: <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (104p)
SType { SType {
instr: SType, instr: SType,
rs1: Register, rs1: Register,
@@ -153,7 +159,8 @@ pub enum Instruction {
imm: Immediate, imm: Immediate,
}, },
/// B-type instruction format /// B-type instruction format
/// https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf (104p) ///
/// For more details: <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (104p)
BType { BType {
instr: BType, instr: BType,
rs1: Register, rs1: Register,
@@ -506,8 +513,10 @@ pub enum UType {
/// The assembler implements a number of convenience psuedo-instructions that are formed from /// The assembler implements a number of convenience psuedo-instructions that are formed from
/// instructions in the base ISA, but have implicit arguments or in some case reversed arguments, /// instructions in the base ISA, but have implicit arguments or in some case reversed arguments,
/// that result in distinct semantics. /// that result in distinct semantics.
/// https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#assembler-pseudo-instructions ///
/// https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf (110p) /// For more details:
/// - <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#assembler-pseudo-instructions>
/// - <https://riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (110p)
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum Pseudo { pub enum Pseudo {
/// la rd, symbol /// la rd, symbol
@@ -593,7 +602,8 @@ impl Immediate {
/// The relocation function creates synthesize operand values that are resolved /// The relocation function creates synthesize operand values that are resolved
/// at program link time and are used as immediate parameters to specific instructions. /// at program link time and are used as immediate parameters to specific instructions.
/// https://github.com/riscv-non-isa/riscv-asm-manual/blob/master/riscv-asm.md ///
/// For more details: <https://github.com/riscv-non-isa/riscv-asm-manual/blob/master/riscv-asm.md>
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum RelocationFunction { pub enum RelocationFunction {
/// %hi /// %hi
@@ -603,7 +613,8 @@ pub enum RelocationFunction {
} }
/// `Label` is used as branch, unconditional jump targets and symbol offsets. /// `Label` is used as branch, unconditional jump targets and symbol offsets.
/// https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#labels ///
/// For more details: <https://github.com/michaeljclark/michaeljclark.github.io/blob/master/asm.md#labels>
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
pub struct Label(pub String); pub struct Label(pub String);
@@ -675,7 +686,8 @@ impl DataSize {
// TODO: Add calling convention information (caller/callee-save registers) // TODO: Add calling convention information (caller/callee-save registers)
/// ABI name for RISC-V integer and floating-point register /// ABI name for RISC-V integer and floating-point register
/// https://content.riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf (109p) ///
/// For more details: <https://content.riscv.org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf> (109p)
#[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)] #[derive(Debug, Clone, PartialEq, Eq, Hash, Copy)]
pub enum Register { pub enum Register {
Zero, Zero,

View File

@@ -26,7 +26,8 @@ pub enum Value {
/// ///
/// * Casting from an f32 to an f64 is perfect and lossless (f32 -> f64) /// * Casting from an f32 to an f64 is perfect and lossless (f32 -> f64)
/// * Casting from an f64 to an f32 will produce the closest possible value (f64 -> f32) /// * Casting from an f64 to an f32 will produce the closest possible value (f64 -> f32)
/// https://doc.rust-lang.org/stable/reference/expressions/operator-expr.html#type-cast-expressions ///
/// For more details: <https://doc.rust-lang.org/stable/reference/expressions/operator-expr.html#type-cast-expressions>
value: OrderedFloat<f64>, value: OrderedFloat<f64>,
width: usize, width: usize,
}, },

View File

@@ -221,7 +221,8 @@ pub enum Instruction {
target_dtype: Dtype, target_dtype: Dtype,
}, },
/// `GetElementPtr` is inspired from `getelementptr` instruction of LLVM. /// `GetElementPtr` is inspired from `getelementptr` instruction of LLVM.
/// https://llvm.org/docs/LangRef.html#i-getelementptr ///
/// For more details: <https://llvm.org/docs/LangRef.html#i-getelementptr>
GetElementPtr { GetElementPtr {
ptr: Operand, ptr: Operand,
offset: Operand, offset: Operand,
@@ -501,7 +502,8 @@ pub enum Constant {
/// ///
/// * Casting from an f32 to an f64 is perfect and lossless (f32 -> f64) /// * Casting from an f32 to an f64 is perfect and lossless (f32 -> f64)
/// * Casting from an f64 to an f32 will produce the closest possible value (f64 -> f32) /// * Casting from an f64 to an f32 will produce the closest possible value (f64 -> f32)
/// https://doc.rust-lang.org/stable/reference/expressions/operator-expr.html#type-cast-expressions ///
/// For more details: <https://doc.rust-lang.org/stable/reference/expressions/operator-expr.html#type-cast-expressions>
value: OrderedFloat<f64>, value: OrderedFloat<f64>,
width: usize, width: usize,
}, },

View File

@@ -44,7 +44,7 @@ mod tests;
mod utils; mod utils;
mod write_base; mod write_base;
mod asm; pub mod asm;
mod c; mod c;
pub mod ir; pub mod ir;