annotate mc-code-ia32.c @ 292:6d4231b6f9fe

switch statement prepare
author kono
date Sat, 05 Jun 2004 00:08:09 +0900
parents 7b6df595b205
children 60dba3ef1f69
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/",
246
0dcc0ec81ed2 MIPS on going (90%)
kono
parents: 245
diff changeset
15 "/usr/lib/dietlibc/include/",
173
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
16 0
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
17 };
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
18
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
19
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
20 #define SIZE_OF_INT 4
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
21 #define SIZE_OF_SHORT 2
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
22 #define SIZE_OF_FLOAT 4
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
23 #define SIZE_OF_DOUBLE 8
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
24 #define SIZE_OF_LONGLONG 8
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
25 #define ENDIAN 0
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
26
254
5aaca4f9d96b *** empty log message ***
kono
parents: 246
diff changeset
27 int size_of_int = SIZE_OF_INT;
5aaca4f9d96b *** empty log message ***
kono
parents: 246
diff changeset
28 int size_of_short = SIZE_OF_SHORT;
5aaca4f9d96b *** empty log message ***
kono
parents: 246
diff changeset
29 int size_of_float = SIZE_OF_FLOAT;
5aaca4f9d96b *** empty log message ***
kono
parents: 246
diff changeset
30 int size_of_double = SIZE_OF_DOUBLE;
5aaca4f9d96b *** empty log message ***
kono
parents: 246
diff changeset
31 int size_of_longlong = SIZE_OF_LONGLONG;
5aaca4f9d96b *** empty log message ***
kono
parents: 246
diff changeset
32 int endian = ENDIAN;
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
33
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
34 #define SAVE_STACKS 1
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
35
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
36 #define TEXT_EMIT_MODE 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
37 #define DATA_EMIT_MODE 1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
38 #define RODATA_EMIT_MODE 2
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
39
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
40 static int output_mode = TEXT_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
41 static int data_alignment = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
42
224
82a55cc6b5fc *** empty log message ***
kono
parents: 219
diff changeset
43 static int creg;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
44 static int lreg;
224
82a55cc6b5fc *** empty log message ***
kono
parents: 219
diff changeset
45
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
46 int code_lassop_p = 0;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
47
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
48 static int MAX_REGISTER=6; /* intel386のレジスタを6つまで使う*/
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
49 #define REAL_MAX_REGISTER 8 /* intel386のレジスタが8つということ*/
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
50 static int MAX_DATA_REG=4;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
51 static int MAX_POINTER=3;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
52 // static int MAX_REGISTGER_VAR=2;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
53 // static int MAX_FREGISTER=1;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
54
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
55 #define MAX_FPU_STACK 7
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
56 #define REG_VAR 3
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
57
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
58 // static int MAX_INPUT_REGISTER_VAR = 0;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
59 static int MAX_CODE_INPUT_REGISTER_VAR = 2;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
60 // static int MAX_INPUT_DREGISTER_VAR = 0;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
61 // static int MAX_INPUT_FREGISTER_VAR = 0;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
62 // static int MAX_CODE_INPUT_DREGISTER_VAR = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
63
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
64 static int reg_sp; /* REGister Stack-Pointer */
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
65 static int reg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
66
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
67 /* floating point registers */
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
68
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
69 static int freg_sp; /* floating point REGister Stack-Pointer */
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
70 static int freg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
71
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
72 static int reg_var;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
73 static int regvar[2];
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
74
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
75
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
76 /*
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
77 -28 -8 local2
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
78 -24 -4 local1
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
79 -20 8 arg3
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
80 -16 4 arg2
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
81 -12 0 arg1
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
82 local2 -20 4 -8 (%edi)
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
83 local1 <-- -16 0 local variable -4 (%esi)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
84 %edi -12 <- disp_offset %ebp
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
85 %esi -8
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
86 %ebx -4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
87 %ebp = %esp 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
88 %eip 4 <- arg_offset
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
89 arg1 8 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
90 arg2 12 4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
91 see enter/enter1/leave see code_enter
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
92 */
244
39e28d6cfa56 ia32 long long done
kono
parents: 243
diff changeset
93 // static int arg_offset = 8;
39e28d6cfa56 ia32 long long done
kono
parents: 243
diff changeset
94 // static int disp_offset = -12;
39e28d6cfa56 ia32 long long done
kono
parents: 243
diff changeset
95 #define func_disp_offset -12
39e28d6cfa56 ia32 long long done
kono
parents: 243
diff changeset
96 #define code_disp_offset 0
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
97 // static int jump_offset = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
98
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
99 static int code_disp_label;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
100 static int func_disp_label;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
101
263
c922bade771d MIPS go on...
kono
parents: 258
diff changeset
102
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
103 static int
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
104 lvar(int l)
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
105 {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
106 if (is_code(fnptr)) {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
107 return l+code_disp_offset;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
108 } else if (l<0) {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
109 return l+disp_offset;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
110 } else {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
111 return l+arg_offset;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
112 }
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
113 }
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
114
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
115 /*
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
116 creg currrent virtual register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
117 dreg spare virtual register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
118
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
119 rname[creg] currrent real register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
120 rname[dreg] spare real register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
121
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
122 regs[] virtual register usage
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
123 regv[] value in virtual register flag
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
124
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
125 reg_name[rname[creg]]
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
126
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
127 freg current floating point register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
128 fregv calue in floating point register
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
129 */
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
130
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
131 static int dreg; /* general temporal register */
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
132
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
133 #define REAL_MAX_LREGISTER 2
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
134 static int ia32regs[REAL_MAX_REGISTER+REAL_MAX_LREGISTER];
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
135 static int ia32regv[REAL_MAX_REGISTER+REAL_MAX_LREGISTER];
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
136 static int ia32rname[REAL_MAX_REGISTER+REAL_MAX_LREGISTER];
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
137
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
138 static int *regv = ia32regv;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
139 static int *regs = ia32regs;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
140 static int *rname = ia32rname;
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
141
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
142 static int ia32fregs[1];
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
143 static int ia32fregv[1];
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
144
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
145 static int freg;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
146 static int *fregv = ia32fregv;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
147 static int *fregs = ia32fregs;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
148
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
149
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
150 #define REG_EAX 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
151 #define REG_EBX 1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
152 #define REG_ECX 2
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
153 #define REG_EDX 3
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
154 #define REG_ESI 4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
155 #define REG_EDI 5
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
156 #define REG_EBP 6
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
157 #define REG_ESP 7
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
158 #define is_int_reg(reg) (reg<REG_EBP)
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
159 #define REG_LCREG 8
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
160 #define REG_L 9
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
161
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
162
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
163 #define DATA_REG 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
164 #define POINTER_REG 3
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
165 static char *reg_name[8];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
166 static char *reg_name_l[4];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
167 static char *reg_name_w[4];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
168
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
169 static void use_register(int virt, int real, int move);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
170 static int virtual(int real);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
171 static void shift(char *op, int reg,int creg);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
172 static void ld_indexx(int byte, int n, int xreg,int reg,int sign);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
173 static void data_mode(char *name);
263
c922bade771d MIPS go on...
kono
parents: 258
diff changeset
174 static void text_mode();
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
175 static int edx_setup(int rreg);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
176 static void edx_cleanup();
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
177 static void local_table(void);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
178 #if FLOAT_CODE
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
179 static char * fload(int d);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
180 static int code_d1(double d);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
181 static int code_d2(double d);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
182 static void code_save_fstacks();
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
183 #endif
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
184 static void code_save_stacks();
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
185 static void jcond(int l, char cond);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
186
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
187 #define use_int(reg) if (reg==-1) reg=use_int0()
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
188 static int use_int0() { lreg = 0; if (!is_int_reg(creg)) { creg = virtual(REG_EBX); regs[creg]=1;} return creg; }
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
189
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
190 #define use_longlong(reg) reg=use_longlong0(reg)
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
191 static int
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
192 use_longlong0(int reg)
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
193 {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
194 int i;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
195 if (reg==USE_CREG)
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
196 reg = REG_LCREG;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
197 if (!lreg) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
198 code_save_stacks();
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
199 // make edx,eax free
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
200 use_register(creg,REG_EBX,regv[creg]);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
201 use_register(dreg,REG_ECX,regv[dreg]);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
202 for(i=0;i<reg_var;i++)
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
203 use_register(regvar[i],REG_ESI+i,1);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
204 }
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
205 creg = lreg = reg;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
206 return lreg;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
207 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
208
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
209 char *
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
210 l_edx(int i) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
211 return i==REG_L?"%edi":"%edx";
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
212 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
213 char *
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
214 l_eax(int i) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
215 return i==REG_L?"%esi":"%eax";
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
216 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
217
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
218
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
219 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
220 code_init(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
221 {
173
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
222 macro_define("__i386__ 1\n");
182
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
223 macro_define("__LITTLE_ENDIAN__ 1\n");
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
224 macro_define("__STDC__ 1\n");
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
225 macro_define("size_t int\n");
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
226 macro_define("__externsion__\n");
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
227 macro_define("__flexarr\n");
183
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
228 macro_define("__builtin_va_list int*\n");
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
229 macro_define("wchar_t int\n");
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
230 // macro_define("__THROW\n");
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
231 macro_define("__gnuc_va_list int*\n");
173
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
232
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
233 arg_offset = 8;
244
39e28d6cfa56 ia32 long long done
kono
parents: 243
diff changeset
234 // func_disp_offset = -12;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
235 disp_offset = -12;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
236 MAX_REGISTER=6;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
237 MAX_DATA_REG=4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
238 MAX_POINTER=3;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
239 MAX_REGISTER_VAR=2;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
240
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
241 reg_name[REG_EAX] = "%eax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
242 reg_name[REG_EBX] = "%ebx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
243 reg_name[REG_ECX] = "%ecx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
244 reg_name[REG_EDX] = "%edx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
245 reg_name[REG_ESI] = "%esi";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
246 reg_name[REG_EDI] = "%edi";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
247 reg_name[REG_EBP] = "%ebp";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
248 reg_name[REG_ESP] = "%esp";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
249 reg_name_l[REG_EAX] = "%al";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
250 reg_name_l[REG_EBX] = "%bl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
251 reg_name_l[REG_ECX] = "%cl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
252 reg_name_l[REG_EDX] = "%dl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
253 reg_name_w[REG_EAX] = "%ax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
254 reg_name_w[REG_EBX] = "%bx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
255 reg_name_w[REG_ECX] = "%cx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
256 reg_name_w[REG_EDX] = "%dx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
257
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
258 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
259
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
260 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
261 register_name(int i,int byte)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
262 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
263 if (i<0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
264 error(REG_ERR);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
265 return "%eax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
266 }
165
kono
parents: 163
diff changeset
267 if (byte==1 && rname[i] <= REG_EDX) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
268 return reg_name_l[rname[i]];
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
269 } else if (byte==SIZE_OF_SHORT && rname[i] <= REG_EDX) {
165
kono
parents: 163
diff changeset
270 return reg_name_w[rname[i]];
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
271 } else {
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
272 return reg_name[rname[i]]; /* 0 or 4 means int */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
273 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
274 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
275
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
276 /*
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
277 int use_int(int i) { return i;}
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
278 int use_float(int i) { return i;}
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
279 int use_double(int i) { return i;}
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
280 int use_longlong(int i) { return i; }
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
281 */
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
282
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
283
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
284 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
285 gexpr_code_init(void){
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
286 use_register(creg,REG_EAX,0);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
287 regv[creg]=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
288 regv[dreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
289 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
290
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
291 void
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
292 code_gexpr(int e){
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
293 }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
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 get_register(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 regs[i]=1; /* そのレジスタを使うことを宣言し */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
302 return i; /* その場所を表す番号を返す */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
303 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
304 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
305 return -1; /* 空いている場所がないなら、それを表す -1 を返す */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
306 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
307
917947ffeb7c power pc version
kono
parents: 87
diff changeset
308 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
309 free_register(int i) { /* いらなくなったレジスタを開放 */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
310 regv[i]=regs[i]=0;
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
311 if(i==REAL_MAX_REGISTER) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
312 regv[virtual(REG_ESI)]=regv[virtual(REG_EDI)]=0;
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
313 }
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
314 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
315
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
316 int
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
317 get_input_register_var(int i,NMTBL *nptr,int is_code)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
318 {
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
319 if (is_code) {
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
320 if (i>=MAX_CODE_INPUT_REGISTER_VAR) return 0;
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
321 i = virtual(i+REG_ESI);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
322 regs[i]=regv[i]=INPUT_REG;
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
323 return list3(REGISTER,i,(int)nptr);
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
324 } else {
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
325 return 0;
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
326 }
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
327 }
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
328
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
329 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
330 get_input_dregister_var(int i,NMTBL *nptr,int is_code,int d)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
331 {
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
332 return 0;
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
333 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
334
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
335 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
336 get_dregister(int d)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
337 {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
338 return -1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
339 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
340
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
341 int
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
342 get_lregister_var(NMTBL *n)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
343 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
344 int h,l;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
345 h = virtual(REG_ESI);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
346 l = virtual(REG_EDI);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
347 if (regv[REAL_MAX_REGISTER]==0&&regs[h]==0&&regs[l]==0) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
348 regs[h]=regs[l]=REG_VAR;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
349 regv[h]=regv[l]=REG_VAR;
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
350 regv[REAL_MAX_REGISTER]=1;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
351 reg_var=2; regvar[0]=h; regvar[1]=l;
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
352 return list2(LREGISTER,REG_L);
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
353 }
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
354 return list2(LVAR,new_lvar(SIZE_OF_LONGLONG));
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
355 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
356
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
357 int
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
358 get_lregister()
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
359 {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
360 return -1;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
361 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
362
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
363
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
364 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
365 register_full(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
366 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
367 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
368 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
369 if (! regs[i]) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
370 return 0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
371 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
372 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
373 return 1;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
374 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
375
917947ffeb7c power pc version
kono
parents: 87
diff changeset
376 int
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
377 free_register_count(int d)
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
378 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
379 int i,count;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
380 count = 0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
381 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
382 if (! regs[i] && ! regv[i]) count++;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
383 }
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
384 return d?0:count;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
385 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
386
917947ffeb7c power pc version
kono
parents: 87
diff changeset
387 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
388 free_all_register(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
389 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
390 int i;
243
c311c26e006a *** empty log message ***
kono
parents: 242
diff changeset
391 for(i=0;i<MAX_REGISTER+REAL_MAX_LREGISTER;i++) {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
392 regs[i]=regv[i]=0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
393 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
394 creg = get_register();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
395 dreg = get_register();
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
396 reg_var = 0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
397 return;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
398 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
399
917947ffeb7c power pc version
kono
parents: 87
diff changeset
400
917947ffeb7c power pc version
kono
parents: 87
diff changeset
401 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
402 register_usage(char *s)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
403 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
404 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
405 if (chk) return;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
406 printf("# %d: %s:",lineno,s);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
407 printf(" creg=%s dreg=%s ",register_name(creg,0),register_name(dreg,0));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
408 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
409 printf("%d",regs[i]);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
410 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
411 printf(":");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
412 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
413 printf("%d",regv[i]);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
414 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
415 #if 0
917947ffeb7c power pc version
kono
parents: 87
diff changeset
416 printf(" regs_stack",register_name(creg,0),register_name(dreg,0));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
417 for(i=reg_sp;i>=0;i--) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
418 if(reg_stack[i]>=0)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
419 printf(" %s",register_name(reg_stack[i],0));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
420 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
421 #endif
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
422 printf(" f:%d",freg_sp);
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
423 printf("\n");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
424 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
425
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
426 void
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
427 code_arg_register(NMTBL *fnptr)
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
428 {
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
429 int args = fnptr->dsp;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
430 NMTBL *n;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
431 int reg_var = 0;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
432 int freg_var = 0;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
433 int type;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
434 int reg;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
435 int is_code0 = is_code(fnptr);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
436
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
437 while (args) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
438 /* process in reverse order */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
439 n = (NMTBL*)caddr(args);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
440 type = n->ty;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
441 if (scalar(type)) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
442 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
443 n->sc = REGISTER;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
444 n->dsp = cadr(reg);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
445 regv[n->dsp]= 1;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
446 regs[n->dsp]= INPUT_REG;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
447 reg_var++;
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
448 cadddr(args)=SIZE_OF_INT; /* why we need this? */
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
449 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
450 } else if (type==FLOAT||type==DOUBLE) {
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
451 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
452 n->sc = DREGISTER;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
453 n->dsp = cadr(reg);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
454 fregv[n->dsp]= 1;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
455 fregs[n->dsp]= INPUT_REG;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
456 freg_var++;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
457 cadddr(args)=size(type); /* why we need this? */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
458 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
459 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
460 args = cadr(args);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
461 }
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
462 }
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
463
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
464 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
465 gexpr_init(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
466 {
292
6d4231b6f9fe switch statement prepare
kono
parents: 291
diff changeset
467 if (reg_sp>0) error(-1);
6d4231b6f9fe switch statement prepare
kono
parents: 291
diff changeset
468 if (freg_sp>0) error(-1);
6d4231b6f9fe switch statement prepare
kono
parents: 291
diff changeset
469 reg_sp = 0;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
470 freg_sp = 0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
471 text_mode();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
472 gexpr_code_init();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
473 register_usage("gexpr_init");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
474 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
475
917947ffeb7c power pc version
kono
parents: 87
diff changeset
476
917947ffeb7c power pc version
kono
parents: 87
diff changeset
477 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
478 emit_init(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
479 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
480 int i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
481 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
482 free_all_register();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
483 reg_sp = 0;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
484 freg_sp = 0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
485 text_mode();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
486 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
487
917947ffeb7c power pc version
kono
parents: 87
diff changeset
488 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
489 virtual(int real)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
490 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
491 int real_v,i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
492 real_v = -1;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
493 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
494 if (rname[i]==real) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
495 real_v=i;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
496 break;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
497 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
498 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
499 return real_v;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
500 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
501
917947ffeb7c power pc version
kono
parents: 87
diff changeset
502 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
503 pop_register(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
504 { /* レジスタから値を取り出す */
917947ffeb7c power pc version
kono
parents: 87
diff changeset
505 return reg_stack[--reg_sp];
917947ffeb7c power pc version
kono
parents: 87
diff changeset
506 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
507
917947ffeb7c power pc version
kono
parents: 87
diff changeset
508 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
509 emit_pop_free(int xreg)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
510 {
159
b80e9737c3ce regs[creg]==0 in ia32
kono
parents: 156
diff changeset
511 if (xreg==dreg||xreg==creg) {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
512 regv[dreg]=0;
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
513 } else if (xreg>=0) {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
514 free_register(xreg);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
515 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
516 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
517
917947ffeb7c power pc version
kono
parents: 87
diff changeset
518
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
519 int
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
520 get_register_var(NMTBL *nptr)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
521 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
522 int i;
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
523 for(i=REG_ESI;i<REG_EBP;i++) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
524 if (! regs[i]) { /* 使われていないなら */
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
525 regs[i]=REG_VAR; /* そのレジスタを使うことを宣言し */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
526 regv[i]=0;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
527 regvar[reg_var++]=i;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
528 return list3(REGISTER,i,(int)nptr); /* その場所を表す番号を返す */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
529 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
530 }
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
531 return list2(LVAR,new_lvar(SIZE_OF_INT));
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
532 }
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
533
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
534 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
535 get_dregister_var(NMTBL *nptr,int d)
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
536 {
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
537 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
538 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
539
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
540 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
541 use_register(int virt, int real, int move)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
542 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
543 int real_v;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
544 char *move_op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
545 if (rname[virt]==real)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
546 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
547 real_v = virtual(real);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
548 move_op = regs[real_v]?"\txchg %s,%s\n":"\tmovl %s,%s\n";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
549 if (move || (regv[real_v])) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
550 printf(move_op,reg_name[rname[virt]],reg_name[real]);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
551 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
552 rname[real_v] = rname[virt];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
553 rname[virt] = real;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
554 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
555
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
556 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
557 use_pointer(int virt, int move)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
558 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
559 int i;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
560 if (rname[virt]>=POINTER_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
561 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
562 for(i=POINTER_REG;i<MAX_REGISTER;i++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
563 if (!regs[virtual(i)]) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
564 use_register(virt,i,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
565 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
566 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
567 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
568 /* we prefer EBX */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
569 use_register(virt,REG_EBX,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
570 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
571
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
572 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
573 use_data_reg(int virt, int move)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
574 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
575 int i;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
576 if (rname[virt]<MAX_DATA_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
577 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
578 for(i=0;i<MAX_DATA_REG;i++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
579 if (!regs[virtual(i)]) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
580 use_register(virt,i,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
581 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
582 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
583 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
584 /* we prefer EBX */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
585 use_register(virt,REG_EBX,move);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
586 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
587
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
588
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
589 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
590 emit_push()
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
591 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
592 int new_reg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
593 new_reg = get_register();
159
b80e9737c3ce regs[creg]==0 in ia32
kono
parents: 156
diff changeset
594 if (new_reg==creg) error(-1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
595 if(new_reg<0) { /* もうレジスタがない */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
596 if (reg_sp>=MAX_MAX) error(-1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
597 reg_stack[reg_sp++] = -1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
598 printf("\tpushl %s\n",register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
599 /* creg is used soon, don't regv[creg]=0 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
600 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
601 reg_stack[reg_sp++] = creg; /* push するかわりにレジスタを使う */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
602 creg = new_reg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
603 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
604 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
605 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
606
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
607 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
608 emit_pop(int type)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
609 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
610 int xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
611 if ((xreg=pop_register())==-1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
612 if (type==POINTER_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
613 use_pointer(dreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
614 else if (type==DATA_REG)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
615 use_data_reg(dreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
616 if (regv[dreg]) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
617 printf("# emit_pop dreg conflict\n");
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
618 error(-1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
619 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
620 printf("\tpopl %s\n",register_name(dreg,0));
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
621 regv[dreg]=1;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
622 return dreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
623 } else if (xreg<= -REG_LVAR_OFFSET) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
624 code_rlvar(xreg+REG_LVAR_OFFSET,dreg);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
625 free_lvar(xreg+REG_LVAR_OFFSET);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
626 regv[dreg]=1;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
627 return dreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
628 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
629 return xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
630 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
631
186
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
632 int
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
633 stack_top(int type)
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
634 {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
635 int xreg;
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
636 if (type==INT) {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
637 xreg = reg_stack[reg_sp];
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
638 if (xreg<= -REG_LVAR_OFFSET) {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
639 return list2(LVAR,REG_LVAR_OFFSET+xreg);
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
640 } else {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
641 return list2(REGISTER,xreg);
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
642 }
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
643 } else {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
644 xreg = freg_stack[freg_sp];
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
645 if (xreg<= -REG_LVAR_OFFSET) {
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
646 return list2(LVAR,REG_LVAR_OFFSET+xreg);
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
647 } else {
186
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
648 return list2(DREGISTER,xreg);
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
649 }
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
650 }
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
651 return xreg;
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
652 }
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
653
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
654
6391432ca002 nkf binary fix
kono
parents: 183
diff changeset
655
92
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
656 void
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
657 code_label(int labelno)
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
658 {
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
659 printf("_%d:\n",labelno);
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
660 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
661
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
662 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
663 code_gvar(int e1,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
664 use_int(creg);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
665 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
666 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
667 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
668
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
669
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
670 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
671 code_rgvar(int e1,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
672 use_int(creg);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
673 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
674 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
675 }
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
676
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
677 static char *cload(int sign,int sz) { return sz==1?(sign?"movsbl":"movzbl"):sz==SIZE_OF_SHORT?(sign?"movswl":"movzwl"):"movl"; }
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
678
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
679 void
165
kono
parents: 163
diff changeset
680 code_crgvar(int e1,int creg,int sign,int sz){
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
681 use_int(creg);
165
kono
parents: 163
diff changeset
682 printf("\t%s %s,%s\n",cload(sign,sz),
163
fc8514c9d685 *** empty log message ***
kono
parents: 159
diff changeset
683 ((NMTBL*)cadr(e1))->nm,register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
684 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
685 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
686
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
687
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
688 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
689 code_lvar(int e2,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
690 use_int(creg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
691 printf("\tlea %d(%%ebp),%s\n",lvar(e2),register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
692 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
693 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
694
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
695
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
696 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
697 code_register(int e2,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
698 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
699 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
700 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
701 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
702
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
703
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
704 void
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
705 code_rlvar(int e2,int reg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
706 use_int(reg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
707 printf("\tmovl %d(%%ebp),%s\n",lvar(e2),register_name(reg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
708 regv[creg]=1;
61
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
165
kono
parents: 163
diff changeset
713 code_crlvar(int e2,int reg,int sign,int sz) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
714 use_int(reg);
165
kono
parents: 163
diff changeset
715 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
716 regv[creg]=1;
61
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
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
720 void
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
721 code_fname(NMTBL *n,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
722 use_int(creg);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
723 printf("\tmovl $%s,%s\n",n->nm,register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
724 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
725 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
726
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
727
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
728 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
729 code_const(int e2,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
730 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
731 printf("\tmovl $%d,%s\n",e2,register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
732 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
733 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
734
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
735
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
736 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
737 code_neg(int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
738 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
739 printf("\tnegl %s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
740 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
741
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
742
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
743 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
744 code_not(int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
745 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
746 printf("\tnotl %s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
747 }
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 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
751 code_lnot(int creg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
752 char *xrn;
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
753 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
754 use_data_reg(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
755 xrn = register_name(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
756 printf("\tcmpl $0,%s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
757 printf("\tsete %s\n", xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
758 printf("\tmovzbl %s,%s\n", xrn,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
759 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
760
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
761 void
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
762 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
763 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
764 if (car(e2)==REGISTER) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
765 use_int(reg);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
766 printf("\taddl $%d,%s\n",dir,register_name(cadr(e2),0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
767 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
768 regv[reg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
769 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
770 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
771 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
772 xrn = register_name(creg,0);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
773 use_int(reg);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
774 printf("\t%s $%d,(%s)\n",(sz==1)?"addb":(sz==SIZE_OF_SHORT)?"addw":"addl",dir,xrn);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
775 printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(reg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
776 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
777
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
778
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
779 void
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
780 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
781 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
782 if (car(e2)==REGISTER) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
783 use_int(reg);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
784 printf("\tmovl %s,%s\n",register_name(cadr(e2),0),register_name(reg,0));
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
785 printf("\taddl $%d,%s\n",dir,register_name(cadr(e2),0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
786 regv[reg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
787 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
788 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
789 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
790 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
791 xrn = register_name((e2=emit_pop(0)),0);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
792 use_int(reg);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
793 printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(reg,0));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
794 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
795 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
796 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
797
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 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
801 code_return(int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
802 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
803 printf("\tleal _%d,%s\n",retcont,register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
804 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
805 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
806
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
807
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
808 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
809 code_environment(int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
810 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
811 printf("\tmovl %%ebp,%s\n",register_name(creg,0));
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
812 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
813 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
814
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
815 static int rexpr_bool(int e1,int reg);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
816 static int drexpr_bool(int e1,int reg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
817
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
818 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
819 code_bool(int e1,int reg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
820 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
821 int e2,e3;
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
822 if (rexpr_bool(e1,reg)) return;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
823 #if FLOAT_CODE
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
824 if (drexpr_bool(e1,reg)) return;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
825 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
826 b_expr(e1,1,e2=fwdlabel(),1); /* including > < ... */
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
827 if (use) {
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
828 use_int(reg);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
829 xrn = register_name(reg,0);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
830 printf("\txorl %s,%s\n",xrn,xrn);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
831 jmp(e3=fwdlabel());
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
832 fwddef(e2);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
833 printf("\tmovl $1,%s\n",xrn);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
834 fwddef(e3);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
835 regv[reg]=1;
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
836 } else {
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
837 fwddef(e2);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
838 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
839 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
840
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
841 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
842 code_gt(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
843 return (cond?"g":"le");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
844 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
845
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
846 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
847 code_ugt(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
848 return (cond?"a":"be");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
849 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
850
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
851 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
852 code_ge(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
853 return (cond?"ge":"l");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
854 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
855
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
856 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
857 code_uge(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
858 return (cond?"ae":"b");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
859 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
860
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
861 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
862 code_eq(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
863 return (cond?"e":"ne");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
864 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
865
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
866 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
867 code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
868 use_int(reg);
167
0197ca125567 mips short
kono
parents: 166
diff changeset
869 if (sz==1)
0197ca125567 mips short
kono
parents: 166
diff changeset
870 printf("\tcmpb $0,%s\n",((NMTBL*)cadr(e1))->nm);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
871 else if (sz==SIZE_OF_SHORT)
167
0197ca125567 mips short
kono
parents: 166
diff changeset
872 printf("\tcmpw $0,%s\n",((NMTBL*)cadr(e1))->nm);
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
873 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
874 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
875
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
876
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
877 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
878 code_cmp_crlvar(int e1,int reg,int sz,int label,int cond) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
879 use_int(reg);
167
0197ca125567 mips short
kono
parents: 166
diff changeset
880 if (sz==1)
0197ca125567 mips short
kono
parents: 166
diff changeset
881 printf("\tcmpb $0,%d(%%ebp)\n",lvar(e1));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
882 else if (sz==SIZE_OF_SHORT)
167
0197ca125567 mips short
kono
parents: 166
diff changeset
883 printf("\tcmpw $0,%d(%%ebp)\n",lvar(e1));
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
884 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
885 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
886
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
887
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
888 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
889 code_cmp_rgvar(int e1,int reg,int label,int cond) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
890 use_int(reg);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
891 printf("\tcmpl $0,%s\n",((NMTBL*)cadr(e1))->nm);
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
892 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
893 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
894
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
895
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
896 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
897 code_cmp_rlvar(int e1,int reg,int label,int cond) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
898 use_int(reg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
899 printf("\tcmpl $0,%d(%%ebp)\n",lvar(e1));
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
900 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
901 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
902
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
903
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
904 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
905 code_cmp_register(int e2,int label,int cond) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
906 use_int(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
907 printf("\tcmpl $0,%s\n",register_name(e2,0));
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
908 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
909 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
910
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
911
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
912 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
913 ascii(char *s)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
914 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
915 printf("\t.string \"");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
916 while(*s) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
917 if (*s=='\n')
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
918 printf("%cn",92);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
919 else if (*s<' ')
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
920 printf("%c%03o",92,*s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
921 else if (*s==34)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
922 printf("%c%c",92,34);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
923 else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
924 printf("%c",*s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
925 s++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
926 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
927 printf("%c\n",34);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
928 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
929
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
930 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
931 code_string(int e1,int creg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
932 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
933 char *s;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
934 int i,lb;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
935
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
936 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
937 if (0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
938 s=(char *)cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
939 lb=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
940 printf("\tjmp _%d\n",lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
941 i=backdef();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
942 ascii(s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
943 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
944 fwddef(lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
945 printf("\tlea _%d,%s\n",i,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
946 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
947 s=(char *)cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
948 printf(".section\t.rodata\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
949 lb=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
950 printf("_%d:\n",lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
951 ascii(s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
952 if (output_mode==TEXT_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
953 printf(".text\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
954 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
955 text_mode();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
956 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
957 printf("\tlea _%d,%s\n",lb,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
958 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
959 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
960
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
961 #define MAX_COPY_LEN 20
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
962
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
963 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
964 emit_copy(int from,int to,int length,int offset,int value,int det)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
965 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
966 int fix = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
967 /* length <0 means upward direction copy */
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
968 use_int(from);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
969 use_int(to);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
970 switch (length) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
971 case 0: break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
972 case 1: case -1:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
973 printf("\tmovb %d(%s),%s\n",offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
974 register_name(from,0), reg_name_l[rname[dreg]] );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
975 printf("\tmovb %s,%d(%s)\n",reg_name_l[rname[dreg]] ,offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
976 register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
977 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
978 case 2: case -2:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
979 printf("\tmovw %d(%s),%s\n",offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
980 register_name(from,0), reg_name_w[rname[dreg]] );
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
981 printf("\tmovw %s,%d(%s)\n",reg_name_w[rname[dreg]] ,offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
982 register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
983 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
984 case 4: case -4:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
985 printf("\tmovl %d(%s),%s\n",offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
986 register_name(from,0), register_name(dreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
987 printf("\tmovl %s,%d(%s)\n",register_name(dreg,0), offset,
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
988 register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
989 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
990 default:
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
991 if (length <0) {
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
992 if (length > -MAX_COPY_LEN) {
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
993 for(;length<=-4;length+=4,offset-=4)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
994 emit_copy(from,to,-4,offset-4,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
995 for(;length<=-2;length+=2,offset-=2)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
996 emit_copy(from,to,-2,offset-2,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
997 if(length<0)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
998 emit_copy(from,to,length,offset-1,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
999 break;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1000 }
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1001 } else if (length <=MAX_COPY_LEN) {
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1002 for(;length>=4;length-=4,offset+=4)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1003 emit_copy(from,to,4,offset,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1004 for(;length>=2;length-=2,offset+=2)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1005 emit_copy(from,to,2,offset,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1006 if(length>0)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1007 emit_copy(from,to,length,offset,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1008 break;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1009 }
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1010 /*
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1011 if (det) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1012 call bcopy
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1013 g_expr(list3(FUNCTION,,);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1014 break;
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1015 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1016 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1017 use_register(from,REG_ESI,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1018 use_register(to, REG_EDI,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1019 use_register(dreg,REG_ECX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1020 if (length<0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1021 printf("\tmovl $%d,%%ecx\n",-length/4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1022 printf("\taddl $%d,%%esi\n",-length);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1023 printf("\taddl $%d,%%edi\n",-length);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1024 printf("\tstd\n\trep\n\tmovsl\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1025 if(length%4) {
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1026 emit_copy(from,to,length,offset+length/SIZE_OF_INT,0,det);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1027 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1028 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1029 printf("\tmovl $%d,%%ecx\n",length/4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1030 fix = (length/4)*4;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1031 printf("\tcld\n\trep\n\tmovsl\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1032 if(length%4) {
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1033 emit_copy(from,to,length,offset+length/SIZE_OF_INT,0,det);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1034 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1035 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1036 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1037 if (value) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1038 /* creg must point top of the destination data */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1039 /* this code is necessary for the value of assignment or function call */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1040 /* otherwise we don't need this */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1041 if (fix) printf("\tsubl $%d,%s\n",fix,register_name(to,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1042 if(creg!=to) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1043 if (to==dreg)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1044 printf("\tmovl %s,%s\n",register_name(to,0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1045 else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1046 free_register(creg); creg=to;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1047 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1048 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1049 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1050 regv[from]=regv[to]=regv[dreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1051 regv[creg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1052 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1053
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1054 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1055 struct_push(int e4,int t)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1056 {
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1057 int length,xreg,save,lreg,count;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1058 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1059 length=size(t);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1060 if(length%SIZE_OF_INT) {
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1061 length += SIZE_OF_INT - (length%SIZE_OF_INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1062 }
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1063 for(count=0;length<MAX_COPY_LEN;count++,length-=SIZE_OF_INT) {
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1064 if (length==0) return count;
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1065 else {
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1066 printf("\tpushl %d(%s)\n",
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1067 length-SIZE_OF_INT,register_name(creg,0));
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1068 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1069 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1070 printf("\tsubl $%d,%%esp\n",length);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1071 if (register_full()) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1072 save = 1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1073 for(lreg=0;lreg==creg||lreg==dreg;lreg++);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1074 printf("\tpushl %s\n",register_name(lreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1075 xreg = lreg; regv[xreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1076 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1077 save=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1078 xreg = get_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1079 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1080 if (save)
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1081 printf("\tlea %d(%%esp),%s\n",SIZE_OF_INT,register_name(xreg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1082 else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1083 printf("\tmovl %%esp,%s\n",register_name(xreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1084 regv[xreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1085 /* downward direction copy */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1086 emit_copy(creg,xreg,length,0,0,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1087 /* we have value in creg, it may be changed */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1088 if (save) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1089 if(creg==xreg) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1090 creg = get_register(); /* creg is freed in emit_copy */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1091 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1092 printf("\tpopl %s\n",register_name(xreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1093 regv[xreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1094 } else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1095 free_register(xreg);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1096 return length/SIZE_OF_INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1097 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1098
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1099 int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1100 function(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1101 {
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1102 int e2,e3,e4,nargs,t,ret_type;
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1103 NMTBL *n=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1104 int save,saved;
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 133
diff changeset
1105 ret_type = cadr(cadddr(e1));
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 133
diff changeset
1106 if (ret_type==CHAR) ret_type=INT;
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 133
diff changeset
1107
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1108 #ifdef SAVE_STACKS
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1109 code_save_stacks();
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1110 #if FLOAT_CODE
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1111 code_save_fstacks();
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1112 #endif
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1113 #endif
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1114 if (free_register_count(0)<1) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1115 for(save = 0;save==dreg||save==creg;save++);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1116 printf("\tpushl %s\n",register_name(save,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1117 saved = 1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1118 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1119 save = get_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1120 saved = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1121 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1122 regv[save]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1123 e2 = cadr(e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1124 nargs = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1125 for (e3 = caddr(e1); e3; e3 = cadr(e3)) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1126 t=caddr(e3);
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1127 e4 = car(e3);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1128 if(scalar(t)) {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1129 if (car(e4)==REGISTER) {
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1130 printf("\tpushl %s\n",register_name(cadr(e4),0));
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1131 } else {
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1132 g_expr(e4);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1133 printf("\tpushl %s\n",register_name(creg,0));
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1134 }
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1135 } else if (t==LONGLONG||t==ULONGLONG) {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1136 if (car(e4)==LREGISTER) {
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1137 printf("\tpushl %s\n\tpushl %s\n",l_edx(cadr(e4)),l_eax(cadr(e4)));
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1138 } else {
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1139 g_expr(e4);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1140 printf("\tpushl %%edx\n\tpushl %%eax\n");
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1141 }
241
96b5ee862a41 *** empty log message ***
kono
parents: 240
diff changeset
1142 ++nargs;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1143 } else if (t==DOUBLE) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1144 g_expr(e4);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1145 printf("\tleal\t-8(%%esp),%%esp\n\tfstpl\t(%%esp)\n");
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1146 nargs += SIZE_OF_DOUBLE/SIZE_OF_INT;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1147 fregv[freg]=0;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1148 continue;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1149 } else if (t==FLOAT) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1150 g_expr(e4);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1151 printf("\tleal\t-4(%%esp),%%esp\n\tfstps\t(%%esp)\n");
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1152 nargs += SIZE_OF_FLOAT/SIZE_OF_INT;
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1153 fregv[freg]=0;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1154 continue;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1155 } else if (car(t)==STRUCT||car(t)==UNION) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1156 nargs += struct_push(e4,t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1157 continue;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1158 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1159 error(TYERR);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1160 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1161 ++nargs;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1162 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1163 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1164 n=(NMTBL *)cadr(e2);
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1165 regv[creg]=0;
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1166 use_register(creg,REG_EAX,0); /* will be destroyed */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1167 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1168 g_expr(e2);
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1169 regv[creg]=1;
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1170 use_register(creg,REG_EAX,1); /* will be destroyed */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1171 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1172
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1173 /* we don't have to save creg nor dreg */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1174 regs[creg]=0; regs[dreg]=0;
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1175 regv[dreg]= regv[save]= 0;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1176 use_register(dreg,REG_EBX,0); /* will be destroyed */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1177 use_register(save,REG_ECX,0); /* will be destroyed */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1178 regs[creg]=1; regs[dreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1179
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1180 if (car(e2) == FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1181 printf("\tcall\t%s\n",n->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1182 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1183 printf("\tcall\t*%s\n",register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1184 }
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1185 if (nargs) printf("\taddl $%d,%%esp\n",SIZE_OF_INT*nargs);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1186 if (saved) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1187 printf("\tpopl %s\n",register_name(save,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1188 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1189 free_register(save);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1190 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1191 regv[save]=0;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1192 if (ret_type==DOUBLE||ret_type==FLOAT) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1193 } else if (ret_type==LONGLONG||ret_type==ULONGLONG) {
243
c311c26e006a *** empty log message ***
kono
parents: 242
diff changeset
1194 use_longlong0(USE_CREG);
c311c26e006a *** empty log message ***
kono
parents: 242
diff changeset
1195 regv[creg]=1;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1196 } else if (ret_type==VOID) {
243
c311c26e006a *** empty log message ***
kono
parents: 242
diff changeset
1197 regv[freg]=0; regv[creg]=0;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1198 } else {
243
c311c26e006a *** empty log message ***
kono
parents: 242
diff changeset
1199 use_register(creg,REG_EAX,0);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1200 fregv[freg]=0; regv[creg]=1;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1201 }
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1202 return ret_type;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1203 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1204
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1205 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1206 code_frame_pointer(int e3) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1207 use_int(e3);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1208 printf("\tmovl %s,%%ebp\n",register_name(e3,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1209 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1210
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1211
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1212 void
62
129f4802b027 separation done
kono
parents: 61
diff changeset
1213 code_fix_frame_pointer(int disp_offset) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1214 printf("\tlea %d(%%ebp),%%ebp\n",disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1215 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1216
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1217
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1218 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1219 code_jmp(char *s) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1220 printf("\tjmp %s\n",s);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1221 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1222
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1223
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1224 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1225 code_indirect_jmp(int e2) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1226 printf("\tjmp *%s\n",register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1227 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1228
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1229 int
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1230 code_rindirect(int e1, int reg,int offset, int sign)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1231 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1232 char *crn,*op;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1233 int byte;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1234 g_expr(e1);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1235 byte = 0; op="movl";
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1236 crn = register_name(creg,0);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1237 use_int(reg);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1238 printf("\t%s %d(%s),%s\n",op,offset,crn,register_name(reg,0));
246
0dcc0ec81ed2 MIPS on going (90%)
kono
parents: 245
diff changeset
1239 return sign?INT:UNSIGNED;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1240 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1241
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1242 int
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1243 code_crindirect(int e1, int reg,int offset, int sign)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1244 {
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1245 char *crn,*op;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1246 int byte;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1247 g_expr(e1);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1248 byte = 0; op=sign?"movsbl":"movzbl";
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1249 crn = register_name(creg,0);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1250 use_int(reg);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1251 printf("\t%s %d(%s),%s\n",op,offset,crn,register_name(reg,0));
246
0dcc0ec81ed2 MIPS on going (90%)
kono
parents: 245
diff changeset
1252 return sign?CHAR:UCHAR;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1253 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1254
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1255 int
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1256 code_srindirect(int e1, int reg,int offset, int sign)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1257 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1258 char *crn,*op;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1259 int byte;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1260 g_expr(e1);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1261 byte = 0; op=sign?"movswl":"movzwl";
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1262 crn = register_name(creg,0);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1263 use_int(reg);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1264 printf("\t%s %d(%s),%s\n",op,offset,crn,register_name(reg,0));
246
0dcc0ec81ed2 MIPS on going (90%)
kono
parents: 245
diff changeset
1265 return sign?SHORT:USHORT;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1266 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1267
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1268 #if FLOAT_CODE
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1269 int
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1270 code_drindirect(int e1, int reg,int offset, int d)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1271 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1272 g_expr(e1);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1273 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1274 return DOUBLE;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1275 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1276 #endif
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1277
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1278 #if LONGLONG_CODE
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1279
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1280 static void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1281 lload(int creg,int offset,int reg)
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1282 {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1283 char *crn = register_name(creg,0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1284 use_longlong(reg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1285 if((reg==REG_L&&rname[creg]==REG_ESI)||(rname[creg]==REG_EAX)) {
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1286 printf("\tmovl %d(%s),%s\n",offset+SIZE_OF_INT,crn,l_edx(reg));
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1287 printf("\tmovl %d(%s),%s\n",offset,crn,l_eax(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1288 } else {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1289 printf("\tmovl %d(%s),%s\n",offset,crn,l_eax(reg));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1290 printf("\tmovl %d(%s),%s\n",offset+SIZE_OF_INT,crn,l_edx(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1291 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1292 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1293
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1294 int
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1295 code_lrindirect(int e1, int reg, int offset, int us)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1296 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1297 int reg0;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1298 g_expr(e1);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1299 regv[reg0=creg]=1;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1300 use_longlong(reg);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1301 lload(reg0,offset,reg);
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 196
diff changeset
1302 return LONGLONG;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1303 }
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1304 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1305
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1306 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1307 move(int byte)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1308 {
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1309 return byte==1?"movb":byte==SIZE_OF_SHORT?"movw":"movl";
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1310 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1311
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1312 void
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1313 code_assign_gvar(int e2,int creg,int byte) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1314 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1315 if (byte) use_data_reg(creg,1);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1316 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
1317 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1318
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1319 void
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1320 code_assign_lvar(int e2,int creg,int byte) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1321 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1322 if (byte) use_data_reg(creg,1);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1323 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
1324 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1325
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1326 void
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1327 code_assign_register(int e2,int byte,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1328 use_int(creg);
286
179e22f166ef register assop fix
kono
parents: 280
diff changeset
1329 if (creg!=e2)
179e22f166ef register assop fix
kono
parents: 280
diff changeset
1330 printf("\tmovl %s,%s\n",register_name(creg,0),register_name(e2,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1331 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1332
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1333 void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1334 code_assign(int e2,int byte,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1335 use_int(e2);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1336 use_int(creg);
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1337 if (byte) use_data_reg(creg,1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1338 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
1339 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1340 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1341
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1342 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1343 code_register_assop(int e2,int reg0,int op,int byte) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1344 int reg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1345 int xreg = creg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1346 creg = reg = e2;
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1347 tosop(op,reg,xreg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1348 creg = xreg;
286
179e22f166ef register assop fix
kono
parents: 280
diff changeset
1349 // 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
1350 regs[creg]=regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1351 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1352
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1353
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1354 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1355 code_assop(int op,int reg,int byte,int sign) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1356 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1357 int xreg;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1358 int edx = edx_setup(-1);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1359 use_int(reg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1360 xrn = register_name(xreg = emit_pop(0),0); /* pop e3 value */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1361 regv[xreg]=regs[xreg]=1;
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1362 printf("\tmovl %s,%s # assop \n",register_name(reg,0),register_name(edx,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1363 regv[edx]=1;
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1364 ld_indexx(byte,0,edx,reg,sign);
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1365 tosop(op,reg,xreg);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1366 printf("\t%s %s,(%s)\n",move(byte),register_name(reg,byte),register_name(edx,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1367 edx_cleanup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1368 emit_pop_free(xreg);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1369 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1370 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1371
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1372
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1373 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1374 tosop(int op,int reg,int oreg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1375 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1376 int dx;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1377 char *orn,*crn;
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1378 use_int(reg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1379
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1380 switch(op) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1381 case LSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1382 case ULSHIFT:
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1383 shift("sall",oreg,reg);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1384 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1385 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1386 case RSHIFT:
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1387 shift("sarl",oreg,reg);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1388 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1389 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1390 case URSHIFT:
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1391 shift("shrl",oreg,reg);
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1392 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1393 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1394 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1395 if(oreg==-1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1396 printf("\tpopl %s\n",register_name(dreg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1397 oreg = dreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1398 regv[dreg]=1;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1399 } else if (oreg<= -REG_LVAR_OFFSET) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1400 code_rlvar(oreg+REG_LVAR_OFFSET,dreg);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
1401 free_lvar(oreg+REG_LVAR_OFFSET);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1402 oreg = dreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1403 regv[dreg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1404 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1405 regv[oreg]=1; regs[oreg]=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1406 orn = register_name(oreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1407 crn = register_name(creg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1408 switch(op) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1409 case ADD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1410 printf("\taddl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1411 break;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1412 case SUB: case CMP:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1413 printf("\tsubl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1414 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1415 case BAND:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1416 printf("\tandl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1417 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1418 case EOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1419 printf("\txorl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1420 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1421 case BOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1422 printf("\torl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1423 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1424 case MUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1425 case UMUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1426 printf("\t%s %s,%s\n","imull",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1427 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1428 case DIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1429 case UDIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1430 use_register(creg,REG_EAX,1);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1431 edx_setup(REG_EDX);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1432 orn = register_name(oreg,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1433 if (op==DIV)
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1434 printf("\tcltd\n\tidivl %s\n",orn);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1435 else
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1436 printf("\txor %%edx,%%edx\n\tdivl %s\n",orn);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1437 edx_cleanup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1438 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1439 case MOD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1440 case UMOD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1441 use_register(creg,REG_EAX,1);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1442 edx_setup(REG_EDX);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1443 orn = register_name(oreg,0);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1444 if (op==MOD)
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1445 printf("\tcltd\n\tidivl %s\n",orn);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1446 else
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1447 printf("\txor %%edx,%%edx\n\tdivl %s\n",orn);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1448 dx = virtual(REG_EDX);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1449 if (dx!=creg) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1450 rname[dx]=rname[creg];
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1451 rname[creg]=REG_EDX;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1452 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1453 edx_cleanup();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1454 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1455 }
159
b80e9737c3ce regs[creg]==0 in ia32
kono
parents: 156
diff changeset
1456 if (oreg!=dreg&&oreg!=creg&&oreg>=0)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1457 free_register(oreg);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1458 else if (oreg==dreg) regv[dreg]=0;
144
56211702f298 creg/freg continue
kono
parents: 139
diff changeset
1459 regv[creg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1460 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1461
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1462 int
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1463 code_const_op_p(int op,int e)
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1464 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1465 if (car(e)!=CONST) return 0;
190
1b1c58483e67 minor fix
kono
parents: 189
diff changeset
1466 if (op==DIV||op==UDIV||op==MOD||op==UMOD) return 0;
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1467 else return 1;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1468 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1469
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1470 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1471 oprtc(int op,int reg,int orn)
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1472 {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1473 char *crn;
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1474 use_int(reg);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1475 crn = register_name(reg,0);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
1476 orn = cadr(orn);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1477
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1478 switch(op) {
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1479 case LSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1480 case ULSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1481 printf("\tsall $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1482 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1483 case RSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1484 printf("\tsarl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1485 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1486 case URSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1487 printf("\tshrl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1488 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1489 case ADD:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1490 printf("\taddl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1491 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1492 case SUB: case CMP:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1493 printf("\tsubl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1494 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1495 case BAND:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1496 printf("\tandl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1497 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1498 case EOR:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1499 printf("\txorl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1500 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1501 case BOR:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1502 printf("\torl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1503 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1504 case MUL:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1505 case UMUL:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1506 printf("\t%s $%d,%s\n","imull",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1507 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1508 default:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1509 error(-1);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1510 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1511 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1512
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1513
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1514 static int edx_stack=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1515
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1516 int
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1517 edx_setup(int rreg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1518 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1519 int edx_save;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1520 /* make real EDX register empty */
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1521 if (free_register_count(0)<1) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1522 for(edx_save = 0;edx_save==dreg||edx_save==creg;edx_save++);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1523 printf("\tpushl %s\n",register_name(edx_save,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1524 edx_stack = list3(edx_save,edx_stack,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1525 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1526 edx_save = get_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1527 edx_stack = list3(edx_save,edx_stack,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1528 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1529 regv[edx_save]=0;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1530 if (rreg!=-1)
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
1531 use_register(edx_save,rreg,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1532 return edx_save;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1533 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1534
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1535
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1536 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1537 edx_cleanup()
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1538 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1539 if (caddr(edx_stack)==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1540 printf("\tpopl %s\n",register_name(car(edx_stack),0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1541 } else
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1542 free_register(car(edx_stack));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1543 edx_stack = cadr(edx_stack);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1544 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1545
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1546 void
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1547 shift(char *op, int reg,int creg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1548 {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1549 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1550 if (reg>=0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1551 use_register(reg,REG_ECX,1);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1552 } else if (reg<= -REG_LVAR_OFFSET) {
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1553 use_register(dreg,REG_ECX,0);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1554 code_rlvar(reg+REG_LVAR_OFFSET,dreg);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1555 reg = dreg;
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1556 regv[dreg]=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1557 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1558 use_register(dreg,REG_ECX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1559 printf("\tpopl %%ecx\n");
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1560 regv[dreg]=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1561 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1562 printf("\t%s %%cl,%s\n",op,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1563 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1564
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1565 void
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1566 ld_indexx(int byte, int n, int xreg,int reg,int sign)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1567 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1568 char *op;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1569
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1570 use_int(reg);
166
9e55cc5551fb *** empty log message ***
kono
parents: 165
diff changeset
1571 op = byte ? (sign?"movsbl":"movzbl") : "movl";
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1572 if (n)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1573 printf("\t%s %d(%s),%s\n",op,n,
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1574 register_name(xreg,0),register_name(reg,byte));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1575 else
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1576 printf("\t%s (%s),%s\n",op,
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1577 register_name(xreg,0),register_name(reg,byte));
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1578 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1579
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1580 int
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1581 code_csvalue()
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
1582 {
123
5f180dc8d84e intel fix.
kono
parents: 119
diff changeset
1583 return rname[creg]; /* for switch value */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1584 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1585
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1586 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1587 code_cmpdimm(int e, int csreg,int label,int cond)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1588 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1589 /* used in dosiwtch() */
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1590 if(chk) return;
123
5f180dc8d84e intel fix.
kono
parents: 119
diff changeset
1591 use_register(creg,csreg,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1592 printf("\tcmpl $%d,%s\n",e,register_name(creg,0));
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1593 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1594 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1595
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1596 void
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1597 code_opening(char *filename)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1598 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1599 printf("\t.file \"%s\"\n",filename);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1600 printf("\t.version\t\"01.01\"\n");
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1601 /* printf("gcc2_compiled.:\n"); */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1602 printf(".text\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1603 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1604
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1605 void
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1606 code_closing()
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1607 {
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
1608 global_table();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1609 printf("\t.ident \"Micro-C compiled\"\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1610 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1611
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1612 static char *
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1613 code_cond(int op,int cond)
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1614 {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1615 switch(op) {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1616 case GT: return code_gt(cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1617 case UGT: return code_ugt(cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1618 case GE: return code_ge(cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1619 case UGE: return code_uge(cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1620 case LT: return code_ge(!cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1621 case ULT: return code_uge(!cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1622 case LE: return code_gt(!cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1623 case ULE: return code_ugt(!cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1624 case EQ: return code_eq(cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1625 case NEQ: return code_eq(!cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1626 default: return 0;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1627 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1628 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1629
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1630 static int
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1631 rexpr_bool(int e1,int reg)
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1632 {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1633 char *s;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1634 if (!(s=code_cond(car(e1),1))) return 0;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1635 g_expr(list3(CMP,cadr(e1),caddr(e1)));
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1636 use_int(reg);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1637 use_data_reg(reg,0);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1638 printf("\tset%s\t%s\n",s,register_name(reg,1));
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1639 printf("\tmovzbl %s,%s\n",register_name(reg,1),register_name(reg,0));
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1640 return 1;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1641 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1642
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1643 void
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
1644 rexpr(int e1, int l1, int cond,int t)
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
1645 {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1646 g_expr(list3(CMP,cadr(e1),caddr(e1)));
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1647 printf("\tj%s\t_%d\n",code_cond(car(e1),cond),l1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1648 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1649
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1650
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1651 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1652 jcond(int l, char cond)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1653 {
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1654 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1655 printf("\tj%s\t_%d\n",cond?"ne":"e",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1656 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1657
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1658 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1659 jmp(int l)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1660 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1661 control=0;
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1662 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1663 printf("\tjmp\t_%d\n",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1664 /* align? */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1665 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1666 this is not allowed because of ? operator
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1667 regv[creg]=regv[dreg]=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1668 use_register(creg,REG_EAX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1669 use_register(dreg,REG_EBX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1670 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1671 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1672
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1673 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1674 gen_comment(char *s)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1675 {
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1676 if (chk) return;
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1677 printf("## %s",s);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1678 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1679
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1680
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1681 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1682 code_enter(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1683 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1684 printf("\t.align 4\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1685 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1686 printf(".globl %s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1687 printf("\t.type\t%s,@function\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1688 printf("%s:\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1689 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1690
77
2b8ba655e572 fix arg type
kono
parents: 66
diff changeset
1691
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1692 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1693 code_enter1(int args)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1694 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1695 code_disp_label=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1696 printf("\tlea _%d(%%ebp),%%esp\n",code_disp_label);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1697
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1698 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
1699 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1700
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1701 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1702 code_leave(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1703 {
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1704 disp &= -SIZE_OF_INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1705 printf("\t.set _%d,%d\n",code_disp_label,disp+code_disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1706 printf("_%d:\n",labelno);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1707 printf("\t.size\t%s,_%d-%s\n",name,labelno,name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1708 local_table();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1709 labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1710 free_all_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1711 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1712
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1713 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1714 enter(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1715 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1716 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1717 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1718 printf(".globl %s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1719 printf("%s:\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1720 printf("\t.type\t%s,@function\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1721 printf("\tpushl %%ebp\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1722 printf("\tmovl %%esp,%%ebp\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1723 printf("\tpushl %%ebx\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1724 printf("\tpushl %%esi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1725 printf("\tpushl %%edi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1726 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1727
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1728 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1729 enter1()
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1730 {
182
e1e9ec8c96a7 some fix
kono
parents: 173
diff changeset
1731 text_mode();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1732 func_disp_label=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1733 printf("\tlea _%d(%%ebp),%%esp\n",func_disp_label);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1734 /* if(disp) printf("\tsubl $%d,%%esp\n",-disp); */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1735 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1736
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1737 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1738 leave(int control, char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1739 {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1740 int sz;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1741
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1742 disp &= -SIZE_OF_INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1743 if (control)
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1744 code_set_return_register(1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1745 if (retcont) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1746 if (control)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1747 jmp(retlabel);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1748 fwddef(retcont);
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1749 if (cadr(fnptr->ty)==FLOAT||cadr(fnptr->ty)==DOUBLE) {
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1750 printf("\tfldl %d(%%ebp)\n",-SIZE_OF_DOUBLE);
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1751 } else if (cadr(fnptr->ty)>0&&(
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1752 car(cadr(fnptr->ty))==STRUCT ||
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1753 car(cadr(fnptr->ty))==UNION)) {
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1754 sz = size(cadr(fnptr->ty));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1755 printf("\tlea %d(%%ebp),%s\n",-sz,register_name(dreg,0));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1756 printf("\tmovl %d(%%ebp),%s\n",disp-SIZE_OF_INT,
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1757 register_name(creg,0));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1758 emit_copy(dreg,creg,sz,0,1,1);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1759 } else if (cadr(fnptr->ty)!=VOID) {
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1760 use_register(creg,REG_EAX,0);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1761 printf("\tmovl %s,%s\n",reg_name[REG_ESI],register_name(creg,0));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1762 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1763 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1764 fwddef(retlabel);
63
e13486b2c12e stack alignment
kono
parents: 62
diff changeset
1765
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1766 printf("\tlea %d(%%ebp),%%esp\n",disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1767 printf("\tpopl %%edi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1768 printf("\tpopl %%esi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1769 printf("\tpopl %%ebx\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1770 printf("\tleave\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1771 printf("\tret\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1772 printf("\t.set _%d,%d\n",func_disp_label,disp+disp_offset);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1773 printf("_%d:\n",labelno);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1774 printf("\t.size\t%s,_%d-%s\n",name,labelno,name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1775 local_table();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1776 labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1777 free_all_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1778 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1779
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1780 int
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1781 code_get_fixed_creg(int reg,int type) {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1782 if (type==FLOAT||type==DOUBLE) {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1783 return 0;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1784 } else if (type==LONGLONG||type==ULONGLONG) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1785 use_longlong(reg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1786 return reg;
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1787 } else {
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
1788 use_int(reg);
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1789 return rname[reg];
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1790 }
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1791 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1792
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1793 void
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1794 code_set_fixed_creg(int reg,int mode,int type) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1795 if (type==FLOAT||type==DOUBLE) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1796 } else if (type==LONGLONG||type==ULONGLONG) {
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1797 } else {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1798 use_register(creg,reg,mode);
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1799 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1800 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1801
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1802 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1803 code_set_return_register(int mode) {
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1804 if (fnptr->ty==DOUBLE||fnptr->ty==FLOAT) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1805 } else if (fnptr->ty==LONGLONG||fnptr->ty==ULONGLONG) {
243
c311c26e006a *** empty log message ***
kono
parents: 242
diff changeset
1806 use_longlong0(USE_CREG);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1807 } else {
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1808 use_register(creg,REG_EAX,mode);
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1809 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1810 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1811
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1812 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1813 gen_gdecl(char *n, int gpc)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1814 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1815 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1816 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1817 printf(".globl %s\n",n);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1818 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1819 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1820
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1821 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1822 align(int t)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1823 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1824 if (t!=CHAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1825 if (data_alignment & 1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1826 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1827 data_alignment = 0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1828 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1829 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1830
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1831 #if LONGLONG_CODE
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1832 static long long ll0 = 1LL;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1833
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1834 static int
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1835 code_l1(long long d)
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1836 {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1837 int *i = (int *)&ll0; int *j = (int *)&d;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1838 return (i[1] == 1)?j[1]:j[0];
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1839 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1840
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1841 static int
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1842 code_l2(long long d)
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1843 {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1844 int *i = (int *)&ll0; int *j = (int *)&d;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1845 return (i[1] == 1)?j[0]:j[1];
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1846 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1847 #endif
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1848
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1849 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1850 emit_data(int e, int t, NMTBL *n)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1851 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1852 int l;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1853 #if FLOAT_CODE
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1854 double d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1855 float f;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1856 #endif
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1857 #if LONGLONG_CODE
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1858 long long ll;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1859 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1860 char *name;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1861 name = n->nm;
156
da529eab5618 static initialization
kono
parents: 147
diff changeset
1862 if(mode!=GDECL && mode!=STADECL) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1863 error(-1); return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1864 }
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1865 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1866 if (n->dsp != -1) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1867 n->dsp = -1; /* initiallized flag */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1868 printf(".globl\t%s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1869 data_mode(name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1870 align(t);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1871 printf("%s:\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1872 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1873 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1874 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1875 if(car(e)==CONST) {
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1876 if (t==CHAR||t==UCHAR) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1877 printf("\t.byte %d\n",cadr(e));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1878 if (data_alignment>0)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1879 data_alignment++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1880 gpc += 1;
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1881 } else if (t==SHORT||t==USHORT) {
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1882 printf("\t.short %d\n",cadr(e));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1883 if (data_alignment>0) data_alignment++;
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1884 gpc += SIZE_OF_SHORT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1885 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1886 printf("\t.long %d\n",cadr(e));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1887 gpc += SIZE_OF_INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1888 }
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1889 #if LONGLONG_CODE
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1890 } else if(t==LONGLONG||t==ULONGLONG) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1891 ll = lcadr(e);
243
c311c26e006a *** empty log message ***
kono
parents: 242
diff changeset
1892 printf("\t.long\t0x%x,0x%x\n",code_l1(ll),code_l2(ll));
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1893 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1894 #if FLOAT_CODE
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1895 } else if(t==DOUBLE) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1896 d = dcadr(e);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1897 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
1898 } else if(t==FLOAT) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1899 f = dcadr(e);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1900 printf("\t.long\t0x%x\n",*(int *)&f);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1901 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1902 } else if(t!=CHAR) {
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1903 gpc += SIZE_OF_INT;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1904 if(car(e)==ADDRESS&&car(cadr(e))==GVAR) {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1905 printf("\t.long %s\n",((NMTBL *)cadr(cadr(e)))->nm);
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1906 } else if(car(e)==GVAR) {
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1907 printf("\t.long %s\n",((NMTBL *)cadr(e))->nm);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1908 } else if(car(e)==FNAME) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1909 printf("\t.long %s\n",((NMTBL *)cadr(e))->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1910 } else if(car(e)==STRING) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1911 if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1912 l = fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1913 printf("\t.long _%d\n",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1914 printf(".section\t.rodata\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1915 printf("_%d:\n",l);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1916 output_mode = RODATA_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1917 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1918 ascii((char *)cadr(e));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1919 } else error(TYERR);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1920 } else error(TYERR);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1921 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1922
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1923 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1924 emit_data_closing(NMTBL *n)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1925 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1926 int lb;
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
1927 if (chk) return;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1928 if (mode==GDECL) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1929 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1930 lb=fwdlabel();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1931 printf("_%d:\n",lb);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1932 printf("\t.size\t%s,_%d-%s\n",n->nm,lb,n->nm);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1933 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1934 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1935
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1936 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1937 global_table(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1938 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1939 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1940 int init;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1941 init=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1942 for(n=ntable;n < &ntable[GSYMS];n++) {
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
1943 if ((n->sc == GVAR||n->sc == STATIC) && n->dsp != -1) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1944 /* n->dsp = -1 means initialized global */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1945 if (init==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1946 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1947 init=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1948 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1949 printf(".comm %s,%d\n",n->nm,size(n->ty));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1950 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1951 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1952 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1953
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1954 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1955 local_table(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1956 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1957 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1958 int init;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1959 init=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1960 /* static local variables */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1961 for(n=ntable+GSYMS;n < &ntable[GSYMS+LSYMS];n++) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1962 if (n->sc == GVAR) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1963 if (init==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1964 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1965 init=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1966 }
156
da529eab5618 static initialization
kono
parents: 147
diff changeset
1967 if (n->dsp!= -1) /* -1 means initialized global */
da529eab5618 static initialization
kono
parents: 147
diff changeset
1968 printf(".lcomm %s,%d\n",n->nm,size(n->ty));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1969 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1970 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1971 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1972
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1973 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1974 text_mode(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1975 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1976 if (output_mode!=TEXT_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1977 printf(".text\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1978 printf("\t.align 2\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1979 output_mode = TEXT_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1980 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1981 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1982
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1983 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1984 data_mode(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1985 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1986 if (output_mode!=DATA_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1987 printf(".data\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1988 output_mode = DATA_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1989 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1990 if (name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1991 printf("\t.type\t%s,@object\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1992 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1993
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1994 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
1995
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1996 /* floating point */
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1997
f94ca1168520 float first try...
kono
parents: 78
diff changeset
1998
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1999 char *
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2000 fstore(int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2001 {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2002 return use?
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2003 (d?"fstl":"fsts"):
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2004 (d?"fstpl":"fstps")
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2005 ;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2006 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2007
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2008 char *
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2009 fstore_u(int d)
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2010 {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2011 return d?"fstpl":"fstps";
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2012 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2013
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2014 char *
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2015 fload(int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2016 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2017 return d?"fldl":"flds";
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2018 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2019
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2020
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2021 void code_dassign_gvar(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2022 {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2023 printf("\t%s %s\n",fstore(d),((NMTBL*)cadr(e2))->nm);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2024 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2025
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2026 void code_dassign_lvar(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2027 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2028 printf("\t%s %d(%%ebp)\n",fstore(d),lvar(e2));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2029 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2030
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2031 void code_dassign_dregister(int e,int d,int freg)
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
2032 {
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
2033 error(-1);
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
2034 }
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
2035
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2036 void code_dassign(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2037 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2038 printf("\t%s (%s)\n",fstore(d),register_name(e2,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2039 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2040
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2041 static double d0 = 1.0;
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2042
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2043 int
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2044 code_d1(double d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2045 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2046 int *i = (int *)&d0; int *j = (int *)&d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2047 return (i[1] == 0x3ff00000)?j[0]:j[1];
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2048 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2049
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2050 int
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2051 code_d2(double d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2052 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2053 int *i = (int *)&d0; int *j = (int *)&d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2054 return (i[1] == 0x3ff00000)?j[1]:j[0];
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2055 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2056
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2057 void code_dconst(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2058 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2059 int lb;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2060 double value = dcadr(e2);
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2061
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2062 if (value==0.0) {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2063 printf("\tfldz\n"); return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2064 }
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2065 if (value==1.0) {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2066 printf("\tfld1\n"); return;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2067 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2068 printf(" \t.section\t.rodata\n\t.align 8\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2069 lb=fwdlabel();
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2070 printf("_%d:\n",lb);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2071 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
2072 if (output_mode==TEXT_EMIT_MODE) {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2073 printf(".text\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2074 } else {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2075 text_mode();
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2076 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2077 printf("\tfldl _%d\n",lb);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2078 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2079
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2080 void code_dneg(int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2081 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2082 printf("\tfchs\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2083 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2084
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2085 void code_d2i(int reg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2086 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2087 use_int(reg);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2088 printf("\tlea -%d(%%esp),%%esp\n",SIZE_OF_INT*2);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2089 printf("\tfnstcw (%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2090 printf("\tmovl (%%esp), %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2091 printf("\tmovb $12, 1(%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2092 printf("\tfldcw (%%esp)\n");
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2093 printf("\tfistpl %d(%%esp)\n",SIZE_OF_INT);
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
2094 printf("\tmovl %s, (%%esp)\n",register_name(creg,0));
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
2095 printf("\tfldcw (%%esp)\n");
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2096 printf("\tpopl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2097 printf("\tpopl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2098 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2099
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2100 void code_i2d(int reg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2101 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2102 printf("\tpushl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2103 printf("\tfildl (%%esp)\n");
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2104 printf("\tlea %d(%%esp),%%esp\n",SIZE_OF_INT);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2105 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2106
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2107 void code_d2u(int reg)
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
2108 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2109 use_int(reg);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2110 printf("\tlea -%d(%%esp),%%esp\n",SIZE_OF_INT*3);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
2111 printf("\tfnstcw (%%esp)\n");
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2112 printf("\tmovl (%%esp), %s\n",register_name(reg,0));
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
2113 printf("\tmovb $12, 1(%%esp)\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
2114 printf("\tfldcw (%%esp)\n");
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2115 printf("\tmovl %s, (%%esp)\n",register_name(reg,0));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2116 printf("\tfistpll %d(%%esp)\n",SIZE_OF_INT);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
2117 printf("\tfldcw (%%esp)\n");
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2118 printf("\tmovl %d(%%esp),%s\n",SIZE_OF_INT,register_name(reg,0));
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2119 printf("\tlea %d(%%esp),%%esp\n",SIZE_OF_INT*3);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
2120 }
3789aef7331d minor fix
kono
parents: 84
diff changeset
2121
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2122 void code_u2d(int reg)
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
2123 {
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
2124 printf("\tpushl %s\n",register_name(creg,0));
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
2125 printf("\tpushl %s\n",register_name(creg,0));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2126 printf("\tmovl $0, %d(%%esp)\n",SIZE_OF_INT);
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
2127 printf("\tfildll (%%esp)\n");
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2128 printf("\tlea %d(%%esp),%%esp\n",SIZE_OF_INT*2);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
2129 }
3789aef7331d minor fix
kono
parents: 84
diff changeset
2130
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2131 void code_d2f(int reg) { }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2132 void code_f2d(int reg) { }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2133 void code_f2i(int reg) { code_d2i(reg); }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2134 void code_f2u(int reg) { code_d2u(reg); }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2135 void code_i2f(int reg) { code_i2d(reg); }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2136 void code_u2f(int reg) { code_u2d(reg); }
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2137
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2138 void code_drgvar(int e2,int d,int freg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2139 {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2140 printf("\t%s %s\n",fload(d),((NMTBL*)cadr(e2))->nm);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2141 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2142
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2143
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2144 void code_drlvar(int e2,int d,int freg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2145 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2146 printf("\t%s %d(%%ebp)\n",fload(d),lvar(e2));
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2147 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2148
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2149 void code_cmp_drgvar(int e2,int reg,int d,int label,int cond)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2150 {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2151 printf("\tfcomp %s\n",((NMTBL*)cadr(e2))->nm);
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2152 jcond(label,cond);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2153 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2154
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2155 void code_cmp_drlvar(int e2,int reg,int d,int label,int cond)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2156 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2157 printf("\tfcomp %d(%%ebp)\n",lvar(e2));
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2158 jcond(label,cond);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2159 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2160
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2161 void dtosop(int op,int reg,int e1)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2162 {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2163 switch(op) {
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2164 case FADD:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2165 case DADD: printf("\tfaddp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2166 case FSUB:
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
2167 case DSUB: printf("\tfsubp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2168 case FDIV:
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
2169 case DDIV: printf("\tfdivp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2170 case FMUL:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2171 case DMUL: printf("\tfmulp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2172 case FCMP:
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
2173 case DCMP:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2174 printf("\tfucompp\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2175 printf("\tfnstsw\t%%ax\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2176 break;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2177 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2178 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2179
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2180 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2181 code_dassop(int op,int reg,int d) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2182 /* we have lvalue in creg, applied floating value is in %st(0) */
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
2183 emit_dpop(d); /* do nothing for 387 */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2184 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2185 dtosop(op,reg,0);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2186 printf("\t%s (%s)\n",fstore(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2187 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2188
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2189 void
219
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2190 code_register_dassop(int reg,int op,int d) {
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2191 error(-1);
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2192 }
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2193
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2194 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2195 code_dpreinc(int e1,int e2,int d,int freg) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2196 g_expr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2197 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2198 printf("\tfld1\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2199 if (caddr(e1)>0)
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2200 printf("\tfaddp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2201 else
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2202 printf("\tfsubrp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2203 printf("\t%s (%s)\n",fstore(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2204 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2205
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2206 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2207 code_dpostinc(int e1,int e2,int d,int freg) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2208 g_expr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2209 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2210 if (use)
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
2211 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2212 printf("\tfld1\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2213 if (caddr(e1)>0)
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2214 printf("\tfaddp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2215 else
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2216 printf("\tfsubrp %%st,%%st(1)\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2217 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
2218 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2219
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2220 #define COND_BRANCH 1
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2221 #define COND_VALUE 2
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2222
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2223 int
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2224 drexpr0(int e1, int e2,int l1, int op,int cond,int reg,int mode)
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2225 {
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2226 char *s;
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2227 if (!cond) {
230
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
2228 switch(op) {
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2229 case FOP+GT:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2230 return drexpr0(e2,e1,l1,FOP+GE,1,reg,mode);
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2231 case FOP+GE:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2232 return drexpr0(e2,e1,l1,FOP+GT,1,reg,mode);
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2233 case FOP+EQ:
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2234 op=FOP+NEQ; break;
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2235 case FOP+NEQ:
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2236 op=FOP+EQ; break;
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2237 case DOP+GT:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2238 return drexpr0(e2,e1,l1,DOP+GE,1,reg,mode);
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2239 case DOP+GE:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2240 return drexpr0(e2,e1,l1,DOP+GT,1,reg,mode);
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2241 case DOP+EQ:
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2242 op=DOP+NEQ; break;
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2243 case DOP+NEQ:
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2244 op=DOP+EQ; break;
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2245 default: return 0;
230
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
2246 }
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
2247 }
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2248 s = "e";
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2249 switch(op) {
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2250 case DOP+GE:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2251 case FOP+GE:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2252 g_expr(list3(DCMP,e1,e2));
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2253 printf("\ttestb\t$5,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2254 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2255 case DOP+GT:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2256 case FOP+GT:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2257 g_expr(list3(DCMP,e1,e2));
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2258 printf("\ttestb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2259 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2260 case DOP+EQ:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2261 case FOP+EQ:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2262 g_expr(list3(DCMP,e1,e2));
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2263 printf("\tandb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2264 printf("\txorb\t$64,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2265 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2266 case DOP+NEQ:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2267 case FOP+NEQ:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2268 g_expr(list3(DCMP,e1,e2));
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2269 printf("\tandb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2270 printf("\txorb\t$64,%%ah\n");
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2271 s = "ne";
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2272 break;
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2273 default:
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2274 return 0;
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2275 }
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2276 if (mode==COND_BRANCH) {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2277 printf("\tj%s\t_%d\n",s,l1);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2278 } else {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2279 use_int(reg); use_data_reg(reg,0);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2280 printf("\tset%s\t%s\n",s,register_name(reg,1));
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2281 printf("\tmovzbl\t%s,%s\n",
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2282 register_name(reg,1),register_name(reg,0));
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2283 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2284 return 1;
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2285 }
1a723130a2c7 condtional
kono
parents: 83
diff changeset
2286
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2287 void
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2288 drexpr(int e1, int e2,int l1, int op,int cond)
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2289 {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2290 drexpr0(e1, e2,l1, op,cond,USE_CREG,COND_BRANCH);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2291 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2292
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2293 static int
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2294 drexpr_bool(int e1, int reg)
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2295 {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2296 return drexpr0(cadr(e1), caddr(e1),0, car(e1),1,reg,COND_VALUE);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2297 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2298
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2299
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2300 void
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2301 code_dregister(int e2,int freg,int d)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2302 {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2303 error(-1);
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2304 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2305
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2306 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2307 code_cmp_dregister(int e2,int d,int label,int cond)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2308 {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2309 if (e2!=USE_CREG)
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2310 error(-1);
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2311 printf("\tfldz\n");
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2312 printf("\tfucompp\n");
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2313 printf("\tfnstsw\t%%ax\n");
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2314 printf("\tandb\t$69,%%ah\n");
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2315 printf("\txorb\t$64,%%ah\n");
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2316 jcond(label,cond);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2317 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2318
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2319 int pop_fregister()
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2320 {
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2321 if (freg_sp<0) { error(-1); return -1;}
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2322 printf("# fpop: %d\n",freg_sp-1);
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2323 return freg_stack[--freg_sp];
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2324 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2325
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2326 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2327 emit_dpop(int d)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2328 {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2329 int xreg;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2330 if ((xreg=pop_fregister())==-1) {
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2331 } else if (xreg<= -REG_LVAR_OFFSET) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2332 code_drlvar(REG_LVAR_OFFSET+xreg,1,freg);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
2333 free_lvar(xreg+REG_LVAR_OFFSET);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2334 /* pushed order is reversed. We don't need this for comutable
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2335 operator, but it is ok to do this. */
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2336 printf("\tfxch\t%%st(1)\n");
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2337 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2338 return xreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2339 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2340
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2341
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2342 void emit_dpop_free(int e1,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2343 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2344 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2345
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
2346 void emit_dpush(int type)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2347 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2348 if (freg_sp>=MAX_FPU_STACK) code_save_fstacks();
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2349 if (freg_sp>MAX_MAX) error(-1);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2350 freg_stack[freg_sp++]=-1;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2351 printf("# fpush:%d\n",freg_sp);
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2352 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2353
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2354 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2355
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2356 void
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2357 code_save_stacks()
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2358 {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2359 /* temporal registers or stacks in fpu are saved in local variable */
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2360 int xreg,sp,screg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2361 sp=reg_sp;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2362 while(sp-->0) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2363 if ((xreg=reg_stack[sp])>=0) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2364 screg=creg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2365 if(creg!=xreg) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2366 if (xreg!=dreg) free_register(xreg);
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2367 creg = xreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2368 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2369 code_assign_lvar(
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2370 (reg_stack[sp]=new_lvar(SIZE_OF_INT)),creg,0);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2371 reg_stack[sp]= reg_stack[sp]-REG_LVAR_OFFSET;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2372 regv[xreg]=0;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2373 creg=screg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2374 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2375 }
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2376 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2377
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2378 #if FLOAT_CODE
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2379 void
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2380 code_save_fstacks()
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2381 {
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
2382 int xreg,sp,uses;
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
2383 uses = use; use = 0;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2384 sp=freg_sp;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2385 while(sp-->0) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2386 if ((xreg=freg_stack[sp])==-1) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2387 code_dassign_lvar(
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2388 (freg_stack[sp]=new_lvar(SIZE_OF_DOUBLE)),freg,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2389 freg_stack[sp]= freg_stack[sp]-REG_LVAR_OFFSET;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2390 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2391 }
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
2392 use = uses;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2393 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2394 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2395
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2396
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2397
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2398 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2399
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2400
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2401 /* 64bit int part */
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2402
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2403 static void
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2404 pcond(char *s,int l1)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2405 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2406 printf("\tj%s\t_%d\n",s,l1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2407 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2408
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2409 void
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2410 lrexpr(int e1, int e2,int l1, int op,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2411 {
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2412 int l2;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2413 code_save_stacks();
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2414 g_expr(e1);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2415 emit_lpush();
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2416 g_expr(e2);
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2417 // we are sure %ecx,%ebx is free
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2418 printf("\tpopl %%ecx\n"); // LSW
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2419 printf("\tpopl %%ebx\n"); // MSW
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2420 printf("\tsubl %%edx,%%ebx\n");
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2421 l2 = fwdlabel();
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2422 // cond==0 jump on false condtion ( if(x) => rexpr(.. cond=0 ...) )
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2423 switch(op) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2424 case LOP+GT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2425 case LOP+GE:
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2426 pcond(code_gt(1),cond?l1:l2);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2427 pcond(code_eq(0),cond?l2:l1);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2428 break;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2429 case LOP+UGT:
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2430 case LOP+UGE:
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2431 pcond(code_ugt(1),cond?l1:l2);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2432 pcond(code_eq(0), cond?l2:l1);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2433 break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2434 case LOP+EQ:
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2435 pcond(code_eq(0),(cond?l2:l1));
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2436 pcond(code_eq(cond),l1);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2437 break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2438 case LOP+NEQ:
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2439 pcond(code_eq(0),(cond?l1:l2));
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2440 pcond(code_eq(!cond),l1);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2441 break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2442 default:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2443 error(-1);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2444 }
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2445 printf("\tsubl %%eax,%%ecx\n");
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2446 switch(op) {
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2447 case LOP+GT: pcond(code_gt(cond), l1); break;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2448 case LOP+GE: pcond(code_ge(cond), l1); break;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2449 case LOP+UGT: pcond(code_ugt(cond), l1); break;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2450 case LOP+UGE: pcond(code_uge(cond), l1); break;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2451 }
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2452 fwddef(l2);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2453 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2454
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2455 int emit_lpop()
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2456 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2457 return 0;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2458 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2459
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2460 void code_lregister(int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2461 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2462 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2463 if (reg!=REG_L) {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2464 printf("\tmovl %%esi,%s\n",l_eax(reg));
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2465 printf("\tmovl %%edi,%s\n",l_edx(reg));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2466 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2467 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2468
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2469 void code_cmp_lregister(int reg,int label,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2470 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2471 char *crn;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2472 use_int(reg);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2473 crn = register_name(reg,0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2474 printf("\tmovl %%esi,%s\n",crn);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2475 printf("\torl %%edi,%s\n",crn);
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2476 printf("\ttestl %s,%s\n",crn,crn);
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2477 jcond(label,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2478 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2479
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2480 void code_cmp_lrgvar(int e1,int e2,int label,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2481 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2482 char *n,*crn;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2483 n = ((NMTBL*)cadr(e1))->nm;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2484 use_int(e2);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2485 crn = register_name(e2,0);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2486 printf("\tmovl %s,%s\n",n,crn);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2487 printf("\torl %s+4,%s\n",n,crn);
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2488 printf("\ttestl %s,%s\n",crn,crn);
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2489 jcond(label,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2490 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2491
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2492 void code_cmp_lrlvar(int e1,int e2,int label,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2493 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2494 char *crn;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2495 use_int(e2);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2496 crn = register_name(e2,0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2497 printf("\tmovl %d(%%ebp),%s\n",lvar(e1),crn);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2498 printf("\torl %d(%%ebp),%s\n",lvar(e1)+4,crn);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2499 printf("\ttestl %s,%s\n",crn,crn);
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2500 jcond(label,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2501 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2502
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2503 void code_lassign(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2504 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2505 char *rn;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2506 // e1 = e2
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2507 use_longlong(e2);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2508 rn = register_name(e1,0);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2509 printf("\tmovl %s,(%s)\n",l_eax(e2),rn);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2510 printf("\tmovl %s,4(%s)\n",l_edx(e2),rn);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2511 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2512
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2513 void code_lassign_gvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2514 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2515 char *n;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2516 n = ((NMTBL*)cadr(e1))->nm;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2517 use_longlong(e2);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2518 printf("\tmovl %s,%s\n",l_eax(e2),n);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2519 printf("\tmovl %s,%s+4\n",l_edx(e2),n);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2520 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2521
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2522 void code_lassign_lvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2523 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2524 use_longlong(e2);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2525 printf("\tmovl %s,%d(%%ebp)\n",l_eax(e2),lvar(e1));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2526 printf("\tmovl %s,%d(%%ebp)\n",l_edx(e2),lvar(e1)+4);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2527 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2528
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2529 void code_lassign_lregister(int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2530 {
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2531 // e2 = reg
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2532 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2533 if (e2!=reg) {
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2534 printf("\tmovl %s,%s\n",l_eax(reg),l_eax(e2));
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2535 printf("\tmovl %s,%s\n",l_edx(reg),l_edx(e2));
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2536 }
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2537 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2538
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2539 void
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2540 code_lconst(int e1,int creg)
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2541 {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2542 use_longlong(creg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2543 printf("\tmovl $%d,%s\n",code_l1(lcadr(e1)),l_eax(creg));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2544 printf("\tmovl $%d,%s\n",code_l2(lcadr(e1)),l_edx(creg));
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2545 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2546
212
32f54ab63b35 *** empty log message ***
kono
parents: 205
diff changeset
2547 void code_lneg(int e1)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2548 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2549 use_longlong(e1);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2550 printf("\tnegl %s\n",l_eax(e1));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2551 printf("\tadcl $0,%s\n",l_edx(e1));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2552 printf("\tnegl %s\n",l_edx(e1));
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2553 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2554
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2555 void code_lrgvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2556 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2557 char *n;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2558 n = ((NMTBL*)cadr(e1))->nm;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2559 use_longlong(e2);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2560 printf("\tmovl %s,%s\n",n,l_eax(e2));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2561 printf("\tmovl %s+4,%s\n",n,l_edx(e2));
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2562 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2563
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2564 void code_lrlvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2565 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2566 use_longlong(e2);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2567 printf("\tmovl %d(%%ebp),%s\n",lvar(e1),l_eax(e2));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2568 printf("\tmovl %d(%%ebp),%s\n",lvar(e1)+4,l_edx(e2));
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2569 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2570
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2571 #define check_lreg(reg) if (reg==REG_L) code_lassign_lregister(reg,REG_LCREG)
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2572
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2573 void
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2574 ltosop(int op,int reg,int e2)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2575 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2576 char *opl,*oph,*call;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2577 int lb;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2578
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2579 // e2 (operand) is on the top of the stack
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2580 use_longlong(reg);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2581 opl = 0; call=0;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2582
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2583 switch(op) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2584 case LLSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2585 case LULSHIFT:
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2586 printf("\tmovl %%ecx,4(%%esp)\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2587 printf("\tpopl %%ecx\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2588 printf("\tshldl %%eax,%%edx\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2589 printf("\tsall %%cl,%%eax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2590 printf("\ttestb $32,%%cl\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2591 printf("\tje\t_%d\n",(lb=fwdlabel()));
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2592 printf("\tmovl %%eax,%%edx\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2593 printf("\txorl %%eax,%%eax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2594 fwddef(lb);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2595 printf("\tpopl %%ecx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2596 check_lreg(reg);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2597 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2598 case LRSHIFT:
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2599 printf("\tmovl %%ecx,4(%%esp)\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2600 printf("\tpopl %%ecx\n");
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2601 printf("\tshrdl %%edx,%%eax\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2602 printf("\tsarl %%cl,%%eax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2603 printf("\ttestb $32,%%cl\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2604 printf("\tje\t_%d\n",(lb=fwdlabel()));
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2605 printf("\tmovl %%edx,%%eax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2606 printf("\tsarl $31,%%edx\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2607 fwddef(lb);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2608 printf("\tpopl %%ecx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2609 check_lreg(reg);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2610 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2611 case LURSHIFT:
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2612 printf("\tmovl %%ecx,4(%%esp)\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2613 printf("\tpopl %%ecx\n");
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2614 printf("\tshrdl %%edx,%%eax\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2615 printf("\tshrl %%cl,%%eax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2616 printf("\ttestb $32,%%cl\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2617 printf("\tje\t_%d\n",(lb=fwdlabel()));
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2618 printf("\tmovl %%edx,%%eax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2619 printf("\txorl %%edx,%%edx\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2620 fwddef(lb);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2621 printf("\tpopl %%ecx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2622 check_lreg(reg);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2623 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2624 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2625 switch(op) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2626 case LADD: opl="addl";oph="adcl"; break;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2627 case LSUB: opl="subl";oph="sbbl"; break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2628 case LBAND: opl=oph="andl"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2629 case LEOR: opl=oph="xorl"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2630 case LBOR: opl=oph="orl"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2631 case LMUL:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2632 case LUMUL:
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2633 printf("\tpushl %%edx\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2634 printf("\tpushl %%eax\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2635 printf("\tpushl %%ecx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2636 // 0 saved ecx
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2637 // 4 c_l
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2638 // 8 c_h
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2639 // 12 o_l
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2640 // 16 o_h
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2641 printf("\tmull 12(%%esp)\n"); // c_l*o_l -> %edx,%eax
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2642 printf("\tmovl 4(%%esp),%%ecx\n"); // c_l->%ecx
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2643 printf("\timull 16(%%esp),%%ecx\n"); // c_l*o_h->%ecx
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2644 printf("\taddl %%ecx,%%edx\n"); // %edx+%ecx->%edx
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2645 printf("\tmovl 8(%%esp),%%ecx\n"); // c_h->%ecx
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2646 printf("\timull 12(%%esp),%%ecx\n"); // c_h*o_l->%ecx
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2647 printf("\taddl %%ecx,%%edx\n"); // %edx+%ecx->%edx
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2648 printf("\tpopl %%ecx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2649 // printf("\taddl $8,%%esp\n");
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2650 printf("\tlea 16(%%esp),%%esp\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2651 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2652 case LDIV: call="__divdi3"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2653 case LUDIV: call="__udivdi3"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2654 case LMOD: call="__moddi3"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2655 case LUMOD: call="__umoddi3"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2656 default: error(-1);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2657 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2658 if (opl) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2659 printf("\t%s (%%esp),%%eax\n\t%s 4(%%esp),%%edx\n",opl,oph);
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2660 printf("\tlea 8(%%esp),%%esp\n");
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2661 check_lreg(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2662 } else if (call) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2663 printf("\tpushl %%edx\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2664 printf("\tpushl %%eax\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2665 printf("\tcall %s\n",call);
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2666 // printf("\taddl $8,%%esp\n");
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2667 printf("\tlea 16(%%esp),%%esp\n");
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2668 check_lreg(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2669 } else {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2670 error(-1);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2671 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2672 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2673
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2674 int code_lconst_op_p(int op,int e) {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2675 long long l;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2676 if (car(e)==CONST) l = cadr(e);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2677 else if (car(e)==LCONST) l = lcadr(e);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2678 else return 0;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2679
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2680 switch(op) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2681 case LLSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2682 case LULSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2683 case LRSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2684 case LURSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2685 return (0<=l&&l<=32);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2686 case LADD:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2687 case LSUB:
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2688 case LBAND:
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2689 case LEOR:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2690 case LBOR:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2691 return 1;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2692 default:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2693 return 0;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2694 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2695 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2696
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2697 void loprtc(int op,int reg,int e) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2698 char *opl,*oph;
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2699 int vl;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2700 int vh;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2701 long long l;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2702
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2703 if (car(e)==CONST) l = cadr(e);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2704 else if (car(e)==LCONST) l = lcadr(e);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2705 else error(-1);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2706
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2707 vl = code_l1(l);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2708 vh = code_l2(l);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2709
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2710 use_longlong(reg);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2711 opl = 0;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2712
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2713 switch(op) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2714 case LLSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2715 case LULSHIFT:
286
179e22f166ef register assop fix
kono
parents: 280
diff changeset
2716 printf("\tshldl $%d,%s,%s\n",vl,l_eax(reg),l_edx(reg));
179e22f166ef register assop fix
kono
parents: 280
diff changeset
2717 printf("\tsall $%d,%s\n",vl,l_eax(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2718 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2719 case LRSHIFT:
286
179e22f166ef register assop fix
kono
parents: 280
diff changeset
2720 printf("\tshrdl $%d,%s,%s\n",vl,l_edx(reg),l_eax(reg));
179e22f166ef register assop fix
kono
parents: 280
diff changeset
2721 printf("\tsarl $%d,%s\n",vl,l_edx(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2722 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2723 case LURSHIFT:
286
179e22f166ef register assop fix
kono
parents: 280
diff changeset
2724 printf("\tshrdl $%d,%s,%s\n",vl,l_edx(reg),l_eax(reg));
179e22f166ef register assop fix
kono
parents: 280
diff changeset
2725 printf("\tshrl $%d,%s\n",vl,l_edx(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2726 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2727 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2728 switch(op) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2729 case LADD: opl="addl";oph="adcl"; break;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2730 case LSUB: opl="subl";oph="sbbl"; break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2731 case LBAND: opl=oph="andl"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2732 case LEOR: opl=oph="xorl"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2733 case LBOR: opl=oph="orl"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2734 default: error(-1);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2735 }
286
179e22f166ef register assop fix
kono
parents: 280
diff changeset
2736 printf("\t%s $%d,%s\n\t%s $%d,%s\n",opl,vl,l_eax(reg),oph,vh,l_edx(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2737 }
213
kono
parents: 212
diff changeset
2738
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2739 void emit_lpop_free(int e1)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2740 {
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2741 // printf("\taddl $8,%%esp\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2742 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2743
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2744 void emit_lpush()
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2745 {
241
96b5ee862a41 *** empty log message ***
kono
parents: 240
diff changeset
2746 printf("\tpushl %%edx\n\tpushl %%eax\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2747 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2748
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2749 void code_i2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2750 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2751 int reg0 = USE_CREG;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2752 use_register(creg,REG_EAX,1);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2753 regv[creg]=0;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2754 use_longlong(reg0);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2755 printf("\tcltd\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2756 check_lreg(reg);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2757 lreg = creg = reg0;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2758 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2759
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2760 void code_i2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2761 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2762 code_i2ll(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2763 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2764
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2765 void code_u2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2766 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2767 int reg0 = USE_CREG;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2768 use_register(creg,REG_EAX,1);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2769 regv[creg]=0;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2770 use_longlong(reg0);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2771 printf("\txorl %%edx,%%edx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2772 check_lreg(reg);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2773 lreg = creg = reg0;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2774 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2775
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2776 void code_u2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2777 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2778 code_u2ll(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2779 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2780
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2781 void code_ll2i(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2782 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2783 use_int(reg);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2784 if (virtual(REG_EAX)!=reg)
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2785 printf("\tmovl %%eax,%s\n",register_name(creg,0));
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2786 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2787
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2788 void code_ll2u(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2789 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2790 code_ll2i(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2791 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2792
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2793 void code_ull2i(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2794 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2795 code_ll2i(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2796 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2797
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2798 void code_ull2u(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2799 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2800 code_ll2i(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2801 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2802
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2803 #if FLOAT_CODE
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2804 void code_d2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2805 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2806 use_longlong(reg);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2807 printf("\tsubl $40,%%esp\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2808 printf("\tfnstcw 2(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2809 printf("\tmovw 2(%%esp),%%ax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2810 printf("\torw $3072,%%ax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2811 printf("\tmovw %%ax,0(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2812 printf("\tfldcw 0(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2813 printf("\tfistpll 12(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2814 printf("\tfldcw 2(%%esp)\n");
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2815 printf("\tmovl 12(%%esp),%%eax\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2816 printf("\tmovl 16(%%esp),%%edx\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2817 printf("\taddl $40,%%esp\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2818 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2819
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2820 void code_d2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2821 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2822 use_longlong(reg);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2823 printf("\tsubl $16,%%esp\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2824 printf("\tfstpl (%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2825 printf("\tcall __fixunsdfdi\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2826 printf("\taddl $16,%%esp\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2827 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2828
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2829 void code_f2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2830 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2831 code_d2ll(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2832 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2833
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2834 void code_f2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2835 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2836 use_longlong(reg);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2837 printf("\tsubl $16,%%esp\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
2838 printf("\tfstps (%%esp)\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2839 printf("\tcall __fixunssfdi\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2840 printf("\taddl $16,%%esp\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2841 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2842
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2843 void code_ll2d(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2844 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2845 printf("\tsubl $8,%%esp\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2846 printf("\tmovl %%eax,(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2847 printf("\tmovl %%edx,4(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2848 printf("\tfildll (%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2849 printf("\taddl $8,%%esp\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2850 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2851
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2852 void code_ll2f(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2853 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2854 code_ll2d(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2855 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2856
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2857 void code_ull2d(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2858 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2859 code_ll2d(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2860 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2861
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2862 void code_ull2f(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2863 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2864 code_ll2d(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2865 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2866
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2867 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2868
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2869
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2870 void code_lpreinc(int e1,int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2871 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2872 int dir = caddr(e1);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2873 int creg0;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2874 char *crn;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2875 if (car(e2)==LREGISTER) {
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2876 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2877 printf("\taddl $%d,%%esi\n",dir);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2878 printf("\tadcl $%d,%%edi\n",dir>0?0:-1);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2879 if (reg!=REG_L) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2880 code_lregister(REG_L,reg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2881 }
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2882 return;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2883 }
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2884 g_expr(e2);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2885 crn = register_name(creg0=creg,0);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2886 printf("\taddl $%d,(%s)\n",dir,crn);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2887 printf("\tadcl $%d,4(%s)\n",dir>0?0:-1,crn);
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2888 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2889 lload(creg0,0,reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2890 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2891
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2892 void code_lpostinc(int e1,int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2893 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2894 int dir = caddr(e1);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2895 int creg0;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2896 char *crn;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2897 if (car(e2)==LREGISTER) {
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2898 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2899 if (reg!=REG_L) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2900 code_lregister(REG_L,reg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2901 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2902 printf("\taddl $%d,%%esi\n",dir);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2903 printf("\tadcl $%d,%%edi\n",dir>0?0:-1);
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2904 return;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2905 }
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2906 g_expr(e2);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2907 crn = register_name(creg0=creg,0);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2908 printf("\taddl $%d,(%s)\n",dir,crn);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2909 printf("\tadcl $%d,4(%s)\n",dir>0?0:-1,crn);
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2910 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2911 lload(creg0,0,reg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2912 printf("\taddl $%d,%s\n",-dir,l_eax(reg));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2913 printf("\tadcl $%d,%s\n",-dir>0?0:-1,l_edx(reg));
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2914 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2915
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2916 void code_lassop(int op,int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2917 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2918 error(-1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2919 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2920
219
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2921 void
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2922 code_register_lassop(int reg,int op) {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
2923 error(-1);
219
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2924 }
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2925
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2926
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2927 #endif
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
2928
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2929 /* end */
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2930