1073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon/*
2073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
3073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonCopyright (c) 2009, 2010, 2011 STMicroelectronics
4073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonWritten by Christophe Lyon
5073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
6073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonPermission is hereby granted, free of charge, to any person obtaining a copy
7073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonof this software and associated documentation files (the "Software"), to deal
8073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonin the Software without restriction, including without limitation the rights
9073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonto use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyoncopies of the Software, and to permit persons to whom the Software is
11073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonfurnished to do so, subject to the following conditions:
12073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
13073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonThe above copyright notice and this permission notice shall be included in
14073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonall copies or substantial portions of the Software.
15073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
16073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22073831adf9442c019e8d34b18b0c04b1d780a19Christophe LyonTHE SOFTWARE.
23073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
24073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon*/
25073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
266f4d36f3deebf87b2710b5b7b5b30e8b2b60c285Christophe Lyon#if defined(__cplusplus)
276f4d36f3deebf87b2710b5b7b5b30e8b2b60c285Christophe Lyon#include <cstdio>
286f4d36f3deebf87b2710b5b7b5b30e8b2b60c285Christophe Lyon#include <cstdint>
296f4d36f3deebf87b2710b5b7b5b30e8b2b60c285Christophe Lyon#else
30073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#include <stdio.h>
31f3c80a50bd8b39a0a6d565448a0b1c921a902eb8Christophe Lyon#if defined(_MSC_VER)
32f3c80a50bd8b39a0a6d565448a0b1c921a902eb8Christophe Lyon#include "msstdint.h"
33f3c80a50bd8b39a0a6d565448a0b1c921a902eb8Christophe Lyon#else
34073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#include <stdint.h>
356f4d36f3deebf87b2710b5b7b5b30e8b2b60c285Christophe Lyon#endif
36f3c80a50bd8b39a0a6d565448a0b1c921a902eb8Christophe Lyon#endif
37073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
38073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon#ifndef __arm__
390dab5f72da4b2434882b51b44ac377af9e3160feChristophe Lyon#include "stm-arm.h"
400dab5f72da4b2434882b51b44ac377af9e3160feChristophe Lyon#include "stm-dspfns.h" /* For Overflow */
4169a69f989ad0cf384baa60db7a4c88b8f7c26d06Christophe Lyon#else
4269a69f989ad0cf384baa60db7a4c88b8f7c26d06Christophe Lyon#include <dspfns.h> /* For Overflow */
4369a69f989ad0cf384baa60db7a4c88b8f7c26d06Christophe Lyon#endif
44073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
45073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonextern FILE* ref_file;
46073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
47073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyonvoid exec_integer (void)
48073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon{
49073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  int i;
50073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  uint32_t uvar, ures;
51073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  int32_t svar1, svar2, sres;
52073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
53073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  uint8_t clz;
54073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
55073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "\n\nInteger (non-NEON) intrinsics\n");
56073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
57073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* __clz */
58073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* uint8_t __clz(uint32_t val); */
59073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  uvar = 0xFFFFFFFF;
60073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  for(i=0; i<=32; i++) {
61073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon    clz = __clz(uvar);
62073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon    fprintf(ref_file, "__clz(%#x) = %d\n", (unsigned int)uvar, clz);
63073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon    uvar >>= 1;
64073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  }
65073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
66073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* __qadd */
67073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* int32_t __qadd(int32_t val1, int32_t val2); */
68073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 1;
69073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 2;
70073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
71073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qadd(svar1, svar2);
72073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qadd(%#x, %#x) = %#x sat %d\n",
73073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
74073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
75073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = -1;
76073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = -2;
77073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
78073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qadd(svar1, svar2);
79073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qadd(%#x, %#x) = %#x sat %d\n",
80073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
81073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
82073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = -1;
83073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 2;
84073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
85073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qadd(svar1, svar2);
86073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qadd(%#x, %#x) = %#x sat %d\n",
87073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
88073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
89073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x7000;
90073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 0x7000;
91073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
92073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qadd(svar1, svar2);
93073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qadd(%#x, %#x) = %#x sat %d\n",
94073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
95073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
96073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x8FFF;
97073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 0x8FFF;
98073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
99073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qadd(svar1, svar2);
100073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qadd(%#x, %#x) = %#x sat %d\n",
101073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
102073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
103073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x70000000;
104073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 0x70000000;
105073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
106073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qadd(svar1, svar2);
107073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qadd(%#x, %#x) = %#x sat %d\n",
108073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
109073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
110073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x8FFFFFFF;
111073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 0x8FFFFFFF;
112073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
113073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qadd(svar1, svar2);
114073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qadd(%#x, %#x) = %#x sat %d\n",
115073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
116073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
117073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* __qdbl */
118073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* int32_t __qdbl(int32_t val); */
119073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 1;
120073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
121073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qdbl(svar1);
122073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qdbl(%#x) = %#x sat %d\n",
123073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
124073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
125073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x70000000;
126073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
127073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qdbl(svar1);
128073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qdbl(%#x) = %#x sat %d\n",
129073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
130073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
131073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x8FFFFFFF;
132073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
133073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qdbl(svar1);
134073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qdbl(%#x) = %#x sat %d\n",
135073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
136073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
137073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0xEFFFFFFF;
138073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
139073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qdbl(svar1);
140073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qdbl(%#x) = %#x sat %d\n",
141073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
142073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
143073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* __qsub */
144073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* int32_t __qsub(int32_t val1, int32_t val2); */
145073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 1;
146073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 2;
147073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
148073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qsub(svar1, svar2);
149073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qsub(%#x, %#x) = %#x sat %d\n",
150073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
151073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
152073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = -1;
153073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = -2;
154073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
155073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qsub(svar1, svar2);
156073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qsub(%#x, %#x) = %#x sat %d\n",
157073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
158073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
159073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = -1;
160073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 2;
161073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
162073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qsub(svar1, svar2);
163073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qsub(%#x, %#x) = %#x sat %d\n",
164073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
165073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
166073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x7000;
167073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 0xFFFF9000;
168073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
169073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qsub(svar1, svar2);
170073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qsub(%#x, %#x) = %#x sat %d\n",
171073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
172073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
173073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x8FFF;
174073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 0xFFFF7001;
175073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
176073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qsub(svar1, svar2);
177073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qsub(%#x, %#x) = %#x sat %d\n",
178073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
179073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
180073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x70000000;
181073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 0x90000000;
182073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
183073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qsub(svar1, svar2);
184073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qsub(%#x, %#x) = %#x sat %d\n",
185073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
186073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
187073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x8FFFFFFF;
188073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 0x70000001;
189073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
190073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qsub(svar1, svar2);
191073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qsub(%#x, %#x) = %#x sat %d\n",
192073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
193073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
194073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0;
195073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar2 = 0x80000000;
196073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
197073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __qsub(svar1, svar2);
198073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__qsub(%#x, %#x) = %#x sat %d\n",
199073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)svar2, (unsigned int)sres, Overflow);
200073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
201073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* __rbit */
202073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* uint32_t __rbit(uint32_t val); */
203073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  uvar = 0x12345678;
204073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  ures = __rbit(uvar);
205073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__rbit(%#x) = %#x\n",
206073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)uvar, (unsigned int)ures);
207073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
208073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* __rev */
209073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* uint32_t __rev(uint32_t val); */
210073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  uvar = 0x12345678;
211073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  ures = __rev(uvar);
212073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__rev(%#x) = %#x\n",
213073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)uvar, (unsigned int)ures);
214073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
215073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* __ssat */
216073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* int32_t __ssat(int32_t val, uint32_t sat); */
217073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x12345678;
218073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
219073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __ssat(svar1, 30);
220073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__ssat(%#x, 30) = %#x sat %d\n",
221073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
222073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
223073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x12345678;
224073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
225073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __ssat(svar1, 19);
226073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__ssat(%#x, 19) = %#x sat %d\n",
227073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
228073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
229073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x87654321;
230073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
231073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __ssat(svar1, 29);
232073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__ssat(%#x, 29) = %#x sat %d\n",
233073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
234073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
235073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x87654321;
236073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
237073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __ssat(svar1, 12);
238073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__ssat(%#x, 12) = %#x sat %d\n",
239073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
240073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
241073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x87654321;
242073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
243073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __ssat(svar1, 32);
244073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__ssat(%#x, 32) = %#x sat %d\n",
245073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
246073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
247073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x87654321;
248073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
249073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __ssat(svar1, 1);
250073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__ssat(%#x, 1) = %#x sat %d\n",
251073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
252073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
253073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* __usat */
254073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  /* int32_t __usat(uint32_t val, uint32_t sat); */
255073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x12345678;
256073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
257073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __usat(svar1, 30);
258073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__usat(%#x, 30) = %#x sat %d\n",
259073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
260073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
261073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x12345678;
262073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
263073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __usat(svar1, 19);
264073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__usat(%#x, 19) = %#x sat %d\n",
265073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
266073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
267073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x87654321;
268073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
269073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __usat(svar1, 29);
270073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__usat(%#x, 29) = %#x sat %d\n",
271073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
272073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
273073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x87654321;
274073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
275073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __usat(svar1, 12);
276073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__usat(%#x, 12) = %#x sat %d\n",
277073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
278073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
279073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x87654321;
280073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
281073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __usat(svar1, 31);
282073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__usat(%#x, 31) = %#x sat %d\n",
283073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
284073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon
285073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  svar1 = 0x87654321;
286073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  Overflow = 0;
287073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  sres = __usat(svar1, 0);
288073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon  fprintf(ref_file, "__usat(%#x, 0) = %#x sat %d\n",
289073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon          (unsigned int)svar1, (unsigned int)sres, Overflow);
290073831adf9442c019e8d34b18b0c04b1d780a19Christophe Lyon}
291