diff options
Diffstat (limited to 'sim/common/cgen-utils.c')
-rw-r--r-- | sim/common/cgen-utils.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/sim/common/cgen-utils.c b/sim/common/cgen-utils.c index b1c9f02..1ad5ce7 100644 --- a/sim/common/cgen-utils.c +++ b/sim/common/cgen-utils.c @@ -320,3 +320,38 @@ CONVDISI (val) } #endif /* DI_FN_SUPPORT */ + +SI +RORSI (val, shift) + SI val; + int shift; +{ + if (shift != 0) + { + int remain = 32 - shift; + int mask = (1 << shift) - 1; + SI result = (val & mask) << remain; + mask = (1 << remain) - 1; + result |= (val >> shift) & mask; + return result; + } + return val; +} + +SI +ROLSI (val, shift) + SI val; + int shift; +{ + if (shift != 0) + { + int remain = 32 - shift; + int mask = (1 << remain) - 1; + SI result = (val & mask) << shift; + mask = (1 << shift) - 1; + result |= (val >> remain) & mask; + return result; + } + + return val; +} |