* add p cc
[mascara-docs.git] / compilers / pcc / pcc-1.0.0 / arch / pdp10 / order.c
blob1f695df2e20293b323e82ab896f9e76a8b90352a
1 /* $Id: order.c,v 1.63 2008/01/15 21:47:06 ragge Exp $ */
2 /*
3 * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 # include "pass2.h"
32 int canaddr(NODE *);
34 /* is it legal to make an OREG or NAME entry which has an
35 * offset of off, (from a register of r), if the
36 * resulting thing had type t */
37 int
38 notoff(TWORD t, int r, CONSZ off, char *cp)
40 return(0); /* YES */
43 int radebug = 0;
45 void
46 offstar(NODE *p, int shape)
48 NODE *q;
50 if (x2debug)
51 printf("offstar(%p)\n", p);
53 if( p->n_op == PLUS || p->n_op == MINUS ){
54 if( p->n_right->n_op == ICON ){
55 q = p->n_left;
56 if (q->n_op != REG)
57 geninsn(q, INAREG);
58 p->n_su = -1;
61 geninsn(p, INAREG);
65 * findops() failed, see if we can rewrite it to match.
67 int
68 setbin(NODE *p)
70 TWORD ty;
71 NODE *r, *s;
73 ty = p->n_type;
74 switch (p->n_op) {
75 case MINUS:
76 switch (ty) {
77 case PTR+CHAR:
78 case PTR+UCHAR:
79 case PTR+SHORT:
80 case PTR+USHORT:
82 * Must negate the right side and change op to PLUS.
84 r = p->n_right;
85 if (r->n_op == ICON) {
86 r->n_lval = -r->n_lval;
87 } else {
88 s = talloc();
89 s->n_type = r->n_type;
90 s->n_op = UMINUS;
91 s->n_left = r;
92 p->n_right = s;
94 p->n_op = PLUS;
95 return 1;
98 return 0;
101 /* setup for assignment operator */
103 setasg(NODE *p, int cookie)
105 return(0);
108 /* setup for unary operator */
110 setuni(NODE *p, int cookie)
112 return 0;
116 special(NODE *p, int shape)
118 switch (shape) {
119 case SUSHCON:
120 if (p->n_op == ICON && p->n_name[0] == '\0' &&
121 (p->n_lval > 0 && p->n_lval <= 0777777))
122 return 1;
123 break;
125 case SNSHCON:
126 if (p->n_op == ICON && p->n_name[0] == '\0' &&
127 (p->n_lval < 0 && p->n_lval > -01000000))
128 return 1;
129 break;
130 case SILDB:
131 if (p->n_op == ASSIGN && p->n_left->n_op == REG &&
132 p->n_right->n_op == PLUS &&
133 p->n_right->n_left->n_op == REG &&
134 p->n_right->n_right->n_op == ICON &&
135 p->n_right->n_right->n_lval == 1 &&
136 p->n_right->n_left->n_rval == p->n_left->n_rval)
137 return 1;
138 break;
140 return 0;
144 * Set evaluation order of a binary node if it differs from default.
147 setorder(NODE *p)
149 return 0; /* nothing differs on x86 */
153 * Special handling of some instruction register allocation.
155 struct rspecial *
156 nspecial(struct optab *q)
158 return 0; /* XXX gcc */
162 * Do the actual conversion of offstar-found OREGs into real OREGs.
164 void
165 myormake(NODE *p)
167 if (x2debug)
168 printf("myormake(%p)\n", p);
172 * set registers in calling conventions live.
174 int *
175 livecall(NODE *p)
177 static int r[8], *s = r;
179 *s = -1;
180 if (p->n_op == UCALL || p->n_op == UFORTCALL || p->n_op == USTCALL ||
181 p->n_op == FORTCALL)
182 return s;
183 for (p = p->n_right; p->n_op == CM; p = p->n_left) {
184 if (p->n_right->n_op == ASSIGN &&
185 p->n_right->n_left->n_op == REG)
186 *s++ = p->n_right->n_left->n_rval;
188 if (p->n_op == ASSIGN &&
189 p->n_left->n_op == REG)
190 *s++ = p->n_left->n_rval;
191 *s = -1;
192 return r;
196 * Signal whether the instruction is acceptable for this target.
199 acceptable(struct optab *op)
201 return 1;