From 64b69c9a94d4e1844c9b338e5cc2857c8fbd179d Mon Sep 17 00:00:00 2001 From: TheCPP Date: Fri, 12 Jul 2024 21:10:03 +0200 Subject: [PATCH] [DOC] adding more crate level debugging --- src/lib.rs | 34 +++++++++++++++++++++++++++++++++- tools/ygen-mc/src/main.rs | 20 +++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d4d0a481..648a4681 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,7 +4,39 @@ #![allow(clippy::redundant_field_names)] #![allow(rustdoc::invalid_html_tags)] -//! Ygen - Yet another Code Generator +//! # Ygen - Yet another Code Generator +//! ### Description +//! Ygen is a libary to build modern compilers and tools
+//! It includes many features like IR Optimization, Argument parsing, and much more
+//! There are many utility functions and classes to help you write many asspects of your compiler:
+//! - Like the Colorize trait to colorize your strings (maybe used for printing errors) +//! - The TokenMngr in combination with the SrcMngr to easily write a lexer and store the source location (usefull for including +//! debugging information) +//! +//! #### The YGEN-IR +//! The Ygen Internal Representation isn't very different to LLVMs IR.
+//! A tip:
+//! To dump the Ir of a YGen-Module use the `dump`-Function which dumps the entire IR into a string
+//! If you want to print the IR out the stdout consider using the `dumpColored`-Function which includes Color Information
+//! But if you pipe that into a file it also includes the Color bytes which then look a bit sus so consider printing it to stderr +//! +//! ###### Here is a quick introduction to the YGEN-IR: +//! A function is defined like this: +//! ``` +//! define i32 @add( i32 %0, i32 %1 ) { +//! entry: +//! %2 = add i32 %0, %1 +//! ret i32 %2 +//!} +//! ``` +//! So `define` then the return type of the function, a `@`, the function name and the arguments.
+//! An important thing to understand is that you can only define every variable once because +//! it follows the SSA form.
+//! +//! In YGEN-iR there are many inbuild instructions +//! Like in our add function example: +//! - `add` adds two numbers +//! - `ret` returns an constant or a variable /// The target module: every stuff which has to do with targets. Like: /// * The target triple diff --git a/tools/ygen-mc/src/main.rs b/tools/ygen-mc/src/main.rs index cc8edc92..cd57483f 100644 --- a/tools/ygen-mc/src/main.rs +++ b/tools/ygen-mc/src/main.rs @@ -1,8 +1,26 @@ +#![allow(rustdoc::invalid_html_tags)] + +//! # `ygen-mc`: Ygen machine code code playground +//! With the ygen machine code playground you can play around with assembler instructions +//! and see their opcodes.
+//! It's suppused to being the Ygen variant of the `llvm-mc` +//! ### Usage +//! **Options:**
+//! +//! > **-h, --help** Displays help
+//! > **-v, --version** Displays the version
+//! > **-clr, --color** Colorates the ouput
+//! +//! **Arguments:**
+//! +//! > **-as=, --assemble-string=** The assembly instruction to assemble
+//! > **-triple=, --triple=** The target triple
+ use Ygen::Support::Cli; fn main() { let mut cli = Cli::new( - "ygen-mc", "Ygen's machine code playground", "1.0", "Cr0a3" + "ygen-mc", "Ygens machine code playground", "1.0", "Cr0a3" ); cli.add_opt("h", "help", "Displays help");