From 27a0e12979900cd8a9cca967833cb0f09e95c13f Mon Sep 17 00:00:00 2001 From: Dmitry Atamanov Date: Sun, 28 Aug 2022 21:09:22 +0500 Subject: [PATCH] Add rotate_left and rotate_right macros --- lib/std/bits.c3 | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/std/bits.c3 b/lib/std/bits.c3 index 1a6e7fd17..5807e3e92 100644 --- a/lib/std/bits.c3 +++ b/lib/std/bits.c3 @@ -59,3 +59,20 @@ macro fshr(hi, lo, shift) @builtin { return $$fshr(hi, lo, ($typeof(hi))shift); } + +/** + * @require types::is_intlike($typeof(i)) && types::is_intlike($typeof(amount)) `The input must be an integer or integer vector` + **/ +macro rotate_left(i, amount) @builtin +{ + return $$fshl(i, i, ($typeof(i))amount); +} + +/** + * @require types::is_intlike($typeof(i)) && types::is_intlike($typeof(amount)) `The input must be an integer or integer vector` + **/ +macro rotate_right(i, amount) @builtin +{ + return $$fshr(i, i, ($typeof(i))amount); +} +