Subversion Repositories tendra.SVN

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/* 	$Id: special.c,v 1.1.1.1 1998/01/17 15:56:01 release Exp $	 */
32
 
33
#ifndef lint
34
static char vcid[] = "$Id: special.c,v 1.1.1.1 1998/01/17 15:56:01 release Exp $";
35
#endif /* lint */
36
 
37
/*
38
   special.c
39
   inlines some of the simpler standard library functions
40
*/
41
 
42
/*
43
$Log: special.c,v $
44
 * Revision 1.1.1.1  1998/01/17  15:56:01  release
45
 * First version to be checked into rolling release.
46
 *
47
 * Revision 1.3  1995/08/21  08:46:29  john
48
 * Changed include files
49
 *
50
 * Revision 1.2  1995/03/29  14:06:06  john
51
 * Changes to keep tcheck happy
52
 *
53
 * Revision 1.1.1.1  1995/03/23  10:39:22  john
54
 * Entered into CVS
55
 *
56
 * Revision 1.5  1995/03/23  10:14:26  john
57
 * Minor change
58
 *
59
 * Revision 1.4  1995/01/31  14:25:53  john
60
 * Removed dead variable
61
 *
62
*/
63
 
64
#include "config.h"
65
#include "expmacs.h"
66
#include "addresstypes.h"
67
#include "shapemacs.h"
68
#include "move.h"
69
#include "pseudo.h"
70
#include "getregs.h"
71
#include "guard.h"
72
#include "code_here.h"
73
#include "inst_fmt.h"
74
#include "alpha_ins.h"
75
#include "labels.h"
76
#include "tags.h"
77
#include "procrectypes.h"
78
#include "bitsmacs.h"
79
#include "common_types.h"
80
#include "reg_defs.h"
81
#include "fail.h"
82
#include "special.h"
83
 
84
 
85
int   specno
86
    PROTO_N ( (n) )
87
    PROTO_T ( char *n )
88
{
89
	/* these are the procs I could do
90
				   something about */
91
  if    (strcmp (n, "strcpy") == 0)
92
          return - 1;
93
  if (strcmp (n, "strlen") == 0)
94
    return 2;
95
  if (strcmp (n, "strcmp") == 0)
96
    return - 3;
97
  return 0;
98
}
99
 
100
static  needs strcpyneeds = {
101
  0, 0, 0, 0
102
};
103
static  needs strlenneeds = {
104
  2, 0, uses2_bit, 0
105
};
106
static  needs strcmpneeds = {
107
  2, 0, 0, 0
108
};
109
 
110
needs specialneeds
111
    PROTO_N ( (i) )
112
    PROTO_T ( int i )
113
{
114
    /* these are the needs for their expansion */
115
  switch (i) {
116
    case 1: 
117
      return strcpyneeds;
118
    case 2: 
119
      return strlenneeds;
120
    case 3: 
121
      return strcmpneeds;
122
    default: 
123
	failer ("not special fn");
124
  }
125
  return strcpyneeds;
126
}
127
 
128
int   specialfn
129
    PROTO_N ( (fn) )
130
    PROTO_T ( exp fn )
131
{
132
    /* could I treat this function load specially ? */
133
  if (name (fn) == name_tag && name (son (fn)) == ident_tag &&
134
      isglob (son (fn)) && son (son (fn)) == nilexp) {
135
    char *extname = brog(son (fn)) -> dec_u.dec_val.dec_id;
136
    return specno (extname);
137
  }
138
  return 0;
139
}
140
 
141
 
142
int   specialmake
143
    PROTO_N ( (n, par, sp, dest, exitlab) )
144
    PROTO_T ( int n X exp par X space sp X where dest X int exitlab )
145
{
146
  switch (n) {
147
    case  2: 		/* translate strlen in the obvious manner 
148
				*/
149
      {
150
	      where w;
151
	int   lstart = new_label ();
152
	int   r;
153
	int   r1;
154
	setregalt (w.answhere, AT);
155
	w.ashwhere = ashof (sh (par));
156
	code_here (par, sp, w);
157
	r = (dest.answhere.discrim == inreg) ? regalt (dest.answhere)
158
	  : getreg (sp.fixed);
159
	r1 = getreg (guardreg (r, sp).fixed);
160
	if (r == 0) {
161
	  r = 2;
162
	}
163
	      operate_fmt_immediate(i_addq,AT,1,r);
164
	      /*rri_ins (i_addq, r, 3, 1);*/
165
	set_label (lstart);
166
 
167
/*	ls_ins (i_lb, r1, ind3);
168
	rri_ins (i_add, 3, 3, 1);*/
169
/*	condr_ins (i_bnez, r1, lstart);
170
 
171
	operate_fmt (i_sub, r, 3, r);
172
	setregalt (aa, r);
173
	move (aa, dest, sp, 1);*/
174
	return exitlab;
175
      }
176
    default: 
177
	failer ("not special");
178
  }
179
  return exitlab;
180
}