| @@ -1,15 +1,15 @@ | | | @@ -1,15 +1,15 @@ |
1 | /* Id: pftn.c,v 1.280 2010/05/23 19:52:04 ragge Exp */ | | 1 | /* Id: pftn.c,v 1.280 2010/05/23 19:52:04 ragge Exp */ |
2 | /* $NetBSD: pftn.c,v 1.5 2010/06/03 19:07:59 plunky Exp $ */ | | 2 | /* $NetBSD: pftn.c,v 1.6 2011/08/10 08:08:39 plunky Exp $ */ |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se). | | 4 | * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se). |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
15 | * | | 15 | * |
| @@ -3046,76 +3046,76 @@ imop(int op, NODE *l, NODE *r) | | | @@ -3046,76 +3046,76 @@ imop(int op, NODE *l, NODE *r) |
3046 | if (ISITY(l->n_type)) | | 3046 | if (ISITY(l->n_type)) |
3047 | li = 1, l->n_type = l->n_type - (FIMAG-FLOAT); | | 3047 | li = 1, l->n_type = l->n_type - (FIMAG-FLOAT); |
3048 | if (ISITY(r->n_type)) | | 3048 | if (ISITY(r->n_type)) |
3049 | ri = 1, r->n_type = r->n_type - (FIMAG-FLOAT); | | 3049 | ri = 1, r->n_type = r->n_type - (FIMAG-FLOAT); |
3050 | | | 3050 | |
3051 | if (op == ASSIGN) | | 3051 | if (op == ASSIGN) |
3052 | cerror("imop ASSIGN"); | | 3052 | cerror("imop ASSIGN"); |
3053 | | | 3053 | |
3054 | mxtyp = maxtyp(l, r); | | 3054 | mxtyp = maxtyp(l, r); |
3055 | switch (op) { | | 3055 | switch (op) { |
3056 | case PLUS: | | 3056 | case PLUS: |
3057 | if (li && ri) { | | 3057 | if (li && ri) { |
3058 | p = buildtree(PLUS, l, r); | | 3058 | p = buildtree(PLUS, l, r); |
3059 | p->n_type = p->n_type += (FIMAG-FLOAT); | | 3059 | p->n_type += (FIMAG-FLOAT); |
3060 | } else { | | 3060 | } else { |
3061 | /* If one is imaginary and one is real, make complex */ | | 3061 | /* If one is imaginary and one is real, make complex */ |
3062 | if (li) | | 3062 | if (li) |
3063 | q = l, l = r, r = q; /* switch */ | | 3063 | q = l, l = r, r = q; /* switch */ |
3064 | q = cxstore(mxtyp); | | 3064 | q = cxstore(mxtyp); |
3065 | p = buildtree(ASSIGN, | | 3065 | p = buildtree(ASSIGN, |
3066 | structref(ccopy(q), DOT, real), l); | | 3066 | structref(ccopy(q), DOT, real), l); |
3067 | p = comop(p, buildtree(ASSIGN, | | 3067 | p = comop(p, buildtree(ASSIGN, |
3068 | structref(ccopy(q), DOT, imag), r)); | | 3068 | structref(ccopy(q), DOT, imag), r)); |
3069 | p = comop(p, q); | | 3069 | p = comop(p, q); |
3070 | } | | 3070 | } |
3071 | break; | | 3071 | break; |
3072 | | | 3072 | |
3073 | case MINUS: | | 3073 | case MINUS: |
3074 | if (li && ri) { | | 3074 | if (li && ri) { |
3075 | p = buildtree(MINUS, l, r); | | 3075 | p = buildtree(MINUS, l, r); |
3076 | p->n_type = p->n_type += (FIMAG-FLOAT); | | 3076 | p->n_type += (FIMAG-FLOAT); |
3077 | } else if (li) { | | 3077 | } else if (li) { |
3078 | q = cxstore(mxtyp); | | 3078 | q = cxstore(mxtyp); |
3079 | p = buildtree(ASSIGN, structref(ccopy(q), DOT, real), | | 3079 | p = buildtree(ASSIGN, structref(ccopy(q), DOT, real), |
3080 | buildtree(UMINUS, r, NIL)); | | 3080 | buildtree(UMINUS, r, NIL)); |
3081 | p = comop(p, buildtree(ASSIGN, | | 3081 | p = comop(p, buildtree(ASSIGN, |
3082 | structref(ccopy(q), DOT, imag), l)); | | 3082 | structref(ccopy(q), DOT, imag), l)); |
3083 | p = comop(p, q); | | 3083 | p = comop(p, q); |
3084 | } else /* if (ri) */ { | | 3084 | } else /* if (ri) */ { |
3085 | q = cxstore(mxtyp); | | 3085 | q = cxstore(mxtyp); |
3086 | p = buildtree(ASSIGN, | | 3086 | p = buildtree(ASSIGN, |
3087 | structref(ccopy(q), DOT, real), l); | | 3087 | structref(ccopy(q), DOT, real), l); |
3088 | p = comop(p, buildtree(ASSIGN, | | 3088 | p = comop(p, buildtree(ASSIGN, |
3089 | structref(ccopy(q), DOT, imag), | | 3089 | structref(ccopy(q), DOT, imag), |
3090 | buildtree(UMINUS, r, NIL))); | | 3090 | buildtree(UMINUS, r, NIL))); |
3091 | p = comop(p, q); | | 3091 | p = comop(p, q); |
3092 | } | | 3092 | } |
3093 | break; | | 3093 | break; |
3094 | | | 3094 | |
3095 | case MUL: | | 3095 | case MUL: |
3096 | p = buildtree(MUL, l, r); | | 3096 | p = buildtree(MUL, l, r); |
3097 | if (li && ri) | | 3097 | if (li && ri) |
3098 | p = buildtree(UMINUS, p, NIL); | | 3098 | p = buildtree(UMINUS, p, NIL); |
3099 | if (li ^ ri) | | 3099 | if (li ^ ri) |
3100 | p->n_type = p->n_type += (FIMAG-FLOAT); | | 3100 | p->n_type += (FIMAG-FLOAT); |
3101 | break; | | 3101 | break; |
3102 | | | 3102 | |
3103 | case DIV: | | 3103 | case DIV: |
3104 | p = buildtree(DIV, l, r); | | 3104 | p = buildtree(DIV, l, r); |
3105 | if (ri && !li) | | 3105 | if (ri && !li) |
3106 | p = buildtree(UMINUS, p, NIL); | | 3106 | p = buildtree(UMINUS, p, NIL); |
3107 | if (li ^ ri) | | 3107 | if (li ^ ri) |
3108 | p->n_type = p->n_type += (FIMAG-FLOAT); | | 3108 | p->n_type += (FIMAG-FLOAT); |
3109 | break; | | 3109 | break; |
3110 | default: | | 3110 | default: |
3111 | cerror("imop"); | | 3111 | cerror("imop"); |
3112 | p = NULL; | | 3112 | p = NULL; |
3113 | } | | 3113 | } |
3114 | return p; | | 3114 | return p; |
3115 | } | | 3115 | } |
3116 | | | 3116 | |
3117 | NODE * | | 3117 | NODE * |
3118 | cxelem(int op, NODE *p) | | 3118 | cxelem(int op, NODE *p) |
3119 | { | | 3119 | { |
3120 | | | 3120 | |
3121 | if (ANYCX(p)) { | | 3121 | if (ANYCX(p)) { |