GNU PROLOG with UTF8 support
ma_protos.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------*
2  * GNU Prolog *
3  * *
4  * Part : mini-assembler to assembler translator *
5  * File : ma_protos.h *
6  * Descr.: code generation - header file *
7  * Author: Daniel Diaz *
8  * *
9  * Copyright (C) 1999-2015 Daniel Diaz *
10  * *
11  * This file is part of GNU Prolog *
12  * *
13  * GNU Prolog is free software: you can redistribute it and/or *
14  * modify it under the terms of either: *
15  * *
16  * - the GNU Lesser General Public License as published by the Free *
17  * Software Foundation; either version 3 of the License, or (at your *
18  * option) any later version. *
19  * *
20  * or *
21  * *
22  * - the GNU General Public License as published by the Free *
23  * Software Foundation; either version 2 of the License, or (at your *
24  * option) any later version. *
25  * *
26  * or both in parallel, as here. *
27  * *
28  * GNU Prolog is distributed in the hope that it will be useful, *
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
31  * General Public License for more details. *
32  * *
33  * You should have received copies of the GNU General Public License and *
34  * the GNU Lesser General Public License along with this program. If *
35  * not, see http://www.gnu.org/licenses/. *
36  *-------------------------------------------------------------------------*/
37 
38 
39 #include "../EnginePl/pl_long.h"
40 
41 #if 0
42 #define CHECK_PRINTF_ARGS
43 #endif
44 
45 #ifdef CHECK_PRINTF_ARGS
46 #define GCCPRINTF(x) __attribute__((format(printf, x, x + 1)))
47 #else
48 #define GCCPRINTF(x)
49 #endif
50 
51 
52 
53 
54 /*---------------------------------*
55  * Constants *
56  *---------------------------------*/
57 
58 /*---------------------------------*
59  * Type Definitions *
60  *---------------------------------*/
61 
62 /*---------------------------------*
63  * Global Variables *
64  *---------------------------------*/
65 
66  /* defined in mapper files */
67 
68 #ifndef MAPPER_FILE
69 
70 extern int can_produce_pic_code;
71 extern char *comment_prefix;
72 extern char *local_symb_prefix;
73 extern int strings_need_null;
74 extern int call_c_reverse_args;
75 extern char *inline_asm_data[];
76 
77 #endif
78 
79 
80  /* defined in ma_parser.c */
81 
82 #ifndef MA_PARSER_FILE
83 
84 extern int reload_e;
85 
86 #endif
87 
88 #ifndef MA2ASM_FILE
89 
90 extern int pic_code;
91 
92 #endif
93 
94 
95 
96 
97 /*---------------------------------*
98  * Function Prototypes *
99  *---------------------------------*/
100 
101 
102  /* defined in ma2asm.c - used by the parser */
103 
105 
106 void Call_C(char *fct_name, int fc, int nb_args, int nb_args_in_words, ArgInf arg[]);
107 
108 void Switch_Ret(int nb_swt, SwtInf swt[]);
109 
110 void Decl_Code(char *name, int prolog, int global);
111 
112 void Decl_Long(char *name, int global, VType vtype, PlLong value);
113 
114 
115 
116 
117 
118  /* defined in ma2asm.c - used by mappers */
119 
120 int Is_Code_Defined(char *name);
121 
122 int Get_Long_Infos(char *name, int *global, VType *vtype, int *value);
123 
124 void Label_Printf(char *label, ...) GCCPRINTF(1);
125 
126 void Inst_Printf(char *op, char *operands, ...) GCCPRINTF(2);
127 
128 void Inst_Out(char *op, char *operands);
129 
130 void Char_Out(char c);
131 
132 void String_Out(char *s);
133 
134 void Int_Out(int d);
135 
136 
137  /* defined in mapper files */
138 
139 void Asm_Start(void);
140 
141 void Asm_Stop(void);
142 
143 void Code_Start(char *label, int prolog, int global);
144 
145 void Code_Stop(void);
146 
147 void Label(char *label);
148 
149 void Reload_E_In_Register(void);
150 
151 void Pl_Jump(char *label);
152 
153 void Prep_CP(void);
154 
155 void Here_CP(void);
156 
157 void Pl_Call(char *label);
158 
159 void Pl_Fail(void);
160 
161 void Pl_Ret(void);
162 
163 void Jump(char *label);
164 
165 void Move_From_Reg_X(int index);
166 
167 void Move_From_Reg_Y(int index);
168 
169 void Move_To_Reg_X(int index);
170 
171 void Move_To_Reg_Y(int index);
172 
173 void Call_C_Start(char *fct_name, int fc, int nb_args,
174  int nb_args_in_words, char **p_inline);
175 
176 int Call_C_Arg_Int(int offset, PlLong int_val);
177 
178 int Call_C_Arg_Double(int offset, double dbl_val);
179 
180 int Call_C_Arg_String(int offset, int str_no);
181 
182 int Call_C_Arg_Mem_L(int offset, int adr_of, char *name, int index);
183 
184 int Call_C_Arg_Reg_X(int offset, int adr_of, int index);
185 
186 int Call_C_Arg_Reg_Y(int offset, int adr_of, int index);
187 
188 int Call_C_Arg_Foreign_L(int offset, int adr_of, int index);
189 
190 int Call_C_Arg_Foreign_D(int offset, int adr_of, int index);
191 
192 void Call_C_Invoke(char *fct_name, int fc, int nb_args, int nb_args_in_words);
193 
194 void Call_C_Stop(char *fct_name, int nb_args, char **p_inline);
195 
196 void Call_C_Adjust_Stack(int nb_pushes);
197 
198 void Jump_Ret(void);
199 
200 void Fail_Ret(void);
201 
202 void Move_Ret_To_Mem_L(char *name, int index);
203 
204 void Move_Ret_To_Reg_X(int index);
205 
206 void Move_Ret_To_Reg_Y(int index);
207 
208 void Move_Ret_To_Foreign_L(int index);
209 
210 void Move_Ret_To_Foreign_D(int index);
211 
212 void Cmp_Ret_And_Int(PlLong int_val);
213 
214 void Jump_If_Equal(char *label);
215 
216 void Jump_If_Greater(char *label);
217 
218 void C_Ret(void);
219 
220 void Dico_String_Start(int nb);
221 
222 void Dico_String(int str_no, char *asciiz);
223 
224 void Dico_String_Stop(int nb);
225 
226 void Dico_Long_Start(int nb);
227 
228 void Dico_Long(char *name, int global, VType vtype, PlLong value);
229 
230 void Dico_Long_Stop(int nb);
231 
232 void Data_Start(char *initializer_fct);
233 
234 void Data_Stop(char *initializer_fct);
235 
236 
237 
238 
239 #define INL_ACCESS_NAME(p) (p[0])
240 #define INL_ACCESS_NEXT(p) (p[1])
241 #define INL_ACCESS_LEVEL(p) (PlLong) (p[2])
242 #define INL_ACCESS_INFO(p) (PlLong) (p[3])
243 
244 #define INL_NEXT ((char *) (0))
245 #define INL_LEVEL(x) ((char *) (x))
246 #define INL_INFO(x) ((char *) (x))
247 #define INL_LABEL(x) ((char *) (x))
248 #define INL_END_FUNC ((char *) (-1))
249 
void Dico_String_Start(int nb)
Definition: alpha_any.c:1490
static char name[32]
Definition: test_oc_defs.h:8
void String_Out(char *s)
Definition: ma2asm.c:666
#define GCCPRINTF(x)
Definition: ma_protos.h:48
char * local_symb_prefix
Definition: alpha_any.c:80
char fct_name[MAX_STR_LEN]
Definition: ma_parser.c:110
void Jump_Ret(void)
Definition: alpha_any.c:1325
int pic_code
Definition: ma2asm.c:97
void Jump_If_Greater(char *label)
Definition: alpha_any.c:1460
void Dico_Long_Start(int nb)
Definition: alpha_any.c:1533
void Prep_CP(void)
Definition: alpha_any.c:694
static CHAR32_T c
Definition: scan_supp.c:65
void Fail_Ret(void)
Definition: alpha_any.c:1339
void Call_C_Stop(char *fct_name, int nb_args, char **p_inline)
Definition: alpha_any.c:1313
void Dico_Long(char *name, int global, VType vtype, PlLong value)
Definition: alpha_any.c:1551
int Call_C_Arg_Foreign_D(int offset, int adr_of, int index)
Definition: alpha_any.c:1215
int nb_swt
Definition: ma_parser.c:117
int nb_args
Definition: ma_parser.c:112
char * comment_prefix
Definition: alpha_any.c:79
VType
Definition: ma_parser.h:106
void Code_Start(char *label, int prolog, int global)
Definition: alpha_any.c:589
void Move_Ret_To_Reg_Y(int index)
Definition: alpha_any.c:1387
PlLong int_val
Definition: ma_parser.c:138
double dbl_val
Definition: ma_parser.c:139
void Data_Stop(char *initializer_fct)
Definition: alpha_any.c:1659
void Pl_Jump(char *label)
Definition: alpha_any.c:676
void Jump(char *label)
Definition: alpha_any.c:780
void C_Ret(void)
Definition: alpha_any.c:1475
void Pl_Call(char *label)
Definition: alpha_any.c:727
void Move_Ret_To_Reg_X(int index)
Definition: alpha_any.c:1374
intptr_t PlLong
Definition: gprolog.h:88
void Int_Out(int d)
Definition: ma2asm.c:680
int Call_C_Arg_Reg_Y(int offset, int adr_of, int index)
Definition: alpha_any.c:1099
int reload_e
Definition: ma_parser.c:106
int Call_C_Arg_Int(int offset, PlLong int_val)
Definition: alpha_any.c:870
void Move_From_Reg_Y(int index)
Definition: alpha_any.c:807
int nb_args_in_words
Definition: ma_parser.c:113
void Cmp_Ret_And_Int(PlLong int_val)
Definition: alpha_any.c:1433
ArgInf arg[MAX_ARGS]
Definition: ma_parser.c:114
void Inst_Printf(char *op, char *operands,...) GCCPRINTF(2)
Definition: ma2asm.c:616
void Move_From_Reg_X(int index)
Definition: alpha_any.c:794
void Call_C_Start(char *fct_name, int fc, int nb_args, int nb_args_in_words, char **p_inline)
Definition: alpha_any.c:857
double d
Definition: asm.c:27
int Call_C_Arg_Mem_L(int offset, int adr_of, char *name, int index)
Definition: alpha_any.c:987
void Label_Printf(char *label,...) GCCPRINTF(1)
Definition: ma2asm.c:595
void Label(char *label)
Definition: alpha_any.c:651
void Asm_Start(void)
Definition: alpha_any.c:520
Definition: wam_inst.h:249
void Pl_Fail(void)
Definition: alpha_any.c:742
Definition: ma_parser.h:77
void Decl_Code(char *name, int prolog, int global)
Definition: ma2asm.c:542
void Call_C_Invoke(char *fct_name, int fc, int nb_args, int nb_args_in_words)
Definition: alpha_any.c:1296
char * initializer_fct
Definition: ma2asm.c:110
void Asm_Stop(void)
Definition: alpha_any.c:565
void Reload_E_In_Register(void)
Definition: alpha_any.c:664
PlLong swt[]
Definition: chkma.c:101
int Call_C_Arg_Reg_X(int offset, int adr_of, int index)
Definition: alpha_any.c:1040
void Decl_Long(char *name, int global, VType vtype, PlLong value)
Definition: ma2asm.c:522
int fc
Definition: ma_parser.c:111
void Move_To_Reg_X(int index)
Definition: alpha_any.c:826
int call_c_reverse_args
Definition: alpha_any.c:82
void Declare_Initializer(char *initializer_fct)
Definition: ma2asm.c:239
void Jump_If_Equal(char *label)
Definition: alpha_any.c:1447
int Get_Long_Infos(char *name, int *global, VType *vtype, int *value)
Definition: ma2asm.c:572
int Call_C_Arg_Foreign_L(int offset, int adr_of, int index)
Definition: alpha_any.c:1162
void Inst_Out(char *op, char *operands)
Definition: ma2asm.c:638
char * inline_asm_data[]
Definition: alpha_any.c:84
void Dico_String(int str_no, char *asciiz)
Definition: alpha_any.c:1507
void Pl_Ret(void)
Definition: alpha_any.c:762
void Move_Ret_To_Foreign_L(int index)
Definition: alpha_any.c:1405
int can_produce_pic_code
Definition: alpha_any.c:78
void Move_To_Reg_Y(int index)
Definition: alpha_any.c:839
int Call_C_Arg_Double(int offset, double dbl_val)
Definition: alpha_any.c:907
void Dico_Long_Stop(int nb)
Definition: alpha_any.c:1621
void Switch_Ret(int nb_swt, SwtInf swt[])
Definition: ma2asm.c:435
int strings_need_null
Definition: alpha_any.c:81
void Code_Stop(void)
Definition: alpha_any.c:636
int Is_Code_Defined(char *name)
Definition: ma2asm.c:561
void Move_Ret_To_Mem_L(char *name, int index)
Definition: alpha_any.c:1354
void Char_Out(char c)
Definition: ma2asm.c:652
int Call_C_Arg_String(int offset, int str_no)
Definition: alpha_any.c:950
void Data_Start(char *initializer_fct)
Definition: alpha_any.c:1633
void Move_Ret_To_Foreign_D(int index)
Definition: alpha_any.c:1419
void Call_C(char *fct_name, int fc, int nb_args, int nb_args_in_words, ArgInf arg[])
Definition: ma2asm.c:252
void * label
void Call_C_Adjust_Stack(int nb_pushes)
void Here_CP(void)
Definition: alpha_any.c:712
void Dico_String_Stop(int nb)
Definition: alpha_any.c:1521