This document provides guidelines for maintaining high-quality Rust code. These rules MUST be followed by all AI coding agents and contributors.
All code you write MUST be fully optimized.
"Fully optimized" includes:
This guide provides a thorough introduction to programming in 32-bit RISC-V assembly language, focusing on the RV32I base integer instruction set. It starts with content from this cheat sheet and expands it into a complete, structured reference. The guide is organized for easy navigation, with clear sections, tables for listings, explanations, examples, and notes. It draws from official specifications and tutorials to ensure accuracy and completeness. Beginners can follow sequentially, while experienced users can reference specific sections.
Key assumptions:
UV Cheat Sheet incorporating the latest tips and tricks from the official UV documentation:
Install UV using the official standalone installer:
macOS and Linux:
| // Idiomatic | |
| // Modifies string_var in place; doesn't return anything | |
| // The original string_var remains valid | |
| fn takes_string_ref_no_return(string_var: &mut String) { | |
| string_var.push_str("world"); | |
| } | |
| // Idiomatic | |
| // Returns a new owned String | |
| // The original str_var also remains valid |
| # !/bin/bash | |
| # Reference: https://copr.fedorainfracloud.org/coprs/principis/howdy/ | |
| # sudo required | |
| if ! [ $(id -u) = 0 ]; then | |
| echo "Root privilege is needed. Please rerun the script as root." >&2 | |
| exit 1 | |
| fi | |
| SUDO_CFG="/etc/pam.d/sudo" |
The following examples are written from the perspective of an engineer who writes code using the Go programming language, and so you'll find that I've written notes about how Rust is different and I don't really cover the why or how of the example Go code. Additionally, the Go examples are far from exhaustive because I'm using this as a 'scratch pad' for my Rust learnings.
| #!/bin/sh | |
| # Copyright 2019 (c) Ayane Satomi | |
| # Public Domain | |
| # | |
| # Delegate Script for VSCode | |
| # This makes sure VScode only runs in a Toolbox container. | |
| # This only works with a default container. | |
| FEDORA_DEFAULT_CONTAINER="fedora-toolbox-$(whoami)-30" |
This document was originally written several years ago. At the time I was working as an execution core verification engineer at Arm. The following points are coloured heavily by working in and around the execution cores of various processors. Apply a pinch of salt; points contain varying degrees of opinion.
It is still my opinion that RISC-V could be much better designed; though I will also say that if I was building a 32 or 64-bit CPU today I'd likely implement the architecture to benefit from the existing tooling.
Mostly based upon the RISC-V ISA spec v2.0. Some updates have been made for v2.2
The RISC-V ISA has pursued minimalism to a fault. There is a large emphasis on minimizing instruction count, normalizing encoding, etc. This pursuit of minimalism has resulted in false orthogonalities (such as reusing the same instruction for branches, calls and returns) and a requirement for superfluous instructions which impacts code density both in terms of size and
| It was working in my head | |
| Even though it doesn't work, how does it feel? | |
| Oh, you said you DIDN'T want that to happen? | |
| THIS can't be the source of THAT | |
| I thought he knew the context of what I was talking about | |
| I can have a look but there's a lot of if statements in that code! | |
| It works, but it's not been tested | |
| The accounting department must have cancelled that subscription | |
| The marketing department made us put that there | |
| I couldn't find any examples of how that can be done anywhere else in the project |