1 /* 2 * Test the LOCFHR instruction. 3 * 4 * SPDX-License-Identifier: GPL-2.0-or-later 5 */ 6 #include <assert.h> 7 #include <stdlib.h> 8 9 static inline __attribute__((__always_inline__)) long 10 locfhr(long r1, long r2, int m3, int cc) 11 { 12 cc <<= 28; 13 asm("spm %[cc]\n" 14 "locfhr %[r1],%[r2],%[m3]\n" 15 : [r1] "+r" (r1) 16 : [cc] "r" (cc), [r2] "r" (r2), [m3] "i" (m3) 17 : "cc"); 18 return r1; 19 } 20 21 int main(void) 22 { 23 assert(locfhr(0x1111111122222222, 0x3333333344444444, 8, 0) == 24 0x3333333322222222); 25 assert(locfhr(0x5555555566666666, 0x7777777788888888, 11, 1) == 26 0x5555555566666666); 27 28 return EXIT_SUCCESS; 29 } 30