Skip to content

Commit 511ebcd

Browse files
committed
Add documentation for loop_asm!
1 parent ed7799a commit 511ebcd

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

riscv-rt/macros/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,25 @@ impl Parse for AsmLoopArgs {
224224
}
225225
}
226226

227+
/// Loops an asm expression n times.
228+
///
229+
/// `loop_asm!` takes 2 arguments, the first is a string literal and the second is a number literal
230+
/// See [the formatting syntax documentation in `std::fmt`](../std/fmt/index.html)
231+
/// for details.
232+
///
233+
/// Argument 1 is an assembly expression, all "{}" in this assembly expression will be replaced with the
234+
/// current loop index.
235+
///
236+
/// Argument 2 is the number of loops to do with the provided expression.
237+
///
238+
/// # Examples
239+
///
240+
/// ```
241+
/// # use riscv_rt_macros::loop_asm;
242+
/// unsafe {
243+
/// loop_asm!("fmv.w.x f{}, x0", 32); // => core::arch::asm!("fmv.w.x f0, x0") ... core::arch::asm!("fmv.w.x f31, x0")
244+
/// }
245+
/// ```
227246
#[proc_macro]
228247
pub fn loop_asm(input: TokenStream) -> TokenStream {
229248
let args = parse_macro_input!(input as AsmLoopArgs);

0 commit comments

Comments
 (0)