-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
87 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#![allow(unused)] | ||
|
||
use proc_macro::TokenStream; | ||
use syn::parse; | ||
|
||
pub fn store_cpu_context(input: TokenStream) -> Result<TokenStream, parse::Error> { | ||
// let reg = syn::parse::<syn::LitStr>(input)?; | ||
|
||
// let after = format!("[{},#-0x20]!", reg.value()); | ||
|
||
let after = format!("[{},#-0x20]!", "sp"); | ||
let asm_str = reg_op_pair("stp", "q", 0..32, &after, true); | ||
|
||
Ok(asm_str.parse().unwrap()) | ||
} | ||
|
||
fn reg_op_pair( | ||
op: &str, | ||
reg: &str, | ||
range: std::ops::Range<usize>, | ||
after: &str, | ||
reverse: bool, | ||
) -> String { | ||
let mut ls = range | ||
.step_by(2) | ||
.map(|p0| { | ||
format!( | ||
"{op} {:>3},{:>3}, {after}", | ||
format!("{reg}{p0}"), | ||
format!("{reg}{}", p0 + 1) | ||
) | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
if reverse { | ||
ls.reverse(); | ||
} | ||
|
||
ls.join("\n") | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
|
||
#[test] | ||
fn test_reg_op_pair() { | ||
let want = " | ||
ldp X1, X2, [sp], #0x10 | ||
ldp X3, X4, [sp], #0x10 | ||
ldp X5, X6, [sp], #0x10 | ||
ldp X7, X8, [sp], #0x10 | ||
ldp X9,X10, [sp], #0x10 | ||
ldp X11,X12, [sp], #0x10 | ||
ldp X13,X14, [sp], #0x10 | ||
ldp X15,X16, [sp], #0x10 | ||
ldp X17,X18, [sp], #0x10 | ||
ldp X19,X20, [sp], #0x10 | ||
ldp X21,X22, [sp], #0x10 | ||
ldp X23,X24, [sp], #0x10 | ||
ldp X25,X26, [sp], #0x10 | ||
ldp X27,X28, [sp], #0x10 | ||
ldp X29,X30, [sp], #0x10 | ||
"; | ||
|
||
let a_str = reg_op_pair("ldp", "X", 1..31, "[sp], #0x10", false); | ||
|
||
println!("{a_str}"); | ||
|
||
assert_eq!(a_str.trim(), want.trim()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod aarch64; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters