macros/writer: add mnemonic suffixes

This commit is contained in:
Richard Patel 2021-08-15 10:42:27 +02:00
parent 67efa31bbd
commit 4853c12054
1 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,7 @@ use quote::quote;
use quote::ToTokens; use quote::ToTokens;
use syn::parse::{Parse, ParseStream}; use syn::parse::{Parse, ParseStream};
use syn::punctuated::Punctuated; use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
use syn::token::Semi; use syn::token::Semi;
use syn::{Expr, Ident}; use syn::{Expr, Ident};
@ -52,7 +53,16 @@ impl Arguments {
fn format_mnemonic(&self, tokens: &mut Vec<TokenTree>) { fn format_mnemonic(&self, tokens: &mut Vec<TokenTree>) {
let arg = &self.args[0]; let arg = &self.args[0];
assert!(!arg.sources.is_empty()); assert!(!arg.sources.is_empty());
self.format_call(tokens, &arg.target, self.ins_call(&arg.sources[0])) // Print the mnemonic.
self.format_call(tokens, &arg.target, self.ins_call(&arg.sources[0]));
// Print any mnemonic suffixes.
for src in arg.sources.iter().skip(1) {
self.format_call(
tokens,
&Ident::new(&src.into_token_stream().to_string(), src.span()),
self.ins_call(&src),
);
}
} }
fn format_call(&self, tokens: &mut Vec<TokenTree>, method_arg: &Ident, args: TokenStream) { fn format_call(&self, tokens: &mut Vec<TokenTree>, method_arg: &Ident, args: TokenStream) {