1 /* Check that thread pointer relative memory accesses are converted to 2 gbr displacement address modes. If we see a gbr register store 3 instruction something is not working properly. */ 4 /* { dg-do compile } */ 5 /* { dg-options "-O1" } */ 6 /* { dg-skip-if "" { "sh*-*-*" } { "-m5*"} { "" } } */ 7 /* { dg-final { scan-assembler-times "stc\tgbr" 0 } } */ 8 9 /* --------------------------------------------------------------------------- 10 Simple GBR load. 11 */ 12 #define func(name, rettype, type, disp)\ 13 rettype \ 14 name ## _tp_load (void) \ 15 { \ 16 type* tp = (type*)__builtin_thread_pointer (); \ 17 return tp[disp]; \ 18 } 19 20 func (test00, int, int, 0) 21 func (test01, int, int, 5) 22 func (test02, int, int, 255) 23 24 func (test03, int, short, 0) 25 func (test04, int, short, 5) 26 func (test05, int, short, 255) 27 28 func (test06, int, char, 0) 29 func (test07, int, char, 5) 30 func (test08, int, char, 255) 31 32 func (test09, int, unsigned int, 0) 33 func (test10, int, unsigned int, 5) 34 func (test11, int, unsigned int, 255) 35 36 func (test12, int, unsigned short, 0) 37 func (test13, int, unsigned short, 5) 38 func (test14, int, unsigned short, 255) 39 40 func (test15, int, unsigned char, 0) 41 func (test16, int, unsigned char, 5) 42 func (test17, int, unsigned char, 255) 43 44 func (test18, long long, long long, 0) 45 func (test19, long long, long long, 5) 46 func (test20, long long, long long, 127) 47 48 func (test21, long long, unsigned long long, 0) 49 func (test22, long long, unsigned long long, 5) 50 func (test23, long long, unsigned long long, 127) 51 52 #undef func 53 54 /* --------------------------------------------------------------------------- 55 Simple GBR store. 56 */ 57 #define func(name, argtype, type, disp)\ 58 void \ 59 name ## _tp_store (argtype a) \ 60 { \ 61 type* tp = (type*)__builtin_thread_pointer (); \ 62 tp[disp] = (type)a; \ 63 } 64 65 func (test00, int, int, 0) 66 func (test01, int, int, 5) 67 func (test02, int, int, 255) 68 69 func (test03, int, short, 0) 70 func (test04, int, short, 5) 71 func (test05, int, short, 255) 72 73 func (test06, int, char, 0) 74 func (test07, int, char, 5) 75 func (test08, int, char, 255) 76 77 func (test09, int, unsigned int, 0) 78 func (test10, int, unsigned int, 5) 79 func (test11, int, unsigned int, 255) 80 81 func (test12, int, unsigned short, 0) 82 func (test13, int, unsigned short, 5) 83 func (test14, int, unsigned short, 255) 84 85 func (test15, int, unsigned char, 0) 86 func (test16, int, unsigned char, 5) 87 func (test17, int, unsigned char, 255) 88 89 func (test18, long long, long long, 0) 90 func (test19, long long, long long, 5) 91 func (test20, long long, long long, 127) 92 93 func (test21, long long, unsigned long long, 0) 94 func (test22, long long, unsigned long long, 5) 95 func (test23, long long, unsigned long long, 127) 96 97 #undef func 98 99 /* --------------------------------------------------------------------------- 100 Arithmetic on the result of a GBR load. 101 */ 102 #define func(name, retargtype, type, disp, op, opname)\ 103 retargtype \ 104 name ## _tp_load_arith_ ##opname (retargtype a) \ 105 { \ 106 type* tp = (type*)__builtin_thread_pointer (); \ 107 return tp[disp] op a; \ 108 } 109 110 #define funcs(op, opname) \ 111 func (test00, int, int, 0, op, opname) \ 112 func (test01, int, int, 5, op, opname) \ 113 func (test02, int, int, 255, op, opname) \ 114 func (test03, int, short, 0, op, opname) \ 115 func (test04, int, short, 5, op, opname) \ 116 func (test05, int, short, 255, op, opname) \ 117 func (test06, int, char, 0, op, opname) \ 118 func (test07, int, char, 5, op, opname) \ 119 func (test08, int, char, 255, op, opname) \ 120 func (test09, int, unsigned int, 0, op, opname) \ 121 func (test10, int, unsigned int, 5, op, opname) \ 122 func (test11, int, unsigned int, 255, op, opname) \ 123 func (test12, int, unsigned short, 0, op, opname) \ 124 func (test13, int, unsigned short, 5, op, opname) \ 125 func (test14, int, unsigned short, 255, op, opname) \ 126 func (test15, int, unsigned char, 0, op, opname) \ 127 func (test16, int, unsigned char, 5, op, opname) \ 128 func (test17, int, unsigned char, 255, op, opname) \ 129 func (test18, long long, long long, 0, op, opname) \ 130 func (test19, long long, long long, 5, op, opname) \ 131 func (test20, long long, long long, 127, op, opname) \ 132 func (test21, long long, unsigned long long, 0, op, opname) \ 133 func (test22, long long, unsigned long long, 5, op, opname) \ 134 func (test23, long long, unsigned long long, 127, op, opname) \ 135 136 funcs (+, plus) 137 funcs (-, minus) 138 funcs (*, mul) 139 funcs (&, and) 140 funcs (|, or) 141 funcs (^, xor) 142 143 #undef funcs 144 #undef func 145 146 /* --------------------------------------------------------------------------- 147 Arithmetic of the result of two GBR loads. 148 */ 149 #define func(name, rettype, type, disp0, disp1, op, opname)\ 150 rettype \ 151 name ## _tp_load_load_arith_ ##opname (void) \ 152 { \ 153 type* tp = (type*)__builtin_thread_pointer (); \ 154 return tp[disp0] op tp[disp1]; \ 155 } 156 157 #define funcs(op, opname) \ 158 func (test00, int, int, 0, 5, op, opname) \ 159 func (test02, int, int, 1, 255, op, opname) \ 160 func (test03, int, short, 0, 5, op, opname) \ 161 func (test05, int, short, 1, 255, op, opname) \ 162 func (test06, int, char, 0, 5, op, opname) \ 163 func (test08, int, char, 1, 255, op, opname) \ 164 func (test09, int, unsigned int, 0, 5, op, opname) \ 165 func (test11, int, unsigned int, 1, 255, op, opname) \ 166 func (test12, int, unsigned short, 0, 5, op, opname) \ 167 func (test14, int, unsigned short, 1, 255, op, opname) \ 168 func (test15, int, unsigned char, 0, 5, op, opname) \ 169 func (test17, int, unsigned char, 1, 255, op, opname) \ 170 func (test18, long long, long long, 0, 5, op, opname) \ 171 func (test19, long long, long long, 1, 127, op, opname) \ 172 func (test20, long long, unsigned long long, 0, 5, op, opname) \ 173 func (test21, long long, unsigned long long, 1, 127, op, opname) \ 174 175 funcs (+, plus) 176 funcs (-, minus) 177 funcs (*, mul) 178 funcs (&, and) 179 funcs (|, or) 180 funcs (^, xor) 181 182 #undef funcs 183 #undef func 184 185 /* --------------------------------------------------------------------------- 186 GBR load GBR store copy. 187 */ 188 189 #define func(name, type, disp0, disp1)\ 190 void \ 191 name ## _tp_copy (void) \ 192 { \ 193 type* tp = (type*)__builtin_thread_pointer (); \ 194 tp[disp0] = tp[disp1]; \ 195 } 196 197 func (test00, int, 0, 5) 198 func (test02, int, 1, 255) 199 func (test03, short, 0, 5) 200 func (test05, short, 1, 255) 201 func (test06, char, 0, 5) 202 func (test08, char, 1, 255) 203 func (test09, unsigned int, 0, 5) 204 func (test11, unsigned int, 1, 255) 205 func (test12, unsigned short, 0, 5) 206 func (test14, unsigned short, 1, 255) 207 func (test15, unsigned char, 0, 5) 208 func (test17, unsigned char, 1, 255) 209 func (test18, long long, 0, 5) 210 func (test19, long long, 1, 127) 211 func (test20, unsigned long long, 0, 5) 212 func (test21, unsigned long long, 1, 127) 213 214 #undef func 215 216 /* --------------------------------------------------------------------------- 217 GBR load, arithmetic, GBR store 218 */ 219 220 #define func(name, argtype, type, disp, op, opname)\ 221 void \ 222 name ## _tp_load_arith_store_ ##opname (argtype a) \ 223 { \ 224 type* tp = (type*)__builtin_thread_pointer (); \ 225 tp[disp] op a; \ 226 } 227 228 #define funcs(op, opname) \ 229 func (test00, int, int, 0, op, opname) \ 230 func (test01, int, int, 5, op, opname) \ 231 func (test02, int, int, 255, op, opname) \ 232 func (test03, int, short, 0, op, opname) \ 233 func (test04, int, short, 5, op, opname) \ 234 func (test05, int, short, 255, op, opname) \ 235 func (test06, int, char, 0, op, opname) \ 236 func (test07, int, char, 5, op, opname) \ 237 func (test08, int, char, 255, op, opname) \ 238 func (test09, int, unsigned int, 0, op, opname) \ 239 func (test10, int, unsigned int, 5, op, opname) \ 240 func (test11, int, unsigned int, 255, op, opname) \ 241 func (test12, int, unsigned short, 0, op, opname) \ 242 func (test13, int, unsigned short, 5, op, opname) \ 243 func (test14, int, unsigned short, 255, op, opname) \ 244 func (test15, int, unsigned char, 0, op, opname) \ 245 func (test16, int, unsigned char, 5, op, opname) \ 246 func (test17, int, unsigned char, 255, op, opname) \ 247 func (test18, long long, long long, 0, op, opname) \ 248 func (test19, long long, long long, 5, op, opname) \ 249 func (test20, long long, long long, 127, op, opname) \ 250 func (test21, long long, unsigned long long, 0, op, opname) \ 251 func (test22, long long, unsigned long long, 5, op, opname) \ 252 func (test23, long long, unsigned long long, 127, op, opname) \ 253 254 funcs (+=, plus) 255 funcs (-=, minus) 256 funcs (*=, mul) 257 funcs (&=, and) 258 funcs (|=, or) 259 funcs (^=, xor) 260