1 /* Copyright (C) 1998 Cygnus Solutions */
2 /* COP2 function test, with non-expert inline assembly */
10 float data_array
[128] __attribute__((aligned(16)));
16 #define TEST(x) do_test(x, #x, __LINE__)
25 void do_test(int ok
, const char* test
, int line
);
29 /* Utility functions */
34 asm volatile (".set noat");
35 asm volatile ("mfc0 $1,$12; dli $2,0x40000000; or $1,$2,$2; mtc0 $1,$12"
38 : "$1", "$2" /* clobbered */);
39 asm volatile (".set at");
44 do_test(int ok
, const char* test
, int line
)
46 static int test_num
= 0;
48 printf("[%d @ %d] (%s): ", ++test_num
, line
, test
);
66 /* test00: test LQC2/SQC2 data non-corruption */
69 volatile float* data
= & data_array
[0];
70 volatile float* data2
= & data_array
[4];
72 /* stuff some initial values */
79 asm volatile ("lqc2 vf01,%0"
81 : "m" (data
[0]) /* input */
82 : "memory" /* clobbered */);
84 /* test no clobbering */
85 TEST(data
[0] == -10.0f
);
86 TEST(data
[1] == +10.0f
);
87 TEST(data
[2] == -20.0f
);
88 TEST(data
[3] == +20.0f
);
90 /* overwrite with VU constants */
91 asm volatile ("sqc2 vf00,%0"
93 : "m" (data
[0]) /* input */
94 : "memory" /* clobbered */);
96 /* test proper values */
97 TEST(data
[0] == 0.0f
);
98 TEST(data
[1] == 0.5f
);
99 TEST(data
[2] == -1.0f
);
100 TEST(data
[3] == +1.0f
);
102 /* read back original array values */
103 asm volatile ("sqc2 vf01,%0"
105 : "m" (data2
[0]) /* input */
106 : "memory" /* clobbered */);
108 /* printf("%f,%f,%f,%f\n", data2[0], data2[1], data2[2], data2[3]); */
110 /* test proper values */
111 TEST(data2
[0] == -10.0f
);
112 TEST(data2
[1] == +10.0f
);
113 TEST(data2
[2] == -20.0f
);
114 TEST(data2
[3] == +20.0f
);
131 printf("%d ok, %d bad\n", num_ok
, num_errors
);
This page took 0.035047 seconds and 4 git commands to generate.