source: mainline/uspace/app/pcc/arch/pdp10/order.c@ 814717fa

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 814717fa was a7de7182, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 14 years ago

Added pcc source tree (contents of pcc-1.0.0.tgz)

  • Property mode set to 100644
File size: 4.4 KB
Line 
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.
5 *
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
16 *
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.
27 */
28
29
30# include "pass2.h"
31
32int canaddr(NODE *);
33
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 */
37int
38notoff(TWORD t, int r, CONSZ off, char *cp)
39{
40 return(0); /* YES */
41}
42
43int radebug = 0;
44
45void
46offstar(NODE *p, int shape)
47{
48 NODE *q;
49
50 if (x2debug)
51 printf("offstar(%p)\n", p);
52
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;
59 }
60 }
61 geninsn(p, INAREG);
62}
63
64/*
65 * findops() failed, see if we can rewrite it to match.
66 */
67int
68setbin(NODE *p)
69{
70 TWORD ty;
71 NODE *r, *s;
72
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:
81 /*
82 * Must negate the right side and change op to PLUS.
83 */
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;
93 }
94 p->n_op = PLUS;
95 return 1;
96 }
97 }
98 return 0;
99}
100
101/* setup for assignment operator */
102int
103setasg(NODE *p, int cookie)
104{
105 return(0);
106}
107
108/* setup for unary operator */
109int
110setuni(NODE *p, int cookie)
111{
112 return 0;
113}
114
115int
116special(NODE *p, int shape)
117{
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;
124
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;
139 }
140 return 0;
141}
142
143/*
144 * Set evaluation order of a binary node if it differs from default.
145 */
146int
147setorder(NODE *p)
148{
149 return 0; /* nothing differs on x86 */
150}
151
152/*
153 * Special handling of some instruction register allocation.
154 */
155struct rspecial *
156nspecial(struct optab *q)
157{
158 return 0; /* XXX gcc */
159}
160
161/*
162 * Do the actual conversion of offstar-found OREGs into real OREGs.
163 */
164void
165myormake(NODE *p)
166{
167 if (x2debug)
168 printf("myormake(%p)\n", p);
169}
170
171/*
172 * set registers in calling conventions live.
173 */
174int *
175livecall(NODE *p)
176{
177 static int r[8], *s = r;
178
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;
187 }
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;
193}
194
195/*
196 * Signal whether the instruction is acceptable for this target.
197 */
198int
199acceptable(struct optab *op)
200{
201 return 1;
202}
Note: See TracBrowser for help on using the repository browser.