5 #define TESTINST1(instruction, RSval, RD) \
11 ".set noreorder \n\t" \
12 "jal end"instruction#RSval "\n\t" \
14 "end"instruction#RSval ": \n\t" \
15 instruction " $" #RD ", " #RSval " \n\t" \
16 "move %0, $" #RD "\n\t" \
19 : "=&r" (out), "=&r" (out1) \
21 : #RD, "ra", "cc", "memory" \
23 printf(instruction" :: out - ra %x, RSval 0x%08x\n", \
27 #define TESTINST2(instruction, RSval, RD) \
33 ".set noreorder \n\t" \
34 "jal end"instruction#RSval "\n\t" \
36 "end"instruction#RSval ": \n\t" \
37 instruction " $" #RD ", " #RSval " \n\t" \
38 "move %0, $" #RD "\n\t" \
41 : "=&r" (out), "=&r" (out1) \
43 : #RD, "ra", "cc", "memory" \
45 printf(instruction" :: out - ra %x, RSval 0x%08x\n", \
46 out - (out1 & ~0xffffffff), RSval); \
49 #define TESTINST3(instruction, RSval, RD) \
51 unsigned int out = 0; \
52 __asm__ __volatile__( \
54 ".set noreorder \n\t" \
55 "lbl"instruction#RSval ": \n\t" \
56 "or $0, $0, $0 \n\t" \
57 "and $0, $0, $0 \n\t" \
58 instruction" $"#RD ", lbl"instruction#RSval "\n\t" \
59 "move %0, $"#RD "\n\t" \
65 printf("%s :: out: 0x%x\n", instruction, out); \
69 #if (__mips_isa_rev>=6)
71 TESTINST1("addiupc", 0, v0
);
72 TESTINST1("addiupc", 4, v1
);
73 TESTINST1("addiupc", 16, a0
);
74 TESTINST1("addiupc", 64, a1
);
75 TESTINST1("addiupc", 256, a3
);
76 TESTINST1("addiupc", 1024, t0
);
77 TESTINST1("addiupc", 4096, t1
);
78 TESTINST1("addiupc", 16384, t2
);
81 TESTINST2("aluipc", 0, v0
);
82 TESTINST2("aluipc", 4, v1
);
83 TESTINST2("aluipc", 16, a0
);
84 TESTINST2("aluipc", 64, a1
);
85 TESTINST2("aluipc", 256, a3
);
86 TESTINST2("aluipc", 1024, t0
);
87 TESTINST2("aluipc", 4096, t1
);
88 TESTINST2("aluipc", 16384, t2
);
91 TESTINST1("auipc", 0, v0
);
92 TESTINST1("auipc", 4, v1
);
93 TESTINST1("auipc", 16, a0
);
94 TESTINST1("auipc", 64, a1
);
95 TESTINST1("auipc", 256, a3
);
96 TESTINST1("auipc", 1024, t0
);
97 TESTINST1("auipc", 4096, t1
);
98 TESTINST1("auipc", 16384, t2
);
101 TESTINST3("lwpc", 0, v0
);
102 TESTINST3("lwpc", 4, v1
);
103 TESTINST3("lwpc", 16, a0
);
104 TESTINST3("lwpc", 64, a1
);
105 TESTINST3("lwpc", 256, a3
);
106 TESTINST3("lwpc", 1024, t0
);
107 TESTINST3("lwpc", 4096, t1
);
108 TESTINST3("lwpc", 16384, t2
);