summaryrefslogtreecommitdiff
path: root/misc/pascal/insn32/include/builtins.h
blob: c60e44eea2b4af62a249de6d7b1ba75d22119d9c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
/***********************************************************************
 * builtins.h
 * Definitions of built-in function calls.
 *
 *   Copyright (C) 2008 Gregory Nutt. All rights reserved.
 *   Author: Gregory Nutt <spudmonkey@racsa.co.cr>
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 * 3. Neither the name NuttX nor the names of its contributors may be
 *    used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 *
 ***********************************************************************/

#ifndef __BUILTINS_H
#define __BUILTINS_H

/***********************************************************************
 * Definitions
 ***********************************************************************/

#define MAX_BUILTIN_ARGS 3

#define ILLEGAL_BUILTIN_INIT \
    { NULL, 0, 0, { 0 }}

/* SYSIO built-ins ****************y*************************************/

/* boolean _xeof(fileno); */
#define xEOF_INIT \
    { "_xeof", sBOOLEAN_SIZE, 1, { sINT_SIZE }}

/* boolean _xeoln(fileno); */
#define xEOLN_INIT \
    { "_xeoln", sBOOLEAN_SIZE, 1, { sINT_SIZE }}

/* void _xreset(int fileno); */
#define xRESET_INIT \
    { "_xreset", 0, 1, { sINT_SIZE }}

/* void _xrewrite(int fileno); */
#define xREWRITE_INIT \
    { "_xrewrite", 0, 1, { sINT_SIZE }}

/* void _xreadln(int fileno); */
#define xREADLN_INIT \
    { "_xreadln", 0, 1, { sINT_SIZE }}

#define xREAD_PAGE_INIT ILLEGAL_BUILTIN_INIT

/* void _xread_binary(int fileno, char *buffer, int buffersize); */
#define xREAD_BINARY_INIT \
    { "_xread_binary", 0, 3, { sINT_SIZE, sPTR_SIZE, sINT_SIZE }}

/* void _xread_int(int fileno, int *value); */
#define xREAD_INT_INIT \
    { "_xread_int", 0, 2, { sINT_SIZE, sPTR_SIZE }}

/* void _xread_char(int fileno, char *value); */
#define xREAD_CHAR_INIT \
    { "_xread_char", 0, 2, { sINT_SIZE, sPTR_SIZE }}

/* void _xread_string(int fileno, char *string, int stringsize); */
#define xREAD_STRING_INIT \
    { "_xread_string", 0, 3, { sINT_SIZE, sPTR_SIZE, sINT_SIZE }}

/* void _xread_real(int fileno, real *value); */
#define xREAD_REAL_INIT \
    { "_xread_real", 0, 2, { sINT_SIZE, sPTR_SIZE }}

/* void _xwriteln(int fileno); */
#define xWRITELN_INIT \
    { "_xwriteln", 0, 1, { sINT_SIZE }}

/* void _xwrite_page(int fileno); */
#define xWRITE_PAGE_INIT \
    { "_xwrite_page", 0, 1, { sINT_SIZE }}

/* void _write_binary(int fileno, char *buffer, int buffersize); */
#define xWRITE_BINARY_INIT \
    { "_xwrite_binary", 0, 3, { sINT_SIZE, sPTR_SIZE, sINT_SIZE }}

/* void _write_int(int fileno, int value); */
#define xWRITE_INT_INIT \
    { "_xwrite_int", 0, 2, { sINT_SIZE, sINT_SIZE }}

/* void _write_char(int fileno, int value); */
#define xWRITE_CHAR_INIT \
    { "_xwrite_char", 0, 2, { sINT_SIZE, sINT_SIZE }}

/* void _write_string(int fileno, char *string, int stringsize); */
#define xWRITE_STRING_INIT \
    { "_xwrite_string", 0, 3, { sINT_SIZE, sPTR_SIZE, sINT_SIZE }}

/* void _write_real(int fileno, real value); */
#define xWRITE_REAL_INIT \
    { "_xwrite_real", 0, 2, { sINT_SIZE, sREAL_SIZE }}

/* Runtime library built-ins *******************************************/
/* string _lbgetenv(string *name); */
#define lbGETENV_INIT \
    { "_lbgetenv", sRSTRING_SIZE, 1, { sRSTRING_SIZE }}

/* void _lbstr2str(string src, string dest); */
#define lbSTR2STR_INIT \
    { "_lbstgr2str", 0, 2, { sRSTRING_SIZE, sRSTRING_SIZE }}

/* void _lbcstr2str(string src, string dest); */
#define lbCSTR2STR_INIT \
    { "_lbcstr2str", 0, 2, { sRSTRING_SIZE, sRSTRING_SIZE }}

/* void _libstr2rstr(string src, string dest); */
#define lbSTR2RSTR_INIT \
    { "_lbstr2rstr", 0, 2, { sRSTRING_SIZE, sRSTRING_SIZE }}

/* void _lbcstr2str(string src, string dest); */
#define lbCSTR2RSTR_INIT \
    { "_lbcstr2rstr", 0, 2, { sRSTRING_SIZE, sRSTRING_SIZE }}

/* void _lbval(const string s, int *v, int *code); */
#define lbVAL_INIT \
    { "_lbval", 0, 2, { sRSTRING_SIZE, sPTR_SIZE, sPTR_SIZE }}

/* string _lbmkstk(void); */
#define lbMKSTK_INIT \
    { "_lbmkstk",  sRSTRING_SIZE, 0, { 0 }}

/* string mkstkstr(string name); */
#define lbMKSTKSTR_INIT \
    { "_lbmkstkstr",  sRSTRING_SIZE, 1, { sRSTRING_SIZE }}

/* string _lbmkstkc(int c); */
#define lbMKSTKC_INIT \
    { "_lbmkstkc",  sRSTRING_SIZE, 1, { sINT_SIZE }}

/* string _lbstgrcat(string name, int c); */
#define lbSTRCAT_INIT \
    { "_lbstrcat",  sRSTRING_SIZE, 2, { sRSTRING_SIZE, sINT_SIZE }}

/* string _lbstrcatc(string name, int c); */
#define lbSTRCATC_INIT \
    { "_lbstrcatc",  sRSTRING_SIZE, 2, { sRSTRING_SIZE, sINT_SIZE }}

/* int _lbstrcmp(string name1, string name2); */
#define lbSTRCMP_INIT \
    { "_lbstrcmp", sINT_SIZE, 2, { sRSTRING_SIZE, sRSTRING_SIZE }}

/* Floating point library built-ins ************************************/

/* real _fpfloat(int v); */
#define fpFLOAT_INIT \
    { "_fpfloat", sREAL_SIZE, 1, { sINT_SIZE }}

/* int _fptrunc(real v); */
#define fpTRUNC_INIT \
    { "_fptrunc", sINT_SIZE, 1, { sREAL_SIZE }}

/* int _fpround(real v); */
#define fpROUND_INIT \
    { "_fpround", sINT_SIZE, 1, { sREAL_SIZE }}

/* real _fpadd_rr(real a, real b); */
#define fpADD_RR_INIT \
    { "_fpadd_rr", sREAL_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* real _fpadd_ri(int a, real b); */
#define fpADD_RI_INIT \
    { "_fpadd_ri", sREAL_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* real _fpadd_ir(real a, int b); */
#define fpADD_IR_INIT \
    { "_fpadd_ir", sREAL_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* real _fpadd_ii(int a, int b); */
#define fpADD_II_INIT \
    { "_fpadd_ii", sREAL_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* real _fpsub_rr(real a, real b); */
#define fpSUB_RR_INIT \
    { "_fpsub_rr", sREAL_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* real _fpsub_ri(int a, real b); */
#define fpSUB_RI_INIT \
    { "_fpsub_ri", sREAL_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* real _fpsub_ir(real a, int b); */
#define fpSUB_IR_INIT \
    { "_fpsub_ir", sREAL_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* real _fpsub_ii(int a, int b); */
#define fpSUB_II_INIT \
    { "_fpsub_ii", sREAL_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* real _fpmul_rr(real a, real b); */
#define fpMUL_RR_INIT \
    { "_fpmul_rr", sREAL_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* real _fpmul_ri(int a, real b); */
#define fpMUL_RI_INIT \
    { "_fpmul_ri", sREAL_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* real _fpmul_ir(real a, int b); */
#define fpMUL_IR_INIT \
    { "_fpmul_ir",sREAL_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* real _fpmul_ii(int a, int b); */
#define fpMUL_II_INIT \
    { "_fpmul_ii", sREAL_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* real _fpdiv_rr(real a, real b); */
#define fpDIV_RR_INIT \
    { "_fpdiv_rr", sREAL_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* real _fpdiv_ri(int a, real b); */
#define fpDIV_RI_INIT \
    { "_fpdiv_ri",sREAL_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* real _fpdiv_ir(real a, int b); */
#define fpDIV_IR_INIT \
    { "_fpdiv_ir",sREAL_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* real _fpdiv_ii(int a, int b); */
#define fpDIV_II_INIT \
    { "_fpdiv_ii",sREAL_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* real _fpmod_rr(real a, real b); */
#define fpMOD_RR_INIT \
    { "_fpmod_rr", sREAL_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* real _fpmod_ri(int a, real b); */
#define fpMOD_RI_INIT \
    { "_fpmod_ri", sREAL_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* real _fpmod_ir(real a, int b); */
#define fpMOD_IR_INIT \
    { "_fpmod_ir", sREAL_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* real _fpmod_ii(int a, int b); */
#define fpMOD_II_INIT \
    { "_fpmod_ii", sREAL_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* boolean _fpequ_rr(real a, real b); */
#define fpEQU_RR_INIT \
    { "_fpequ_rr", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* boolean _fpequ_ri(int a, real b); */
#define fpEQU_RI_INIT \
    { "_fpequ_ri", sBOOLEAN_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* boolean _fpequ_ir(real a, int b); */
#define fpEQU_IR_INIT \
    { "_fpequ_ir", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* boolean _fpequ_ii(int a, int b); */
#define fpEQU_II_INIT \
    { "_fpequ_ii", sBOOLEAN_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* boolean _fpneq_rr(real a, real b); */
#define fpNEQ_RR_INIT \
    { "_fpneq_rr", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* boolean _fpneq_ri(int a, real b); */
#define fpNEQ_RI_INIT \
    { "_fpneq_ri", sBOOLEAN_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* boolean _fpneq_ir(real a, int b); */
#define fpNEQ_IR_INIT \
    { "_fpneq_ir", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* boolean _fpneq_ii(int a, int b); */
#define fpNEQ_II_INIT \
    { "_fpneq_ii", sBOOLEAN_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* boolean _fplt_rr(real a, real b); */
#define fpLT_RR_INIT \
    { "_fplt_rr", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* boolean _fplt_ri(int a, real b); */
#define fpLT_RI_INIT \
    { "_fplt_ri", sBOOLEAN_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* boolean _fplt_ir(real a, int b); */
#define fpLT_IR_INIT \
    { "_fplt_ir", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* boolean _fplt_ii(int a, int b); */
#define fpLT_II_INIT \
    { "_fplt_ii", sBOOLEAN_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* boolean _fpgte_rr(real a, real b); */
#define fpGTE_RR_INIT \
    { "_fpgte_rr", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* boolean _fpgte_ri(int a, real b); */
#define fpGTE_RI_INIT \
    { "_fpgte_ri", sBOOLEAN_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* boolean _fpgte_ir(real a, int b); */
#define fpGTE_IR_INIT \
    { "_fpgte_ir", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* boolean _fpgte_ii(int a, int b); */
#define fpGTE_II_INIT \
    { "_fpgte_ii", sBOOLEAN_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* boolean _fpgt_rr(real a, real b); */
#define fpGT_RR_INIT \
    { "_fpgt_rr", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* boolean _fpgt_ri(int a, real b); */
#define fpGT_RI_INIT \
    { "_fpgt_ri", sBOOLEAN_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* boolean _fpgt_ir(real a, int b); */
#define fpGT_IR_INIT \
    { "_fpgt_ir", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* boolean _fpgt_ii(int a, int b); */
#define fpGT_II_INIT \
    { "_fpgt_ii", sBOOLEAN_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* boolean _fplte_rr(real a, real b); */
#define fpLTE_RR_INIT \
    { "_fplte_rr", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sREAL_SIZE }}

/* boolean _fplte_ri(int a, real b); */
#define fpLTE_RI_INIT \
    { "_fplte_ri", sBOOLEAN_SIZE, 2, { sINT_SIZE, sREAL_SIZE }}

/* boolean _fplte_ir(real a, int b); */
#define fpLTE_IR_INIT \
    { "_fplte_ir", sBOOLEAN_SIZE, 2, { sREAL_SIZE, sINT_SIZE }}

/* boolean _fplte_ii(int a, int b); */
#define fpLTE_II_INIT \
    { "_fplte_ii", sBOOLEAN_SIZE, 2, { sINT_SIZE, sINT_SIZE }}

/* real _fpneg_r(real v); */
#define fpNEG_R_INIT \
    { "_fpneg_r", sREAL_SIZE, 1, { sREAL_SIZE }}

/* real _fpneg_i(int v); */
#define fpNEG_I_INIT \
    { "_fpneg_i", sREAL_SIZE, 1, { sINT_SIZE }}

/* real _fpabs_r(real v); */
#define fpABS_R_INIT \
    { "_fpabs_r", sREAL_SIZE, 1, { sREAL_SIZE }}

/* real _fpabs_i(int v); */
#define fpABS_I_INIT \
    { "_fpabs_i", sREAL_SIZE, 1, { sINT_SIZE }}

/* real _fpsqr_r(real v); */
#define fpSQR_R_INIT \
    { "_fpsqr_r", sREAL_SIZE, 1, { sREAL_SIZE }}

/* real _fpsqr_i(int v); */
#define fpSQR_I_INIT \
    { "_fpsqr_i", sREAL_SIZE, 1, { sINT_SIZE }}

/* real _fpsqrt_r(real v); */
#define fpSQRT_R_INIT \
    { "_fpsqrt_r", sREAL_SIZE, 1, { sREAL_SIZE }}

/* real _fpsqrt_i(int v); */
#define fpSQRT_I_INIT \
    { "_fpsqrt_i", sREAL_SIZE, 1, { sINT_SIZE }}

/* real _fpsin_r(real v); */
#define fpSIN_R_INIT \
    { "_fpsin_r", sREAL_SIZE, 1, { sREAL_SIZE }}

/* real _fpsin_i(int v); */
#define fpSIN_I_INIT \
    { "_fpsin_i", sREAL_SIZE, 1, { sINT_SIZE }}

/* real _fpcos_r(real v); */
#define fpCOS_R_INIT \
    { "_fpcos_r", sREAL_SIZE, 1, { sREAL_SIZE }}

/* real _fpcos_i(int v); */
#define fpCOS_I_INIT \
    { "_fpcos_i", sREAL_SIZE, 1, { sINT_SIZE }}

/* real _fpatan_r(real v); */
#define fpATAN_R_INIT \
    { "_fpatan_r", sREAL_SIZE, 1, { sREAL_SIZE }}

/* real _fpatan_i(int v); */
#define fpATAN_I_INIT \
    { "_fpatan_i", sREAL_SIZE, 1, { sINT_SIZE }}

/* real _fpln_r(real v); */
#define fpLN_R_INIT \
    { "_fpln_r", sREAL_SIZE, 1, { sREAL_SIZE }}

/* real _fpln_i(int v); */
#define fpLN_I_INIT \
    { "_fpln_i", sREAL_SIZE, 1, { sINT_SIZE }}

/* real _fpexp_r(real v); */
#define fpEXP_R_INIT \
    { "_fpexpr_r", sREAL_SIZE, 1, { sREAL_SIZE }}

/* real _fpexp_i(int v); */
#define fpEXP_I_INIT \
    { "_fpexpr_i", sREAL_SIZE, 1, { sINT_SIZE }}

/***********************************************************************
 * Public Types
 ***********************************************************************/

struct regm_builtin_s
{
  const char *szName;
  uint32      wRetSize;
  uint32      nParms;
  uint32      wArgSize[MAX_BUILTIN_ARGS];
};

#endif /* __BUILTINS_H */