Debian Codegraph @

arch/pdp7/order.c

raw symbols SCIP
1 /* $Id: order.c,v 1.6 2017/02/16 18:55:31 ragge Exp $ */
2 /*
3 * Copyright (c) 2017 Anders Magnusson ([email protected]).
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 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27
28 # include "pass2.h"
29
30 #include <string.h>
31
32 int 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 */
37 int
38 notoff(TWORD t, int r, CONSZ off, char *cp)
39 {
40 return(1); /* NO */
41 }
42
43 /*
44 * Turn a UMUL-referenced node into OREG.
45 * Be careful about register classes, this is a place where classes change.
46 */
47 void
48 offstar(NODE *p, int shape)
49 {
50
51 if (x2debug)
52 printf("offstar(%p)\n", p);
53
54 if (isreg(p) == 0)
55 (void)geninsn(p, INBREG);
56 }
57
58 /*
59 * Do the actual conversion of offstar-found OREGs into real OREGs.
60 */
61 void
62 myormake(NODE *q)
63 {
64 if (x2debug)
65 printf("myormake(%p)\n", q);
66
67 #if 0
68 p = q->n_left;
69 if (p->n_op == PLUS && (r = p->n_right)->n_op == LS &&
70 r->n_right->n_op == ICON && getlval(r->n_right) == 2 &&
71 p->n_left->n_op == REG && r->n_left->n_op == REG) {
72 q->n_op = OREG;
73 setlval(q, 0);
74 q->n_rval = R2PACK(p->n_left->n_rval, r->n_left->n_rval, 0);
75 tfree(p);
76 }
77 #endif
78 }
79
80 /*
81 * Shape matches for UMUL. Cooperates with offstar().
82 */
83 int
84 shumul(NODE *p, int shape)
85 {
86
87 if (x2debug) {
88 printf("shumul(%p)\n", p);
89 fwalk(p, e2print, 0);
90 }
91
92 if (shape & SOREG)
93 return SROREG;
94 if ((shape & STARNM) && (p->n_op == NAME))
95 return SRDIR;
96 if (shape & STARREG)
97 return SROREG;
98 return SRNOPE;
99 }
100
101 /*
102 * Rewrite operations on binary operators (like +, -, etc...).
103 * Called as a result of table lookup.
104 */
105 int
106 setbin(NODE *p)
107 {
108
109 if (x2debug)
110 printf("setbin(%p)\n", p);
111 return 0;
112
113 }
114
115 /* setup for assignment operator */
116 int
117 setasg(NODE *p, int cookie)
118 {
119 if (x2debug)
120 printf("setasg(%p)\n", p);
121 return(0);
122 }
123
124 /* setup for unary operator */
125 int
126 setuni(NODE *p, int cookie)
127 {
128 return 0;
129 }
130
131 /*
132 * Special handling of some instruction register allocation.
133 */
134 struct rspecial *
135 nspecial(struct optab *q)
136 {
137 switch (q->op) {
138 case ASSIGN:
139 if (q->lshape == STARREG && q->rshape == SNAME) {
140 static struct rspecial s[] = {
141 { NEVER, AC }, { NRES, AC }, { 0 }
142 };
143 return s;
144 }
145 break;
146 default:
147 comperr("nspecial entry %d", q - table);
148 }
149 return 0;
150 }
151
152 /*
153 * Set evaluation order of a binary node if it differs from default.
154 */
155 int
156 setorder(NODE *p)
157 {
158 return 0; /* nothing differs on x86 */
159 }
160
161 /*
162 * set registers in calling conventions live.
163 */
164 int *
165 livecall(NODE *p)
166 {
167 static int r[] = { -1 };
168 return r;
169 }
170
171 /*
172 * Signal whether the instruction is acceptable for this target.
173 */
174 int
175 acceptable(struct optab *op)
176 {
177 if (msettings & M_CHAR18) {
178 if (op->visit & USECHAR18)
179 return 1;
180 else if (op->visit & USECHAR9)
181 return 0;
182 } else {
183 if (op->visit & USECHAR18)
184 return 0;
185 else if (op->visit & USECHAR9)
186 return 1;
187 }
188 return 1;
189 }