Quick Search:

Mode

Context

Displaying the whole file. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.1
 
1.1.1.1
 
janeno_1:ragge:20060417132352
 
code.c
_><_11 /*      $Id$    */
 22 /*
 33  * Copyright (c) 2003 Anders Magnusson (ragge@ludd.luth.se).
 44  * All rights reserved.
 55  *
 66  * Redistribution and use in source and binary forms, with or without
 77  * modification, are permitted provided that the following conditions
 88  * are met:
 99  * 1. Redistributions of source code must retain the above copyright
 1010  *    notice, this list of conditions and the following disclaimer.
 1111  * 2. Redistributions in binary form must reproduce the above copyright
 1212  *    notice, this list of conditions and the following disclaimer in the
 1313  *    documentation and/or other materials provided with the distribution.
 1414  * 3. The name of the author may not be used to endorse or promote products
 1515  *    derived from this software without specific prior written permission
 1616  *
 1717  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 1818  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 1919  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 2020  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 2121  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 2222  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 2323  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 2424  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 2525  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 2626  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 2727  */
 2828 
 2929 
 3030 /*
 3131  * MIPS port by Jan Enoksson (janeno-1@student.ltu.se) and
 3232  * Simon Olsson (simols-1@student.ltu.se) 2005.
 3333  */
 3434 
 3535 # include "pass1.h"
 3636 # include "manifest.h"
 3737 
 3838 /* Offset to arguments passed to a function. */
 3939 int passedargoff;
 4040 
 4141 /*
 4242  * cause the alignment to become a multiple of n
 4343  * never called for text segment.
 4444  */
 4545 void
 4646 defalign(int n)
 4747 {
 4848         n /= SZCHAR;
 4949         if (n == 1)
 5050                 return;
 5151         printf("        .align %d\n", n);
 5252 }
 5353 
 5454 /*
 5555  * define the current location as the name p->sname
 5656  * never called for text segment.
 5757  */
 5858 void
 5959 defnam(struct symtab *p)
 6060 {
 6161         char *c = p->sname;
 6262 
 6363 #ifdef GCC_COMPAT
 6464         c = gcc_findname(p);
 6565 #endif
 6666         if (p->sclass == EXTDEF)
 6767                 printf("        .globl %s\n", c);
 6868         printf("%s:\n", c);
 6969 }
 7070 
 7171 
 7272 /*
 7373  * code for the end of a function
 7474  * deals with struct return here
 7575  */
 7676 void
 7777 efcode()
 7878 {
 7979         NODE *p, *q;
 8080         int sz;
 8181 
 8282         if (cftnsp->stype != STRTY+FTN && cftnsp->stype != UNIONTY+FTN)
 8383                 return;
 8484 }
 8585 
 8686 /*
 8787  * helper for bfcode() to put register arguments on stack.
 8888  */
 8989 static void
 9090 argmove(struct symtab *s, int regno)
 9191 {
 9292         NODE *p, *r;
 9393 
 9494         s->sclass = PARAM;
 9595         s->soffset = NOOFFSET;
 9696 
 9797         oalloc(s, &passedargoff);
 9898 
 9999         spname = s;
 100100         p = buildtree(NAME, NIL, NIL);
 101101         r = bcon(0);
 102102         r->n_op = REG;
 103103         r->n_rval = regno;
 104104         r->n_type = p->n_type;
 105105         r->n_sue = p->n_sue;
 106106         r->n_df = p->n_df;
 107107         ecode(buildtree(ASSIGN, p, r));
 108108 }
 109109 
 110110 /*
 111111  * code for the beginning of a function; a is an array of
 112112  * indices in symtab for the arguments; n is the number
 113113  */
 114114 void
 115115 bfcode(struct symtab **a, int n)
 116116 {
 117117         int i, m;
 118118 
 119119         /* Passed arguments start 64 bits above the framepointer. */
 120120         passedargoff = 64;
 121121         
 122122         if (cftnsp->stype == STRTY+FTN || cftnsp->stype == UNIONTY+FTN) {
 123123                 /* Function returns struct, adjust arg offset */
 124124                 for (i = 0; i < n; i++)
 125125                         a[i]->soffset += SZPOINT(INT);
 126126         }
 127127 
 128128         m = n <= 4 ? n : 4;
 129129         
 130130         for(i = 0; i < m; i++) {
 131131             /*
 132132             if(a[i]->stype == LONGLONG || a[i]->stype == ULONGLONG) {
 133133                 printf("longlong\n");
 134134                 argmove(a[i], A0+i);
 135135 
 136136                 if(i+1 < 4) {
 137137                     argmove(a[i], A0+i+1);
 138138                 }
 139139                 
 140140                 i++;            
 141141                 } else*/
 142142             argmove(a[i], A0+i);
 143143 
 144144         }
 145145 }
 146146 
 147147 
 148148 /*
 149149  * by now, the automatics and register variables are allocated
 150150  */
 151151 void
 152152 bccode()
 153153 {
 154154         SETOFF(autooff, SZINT);
 155155 }
 156156 
 157157 /* called just before final exit */
 158158 /* flag is 1 if errors, 0 if none */
 159159 void
 160160 ejobcode(int flag )
 161161 {
 162162 }
 163163 
 164164 void
 165165 bjobcode()
 166166 {
 167167 }
 168168 
 169169 /*
 170170  * Print character t at position i in one string, until t == -1.
 171171  * Locctr & label is already defined.
 172172  */
 173173 void
 174174 bycode(int t, int i)
 175175 {
 176176         static  int     lastoctal = 0;
 177177 
 178178         /* put byte i+1 in a string */
 179179 
 180180         if (t < 0) {
 181181                 if (i != 0)
 182182                         puts("\"");
 183183         } else {
 184184                 if (i == 0)
 185185                         printf("\t.ascii \"");
 186186                 if (t == '\\' || t == '"') {
 187187                         lastoctal = 0;
 188188                         putchar('\\');
 189189                         putchar(t);
 190190                 } else if (t < 040 || t >= 0177) {
 191191                         lastoctal++;
 192192                         printf("\\%o",t);
 193193                 } else if (lastoctal && '0' <= t && t <= '9') {
 194194                         lastoctal = 0;
 195195                         printf("\"\n\t.ascii \"%c", t);
 196196                 } else {        
 197197                         lastoctal = 0;
 198198                         putchar(t);
 199199                 }
 200200         }
 201201 }
 202202 
 203203 /*
 204204  * n integer words of zeros
 205205  */
 206206 void
 207207 zecode(int n)
 208208 {
 209209         printf("        .zero %d\n", n * (SZINT/SZCHAR));
 210210         inoff += n * SZINT;
 211211 }
 212212 
 213213 /*
 214214  * return the alignment of field of type t
 215215  */
 216216 int
 217217 fldal(unsigned int t)
 218218 {
 219219         uerror("illegal field type");
 220220         return(ALINT);
 221221 }
 222222 
 223223 /* fix up type of field p */
 224224 void
 225225 fldty(struct symtab *p)
 226226 {
 227227 }
 228228 
 229229 /* p points to an array of structures, each consisting
 230230  * of a constant value and a label.
 231231  * The first is >=0 if there is a default label;
 232232  * its value is the label number
 233233  * The entries p[1] to p[n] are the nontrivial cases
 234234  * XXX - fix genswitch.
 235235  */
 236236 void
 237237 genswitch(struct swents **p, int n)
 238238 {
 239239 }
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-11-01 10:11 +0100