source: mainline/uspace/app/pcc/arch/nova/order.c@ 087c27f6

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 087c27f6 was 711e7fe5, checked in by Prutkov Alex <prutkov.alex@…>, 14 years ago

Added printf module

  • Property mode set to 100755
File size: 4.1 KB
Line 
1/* $Id: order.c,v 1.4 2008/09/27 07:35:23 ragge Exp $ */
2/*
3 * Copyright (c) 2006 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
32#include <string.h>
33
34int canaddr(NODE *);
35
36/* is it legal to make an OREG or NAME entry which has an
37 * offset of off, (from a register of r), if the
38 * resulting thing had type t */
39int
40notoff(TWORD t, int r, CONSZ off, char *cp)
41{
42 if (r != 2 && r != 3)
43 return 1; /* can only index ac2 and ac3 */
44 if (t == CHAR || t == UCHAR) {
45 if (off < -256 || off > 254)
46 return 1;
47 } else if (off < -128 || off > 127)
48 return 1;
49 return(0); /* YES */
50}
51
52/*
53 * Turn a UMUL-referenced node into OREG.
54 * Be careful about register classes, this is a place where classes change.
55 */
56void
57offstar(NODE *p, int shape)
58{
59 NODE *r;
60
61 if (x2debug)
62 printf("offstar(%p)\n", p);
63
64 if (isreg(p))
65 return; /* Is already OREG */
66
67 r = p->n_right;
68 if( p->n_op == PLUS || p->n_op == MINUS ){
69 if( r->n_op == ICON ){
70 if (isreg(p->n_left) == 0 ||
71 (p->n_left->n_op == REG &&
72 p->n_left->n_rval != 2 && p->n_left->n_rval != 3))
73 (void)geninsn(p->n_left, INBREG);
74 /* Converted in ormake() */
75 return;
76 }
77 }
78 (void)geninsn(p, INBREG);
79}
80
81/*
82 * Do the actual conversion of offstar-found OREGs into real OREGs.
83 */
84void
85myormake(NODE *q)
86{
87 if (x2debug)
88 printf("myormake(%p)\n", q);
89}
90
91/*
92 * Shape matches for UMUL. Cooperates with offstar().
93 */
94int
95shumul(NODE *p, int order)
96{
97
98 if (x2debug)
99 printf("shumul(%p)\n", p);
100
101 /* Turns currently anything into OREG on x86 */
102 if (shape & SOREG)
103 return SROREG;
104 return SRNOPE;
105}
106
107/*
108 * Rewrite increment/decrement operation.
109 */
110int
111setincr(NODE *p)
112{
113 if (x2debug)
114 printf("setincr(%p)\n", p);
115
116 return(0);
117}
118
119/*
120 * Rewrite operations on binary operators (like +, -, etc...).
121 * Called as a result of table lookup.
122 */
123int
124setbin(NODE *p)
125{
126
127 if (x2debug)
128 printf("setbin(%p)\n", p);
129 return 0;
130
131}
132
133/* setup for assignment operator */
134int
135setasg(NODE *p, int cookie)
136{
137 if (x2debug)
138 printf("setasg(%p)\n", p);
139 return(0);
140}
141
142/* setup for unary operator */
143int
144setuni(NODE *p, int cookie)
145{
146 return 0;
147}
148
149/*
150 * Special handling of some instruction register allocation.
151 */
152struct rspecial *
153nspecial(struct optab *q)
154{
155 comperr("nspecial entry %d", q - table);
156 return 0; /* XXX gcc */
157}
158
159/*
160 * Set evaluation order of a binary node if it differs from default.
161 */
162int
163setorder(NODE *p)
164{
165 return 0;
166}
167/*
168 * Set registers "live" at function calls (like arguments in registers).
169 * This is for liveness analysis of registers.
170 */
171int *
172livecall(NODE *p)
173{
174 static int r[1] = { -1 }; /* Terminate with -1 */
175
176 return &r[0];
177}
178
179/*
180 * Signal whether the instruction is acceptable for this target.
181 */
182int
183acceptable(struct optab *op)
184{
185 return 1;
186}
Note: See TracBrowser for help on using the repository browser.