Update to powerpc crate and make it work

This commit is contained in:
Luke Street
2026-02-15 20:13:21 -07:00
parent 6387fae1df
commit eb5382cddd
4 changed files with 1378 additions and 372 deletions
Generated
+147 -68
View File
@@ -1,17 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "ahash"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47"
dependencies = [
"getrandom",
"once_cell",
"version_check",
]
version = 4
[[package]]
name = "ariadne"
@@ -22,17 +11,11 @@ dependencies = [
"yansi",
]
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "castaway"
version = "0.2.2"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a17ed5635fc8536268e5d4de1e22e81ac34419e5f052d4d51f4e01dcc263fcc"
checksum = "dec551ab6e7578819132c713a93c022a05d60159dc86e7a7050223577484c55a"
dependencies = [
"rustversion",
]
@@ -45,13 +28,16 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "compact_str"
version = "0.6.1"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5138945395949e7dfba09646dc9e766b548ff48e23deb5246890e6b64ae9e1b9"
checksum = "3b79c4069c6cad78e2e0cdfcbd26275770669fb39fd308a752dc110e83b9af32"
dependencies = [
"castaway",
"cfg-if",
"itoa",
"rustversion",
"ryu",
"static_assertions",
]
[[package]]
@@ -64,42 +50,40 @@ dependencies = [
]
[[package]]
name = "encoding_rs"
version = "0.8.31"
name = "equivalent"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b"
dependencies = [
"cfg-if",
]
checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f"
[[package]]
name = "getrandom"
version = "0.2.8"
name = "foldhash"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31"
checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
[[package]]
name = "hashbrown"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1"
dependencies = [
"cfg-if",
"libc",
"wasi",
"foldhash",
]
[[package]]
name = "hashbrown"
version = "0.12.3"
version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
dependencies = [
"ahash",
]
checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100"
[[package]]
name = "indexmap"
version = "1.9.1"
version = "2.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e"
checksum = "7714e70437a7dc3ac8eb7e6f8df75fd8eb422675fc7678aff7364301092b1017"
dependencies = [
"autocfg",
"hashbrown",
"equivalent",
"hashbrown 0.16.1",
]
[[package]]
@@ -108,12 +92,6 @@ version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
[[package]]
name = "libc"
version = "0.2.137"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
[[package]]
name = "memchr"
version = "2.5.0"
@@ -122,21 +100,44 @@ checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]]
name = "object"
version = "0.29.0"
version = "0.36.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53"
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
dependencies = [
"crc32fast",
"hashbrown",
"hashbrown 0.15.5",
"indexmap",
"memchr",
]
[[package]]
name = "once_cell"
version = "1.16.0"
name = "phf"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
checksum = "913273894cec178f401a31ec4b656318d95473527be05c0752cc41cdc32be8b7"
dependencies = [
"phf_shared",
"serde",
]
[[package]]
name = "phf_shared"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06005508882fb681fd97892ecff4b7fd0fee13ef1aa569f8695dae7ab9099981"
dependencies = [
"siphasher",
]
[[package]]
name = "powerpc-asm"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6279a5e74397a442815266b75cba540630860f62cc306e324079e3056a27225b"
dependencies = [
"phf",
"thiserror",
]
[[package]]
name = "ppcasm"
@@ -144,8 +145,8 @@ version = "0.1.0"
dependencies = [
"ariadne",
"compact_str",
"encoding_rs",
"object",
"powerpc-asm",
"pratt",
"smallvec",
"unicode-ident",
@@ -157,6 +158,24 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17e0a4425d076f0718b820673a38fbf3747080c61017eeb0dd79bc7e472b8bb8"
[[package]]
name = "proc-macro2"
version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [
"unicode-ident",
]
[[package]]
name = "quote"
version = "1.0.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21b2ebcf727b7760c461f091f9f0f539b77b8e87f2fd88131e7f1b433b3cece4"
dependencies = [
"proc-macro2",
]
[[package]]
name = "rustversion"
version = "1.0.9"
@@ -169,30 +188,90 @@ version = "1.0.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
[[package]]
name = "serde"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
dependencies = [
"serde_core",
]
[[package]]
name = "serde_core"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.228"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "siphasher"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2aa850e253778c88a04c3d7323b043aeda9d3e30d5971937c1855769763678e"
[[package]]
name = "smallvec"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
[[package]]
name = "static_assertions"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "syn"
version = "2.0.116"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3df424c70518695237746f84cede799c9c58fcb37450d7b23716568cc8bc69cb"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thiserror"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "unicode-ident"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
[[package]]
name = "version_check"
version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "yansi"
version = "0.5.1"
+5 -5
View File
@@ -4,10 +4,10 @@ version = "0.1.0"
edition = "2021"
[dependencies]
compact_str = "0.6.1"
object = { version = "0.29.0", features = ["write_std", "elf"], default-features = false }
smallvec = { version = "1.10.0", features = ["const_generics", "const_new", "union"] }
encoding_rs = "0.8.31"
compact_str = "0.8"
object = { version = "0.36", features = ["write_std", "elf"], default-features = false }
smallvec = { version = "1", features = ["const_generics", "const_new", "union"] }
pratt = "0.4.0"
ariadne = "0.1.5"
unicode-ident = "1.0.5"
unicode-ident = "1"
powerpc-asm = "0.4.1"
+1158 -290
View File
File diff suppressed because it is too large Load Diff
+68 -9
View File
@@ -1,13 +1,11 @@
use core::mem::take;
use std::{
error::Error,
fmt::{Display, Formatter},
iter::Peekable,
ops::Range,
str::Chars,
};
use ariadne::{Color, ColorGenerator, Fmt};
use ariadne::{ColorGenerator, Fmt};
use compact_str::CompactString;
use pratt::{Affix, Associativity, PrattParser, Precedence, Result as PrattResult};
use smallvec::SmallVec;
@@ -109,12 +107,15 @@ enum ExpressionToken {
Operand(Operand),
}
#[derive(Debug, Eq, PartialEq)]
#[derive(Debug, Eq, PartialEq, Clone)]
pub(crate) enum RelocationKind {
Absolute,
Sda21,
Ha,
H,
L,
Rel24,
Rel14,
}
#[derive(Debug, PartialEq)]
@@ -170,6 +171,12 @@ impl<'a> Parser<'a> {
Self { inner: s.chars().peekable(), peek_char: None, position: 0 }
}
/// Returns true if there are no more statements to parse.
pub(crate) fn at_end(&mut self) -> bool {
self.skip_newlines();
self.peek().is_none()
}
fn next(&mut self) -> Option<char> {
if let Some(c) = self.peek_char.take() {
return Some(c);
@@ -278,7 +285,7 @@ impl<'a> Parser<'a> {
fn symbol(&mut self) -> ParseResult<Symbol> {
self.skip();
let mut source = self.begin_source();
let source = self.begin_source();
let c = self.next().ok_or_else(|| {
let mut colors = ColorGenerator::new();
let a = colors.next();
@@ -327,8 +334,42 @@ impl<'a> Parser<'a> {
self.advance();
result.push('"');
}
Some('0') => todo!("octal"),
Some('x') => todo!("hex"),
Some(c @ '0'..='7') => {
self.advance();
let mut val = c as u32 - '0' as u32;
for _ in 0..2 {
match self.peek() {
Some(d @ '0'..='7') => {
self.advance();
val = val * 8 + (d as u32 - '0' as u32);
}
_ => break,
}
}
result.push(char::from(val as u8));
}
Some('x') => {
self.advance();
let mut val = 0u32;
for _ in 0..2 {
match self.peek() {
Some(d @ '0'..='9') => {
self.advance();
val = val * 16 + (d as u32 - '0' as u32);
}
Some(d @ 'a'..='f') => {
self.advance();
val = val * 16 + (d as u32 - 'a' as u32 + 10);
}
Some(d @ 'A'..='F') => {
self.advance();
val = val * 16 + (d as u32 - 'A' as u32 + 10);
}
_ => break,
}
}
result.push(char::from(val as u8));
}
Some(c) => {
let mut colors = ColorGenerator::new();
let a = colors.next();
@@ -422,6 +463,17 @@ impl<'a> Parser<'a> {
self.skip_newlines();
let mut source = self.begin_source();
let mut symbol = self.symbol()?;
// Absorb branch prediction hints (+/-) that follow the mnemonic
// e.g. "beq+" or "bne-"
match self.peek() {
Some(c @ '+') | Some(c @ '-') => {
if let Symbol::Regular(ref mut s) = symbol {
s.push(c);
self.advance();
}
}
_ => {}
}
self.end_source(&mut source);
self.skip();
match self.peek() {
@@ -484,6 +536,7 @@ impl<'a> Parser<'a> {
let kind = match symbol.string().to_ascii_lowercase().as_str() {
"sda21" => RelocationKind::Sda21,
"ha" => RelocationKind::Ha,
"h" => RelocationKind::H,
"l" => RelocationKind::L,
_ => {
let mut colors = ColorGenerator::new();
@@ -514,7 +567,7 @@ impl<'a> Parser<'a> {
};
Ok(match self.peek() {
Some('(') => {
let mut source = self.begin_source();
let source = self.begin_source();
self.advance();
let offset_expr = self.expression()?;
match self.peek() {
@@ -589,7 +642,7 @@ impl<'a> Parser<'a> {
let mut source = self.begin_source();
match self.peek() {
Some('(') => {
let mut source = self.begin_source();
let source = self.begin_source();
self.advance();
let expr = self.expression()?;
self.skip();
@@ -710,6 +763,12 @@ impl<'a> Parser<'a> {
if let Ok(v) = i64::from_str_radix(result.as_str(), radix) {
return Ok(Operand::Number(v, source));
}
// If i64 overflows for a decimal number, try f64
if radix == 10 {
if let Ok(v) = result.parse::<f64>() {
return Ok(Operand::Double(v, source));
}
}
}
return Ok(Operand::Symbol(Symbol::Regular(result), source));
}