Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
tests/tcg/s390x: Test LOCFHR
Add a small test to prevent regressions. Cc: qemu-stable@nongnu.org Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Message-Id: <20230526181240.1425579-5-iii@linux.ibm.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com>
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * Test the LOCFHR instruction. | ||
| * | ||
| * SPDX-License-Identifier: GPL-2.0-or-later | ||
| */ | ||
| #include <assert.h> | ||
| #include <stdlib.h> | ||
|
|
||
| static inline __attribute__((__always_inline__)) long | ||
| locfhr(long r1, long r2, int m3, int cc) | ||
| { | ||
| cc <<= 28; | ||
| asm("spm %[cc]\n" | ||
| "locfhr %[r1],%[r2],%[m3]\n" | ||
| : [r1] "+r" (r1) | ||
| : [cc] "r" (cc), [r2] "r" (r2), [m3] "i" (m3) | ||
| : "cc"); | ||
| return r1; | ||
| } | ||
|
|
||
| int main(void) | ||
| { | ||
| assert(locfhr(0x1111111122222222, 0x3333333344444444, 8, 0) == | ||
| 0x3333333322222222); | ||
| assert(locfhr(0x5555555566666666, 0x7777777788888888, 11, 1) == | ||
| 0x5555555566666666); | ||
|
|
||
| return EXIT_SUCCESS; | ||
| } |