annotate mc-code-ia32.c @ 230:d60c6c31f63a

*** empty log message ***
author kono
date Wed, 28 Apr 2004 15:06:01 +0900 (2004-04-28)
parents 8675ea3d2c7f
children c575422d8b6e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1 /* Micro-C Code Generatation Part for intel386 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2 /* $Id$ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
4 #define EXTERN extern
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
5 #include "mc.h"
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
6 #include "mc-codegen.h"
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
7 #include "mc-code.h"
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
8
173
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
9 char *l_include_path[] = {
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
10 "/usr/include/",
182
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
11 "/usr/include/linux/",
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
12 "/usr/include/diet/",
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
13 "/usr/lib/gcc-lib/i386-linux/2.95.4/include/",
183
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
14 "/usr/lib/gcc-lib/i386-redhat-linux/2.96/include/",
173
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
15 0
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
16 };
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
17
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
18
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
19 #define SAVE_STACKS 1
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
20
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
21 #define TEXT_EMIT_MODE 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
22 #define DATA_EMIT_MODE 1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
23 #define RODATA_EMIT_MODE 2
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
24
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
25 static int output_mode = TEXT_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
26 static int data_alignment = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
27
224
82a55cc6b5fc *** empty log message ***
kono
parents: 219
diff changeset
28 static int creg;
82a55cc6b5fc *** empty log message ***
kono
parents: 219
diff changeset
29
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
30 int size_of_int = 4;
165
kono
parents: 163
diff changeset
31 int size_of_short = 2;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
32 int size_of_float = 4;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
33 int size_of_double = 8;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
34 int size_of_longlong = 8;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
35 int endian = 0;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
36 int MAX_REGISTER=6; /* intel386�Υ쥸������6�ĤޤǻȤ�*/
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
37 #define REAL_MAX_REGISTER 8 /* intel386�Υ쥸������8�ĤȤ�������*/
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
38 int MAX_DATA_REG=4;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
39 int MAX_POINTER=3;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
40 int MAX_REGISTGER_VAR=2;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
41 int MAX_FREGISTER=1;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
42
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
43 #define MAX_FPU_STACK 7
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
44
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
45 int MAX_INPUT_REGISTER_VAR = 0;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
46 int MAX_CODE_INPUT_REGISTER_VAR = 2;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
47 int MAX_INPUT_DREGISTER_VAR = 0;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
48 int MAX_INPUT_FREGISTER_VAR = 0;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
49 int MAX_CODE_INPUT_DREGISTER_VAR = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
50
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
51 int reg_sp; /* REGister Stack-Pointer */
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
52 int reg_stack[MAX_MAX]; /* �ºݤΥ쥸�������ΰ� */
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
53
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
54 /* floating point registers */
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
55
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
56 int freg_sp; /* floating point REGister Stack-Pointer */
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
57 int freg_stack[MAX_MAX]; /* �ºݤΥ쥸�������ΰ� */
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
58
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
59
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
60 /*
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
61 -28 -8 local2
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
62 -24 -4 local1
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
63 -20 8 arg3
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
64 -16 4 arg2
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
65 -12 0 arg1
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
66 local2 -20 4 -8 (%edi)
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
67 local1 <-- -16 0 local variable -4 (%esi)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
68 %edi -12 <- disp_offset %ebp
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
69 %esi -8
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
70 %ebx -4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
71 %ebp = %esp 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
72 %eip 4 <- arg_offset
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
73 arg1 8 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
74 arg2 12 4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
75 see enter/enter1/leave see code_enter
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
76 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
77 int arg_offset = 8;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
78 int disp_offset = -12;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
79 int func_disp_offset = -12;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
80 int code_disp_offset = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
81 int jump_offset = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
82
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
83 static int code_disp_label;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
84 static int func_disp_label;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
85
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
86 static int
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
87 lvar(int l)
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
88 {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
89 if (is_code(fnptr)) {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
90 return l+code_disp_offset;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
91 } else if (l<0) {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
92 return l+disp_offset;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
93 } else {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
94 return l+arg_offset;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
95 }
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
96 }
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
97
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
98 /*
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
99 creg currrent virtual register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
100 dreg spare virtual register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
101
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
102 rname[creg] currrent real register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
103 rname[dreg] spare real register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
104
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
105 regs[] virtual register usage
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
106 regv[] value in virtual register flag
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
107
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
108 reg_name[rname[creg]]
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
109
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
110 freg current floating point register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
111 fregv calue in floating point register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
112 */
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
113
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
114 static int dreg; /* general temporal register */
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
115
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
116 static int ia32regs[REAL_MAX_REGISTER];
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
117 static int ia32regv[REAL_MAX_REGISTER];
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
118 static int ia32rname[REAL_MAX_REGISTER];
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
119
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
120 static int *regv = ia32regv;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
121 static int *regs = ia32regs;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
122 static int *rname = ia32rname;
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
123
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
124 static int ia32fregs[1];
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
125 static int ia32fregv[1];
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
126
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
127 static int freg;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
128 static int *fregv = ia32fregv;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
129 static int *fregs = ia32fregs;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
130
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
131
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
132 #define REG_EAX 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
133 #define REG_EBX 1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
134 #define REG_ECX 2
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
135 #define REG_EDX 3
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
136 #define REG_ESI 4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
137 #define REG_EDI 5
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
138 #define REG_EBP 6
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
139 #define REG_ESP 7
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
140
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
141
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
142 #define DATA_REG 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
143 #define POINTER_REG 3
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
144 static char *reg_name[8];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
145 static char *reg_name_l[4];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
146 static char *reg_name_w[4];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
147
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
148 static void use_register(int virt, int real, int move);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
149 static int virtual(int real);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
150 static void shift(char *op, int reg);
163
fc8514c9d685 *** empty log message ***
kono
parents: 159
diff changeset
151 static void ld_indexx(int byte, int n, int xreg,int sign);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
152 static void data_mode(char *name);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
153 static int edx_setup();
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
154 static void edx_cleanup();
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
155 static void local_table(void);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
156 #if FLOAT_CODE
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
157 static char * fload(int d);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
158 static int code_d1(double d);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
159 static int code_d2(double d);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
160 static void code_save_fstacks();
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
161 #endif
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
162 static void code_save_stacks();
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
163
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
164 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
165 code_init(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
166 {
173
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
167 macro_define("__i386__ 1\n");
182
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
168 macro_define("__LITTLE_ENDIAN__ 1\n");
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
169 macro_define("__STDC__ 1\n");
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
170 macro_define("size_t int\n");
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
171 macro_define("__externsion__\n");
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
172 macro_define("__flexarr\n");
183
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
173 macro_define("__builtin_va_list int*\n");
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
174 macro_define("wchar_t int\n");
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
175 macro_define("__THROW\n");
173
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
176
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
177 arg_offset = 8;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
178 func_disp_offset = -12;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
179 disp_offset = -12;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
180 size_of_int = 4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
181 endian = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
182 MAX_REGISTER=6;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
183 MAX_DATA_REG=4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
184 MAX_POINTER=3;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
185 MAX_REGISTER_VAR=2;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
186
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
187 reg_name[REG_EAX] = "%eax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
188 reg_name[REG_EBX] = "%ebx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
189 reg_name[REG_ECX] = "%ecx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
190 reg_name[REG_EDX] = "%edx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
191 reg_name[REG_ESI] = "%esi";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
192 reg_name[REG_EDI] = "%edi";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
193 reg_name[REG_EBP] = "%ebp";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
194 reg_name[REG_ESP] = "%esp";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
195 reg_name_l[REG_EAX] = "%al";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
196 reg_name_l[REG_EBX] = "%bl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
197 reg_name_l[REG_ECX] = "%cl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
198 reg_name_l[REG_EDX] = "%dl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
199 reg_name_w[REG_EAX] = "%ax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
200 reg_name_w[REG_EBX] = "%bx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
201 reg_name_w[REG_ECX] = "%cx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
202 reg_name_w[REG_EDX] = "%dx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
203
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
204 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
205
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
206 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
207 register_name(int i,int byte)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
208 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
209 if (i<0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
210 error(REG_ERR);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
211 return "%eax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
212 }
165
kono
parents: 163
diff changeset
213 if (byte==1 && rname[i] <= REG_EDX) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
214 return reg_name_l[rname[i]];
165
kono
parents: 163
diff changeset
215 } else if (byte==size_of_short && rname[i] <= REG_EDX) {
kono
parents: 163
diff changeset
216 return reg_name_w[rname[i]];
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
217 } else {
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
218 return reg_name[rname[i]]; /* 0 or 4 means int */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
219 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
220 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
221
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
222 int use_int(int i) { return i;}
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
223 int use_float(int i) { return i;}
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
224 int use_double(int i) { return i;}
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
225 int use_longlong(int i) { return i; }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
226
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
227
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
228 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
229 gexpr_code_init(void){
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
230 use_register(creg,REG_EAX,0);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
231 regv[creg]=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
232 regv[dreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
233 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
234
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
235 void
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
236 code_gexpr(int e){
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
237 }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
238
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
239 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
240 get_register(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
241 { /* �Ȥ��Ƥ��ʤ��쥸������Ĵ�٤� */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
242 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
243 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
244 if (! regs[i]) { /* �Ȥ��Ƥ��ʤ��ʤ� */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
245 regs[i]=1; /* ���Υ쥸������Ȥ����Ȥ������ */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
246 return i; /* ���ξ���ɽ���ֹ���֤� */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
247 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
248 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
249 return -1; /* �����Ƥ����꤬�ʤ��ʤ顢�����ɽ�� -1 ���֤� */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
250 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
251
917947ffeb7c power pc version
kono
parents: 87
diff changeset
252 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
253 free_register(int i) { /* ����ʤ��ʤä��쥸�������� */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
254 regv[i]=regs[i]=0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
255 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
256
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
257 int
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
258 get_input_register_var(int i,NMTBL *nptr,int is_code)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
259 {
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
260 if (is_code) {
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
261 if (i>=MAX_CODE_INPUT_REGISTER_VAR) return 0;
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
262 i = virtual(i+REG_ESI);
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
263 regs[i]=regv[i]=1;
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
264 return list3(REGISTER,i,(int)nptr);
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
265 } else {
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
266 return 0;
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
267 }
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
268 }
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
269
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
270 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
271 get_input_dregister_var(int i,NMTBL *nptr,int is_code,int d)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
272 {
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
273 return 0;
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
274 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
275
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
276 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
277 get_dregister(int d)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
278 {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
279 return -1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
280 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
281
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
282 int
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
283 get_lregister_var(NMTBL *n)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
284 {
204
4c614334f3d0 long long test parse
kono
parents: 203
diff changeset
285 return list2(LVAR,new_lvar(size_of_longlong));
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
286 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
287
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
288 int
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
289 get_lregister()
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
290 {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
291 return -1;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
292 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
293
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
294
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
295 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
296 register_full(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
297 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
298 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
299 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
300 if (! regs[i]) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
301 return 0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
302 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
303 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
304 return 1;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
305 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
306
917947ffeb7c power pc version
kono
parents: 87
diff changeset
307 int
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
308 free_register_count(int d)
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
309 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
310 int i,count;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
311 count = 0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
312 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
313 if (! regs[i] && ! regv[i]) count++;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
314 }
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
315 return d?0:count;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
316 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
317
917947ffeb7c power pc version
kono
parents: 87
diff changeset
318 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
319 free_all_register(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
320 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
321 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
322 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
323 regs[i]=regv[i]=0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
324 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
325 creg = get_register();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
326 dreg = get_register();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
327 return;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
328 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
329
917947ffeb7c power pc version
kono
parents: 87
diff changeset
330
917947ffeb7c power pc version
kono
parents: 87
diff changeset
331 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
332 register_usage(char *s)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
333 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
334 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
335 if (chk) return;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
336 printf("# %d: %s:",lineno,s);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
337 printf(" creg=%s dreg=%s ",register_name(creg,0),register_name(dreg,0));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
338 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
339 printf("%d",regs[i]);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
340 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
341 printf(":");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
342 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
343 printf("%d",regv[i]);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
344 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
345 #if 0
917947ffeb7c power pc version
kono
parents: 87
diff changeset
346 printf(" regs_stack",register_name(creg,0),register_name(dreg,0));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
347 for(i=reg_sp;i>=0;i--) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
348 if(reg_stack[i]>=0)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
349 printf(" %s",register_name(reg_stack[i],0));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
350 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
351 #endif
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
352 printf(" f:%d",freg_sp);
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
353 printf("\n");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
354 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
355
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
356 void
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
357 code_arg_register(NMTBL *fnptr)
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
358 {
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
359 int args = fnptr->dsp;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
360 NMTBL *n;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
361 int reg_var = 0;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
362 int freg_var = 0;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
363 int type;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
364 int reg;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
365 int is_code0 = is_code(fnptr);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
366
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
367 while (args) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
368 /* process in reverse order */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
369 n = (NMTBL*)caddr(args);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
370 type = n->ty;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
371 if (scalar(type)) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
372 if ((reg = get_input_register_var(reg_var,n,is_code0))) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
373 n->sc = REGISTER;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
374 n->dsp = cadr(reg);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
375 regv[n->dsp]= 1;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
376 regs[n->dsp]= INPUT_REG;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
377 reg_var++;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
378 cadddr(args)=size_of_int; /* why we need this? */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
379 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
380 } else if (type==FLOAT||type==DOUBLE) {
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
381 if ((reg = get_input_dregister_var(freg_var,n,is_code0,1))) {
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
382 n->sc = DREGISTER;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
383 n->dsp = cadr(reg);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
384 fregv[n->dsp]= 1;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
385 fregs[n->dsp]= INPUT_REG;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
386 freg_var++;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
387 cadddr(args)=size(type); /* why we need this? */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
388 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
389 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
390 args = cadr(args);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
391 }
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
392 }
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
393
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
394 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
395 gexpr_init(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
396 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
397 while(reg_sp > 0) {
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
398 if (reg_stack[--reg_sp]>=0)
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
399 free_register(reg_stack[reg_sp]);
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
400 }
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
401 freg_sp = 0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
402 text_mode();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
403 gexpr_code_init();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
404 register_usage("gexpr_init");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
405 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
406
917947ffeb7c power pc version
kono
parents: 87
diff changeset
407
917947ffeb7c power pc version
kono
parents: 87
diff changeset
408 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
409 emit_init(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
410 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
411 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
412 for(i=0;i<MAX_REGISTER;i++) { regs[i]=0; regv[i]=0;rname[i]=i;}
917947ffeb7c power pc version
kono
parents: 87
diff changeset
413 free_all_register();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
414 reg_sp = 0;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
415 freg_sp = 0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
416 text_mode();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
417 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
418
917947ffeb7c power pc version
kono
parents: 87
diff changeset
419 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
420 virtual(int real)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
421 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
422 int real_v,i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
423 real_v = -1;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
424 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
425 if (rname[i]==real) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
426 real_v=i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
427 break;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
428 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
429 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
430 return real_v;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
431 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
432
917947ffeb7c power pc version
kono
parents: 87
diff changeset
433 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
434 pop_register(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
435 { /* �쥸���������ͤ���Ф� */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
436 return reg_stack[--reg_sp];
917947ffeb7c power pc version
kono
parents: 87
diff changeset
437 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
438
917947ffeb7c power pc version
kono
parents: 87
diff changeset
439 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
440 emit_pop_free(int xreg)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
441 {
159
b80e9737c3ce regs[creg]==0 in ia32
kono
parents: 156
diff changeset
442 if (xreg==dreg||xreg==creg) {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
443 regv[dreg]=0;
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
444 } else if (xreg>=0) {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
445 free_register(xreg);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
446 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
447 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
448
917947ffeb7c power pc version
kono
parents: 87
diff changeset
449
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
450 int
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
451 get_register_var(NMTBL *nptr)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
452 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
453 int i;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
454 for(i=REG_ESI;i<REG_ESP;i++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
455 if (! regs[i]) { /* �Ȥ��Ƥ��ʤ��ʤ� */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
456 regs[i]=1; /* ���Υ쥸������Ȥ����Ȥ������ */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
457 regv[i]=0;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
458 return list3(REGISTER,i,(int)nptr); /* ���ξ���ɽ���ֹ���֤� */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
459 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
460 }
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
461 return list2(LVAR,new_lvar(size_of_int));
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
462 }
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
463
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
464 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
465 get_dregister_var(NMTBL *nptr,int d)
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
466 {
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
467 return list2(LVAR,new_lvar(d?size_of_double:size_of_float));
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
468 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
469
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
470 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
471 use_register(int virt, int real, int move)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
472 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
473 int real_v;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
474 char *move_op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
475 if (rname[virt]==real)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
476 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
477 real_v = virtual(real);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
478 move_op = regs[real_v]?"\txchg %s,%s\n":"\tmovl %s,%s\n";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
479 if (move || (regv[real_v])) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
480 printf(move_op,reg_name[rname[virt]],reg_name[real]);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
481 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
482 rname[real_v] = rname[virt];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
483 rname[virt] = real;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
484 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
485
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
486 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
487 use_pointer(int virt, int move)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
488 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
489 int i;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
490 if (rname[virt]>=POINTER_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
491 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
492 for(i=POINTER_REG;i<MAX_REGISTER;i++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
493 if (!regs[virtual(i)]) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
494 use_register(virt,i,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
495 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
496 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
497 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
498 /* we prefer EBX */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
499 use_register(virt,REG_EBX,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
500 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
501
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
502 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
503 use_data_reg(int virt, int move)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
504 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
505 int i;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
506 if (rname[virt]<MAX_DATA_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
507 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
508 for(i=0;i<MAX_DATA_REG;i++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
509 if (!regs[virtual(i)]) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
510 use_register(virt,i,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
511 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
512 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
513 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
514 /* we prefer EBX */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
515 use_register(virt,REG_EBX,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
516 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
517
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
518
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
519 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
520 emit_push()
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
521 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
522 int new_reg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
523 new_reg = get_register();
159
b80e9737c3ce regs[creg]==0 in ia32
kono
parents: 156
diff changeset
524 if (new_reg==creg) error(-1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
525 if(new_reg<0) { /* �⤦�쥸�������ʤ� */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
526 if (reg_sp>=MAX_MAX) error(-1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
527 reg_stack[reg_sp++] = -1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
528 printf("\tpushl %s\n",register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
529 /* creg is used soon, don't regv[creg]=0 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
530 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
531 reg_stack[reg_sp++] = creg; /* push ���뤫���˥쥸������Ȥ� */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
532 creg = new_reg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
533 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
534 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
535 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
536
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
537 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
538 emit_pop(int type)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
539 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
540 int xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
541 if ((xreg=pop_register())==-1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
542 if (type==POINTER_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
543 use_pointer(dreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
544 else if (type==DATA_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
545 use_data_reg(dreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
546 if (regv[dreg]) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
547 printf("# emit_pop dreg conflict\n");
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
548 error(-1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
549 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
550 printf("\tpopl %s\n",register_name(dreg,0));
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
551 regv[dreg]=1;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
552 return dreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
553 } else if (xreg<= -REG_LVAR_OFFSET) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
554 code_rlvar(xreg+REG_LVAR_OFFSET,dreg);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
555 free_lvar(xreg+REG_LVAR_OFFSET);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
556 regv[dreg]=1;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
557 return dreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
558 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
559 return xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
560 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
561
186
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
562 int
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
563 stack_top(int type)
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
564 {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
565 int xreg;
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
566 if (type==INT) {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
567 xreg = reg_stack[reg_sp];
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
568 if (xreg<= -REG_LVAR_OFFSET) {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
569 return list2(LVAR,REG_LVAR_OFFSET+xreg);
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
570 } else {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
571 return list2(REGISTER,xreg);
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
572 }
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
573 } else {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
574 xreg = freg_stack[freg_sp];
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
575 if (xreg<= -REG_LVAR_OFFSET) {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
576 return list2(LVAR,REG_LVAR_OFFSET+xreg);
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
577 } else {
186
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
578 return list2(DREGISTER,xreg);
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
579 }
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
580 }
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
581 return xreg;
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
582 }
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
583
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
584
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
585
92
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
586 void
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
587 code_label(int labelno)
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
588 {
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
589 printf("_%d:\n",labelno);
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
590 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
591
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
592 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
593 code_gvar(int e1,int creg) {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
594 printf("\tmovl $%s,%s\n",((NMTBL*)cadr(e1))->nm,register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
595 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
596 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
597
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
598
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
599 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
600 code_rgvar(int e1,int creg) {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
601 printf("\tmovl %s,%s\n",((NMTBL*)cadr(e1))->nm,register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
602 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
603 }
166
9e55cc5551fb *** empty log message ***
kono
parents: 165
diff changeset
604 static char *cload(int sign,int sz) { return sz==1?(sign?"movsbl":"movzbl"):sz==size_of_short?(sign?"movswl":"movzwl"):"movl"; }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
605 void
165
kono
parents: 163
diff changeset
606 code_crgvar(int e1,int creg,int sign,int sz){
kono
parents: 163
diff changeset
607 printf("\t%s %s,%s\n",cload(sign,sz),
163
fc8514c9d685 *** empty log message ***
kono
parents: 159
diff changeset
608 ((NMTBL*)cadr(e1))->nm,register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
609 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
610 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
611
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
612
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
613 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
614 code_lvar(int e2,int creg) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
615 printf("\tlea %d(%%ebp),%s\n",lvar(e2),register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
616 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
617 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
618
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
619
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
620 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
621 code_register(int e2,int creg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
622 printf("\tmovl %s,%s\n",register_name(e2,0),register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
623 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
624 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
625
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
626
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
627 void
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
628 code_rlvar(int e2,int reg) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
629 printf("\tmovl %d(%%ebp),%s\n",lvar(e2),register_name(reg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
630 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
631 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
632
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
633
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
634 void
165
kono
parents: 163
diff changeset
635 code_crlvar(int e2,int reg,int sign,int sz) {
kono
parents: 163
diff changeset
636 printf("\t%s %d(%%ebp),%s\n",cload(sign,sz),lvar(e2),register_name(reg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
637 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
638 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
639
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
640
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
641 void
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
642 code_fname(NMTBL *n,int creg) {
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
643 printf("\tmovl $%s,%s\n",n->nm,register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
644 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
645 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
646
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
647
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
648 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
649 code_const(int e2,int creg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
650 printf("\tmovl $%d,%s\n",e2,register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
651 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
652 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
653
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
654
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
655 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
656 code_neg(int creg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
657 printf("\tnegl %s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
658 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
659
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
660
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
661 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
662 code_not(int creg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
663 printf("\tnotl %s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
664 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
665
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
666
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
667 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
668 code_lnot(int creg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
669 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
670 use_data_reg(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
671 xrn = register_name(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
672 printf("\tcmpl $0,%s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
673 printf("\tsete %s\n", xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
674 printf("\tmovzbl %s,%s\n", xrn,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
675 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
676
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
677 void
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
678 code_preinc(int e1,int e2,int dir,int sign,int sz,int reg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
679 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
680 if (car(e2)==REGISTER) {
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
681 printf("\taddl $%d,%s\n",dir,register_name(cadr(e2),0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
682 printf("\tmovl %s,%s\n",register_name(cadr(e2),0),register_name(reg,0));
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
683 regv[reg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
684 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
685 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
686 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
687 xrn = register_name(creg,0);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
688 printf("\t%s $%d,(%s)\n",(sz==1)?"addb":(sz==size_of_short)?"addw":"addl",dir,xrn);
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
689 printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(creg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
690 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
691
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
692
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
693 void
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
694 code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
695 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
696 if (car(e2)==REGISTER) {
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
697 printf("\tmovl %s,%s\n",register_name(cadr(e2),0),register_name(reg,0));
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
698 printf("\taddl $%d,%s\n",dir,register_name(cadr(e2),0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
699 regv[reg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
700 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
701 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
702 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
703 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
704 xrn = register_name((e2=emit_pop(0)),0);
165
kono
parents: 163
diff changeset
705 printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(creg,0));
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
706 printf("\t%s $%d,(%s)\n",(sz==1)?"addb":(sz==size_of_short)?"addw":"addl",dir,xrn);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
707 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
708 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
709
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
710
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
711
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
712 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
713 code_return(int creg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
714 printf("\tleal _%d,%s\n",retcont,register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
715 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
716 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
717
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
718
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
719 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
720 code_environment(int creg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
721 printf("\tmovl %%ebp,%s\n",register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
722 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
723 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
724
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
725
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
726 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
727 code_bool(int e1,int reg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
728 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
729 int e2,e3;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
730 b_expr(e1,1,e2=fwdlabel(),1); /* including > < ... */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
731 xrn = register_name(creg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
732 printf("\txorl %s,%s\n",xrn,xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
733 jmp(e3=fwdlabel());
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
734 fwddef(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
735 printf("\tmovl $1,%s\n",xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
736 fwddef(e3);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
737 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
738 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
739
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
740 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
741 code_gt(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
742 return (cond?"g":"le");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
743 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
744
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
745 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
746 code_ugt(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
747 return (cond?"a":"be");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
748 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
749
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
750 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
751 code_ge(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
752 return (cond?"ge":"l");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
753 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
754
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
755 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
756 code_uge(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
757 return (cond?"ae":"b");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
758 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
759
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
760 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
761 code_eq(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
762 return (cond?"e":"ne");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
763 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
764
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
765 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
766 code_cmp_crgvar(int e1,int reg,int sz) {
167
0197ca125567 mips short
kono
parents: 166
diff changeset
767 if (sz==1)
0197ca125567 mips short
kono
parents: 166
diff changeset
768 printf("\tcmpb $0,%s\n",((NMTBL*)cadr(e1))->nm);
0197ca125567 mips short
kono
parents: 166
diff changeset
769 else if (sz==size_of_short)
0197ca125567 mips short
kono
parents: 166
diff changeset
770 printf("\tcmpw $0,%s\n",((NMTBL*)cadr(e1))->nm);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
771 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
772
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
773
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
774 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
775 code_cmp_crlvar(int e1,int reg,int sz) {
167
0197ca125567 mips short
kono
parents: 166
diff changeset
776 if (sz==1)
0197ca125567 mips short
kono
parents: 166
diff changeset
777 printf("\tcmpb $0,%d(%%ebp)\n",lvar(e1));
0197ca125567 mips short
kono
parents: 166
diff changeset
778 else if (sz==size_of_short)
0197ca125567 mips short
kono
parents: 166
diff changeset
779 printf("\tcmpw $0,%d(%%ebp)\n",lvar(e1));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
780 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
781
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
782
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
783 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
784 code_cmp_rgvar(int e1,int reg) {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
785 printf("\tcmpl $0,%s\n",((NMTBL*)cadr(e1))->nm);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
786 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
787
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
788
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
789 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
790 code_cmp_rlvar(int e1,int reg) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
791 printf("\tcmpl $0,%d(%%ebp)\n",lvar(e1));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
792 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
793
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
794
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
795 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
796 code_cmp_register(int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
797 printf("\tcmpl $0,%s\n",register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
798 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
799
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
800
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
801 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
802 ascii(char *s)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
803 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
804 printf("\t.string \"");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
805 while(*s) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
806 if (*s=='\n')
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
807 printf("%cn",92);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
808 else if (*s<' ')
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
809 printf("%c%03o",92,*s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
810 else if (*s==34)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
811 printf("%c%c",92,34);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
812 else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
813 printf("%c",*s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
814 s++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
815 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
816 printf("%c\n",34);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
817 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
818
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
819 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
820 code_string(int e1,int creg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
821 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
822 char *s;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
823 int i,lb;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
824
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
825 if (0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
826 s=(char *)cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
827 lb=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
828 printf("\tjmp _%d\n",lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
829 i=backdef();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
830 ascii(s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
831 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
832 fwddef(lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
833 printf("\tlea _%d,%s\n",i,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
834 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
835 s=(char *)cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
836 printf(".section\t.rodata\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
837 lb=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
838 printf("_%d:\n",lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
839 ascii(s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
840 if (output_mode==TEXT_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
841 printf(".text\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
842 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
843 text_mode();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
844 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
845 printf("\tlea _%d,%s\n",lb,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
846 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
847 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
848
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
849 #define MAX_COPY_LEN 20
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
850
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
851 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
852 emit_copy(int from,int to,int length,int offset,int value,int det)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
853 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
854 int fix = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
855 /* length <0 means upward direction copy */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
856 switch (length) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
857 case 0: break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
858 case 1: case -1:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
859 printf("\tmovb %d(%s),%s\n",offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
860 register_name(from,0), reg_name_l[rname[dreg]] );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
861 printf("\tmovb %s,%d(%s)\n",reg_name_l[rname[dreg]] ,offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
862 register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
863 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
864 case 2: case -2:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
865 printf("\tmovw %d(%s),%s\n",offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
866 register_name(from,0), reg_name_w[rname[dreg]] );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
867 printf("\tmovw %s,%d(%s)\n",reg_name_w[rname[dreg]] ,offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
868 register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
869 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
870 case 4: case -4:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
871 printf("\tmovl %d(%s),%s\n",offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
872 register_name(from,0), register_name(dreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
873 printf("\tmovl %s,%d(%s)\n",register_name(dreg,0), offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
874 register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
875 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
876 default:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
877 if (-MAX_COPY_LEN<length && length <0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
878 for(;length<=4;length+=4,offset-=4)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
879 emit_copy(from,to,4,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
880 for(;length<=2;length+=2,offset-=2)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
881 emit_copy(from,to,2,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
882 if(length>0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
883 emit_copy(from,to,length,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
884 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
885 } else if (length <=MAX_COPY_LEN) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
886 for(;length>=4;length-=4,offset+=4)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
887 emit_copy(from,to,4,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
888 for(;length>=2;length-=2,offset+=2)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
889 emit_copy(from,to,2,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
890 if(length>0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
891 emit_copy(from,to,length,offset,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
892 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
893 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
894 if (det) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
895 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
896 call bcopy
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
897 g_expr(list3(FUNCTION,,);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
898 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
899 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
900 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
901 use_register(from,REG_ESI,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
902 use_register(to, REG_EDI,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
903 use_register(dreg,REG_ECX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
904 if (length<0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
905 printf("\tmovl $%d,%%ecx\n",-length/4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
906 printf("\taddl $%d,%%esi\n",-length);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
907 printf("\taddl $%d,%%edi\n",-length);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
908 printf("\tstd\n\trep\n\tmovsl\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
909 if(length%4) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
910 emit_copy(from,to,length,offset+length/4,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
911 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
912 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
913 printf("\tmovl $%d,%%ecx\n",length/4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
914 fix = (length/4)*4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
915 printf("\tcld\n\trep\n\tmovsl\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
916 if(length%4) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
917 emit_copy(from,to,length,offset+length/4,0,det);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
918 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
919 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
920 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
921 if (value) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
922 /* creg must point top of the destination data */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
923 /* this code is necessary for the value of assignment or function call */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
924 /* otherwise we don't need this */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
925 if (fix) printf("\tsubl $%d,%s\n",fix,register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
926 if(creg!=to) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
927 if (to==dreg)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
928 printf("\tmovl %s,%s\n",register_name(to,0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
929 else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
930 free_register(creg); creg=to;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
931 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
932 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
933 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
934 regv[from]=regv[to]=regv[dreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
935 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
936 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
937
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
938 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
939 struct_push(int e4,int t)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
940 {
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
941 int length,xreg,save,lreg,count;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
942 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
943 length=size(t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
944 if(length%size_of_int) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
945 length += size_of_int - (length%size_of_int);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
946 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
947 for(count=0;length<MAX_COPY_LEN;count++,length-=size_of_int) {
f94ca1168520 float first try...
kono
parents: 78
diff changeset
948 if (length==0) return count;
f94ca1168520 float first try...
kono
parents: 78
diff changeset
949 else {
f94ca1168520 float first try...
kono
parents: 78
diff changeset
950 printf("\tpushl %d(%s)\n",
f94ca1168520 float first try...
kono
parents: 78
diff changeset
951 length-size_of_int,register_name(creg,0));
f94ca1168520 float first try...
kono
parents: 78
diff changeset
952 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
953 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
954 printf("\tsubl $%d,%%esp\n",length);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
955 if (register_full()) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
956 save = 1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
957 for(lreg=0;lreg==creg||lreg==dreg;lreg++);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
958 printf("\tpushl %s\n",register_name(lreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
959 xreg = lreg; regv[xreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
960 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
961 save=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
962 xreg = get_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
963 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
964 if (save)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
965 printf("\tlea %d(%%esp),%s\n",size_of_int,register_name(xreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
966 else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
967 printf("\tmovl %%esp,%s\n",register_name(xreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
968 regv[xreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
969 /* downward direction copy */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
970 emit_copy(creg,xreg,length,0,0,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
971 /* we have value in creg, it may be changed */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
972 if (save) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
973 if(creg==xreg) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
974 creg = get_register(); /* creg is freed in emit_copy */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
975 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
976 printf("\tpopl %s\n",register_name(xreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
977 regv[xreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
978 } else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
979 free_register(xreg);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
980 return length/size_of_int;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
981 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
982
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
983 int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
984 function(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
985 {
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
986 int e2,e3,e4,nargs,t,ret_type;
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
987 NMTBL *n=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
988 int save,saved;
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 133
diff changeset
989 ret_type = cadr(cadddr(e1));
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 133
diff changeset
990 if (ret_type==CHAR) ret_type=INT;
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 133
diff changeset
991
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
992 #ifdef SAVE_STACKS
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
993 code_save_stacks();
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
994 #endif
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
995 if (free_register_count(0)<1) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
996 for(save = 0;save==dreg||save==creg;save++);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
997 printf("\tpushl %s\n",register_name(save,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
998 saved = 1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
999 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1000 save = get_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1001 saved = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1002 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1003 regv[save]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1004 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1005 nargs = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1006 for (e3 = caddr(e1); e3; e3 = cadr(e3)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1007 t=caddr(e3);
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1008 e4 = car(e3);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1009 if(scalar(t)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1010 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1011 printf("\tpushl %s\n",register_name(creg,0));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1012 } else if (t==DOUBLE) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1013 g_expr(e4);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1014 printf("\tleal\t-8(%%esp),%%esp\n\tfstpl\t(%%esp)\n");
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1015 nargs += size_of_double/size_of_int;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1016 fregv[freg]=0;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1017 continue;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1018 } else if (t==FLOAT) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1019 g_expr(e4);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1020 printf("\tleal\t-4(%%esp),%%esp\n\tfstps\t(%%esp)\n");
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1021 nargs += size_of_float/size_of_int;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1022 fregv[freg]=0;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1023 continue;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1024 } else if (car(t)==STRUCT||car(t)==UNION) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1025 nargs += struct_push(e4,t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1026 continue;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1027 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1028 error(TYERR);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1029 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1030 ++nargs;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1031 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1032 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1033 n=(NMTBL *)cadr(e2);
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1034 regv[creg]=0;
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1035 use_register(creg,REG_EAX,0); /* will be destroyed */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1036 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1037 g_expr(e2);
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1038 regv[creg]=1;
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1039 use_register(creg,REG_EAX,1); /* will be destroyed */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1040 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1041
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1042 /* we don't have to save creg nor dreg */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1043 regs[creg]=0; regs[dreg]=0;
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1044 regv[dreg]= regv[save]= 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1045 use_register(dreg,REG_EDX,0); /* will be destroyed */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1046 use_register(save,REG_ECX,0); /* will be destroyed */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1047 regs[creg]=1; regs[dreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1048
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1049 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1050 printf("\tcall\t%s\n",n->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1051 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1052 printf("\tcall\t*%s\n",register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1053 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1054 if (nargs) printf("\taddl $%d,%%esp\n",size_of_int*nargs);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1055 if (saved) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1056 printf("\tpopl %s\n",register_name(save,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1057 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1058 free_register(save);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1059 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1060 regv[save]=0;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1061 if (ret_type==DOUBLE||ret_type==FLOAT) {
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1062 fregv[freg]=1; regv[creg]=0;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1063 } else if (ret_type==VOID) {
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1064 fregv[freg]=0; regv[creg]=0;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1065 } else {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1066 fregv[freg]=0; regv[creg]=1;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1067 }
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1068 return ret_type;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1069 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1070
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1071 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1072 code_frame_pointer(int e3) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1073 printf("\tmovl %s,%%ebp\n",register_name(e3,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1074 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1075
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1076
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1077 void
62
129f4802b027 separation done
kono
parents: 61
diff changeset
1078 code_fix_frame_pointer(int disp_offset) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1079 printf("\tlea %d(%%ebp),%%ebp\n",disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1080 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1081
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1082
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1083 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1084 code_jmp(char *s) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1085 printf("\tjmp %s\n",s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1086 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1087
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1088
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1089 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1090 code_indirect_jmp(int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1091 printf("\tjmp *%s\n",register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1092 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1093
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1094 int
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1095 code_rindirect(int e1, int reg,int offset, int us)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1096 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1097 char *crn,*op;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1098 int byte;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1099 g_expr(e1);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1100 byte = 0; op="movl";
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1101 crn = register_name(creg,0);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1102 printf("\t%s %d(%s),%s\n",op,offset,crn,crn);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1103 return us?UNSIGNED:INT;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1104 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1105
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1106 int
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1107 code_crindirect(int e1, int reg,int offset, int us)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1108 {
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1109 char *crn,*op;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1110 int byte;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1111 g_expr(e1);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1112 byte = 0; op=us?"movzbl":"movsbl";
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1113 crn = register_name(creg,0);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1114 printf("\t%s %d(%s),%s\n",op,offset,crn,crn);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1115 return us?UCHAR:CHAR;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1116 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1117
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1118 int
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1119 code_srindirect(int e1, int reg,int offset, int us)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1120 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1121 char *crn,*op;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1122 int byte;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1123 g_expr(e1);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1124 byte = 0; op=us?"movzwl":"movswl";
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1125 crn = register_name(creg,0);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1126 printf("\t%s %d(%s),%s\n",op,offset,crn,crn);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1127 return us?USHORT:SHORT;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1128 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1129
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1130 #if FLOAT_CODE
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1131 int
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1132 code_drindirect(int e1, int reg,int offset, int d)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1133 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1134 g_expr(e1);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1135 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1136 return DOUBLE;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1137 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1138 #endif
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1139
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1140 #if LONGLONG_CODE
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1141 int
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1142 code_lrindirect(int e1, int reg, int offset, int us)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1143 {
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 196
diff changeset
1144 return LONGLONG;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1145 }
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1146 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1147
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1148 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1149 move(int byte)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1150 {
165
kono
parents: 163
diff changeset
1151 return byte==1?"movb":byte==size_of_short?"movw":"movl";
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1152 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1153
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1154 void
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1155 code_assign_gvar(int e2,int creg,int byte) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1156 if (byte) use_data_reg(creg,1);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1157 printf("\t%s %s,%s\n",move(byte),register_name(creg,byte),((NMTBL*)cadr(e2))->nm);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1158 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1159
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1160 void
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1161 code_assign_lvar(int e2,int creg,int byte) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1162 if (byte) use_data_reg(creg,1);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1163 printf("\t%s %s,%d(%%ebp)\n",move(byte),register_name(creg,byte),lvar(e2));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1164 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1165
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1166 void
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1167 code_assign_register(int e2,int byte,int creg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1168 printf("\tmovl %s,%s\n",register_name(creg,0),register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1169 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1170
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1171 void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1172 code_assign(int e2,int byte,int creg) {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1173 if (byte) use_data_reg(creg,1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1174 printf("\t%s %s,(%s)\n",move(byte),register_name(creg,byte),register_name(e2,0));
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1175 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1176 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1177
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1178 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1179 code_register_assop(int e2,int reg0,int op,int byte) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1180 int reg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1181 int xreg = creg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1182 creg = reg = e2;
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1183 tosop(op,reg,xreg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1184 creg = xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1185 printf("\tmovl %s,%s\n",register_name(reg,0),register_name(creg,0));
159
b80e9737c3ce regs[creg]==0 in ia32
kono
parents: 156
diff changeset
1186 regs[creg]=regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1187 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1188
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1189
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1190 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1191 code_assop(int op,int reg,int byte,int sign) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1192 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1193 int xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1194 int edx = edx_setup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1195 xrn = register_name(xreg = emit_pop(0),0); /* pop e3 value */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1196 regv[xreg]=regs[xreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1197 printf("\tmovl %s,%s # assop \n",register_name(creg,0),register_name(edx,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1198 regv[edx]=1;
163
fc8514c9d685 *** empty log message ***
kono
parents: 159
diff changeset
1199 ld_indexx(byte,0,edx,sign);
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1200 tosop(op,reg,xreg);
165
kono
parents: 163
diff changeset
1201 printf("\t%s %s,(%s)\n",move(byte),register_name(creg,byte),register_name(edx,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1202 edx_cleanup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1203 emit_pop_free(xreg);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1204 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1205 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1206
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1207
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1208 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1209 tosop(int op,int reg,int oreg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1210 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1211 int dx;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1212 char *orn,*crn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1213
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1214 switch(op) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1215 case LSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1216 case ULSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1217 shift("sall",oreg);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1218 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1219 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1220 case RSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1221 shift("sarl",oreg);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1222 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1223 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1224 case URSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1225 shift("shrl",oreg);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1226 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1227 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1228 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1229 if(oreg==-1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1230 printf("\tpopl %s\n",register_name(dreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1231 oreg = dreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1232 regv[dreg]=1;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1233 } else if (oreg<= -REG_LVAR_OFFSET) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1234 code_rlvar(oreg+REG_LVAR_OFFSET,dreg);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
1235 free_lvar(oreg+REG_LVAR_OFFSET);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1236 oreg = dreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1237 regv[dreg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1238 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1239 regv[oreg]=1; regs[oreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1240 orn = register_name(oreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1241 crn = register_name(creg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1242 switch(op) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1243 case ADD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1244 printf("\taddl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1245 break;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1246 case SUB: case CMP:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1247 printf("\tsubl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1248 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1249 case BAND:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1250 printf("\tandl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1251 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1252 case EOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1253 printf("\txorl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1254 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1255 case BOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1256 printf("\torl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1257 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1258 case MUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1259 case UMUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1260 printf("\t%s %s,%s\n","imull",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1261 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1262 case DIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1263 case UDIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1264 use_register(creg,REG_EAX,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1265 edx_setup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1266 orn = register_name(oreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1267 if (op==DIV)
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1268 printf("\tcltd\n\tidivl %s\n",orn);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1269 else
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1270 printf("\txor %%edx,%%edx\n\tdivl %s\n",orn);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1271 edx_cleanup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1272 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1273 case MOD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1274 case UMOD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1275 use_register(creg,REG_EAX,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1276 edx_setup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1277 orn = register_name(oreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1278 if (op==DIV)
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1279 printf("\tcltd\n\tidivl %s\n",orn);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1280 else
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1281 printf("\txor %%edx,%%edx\n\tdivl %s\n",orn);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1282 dx = virtual(REG_EDX);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1283 if (dx!=creg) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1284 rname[dx]=rname[creg];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1285 rname[creg]=REG_EDX;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1286 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1287 edx_cleanup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1288 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1289 }
159
b80e9737c3ce regs[creg]==0 in ia32
kono
parents: 156
diff changeset
1290 if (oreg!=dreg&&oreg!=creg&&oreg>=0)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1291 free_register(oreg);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1292 else if (oreg==dreg) regv[dreg]=0;
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1293 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1294 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1295
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1296 int
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1297 code_const_op_p(int op,int v)
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1298 {
190
1b1c58483e67 minor fix
kono
parents: 189
diff changeset
1299 if (op==DIV||op==UDIV||op==MOD||op==UMOD) return 0;
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1300 else return 1;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1301 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1302
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1303 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1304 oprtc(int op,int reg,int orn)
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1305 {
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1306 char *crn = register_name(creg,0);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1307
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1308 switch(op) {
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1309 case LSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1310 case ULSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1311 printf("\tsall $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1312 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1313 case RSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1314 printf("\tsarl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1315 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1316 case URSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1317 printf("\tshrl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1318 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1319 case ADD:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1320 printf("\taddl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1321 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1322 case SUB: case CMP:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1323 printf("\tsubl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1324 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1325 case BAND:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1326 printf("\tandl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1327 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1328 case EOR:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1329 printf("\txorl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1330 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1331 case BOR:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1332 printf("\torl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1333 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1334 case MUL:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1335 case UMUL:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1336 printf("\t%s $%d,%s\n","imull",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1337 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1338 default:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1339 error(-1);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1340 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1341 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1342
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1343
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1344 static int edx_stack=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1345
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1346 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1347 edx_setup()
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1348 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1349 int edx_save;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1350 /* make real EDX register empty */
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1351 if (free_register_count(0)<1) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1352 for(edx_save = 0;edx_save==dreg||edx_save==creg;edx_save++);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1353 printf("\tpushl %s\n",register_name(edx_save,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1354 edx_stack = list3(edx_save,edx_stack,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1355 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1356 edx_save = get_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1357 edx_stack = list3(edx_save,edx_stack,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1358 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1359 regv[edx_save]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1360 use_register(edx_save,REG_EDX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1361 return edx_save;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1362 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1363
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1364
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1365 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1366 edx_cleanup()
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1367 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1368 if (caddr(edx_stack)==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1369 printf("\tpopl %s\n",register_name(car(edx_stack),0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1370 } else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1371 free_register(car(edx_stack));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1372 edx_stack = cadr(edx_stack);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1373 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1374
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1375 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1376 shift(char *op, int reg)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1377 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1378 if (reg>=0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1379 use_register(reg,REG_ECX,1);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1380 } else if (reg<= -REG_LVAR_OFFSET) {
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1381 use_register(dreg,REG_ECX,0);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1382 code_rlvar(reg+REG_LVAR_OFFSET,dreg);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1383 reg = dreg;
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1384 regv[dreg]=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1385 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1386 use_register(dreg,REG_ECX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1387 printf("\tpopl %%ecx\n");
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1388 regv[dreg]=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1389 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1390 printf("\t%s %%cl,%s\n",op,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1391 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1392
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1393 void
163
fc8514c9d685 *** empty log message ***
kono
parents: 159
diff changeset
1394 ld_indexx(int byte, int n, int xreg,int sign)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1395 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1396 char *op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1397
166
9e55cc5551fb *** empty log message ***
kono
parents: 165
diff changeset
1398 op = byte ? (sign?"movsbl":"movzbl") : "movl";
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1399 if (n)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1400 printf("\t%s %d(%s),%s\n",op,n,
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1401 register_name(xreg,0),register_name(creg,byte));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1402 else
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1403 printf("\t%s (%s),%s\n",op,
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1404 register_name(xreg,0),register_name(creg,byte));
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1405 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1406
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1407 int
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1408 code_csvalue()
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1409 {
123
5f180dc8d84e intel fix.
kono
parents: 119
diff changeset
1410 return rname[creg]; /* for switch value */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1411 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1412
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1413 void
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1414 code_cmpdimm(int e, int csreg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1415 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1416 /* used in dosiwtch() */
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1417 if(chk) return;
123
5f180dc8d84e intel fix.
kono
parents: 119
diff changeset
1418 use_register(creg,csreg,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1419 printf("\tcmpl $%d,%s\n",e,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1420 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1421
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1422 void
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1423 code_opening(char *filename)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1424 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1425 printf("\t.file \"%s\"\n",filename);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1426 printf("\t.version\t\"01.01\"\n");
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1427 /* printf("gcc2_compiled.:\n"); */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1428 printf(".text\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1429 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1430
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1431 void
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1432 code_closing()
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1433 {
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1434 global_table();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1435 printf("\t.ident \"Micro-C compiled\"\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1436 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1437
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1438 void
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1439 rexpr(int e1, int l1, char *s,int t)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1440 {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1441 g_expr(list3(CMP,cadr(e1),caddr(e1)));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1442 printf("\tj%s\t_%d\n",s,l1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1443 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1444
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1445
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1446 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1447 jcond(int l, char cond)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1448 {
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1449 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1450 printf("\tj%s\t_%d\n",cond?"ne":"e",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1451 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1452
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1453 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1454 jmp(int l)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1455 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1456 control=0;
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1457 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1458 printf("\tjmp\t_%d\n",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1459 /* align? */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1460 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1461 this is not allowed because of ? operator
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1462 regv[creg]=regv[dreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1463 use_register(creg,REG_EAX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1464 use_register(dreg,REG_EBX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1465 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1466 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1467
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1468 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1469 gen_comment(char *s)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1470 {
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1471 if (chk) return;
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1472 printf("## %s",s);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1473 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1474
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1475
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1476 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1477 code_enter(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1478 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1479 printf("\t.align 4\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1480 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1481 printf(".globl %s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1482 printf("\t.type\t%s,@function\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1483 printf("%s:\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1484 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1485
77
2b8ba655e572 fix arg type
kono
parents: 66
diff changeset
1486
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1487 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1488 code_enter1(int args)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1489 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1490 code_disp_label=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1491 printf("\tlea _%d(%%ebp),%%esp\n",code_disp_label);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1492
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1493 printf("## args %d disp %d code_arg_offset=%d code_disp_offset=%d\n",args,disp,code_arg_offset,code_disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1494 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1495
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1496 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1497 code_leave(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1498 {
63
e13486b2c12e stack alignment
kono
parents: 62
diff changeset
1499 disp&= -size_of_int;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1500 printf("\t.set _%d,%d\n",code_disp_label,disp+code_disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1501 printf("_%d:\n",labelno);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1502 printf("\t.size\t%s,_%d-%s\n",name,labelno,name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1503 local_table();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1504 labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1505 free_all_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1506 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1507
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1508 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1509 enter(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1510 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1511 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1512 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1513 printf(".globl %s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1514 printf("%s:\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1515 printf("\t.type\t%s,@function\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1516 printf("\tpushl %%ebp\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1517 printf("\tmovl %%esp,%%ebp\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1518 printf("\tpushl %%ebx\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1519 printf("\tpushl %%esi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1520 printf("\tpushl %%edi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1521 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1522
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1523 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1524 enter1()
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1525 {
182
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
1526 text_mode();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1527 func_disp_label=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1528 printf("\tlea _%d(%%ebp),%%esp\n",func_disp_label);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1529 /* if(disp) printf("\tsubl $%d,%%esp\n",-disp); */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1530 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1531
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1532 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1533 leave(int control, char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1534 {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1535 int sz;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1536
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1537 disp &= -size_of_int;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1538 if (control)
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1539 code_set_return_register(1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1540 if (retcont) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1541 if (control)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1542 jmp(retlabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1543 fwddef(retcont);
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1544 if (cadr(fnptr->ty)==FLOAT||cadr(fnptr->ty)==DOUBLE) {
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1545 printf("\tfldl %d(%%ebp)\n",-size_of_double);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1546 } else if (cadr(fnptr->ty)>0&&(
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1547 car(cadr(fnptr->ty))==STRUCT ||
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1548 car(cadr(fnptr->ty))==UNION)) {
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1549 sz = size(cadr(fnptr->ty));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1550 printf("\tlea %d(%%ebp),%s\n",-sz,register_name(dreg,0));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1551 printf("\tmovl %d(%%ebp),%s\n",disp-size_of_int,
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1552 register_name(creg,0));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1553 emit_copy(dreg,creg,sz,0,1,1);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1554 } else if (cadr(fnptr->ty)!=VOID) {
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1555 use_register(creg,REG_EAX,0);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1556 printf("\tmovl %s,%s\n",reg_name[REG_ESI],register_name(creg,0));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1557 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1558 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1559 fwddef(retlabel);
63
e13486b2c12e stack alignment
kono
parents: 62
diff changeset
1560
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1561 printf("\tlea %d(%%ebp),%%esp\n",disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1562 printf("\tpopl %%edi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1563 printf("\tpopl %%esi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1564 printf("\tpopl %%ebx\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1565 printf("\tleave\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1566 printf("\tret\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1567 printf("\t.set _%d,%d\n",func_disp_label,disp+disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1568 printf("_%d:\n",labelno);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1569 printf("\t.size\t%s,_%d-%s\n",name,labelno,name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1570 local_table();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1571 labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1572 free_all_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1573 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1574
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1575 int
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1576 code_get_fixed_creg(int reg,int type) {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1577 if (type==FLOAT||type==DOUBLE) {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1578 return 0;
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1579 } else {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1580 return rname[reg];
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1581 }
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1582 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1583
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1584 void
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1585 code_set_fixed_creg(int reg,int mode,int type) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1586 if (type==FLOAT||type==DOUBLE) {
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1587 } else {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1588 use_register(creg,reg,mode);
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1589 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1590 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1591
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1592 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1593 code_set_return_register(int mode) {
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1594 if (fnptr->ty==DOUBLE||fnptr->ty==FLOAT) {
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1595 } else {
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1596 use_register(creg,REG_EAX,mode);
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1597 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1598 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1599
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1600 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1601 gen_gdecl(char *n, int gpc)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1602 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1603 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1604 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1605 printf(".globl %s\n",n);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1606 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1607 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1608
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1609 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1610 align(int t)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1611 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1612 if (t!=CHAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1613 if (data_alignment & 1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1614 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1615 data_alignment = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1616 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1617 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1618
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1619 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1620 emit_data(int e, int t, NMTBL *n)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1621 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1622 int l;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1623 #if FLOAT_CODE
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1624 double d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1625 float f;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1626 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1627 char *name;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1628 name = n->nm;
156
da529eab5618 static initialization
kono
parents: 147
diff changeset
1629 if(mode!=GDECL && mode!=STADECL) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1630 error(-1); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1631 }
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1632 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1633 if (n->dsp != -1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1634 n->dsp = -1; /* initiallized flag */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1635 printf(".globl\t%s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1636 data_mode(name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1637 align(t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1638 printf("%s:\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1639 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1640 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1641 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1642 if(car(e)==CONST) {
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1643 if (t==CHAR||t==UCHAR) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1644 printf("\t.byte %d\n",cadr(e));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1645 if (data_alignment>0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1646 data_alignment++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1647 gpc += 1;
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1648 } else if (t==SHORT||t==USHORT) {
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1649 printf("\t.short %d\n",cadr(e));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1650 if (data_alignment>0) data_alignment++;
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1651 gpc += size_of_short;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1652 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1653 printf("\t.long %d\n",cadr(e));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1654 gpc += size_of_int;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1655 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1656 #if FLOAT_CODE
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1657 } else if(t==DOUBLE) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1658 d = dcadr(e);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1659 printf("\t.long\t0x%x,0x%x\n",code_d1(d),code_d2(d));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1660 } else if(t==FLOAT) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1661 f = dcadr(e);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1662 printf("\t.long\t0x%x\n",*(int *)&f);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1663 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1664 } else if(t!=CHAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1665 gpc += size_of_int;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1666 if(car(e)==ADDRESS&&car(cadr(e))==GVAR) {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1667 printf("\t.long %s\n",((NMTBL *)cadr(cadr(e)))->nm);
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1668 } else if(car(e)==GVAR) {
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1669 printf("\t.long %s\n",((NMTBL *)cadr(e))->nm);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1670 } else if(car(e)==FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1671 printf("\t.long %s\n",((NMTBL *)cadr(e))->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1672 } else if(car(e)==STRING) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1673 if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1674 l = fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1675 printf("\t.long _%d\n",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1676 printf(".section\t.rodata\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1677 printf("_%d:\n",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1678 output_mode = RODATA_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1679 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1680 ascii((char *)cadr(e));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1681 } else error(TYERR);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1682 } else error(TYERR);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1683 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1684
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1685 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1686 emit_data_closing(NMTBL *n)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1687 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1688 int lb;
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1689 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1690 if (mode==GDECL) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1691 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1692 lb=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1693 printf("_%d:\n",lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1694 printf("\t.size\t%s,_%d-%s\n",n->nm,lb,n->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1695 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1696 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1697
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1698 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1699 global_table(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1700 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1701 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1702 int init;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1703 init=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1704 for(n=ntable;n < &ntable[GSYMS];n++) {
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
1705 if ((n->sc == GVAR||n->sc == STATIC) && n->dsp != -1) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1706 /* n->dsp = -1 means initialized global */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1707 if (init==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1708 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1709 init=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1710 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1711 printf(".comm %s,%d\n",n->nm,size(n->ty));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1712 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1713 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1714 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1715
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1716 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1717 local_table(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1718 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1719 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1720 int init;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1721 init=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1722 /* static local variables */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1723 for(n=ntable+GSYMS;n < &ntable[GSYMS+LSYMS];n++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1724 if (n->sc == GVAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1725 if (init==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1726 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1727 init=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1728 }
156
da529eab5618 static initialization
kono
parents: 147
diff changeset
1729 if (n->dsp!= -1) /* -1 means initialized global */
da529eab5618 static initialization
kono
parents: 147
diff changeset
1730 printf(".lcomm %s,%d\n",n->nm,size(n->ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1731 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1732 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1733 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1734
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1735 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1736 text_mode(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1737 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1738 if (output_mode!=TEXT_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1739 printf(".text\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1740 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1741 output_mode = TEXT_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1742 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1743 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1744
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1745 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1746 data_mode(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1747 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1748 if (output_mode!=DATA_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1749 printf(".data\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1750 output_mode = DATA_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1751 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1752 if (name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1753 printf("\t.type\t%s,@object\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1754 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1755
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1756 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1757
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1758 /* floating point */
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1759
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1760
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1761 char *
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1762 fstore(int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1763 {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1764 return use?
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1765 (d?"fstl":"fsts"):
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1766 (d?"fstpl":"fstps")
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1767 ;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1768 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1769
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1770 char *
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1771 fstore_u(int d)
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1772 {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1773 return d?"fstpl":"fstps";
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1774 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1775
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1776 char *
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1777 fload(int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1778 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1779 return d?"fldl":"flds";
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1780 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1781
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1782
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1783 void code_dassign_gvar(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1784 {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1785 printf("\t%s %s\n",fstore(d),((NMTBL*)cadr(e2))->nm);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1786 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1787
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1788 void code_dassign_lvar(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1789 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1790 printf("\t%s %d(%%ebp)\n",fstore(d),lvar(e2));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1791 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1792
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1793 void code_dassign_dregister(int e,int d,int freg)
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1794 {
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1795 error(-1);
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1796 }
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1797
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1798 void code_dassign(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1799 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1800 printf("\t%s (%s)\n",fstore(d),register_name(e2,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1801 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1802
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1803 static double d0 = 1.0;
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1804
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1805 int
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1806 code_d1(double d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1807 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1808 int *i = (int *)&d0; int *j = (int *)&d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1809 return (i[1] == 0x3ff00000)?j[0]:j[1];
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1810 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1811
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1812 int
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1813 code_d2(double d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1814 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1815 int *i = (int *)&d0; int *j = (int *)&d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1816 return (i[1] == 0x3ff00000)?j[1]:j[0];
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1817 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1818
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1819 void code_dconst(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1820 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1821 int lb;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1822 double value = dcadr(e2);
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1823
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1824 if (value==0.0) {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1825 printf("\tfldz\n"); return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1826 }
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1827 if (value==1.0) {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1828 printf("\tfld1\n"); return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1829 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1830 printf(" \t.section\t.rodata\n\t.align 8\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1831 lb=fwdlabel();
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1832 printf("_%d:\n",lb);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1833 printf("\t.long\t0x%x,0x%x\n",code_d1(value),code_d2(value));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1834 if (output_mode==TEXT_EMIT_MODE) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1835 printf(".text\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1836 } else {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1837 text_mode();
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1838 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1839 printf("\tfldl _%d\n",lb);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1840 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1841
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1842 void code_dneg(int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1843 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1844 printf("\tfchs\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1845 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1846
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1847 void code_d2i(int freg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1848 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1849 printf("\tlea -%d(%%esp),%%esp\n",size_of_int*2);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1850 printf("\tfnstcw (%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1851 printf("\tmovl (%%esp), %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1852 printf("\tmovb $12, 1(%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1853 printf("\tfldcw (%%esp)\n");
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1854 printf("\tfistpl %d(%%esp)\n",size_of_int);
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1855 printf("\tmovl %s, (%%esp)\n",register_name(creg,0));
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1856 printf("\tfldcw (%%esp)\n");
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1857 printf("\tpopl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1858 printf("\tpopl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1859 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1860
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1861 void code_i2d(int creg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1862 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1863 printf("\tpushl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1864 printf("\tfildl (%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1865 printf("\tlea %d(%%esp),%%esp\n",size_of_int);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1866 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1867
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1868 void code_d2u(int freg)
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1869 {
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1870 printf("\tlea -%d(%%esp),%%esp\n",size_of_int*3);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1871 printf("\tfnstcw (%%esp)\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
1872 printf("\tmovl (%%esp), %s\n",register_name(creg,0));
3789aef7331d minor fix
kono
parents: 84
diff changeset
1873 printf("\tmovb $12, 1(%%esp)\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
1874 printf("\tfldcw (%%esp)\n");
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1875 printf("\tmovl %s, (%%esp)\n",register_name(creg,0));
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1876 printf("\tfistpll %d(%%esp)\n",size_of_int);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1877 printf("\tfldcw (%%esp)\n");
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1878 printf("\tmovl %d(%%esp),%s\n",size_of_int,register_name(creg,0));
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1879 printf("\tlea %d(%%esp),%%esp\n",size_of_int*3);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1880 }
3789aef7331d minor fix
kono
parents: 84
diff changeset
1881
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1882 void code_u2d(int creg)
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1883 {
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1884 printf("\tpushl %s\n",register_name(creg,0));
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1885 printf("\tpushl %s\n",register_name(creg,0));
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1886 printf("\tmovl $0, %d(%%esp)\n",size_of_int);
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1887 printf("\tfildll (%%esp)\n");
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1888 printf("\tlea %d(%%esp),%%esp\n",size_of_int*2);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1889 }
3789aef7331d minor fix
kono
parents: 84
diff changeset
1890
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
1891 void code_d2f(int freg) { }
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
1892 void code_f2d(int freg) { }
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1893 void code_f2i(int freg) { code_d2i(freg); }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1894 void code_f2u(int freg) { code_d2u(freg); }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1895 void code_i2f(int creg) { code_i2d(creg); }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
1896 void code_u2f(int creg) { code_u2d(creg); }
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
1897
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1898 void code_drgvar(int e2,int d,int freg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1899 {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1900 printf("\t%s %s\n",fload(d),((NMTBL*)cadr(e2))->nm);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1901 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1902
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1903
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1904 void code_drlvar(int e2,int d,int freg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1905 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1906 printf("\t%s %d(%%ebp)\n",fload(d),lvar(e2));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1907 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1908
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1909 void code_cmp_drgvar(int e2,int reg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1910 {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1911 printf("\tfcomp %s\n",((NMTBL*)cadr(e2))->nm);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1912 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1913
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1914 void code_cmp_drlvar(int e2,int reg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1915 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1916 printf("\tfcomp %d(%%ebp)\n",lvar(e2));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1917 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1918
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1919 void dtosop(int op,int reg,int e1)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1920 {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1921 switch(op) {
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
1922 case FADD:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1923 case DADD: printf("\tfaddp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
1924 case FSUB:
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1925 case DSUB: printf("\tfsubp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
1926 case FDIV:
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
1927 case DDIV: printf("\tfdivp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
1928 case FMUL:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1929 case DMUL: printf("\tfmulp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
1930 case FCMP:
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1931 case DCMP:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1932 printf("\tfucompp\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1933 printf("\tfnstsw\t%%ax\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1934 break;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1935 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1936 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1937
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1938 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1939 code_dassop(int op,int reg,int d) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1940 /* we have lvalue in creg, applied floating value is in %st(0) */
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
1941 emit_dpop(d); /* do nothing for 387 */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1942 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1943 dtosop(op,reg,0);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1944 printf("\t%s (%s)\n",fstore(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1945 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1946
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1947 void
219
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
1948 code_register_dassop(int reg,int op,int d) {
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
1949 error(-1);
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
1950 }
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
1951
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
1952 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1953 code_dpreinc(int e1,int e2,int d,int freg) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1954 g_expr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1955 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1956 printf("\tfld1\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
1957 if (caddr(e1)>0)
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1958 printf("\tfaddp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1959 else
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1960 printf("\tfsubrp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1961 printf("\t%s (%s)\n",fstore(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1962 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1963
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1964 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1965 code_dpostinc(int e1,int e2,int d,int freg) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1966 g_expr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1967 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1968 if (use)
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
1969 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1970 printf("\tfld1\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
1971 if (caddr(e1)>0)
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1972 printf("\tfaddp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1973 else
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1974 printf("\tfsubrp %%st,%%st(1)\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
1975 printf("\t%s (%s)\n",(use?fstore_u(d):fstore(d)),register_name(creg,0));
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1976 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1977
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1978 void
230
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1979 drexpr(int e1, int e2,int l1, int op,int cond)
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
1980 {
230
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1981 if (cond) {
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1982 switch(op) {
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1983 case DOP+GE:
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1984 drexpr(e2,e1,l1,DOP+GT,0); break;
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1985 case FOP+GE:
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1986 drexpr(e2,e1,l1,FOP+GT,0); break;
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1987 case DOP+GT:
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1988 drexpr(e2,e1,l1,DOP+GE,0); break;
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1989 case FOP+GT:
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1990 drexpr(e2,e1,l1,FOP+GE,0); break;
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1991 case DOP+EQ:
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1992 op = DOP+NEQ; break;
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1993 case FOP+EQ:
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1994 op = FOP+NEQ; break;
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1995 case DOP+NEQ:
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1996 op = DOP+EQ; break;
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1997 case FOP+NEQ:
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1998 op = FOP+EQ; break;
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
1999 }
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
2000 }
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
2001 g_expr(list3(DCMP,e1,e2));
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2002 switch(op) {
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2003 case DOP+GE:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2004 case FOP+GE:
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2005 printf("\ttestb\t$5,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2006 printf("\tjne\t_%d\n",l1);
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2007 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2008 case DOP+GT:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2009 case FOP+GT:
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2010 printf("\ttestb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2011 printf("\tjne\t_%d\n",l1);
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2012 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2013 case DOP+EQ:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2014 case FOP+EQ:
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2015 printf("\tandb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2016 printf("\txorb\t$64,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2017 printf("\tjne\t_%d\n",l1);
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2018 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2019 case DOP+NEQ:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2020 case FOP+NEQ:
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2021 printf("\tandb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2022 printf("\txorb\t$64,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2023 printf("\tje\t_%d\n",l1);
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2024 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2025 }
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2026 }
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2027
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2028 void
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2029 code_dregister(int e2,int freg,int d)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2030 {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2031 error(-1);
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2032 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2033
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2034 void
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2035 code_cmp_dregister(int e2,int d)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2036 {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2037 error(-1);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2038 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2039
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2040 int pop_fregister()
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2041 {
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2042 if (freg_sp<0) { error(-1); return -1;}
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2043 printf("# fpop: %d\n",freg_sp-1);
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2044 return freg_stack[--freg_sp];
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2045 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2046
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2047 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2048 emit_dpop(int d)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2049 {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2050 int xreg;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2051 if ((xreg=pop_fregister())==-1) {
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2052 } else if (xreg<= -REG_LVAR_OFFSET) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2053 code_drlvar(REG_LVAR_OFFSET+xreg,1,freg);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
2054 free_lvar(xreg+REG_LVAR_OFFSET);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2055 /* pushed order is reversed. We don't need this for comutable
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2056 operator, but it is ok to do this. */
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2057 printf("\tfxch\t%%st(1)\n");
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2058 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2059 return xreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2060 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2061
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2062
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2063 void emit_dpop_free(int e1,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2064 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2065 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2066
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2067 void emit_dpush(int type)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2068 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2069 if (freg_sp>=MAX_FPU_STACK) code_save_fstacks();
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2070 if (freg_sp>MAX_MAX) error(-1);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2071 freg_stack[freg_sp++]=-1;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2072 printf("# fpush:%d\n",freg_sp);
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2073 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2074
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2075 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2076
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2077 void
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2078 code_save_stacks()
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2079 {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2080 /* temporal registers or stacks in fpu are saved in local variable */
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2081 int xreg,sp,screg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2082 sp=reg_sp;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2083 while(sp-->0) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2084 if ((xreg=reg_stack[sp])>=0) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2085 screg=creg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2086 if(creg!=xreg) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2087 if (xreg!=dreg) free_register(xreg);
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2088 creg = xreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2089 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2090 code_assign_lvar(
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2091 (reg_stack[sp]=new_lvar(size_of_int)),creg,0);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2092 reg_stack[sp]= reg_stack[sp]-REG_LVAR_OFFSET;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2093 regv[xreg]=0;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2094 creg=screg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2095 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2096 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2097 #if FLOAT_CODE
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2098 code_save_fstacks();
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2099 #endif
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2100 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2101
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2102 #if FLOAT_CODE
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2103 void
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2104 code_save_fstacks()
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2105 {
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
2106 int xreg,sp,uses;
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
2107 uses = use; use = 0;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2108 sp=freg_sp;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2109 while(sp-->0) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2110 if ((xreg=freg_stack[sp])==-1) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2111 code_dassign_lvar(
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2112 (freg_stack[sp]=new_lvar(size_of_double)),freg,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2113 freg_stack[sp]= freg_stack[sp]-REG_LVAR_OFFSET;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2114 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2115 }
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
2116 use = uses;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2117 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2118 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2119
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2120
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2121
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2122 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2123
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2124
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2125 /* 64bit int part */
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2126
230
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
2127 void lrexpr(int e1, int e2,int l1, int op,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2128 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2129 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2130
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2131 int lpop_register()
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2132 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2133 return 0;
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2134 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2135
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2136 int emit_lpop()
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2137 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2138 return 0;
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2139 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2140
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2141 void code_lregister(int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2142 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2143
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2144 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2145
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2146 void code_cmp_lregister(int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2147 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2148
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2149 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2150
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2151 void code_cmp_lrgvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2152 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2153
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2154 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2155
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2156 void code_cmp_lrlvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2157 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2158
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2159 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2160
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2161 void code_lassign(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2162 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2163
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2164 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2165
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2166 void code_lassign_gvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2167 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2168
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2169 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2170
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2171 void code_lassign_lvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2172 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2173
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2174 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2175
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2176 void code_lassign_lregister(int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2177 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2178
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2179 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2180
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2181 void code_lconst(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2182 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2183
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2184 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2185
212
32f54ab63b35 *** empty log message ***
kono
parents: 205
diff changeset
2186 void code_lneg(int e1)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2187 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2188
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2189 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2190
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2191 void code_lrgvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2192 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2193
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2194 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2196 void code_lrlvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2197 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2198
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2199 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2200
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2201 void ltosop(int e1,int reg,int e2)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2202 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2203
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2204 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2205
213
kono
parents: 212
diff changeset
2206 int code_lconst_op_p(int op,int e) {return 0;}
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2207 void loprtc(int op,int reg,int e) {}
213
kono
parents: 212
diff changeset
2208
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2209 void emit_lpop_free(int e1)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2210 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2211
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2212 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2213
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2214 void emit_lpush()
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2215 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2216
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2217 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2218
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2219 void code_i2ll()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2220 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2221
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2222 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2223
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2224 void code_i2ull()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2225 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2226
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2227 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2228
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2229 void code_u2ll()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2230 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2231
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2232 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2233
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2234 void code_u2ull()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2235 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2236
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2237 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2238
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2239 void code_ll2i()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2240 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2241
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2242 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2243
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2244 void code_ll2u()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2245 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2246
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2247 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2248
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2249 void code_ull2i()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2250 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2251
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2252 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2253
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2254 void code_ull2u()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2255 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2256
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2257 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2258
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2259 #if FLOAT_CODE
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2260 void code_d2ll()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2261 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2262
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2263 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2264
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2265 void code_d2ull()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2266 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2267
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2268 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2269
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2270 void code_f2ll()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2271 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2272
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2273 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2274
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2275 void code_f2ull()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2276 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2277
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2278 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2279
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2280 void code_ll2d()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2281 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2282
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2283 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2284
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2285 void code_ll2f()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2286 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2287
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2288 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2289
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2290 void code_ull2d()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2291 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2292
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2293 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2294
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2295 void code_ull2f()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2296 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2297
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2298 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2299
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2300 void code_ull2ll()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2301 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2302
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2303 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2304
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2305 void code_ull2ull()
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2306 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2307
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2308 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2309
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2310 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2311
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2312
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2313 void code_lpreinc(int e1,int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2314 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2315
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2316 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2317
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2318 void code_lpostinc(int e1,int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2319 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2320
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2321 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2322
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2323 void code_lassop(int op,int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2324 {
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2325
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2326 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2327
219
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2328 void
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2329 code_register_lassop(int reg,int op) {
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2330 }
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2331
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2332
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2333 #endif
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2334
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2335 /* end */
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2336