| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#include <assert.h> |
| 23 |
#include <string.h> |
| 24 |
|
| 25 |
#include "pass2.h" |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
int |
| 32 |
notoff(TWORD ty, int r, CONSZ off, char *cp) |
| 33 |
{ |
| 34 |
if (cp && cp[0]) return 1; |
| 35 |
if (DEUNSIGN(ty) == INT || ty == UCHAR) |
| 36 |
return !(off < 4096 && off > -4096); |
| 37 |
else |
| 38 |
return !(off < 256 && off > -256); |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
void |
| 46 |
offstar(NODE *p, int shape) |
| 47 |
{ |
| 48 |
NODE *r; |
| 49 |
|
| 50 |
if (isreg(p)) |
| 51 |
return; |
| 52 |
|
| 53 |
r = p->n_right; |
| 54 |
if( p->n_op == PLUS || p->n_op == MINUS ){ |
| 55 |
if( r->n_op == ICON ){ |
| 56 |
if (isreg(p->n_left) == 0) |
| 57 |
(void)geninsn(p->n_left, INAREG); |
| 58 |
|
| 59 |
return; |
| 60 |
} |
| 61 |
|
| 62 |
if (r->n_op == LS && r->n_right->n_op == ICON && |
| 63 |
getlval(r->n_right) == 2 && p->n_op == PLUS) { |
| 64 |
if (isreg(p->n_left) == 0) |
| 65 |
(void)geninsn(p->n_left, INAREG); |
| 66 |
if (isreg(r->n_left) == 0) |
| 67 |
(void)geninsn(r->n_left, INAREG); |
| 68 |
return; |
| 69 |
} |
| 70 |
} |
| 71 |
(void)geninsn(p, INAREG); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
void |
| 79 |
myormake(NODE *q) |
| 80 |
{ |
| 81 |
NODE *p, *r; |
| 82 |
|
| 83 |
if (x2debug) |
| 84 |
printf("myormake(%p)\n", q); |
| 85 |
|
| 86 |
p = q->n_left; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
if ((p->n_op == PLUS || p->n_op == MINUS) && p->n_right->n_op == ICON) { |
| 93 |
if (isreg(p->n_left) == 0) |
| 94 |
(void)geninsn(p->n_left, INAREG); |
| 95 |
if (isreg(p->n_right) == 0) |
| 96 |
(void)geninsn(p->n_right, INAREG); |
| 97 |
(void)geninsn(p, INAREG); |
| 98 |
} else if (p->n_op == REG) { |
| 99 |
q->n_op = OREG; |
| 100 |
setlval(q, getlval(p)); |
| 101 |
q->n_rval = p->n_rval; |
| 102 |
tfree(p); |
| 103 |
} else if (p->n_op == PLUS && (r = p->n_right)->n_op == LS && |
| 104 |
r->n_right->n_op == ICON && getlval(r->n_right) == 2 && |
| 105 |
p->n_left->n_op == REG && r->n_left->n_op == REG) { |
| 106 |
q->n_op = OREG; |
| 107 |
setlval(q, 0); |
| 108 |
q->n_rval = R2PACK(p->n_left->n_rval, r->n_left->n_rval, |
| 109 |
getlval(r->n_right)); |
| 110 |
tfree(p); |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
int |
| 118 |
shumul(NODE *p, int shape) |
| 119 |
{ |
| 120 |
|
| 121 |
if (shape & SOREG) |
| 122 |
return SROREG; |
| 123 |
return SRNOPE; |
| 124 |
} |
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
int |
| 133 |
setbin(NODE *p) |
| 134 |
{ |
| 135 |
return 0; |
| 136 |
|
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
int |
| 146 |
setasg(NODE *p, int cookie) |
| 147 |
{ |
| 148 |
return 0; |
| 149 |
} |
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
int |
| 158 |
setuni(NODE *p, int cookie) |
| 159 |
{ |
| 160 |
return 0; |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
struct rspecial * |
| 169 |
nspecial(struct optab *q) |
| 170 |
{ |
| 171 |
|
| 172 |
switch (q->op) { |
| 173 |
#if !defined(ARM_HAS_FPA) && !defined(ARM_HAS_VFP) |
| 174 |
case UMINUS: |
| 175 |
case SCONV: |
| 176 |
if (q->lshape == SBREG && q->rshape == SAREG) { |
| 177 |
static struct rspecial s[] = { |
| 178 |
{ NLEFT, R16 }, |
| 179 |
{ NRES, R0 }, |
| 180 |
{ 0 } |
| 181 |
}; |
| 182 |
return s; |
| 183 |
} else if (q->lshape == SAREG && q->rshape == SBREG) { |
| 184 |
static struct rspecial s[] = { |
| 185 |
{ NLEFT, R0 }, |
| 186 |
{ NRES, R16 }, |
| 187 |
{ 0 } |
| 188 |
}; |
| 189 |
return s; |
| 190 |
} else if (q->lshape == SAREG && q->rshape == SAREG) { |
| 191 |
static struct rspecial s[] = { |
| 192 |
{ NLEFT, R0 }, |
| 193 |
{ NRES, R0 }, |
| 194 |
{ 0 } |
| 195 |
}; |
| 196 |
return s; |
| 197 |
} else if (q->lshape == SBREG && q->rshape == SBREG) { |
| 198 |
static struct rspecial s[] = { |
| 199 |
{ NLEFT, R16 }, |
| 200 |
{ NRES, R16 }, |
| 201 |
{ 0 } |
| 202 |
}; |
| 203 |
return s; |
| 204 |
} |
| 205 |
|
| 206 |
case OPLOG: |
| 207 |
if (q->lshape == SBREG) { |
| 208 |
static struct rspecial s[] = { |
| 209 |
{ NLEFT, R16 }, |
| 210 |
{ NRIGHT, R18 }, |
| 211 |
{ NRES, R0 }, |
| 212 |
{ 0 } |
| 213 |
}; |
| 214 |
return s; |
| 215 |
} else if (q->lshape == SAREG) { |
| 216 |
static struct rspecial s[] = { |
| 217 |
{ NLEFT, R0 }, |
| 218 |
{ NRIGHT, R1 }, |
| 219 |
{ NRES, R0 }, |
| 220 |
{ 0 } |
| 221 |
}; |
| 222 |
return s; |
| 223 |
} |
| 224 |
case PLUS: |
| 225 |
case MINUS: |
| 226 |
case MUL: |
| 227 |
#endif |
| 228 |
case MOD: |
| 229 |
case DIV: |
| 230 |
if (q->lshape == SBREG) { |
| 231 |
static struct rspecial s[] = { |
| 232 |
{ NLEFT, R16 }, |
| 233 |
{ NRIGHT, R18 }, |
| 234 |
{ NRES, R16 }, |
| 235 |
{ 0 } |
| 236 |
}; |
| 237 |
return s; |
| 238 |
} else if (q->lshape == SAREG) { |
| 239 |
static struct rspecial s[] = { |
| 240 |
{ NLEFT, R0 }, |
| 241 |
{ NRIGHT, R1 }, |
| 242 |
{ NRES, R0 }, |
| 243 |
{ 0 } |
| 244 |
}; |
| 245 |
return s; |
| 246 |
} |
| 247 |
case LS: |
| 248 |
case RS: |
| 249 |
if (q->lshape == SBREG) { |
| 250 |
static struct rspecial s[] = { |
| 251 |
{ NLEFT, R16 }, |
| 252 |
{ NRIGHT, R2 }, |
| 253 |
{ NRES, R16 }, |
| 254 |
{ 0 } |
| 255 |
}; |
| 256 |
return s; |
| 257 |
} else if (q->lshape == SAREG) { |
| 258 |
static struct rspecial s[] = { |
| 259 |
{ NLEFT, R0 }, |
| 260 |
{ NRIGHT, R1 }, |
| 261 |
{ NRES, R0 }, |
| 262 |
{ 0 } |
| 263 |
}; |
| 264 |
return s; |
| 265 |
} |
| 266 |
case STASG: |
| 267 |
{ |
| 268 |
static struct rspecial s[] = { |
| 269 |
{ NEVER, R0 }, |
| 270 |
{ NRIGHT, R1 }, |
| 271 |
{ NEVER, R2 }, |
| 272 |
{ 0 } }; |
| 273 |
return s; |
| 274 |
} |
| 275 |
break; |
| 276 |
|
| 277 |
default: |
| 278 |
break; |
| 279 |
} |
| 280 |
|
| 281 |
#ifdef PCC_DEBUG |
| 282 |
comperr("nspecial entry %d [0x%x]: %s", q - table, q->op, q->cstring); |
| 283 |
#endif |
| 284 |
return 0; |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
int |
| 292 |
setorder(NODE *p) |
| 293 |
{ |
| 294 |
return 0; |
| 295 |
} |
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
int * |
| 302 |
livecall(NODE *p) |
| 303 |
{ |
| 304 |
static int r[] = { R3, R2, R1, R0, -1 }; |
| 305 |
int num = 1; |
| 306 |
|
| 307 |
if (p->n_op != CALL && p->n_op != FORTCALL && p->n_op != STCALL) |
| 308 |
return &r[4-0]; |
| 309 |
|
| 310 |
for (p = p->n_right; p->n_op == CM; p = p->n_left) |
| 311 |
num += szty(p->n_right->n_type); |
| 312 |
num += szty(p->n_right->n_type); |
| 313 |
|
| 314 |
num = (num > 4 ? 4 : num); |
| 315 |
|
| 316 |
return &r[4 - num]; |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
int |
| 323 |
acceptable(struct optab *op) |
| 324 |
{ |
| 325 |
return features(op->visit & 0xffff0000); |
| 326 |
} |