Reduce binary size using const arrays

Before, the mnemonic arrays would be generated
on the stack at runtime in each parse function.
This ensures that the arrays  themselves are
treated as const data.
This commit is contained in:
Luke Street 2024-09-26 23:20:49 -06:00
parent c8026715f0
commit 0de65eb1b6
2 changed files with 2033 additions and 1713 deletions

File diff suppressed because it is too large Load Diff

View File

@ -465,6 +465,10 @@ fn gen_mnemonic(
bitset.extend(quote! { | (ins.#modifier() as usize) << #i }); bitset.extend(quote! { | (ins.#modifier() as usize) << #i });
} }
} }
Ok(quote! { ParsedIns { mnemonic: [#(#names),*][#bitset], args: #arguments } }) let names_len = Literal::usize_unsuffixed(names.len());
Ok(quote! { {
const MODIFIERS: [&str; #names_len] = [#(#names),*];
ParsedIns { mnemonic: MODIFIERS[#bitset], args: #arguments }
} })
} }
} }