177
177
#endif // #ifndef __powerpc64__
180
#define ALLCR "cr0","cr1","cr2","cr3","cr4","cr5","cr6","cr7"
182
#define SET_CR(_arg) \
183
__asm__ __volatile__ ("mtcr %0" : : "b"(_arg) : ALLCR );
185
#define SET_XER(_arg) \
186
__asm__ __volatile__ ("mtxer %0" : : "b"(_arg) : "xer" );
188
#define GET_CR(_lval) \
189
__asm__ __volatile__ ("mfcr %0" : "=b"(_lval) )
191
#define GET_XER(_lval) \
192
__asm__ __volatile__ ("mfxer %0" : "=b"(_lval) )
194
#define GET_CR_XER(_lval_cr,_lval_xer) \
195
do { GET_CR(_lval_cr); GET_XER(_lval_xer); } while (0)
197
#define SET_CR_ZERO \
200
#define SET_XER_ZERO \
203
#define SET_CR_XER_ZERO \
204
do { SET_CR_ZERO; SET_XER_ZERO; } while (0)
206
#define SET_FPSCR_ZERO \
207
do { double _d = 0.0; \
208
__asm__ __volatile__ ("mtfsf 0xFF, %0" : : "f"(_d) ); \
212
/* XXXX these must all be callee-save regs! */
180
213
register double f14 __asm__ ("f14");
181
214
register double f15 __asm__ ("f15");
182
215
register double f16 __asm__ ("f16");
183
216
register double f17 __asm__ ("f17");
184
register double f18 __asm__ ("f18");
185
217
register HWord_t r14 __asm__ ("r14");
186
218
register HWord_t r15 __asm__ ("r15");
187
219
register HWord_t r16 __asm__ ("r16");
188
220
register HWord_t r17 __asm__ ("r17");
189
register HWord_t r18 __asm__ ("r18");
191
222
#if defined (HAS_ALTIVEC)
192
223
# include <altivec.h>
194
225
#include <assert.h>
195
226
#include <ctype.h> // isspace
199
227
#include <stdio.h>
200
228
#include <stdlib.h>
201
229
#include <string.h>
5228
for (k=0; k<nb_iargs; k++) {
5232
__asm__ __volatile__ ("mfcr 18");
5234
__asm__ __volatile__ ("mfxer 18");
5237
/* Set up flags for test */
5239
// Only valid bits of xer: 0xE000007F
5240
__asm__ __volatile__ ("lis 15,0xE000");
5241
__asm__ __volatile__ ("addi 15,15,0x007F");
5242
__asm__ __volatile__ ("and 16,15,14");
5244
__asm__ __volatile__ ("mtcr 18");
5245
__asm__ __volatile__ ("mtxer 16");
5246
__asm__ __volatile__ ("mtlr 18");
5247
__asm__ __volatile__ ("mtctr 18");
5249
__asm__ __volatile__ ("mfspr 17, 1"); // func()
5251
__asm__ __volatile__ ("mfxer 18");
5253
__asm__ __volatile__ ("mfcr 18");
5255
__asm__ __volatile__ ("mflr 18");
5257
__asm__ __volatile__ ("mfctr 18");
5263
__asm__ __volatile__ ("mtcr 18");
5265
__asm__ __volatile__ ("mtxer 18");
5267
printf("%s %d (%08x) => %08x (%08x %08x, %08x, %08x)\n",
5268
name, j, iargs[k], res, flags, xer, lr, ctr);
5270
if (verbose) printf("\n");
5274
for (k=0; k<nb_iargs; k++) {
5278
__asm__ __volatile__ ("mfcr 18");
5280
__asm__ __volatile__ ("mfxer 18");
5283
/* Set up flags for test */
5285
__asm__ __volatile__ ("mtcr 18");
5286
__asm__ __volatile__ ("mtlr 14");
5287
__asm__ __volatile__ ("mtctr 18");
5288
__asm__ __volatile__ ("mtxer 18");
5290
__asm__ __volatile__ ("mfspr 17, 8"); // func()
5292
__asm__ __volatile__ ("mfxer 18");
5294
__asm__ __volatile__ ("mfcr 18");
5296
__asm__ __volatile__ ("mflr 18");
5298
__asm__ __volatile__ ("mfctr 18");
5304
__asm__ __volatile__ ("mtcr 18");
5306
__asm__ __volatile__ ("mtxer 18");
5308
printf("%s %d (%08x) => %08x (%08x %08x, %08x, %08x)\n",
5309
name, j, iargs[k], res, flags, xer, lr, ctr);
5311
if (verbose) printf("\n");
5315
for (k=0; k<nb_iargs; k++) {
5319
__asm__ __volatile__ ("mfcr 18");
5321
__asm__ __volatile__ ("mfxer 18");
5324
/* Set up flags for test */
5326
__asm__ __volatile__ ("mtcr 18");
5327
__asm__ __volatile__ ("mtctr 14");
5328
__asm__ __volatile__ ("mtxer 18");
5329
__asm__ __volatile__ ("mtlr 18");
5331
__asm__ __volatile__ ("mfspr 17, 9"); // func()
5333
__asm__ __volatile__ ("mfcr 18");
5335
__asm__ __volatile__ ("mfxer 18");
5337
__asm__ __volatile__ ("mflr 18");
5339
__asm__ __volatile__ ("mfctr 18");
5345
__asm__ __volatile__ ("mtcr 18");
5347
__asm__ __volatile__ ("mtxer 18");
5349
printf("%s %d (%08x) => %08x (%08x %08x, %08x, %08x)\n",
5350
name, j, iargs[k], res, flags, xer, lr, ctr);
5356
static void mftb_cb (const char* name, test_func_t func,
5357
unused uint32_t test_flags)
5359
// How to test this?
5360
// 1) TBU won't change for a while
5361
// 2) TBL will have changed every loop iter
5363
volatile HWord_t res;
5364
volatile uint32_t flags, xer, tmpcr, tmpxer;
5368
for (j=0; j<16; j++) {
5370
__asm__ __volatile__ ("mfcr 18");
5372
__asm__ __volatile__ ("mfxer 18");
5375
/* Set up flags for test */
5377
__asm__ __volatile__ ("mtcr 18");
5378
__asm__ __volatile__ ("mtxer 18");
5380
__asm__ __volatile__ ("mftb 17, 269"); // func
5382
__asm__ __volatile__ ("mfcr 18");
5384
__asm__ __volatile__ ("mfxer 18");
5390
__asm__ __volatile__ ("mtcr 18");
5392
__asm__ __volatile__ ("mtxer 18");
5394
printf("%s %d => %08x (%08x %08x)\n",
5395
name, i, res, flags, xer);
5397
if (verbose) printf("\n");
5400
for (j=0; j<16; j++) {
5402
__asm__ __volatile__ ("mfcr 18");
5404
__asm__ __volatile__ ("mfxer 18");
5407
/* Set up flags for test */
5409
__asm__ __volatile__ ("mtcr 18");
5410
__asm__ __volatile__ ("mtxer 18");
5412
__asm__ __volatile__ ("mftb 17, 268"); // func
5414
__asm__ __volatile__ ("mfcr 18");
5416
__asm__ __volatile__ ("mfxer 18");
5422
__asm__ __volatile__ ("mtcr 18");
5424
__asm__ __volatile__ ("mtxer 18");
5426
printf("%s %d => %08x (%08x %08x)\n",
5427
name, i, res, flags, xer);
5432
5084
static void mtcrf_cb (const char* name, test_func_t func_IN,
5433
5085
unused uint32_t test_flags)
5435
5087
volatile test_func_t func;
5436
5088
uint32_t* func_buf = get_rwx_area();
5437
volatile uint32_t flags, xer, tmpcr, tmpxer;
5089
volatile uint32_t flags, xer;
5438
5090
int i, j, arg_step;
5440
5092
arg_step = (arg_list_size == 0) ? 99 : 1;
5484
5118
static void mtspr_cb (const char* name, test_func_t func,
5485
5119
unused uint32_t test_flags)
5488
volatile HWord_t ctr, lr;
5489
volatile uint32_t flags, xer, tmpcr, tmpxer;
5491
func = func; // just to stop compiler complaining
5495
for (k=0; k<nb_iargs; k++) {
5499
__asm__ __volatile__ ("mfcr 18");
5501
__asm__ __volatile__ ("mfxer 18");
5504
/* Set up flags for test */
5507
// Only valid bits of xer: 0xE000007F
5508
// VEX masks these (maybe it shouldn't?), so let's do it first:
5509
__asm__ __volatile__ ("lis 15,0xE000");
5510
__asm__ __volatile__ ("addi 15,15,0x007F");
5511
__asm__ __volatile__ ("and 16,15,14");
5513
__asm__ __volatile__ ("mtcr 18");
5514
__asm__ __volatile__ ("mtxer 18");
5515
__asm__ __volatile__ ("mtlr 18");
5516
__asm__ __volatile__ ("mtctr 18");
5518
__asm__ __volatile__ ("mtxer 16"); // func()
5520
__asm__ __volatile__ ("mfxer 18");
5522
__asm__ __volatile__ ("mfcr 18");
5524
__asm__ __volatile__ ("mflr 18");
5526
__asm__ __volatile__ ("mfctr 18");
5531
__asm__ __volatile__ ("mtcr 18");
5533
__asm__ __volatile__ ("mtxer 18");
5535
#ifndef __powerpc64__
5536
printf("%s %d, %08x => (%08x %08x, %08x, %08x)\n",
5538
printf("%s %d, %016lx => (%08x %08x, %016lx, %016lx)\n",
5540
name, j, iargs[k], flags, xer, lr, ctr);
5542
if (verbose) printf("\n");
5546
for (k=0; k<nb_iargs; k++) {
5550
__asm__ __volatile__ ("mfcr 18");
5552
__asm__ __volatile__ ("mfxer 18");
5555
/* Set up flags for test */
5557
__asm__ __volatile__ ("mtcr 18");
5558
__asm__ __volatile__ ("mtlr 18");
5559
__asm__ __volatile__ ("mtctr 18");
5560
__asm__ __volatile__ ("mtxer 18");
5562
__asm__ __volatile__ ("mtlr 14"); // func()
5564
__asm__ __volatile__ ("mfxer 18");
5566
__asm__ __volatile__ ("mfcr 18");
5568
__asm__ __volatile__ ("mflr 18");
5570
__asm__ __volatile__ ("mfctr 17"); // CAB: if 18, bashes lr - bad gcc opt?
5575
__asm__ __volatile__ ("mtcr 18");
5577
__asm__ __volatile__ ("mtxer 18");
5579
#ifndef __powerpc64__
5580
printf("%s %d, %08x => (%08x %08x, %08x, %08x)\n",
5582
printf("%s %d, %016lx => (%08x %08x, %016lx, %016lx)\n",
5584
name, j, iargs[k], flags, xer, lr, ctr);
5586
if (verbose) printf("\n");
5590
for (k=0; k<nb_iargs; k++) {
5594
__asm__ __volatile__ ("mfcr 18");
5596
__asm__ __volatile__ ("mfxer 18");
5599
/* Set up flags for test */
5601
__asm__ __volatile__ ("mtcr 18");
5602
__asm__ __volatile__ ("mtctr 18");
5603
__asm__ __volatile__ ("mtxer 18");
5604
__asm__ __volatile__ ("mtlr 18");
5606
__asm__ __volatile__ ("mtctr 14"); // func()
5608
__asm__ __volatile__ ("mfxer 18");
5610
__asm__ __volatile__ ("mfcr 18");
5612
__asm__ __volatile__ ("mflr 18");
5614
__asm__ __volatile__ ("mfctr 17");
5619
__asm__ __volatile__ ("mtcr 18");
5621
__asm__ __volatile__ ("mtxer 18");
5623
#ifndef __powerpc64__
5624
printf("%s %d, %08x => (%08x %08x, %08x, %08x)\n",
5626
printf("%s %d, %016lx => (%08x %08x, %016lx, %016lx)\n",
5628
name, j, iargs[k], flags, xer, lr, ctr);
5633
5123
#ifdef __powerpc64__