annotate mc-code-powerpc.c @ 206:4170cefb48f6

*** empty log message ***
author kono
date Thu, 15 Apr 2004 07:25:38 +0900
parents a50f90d0b63a
children 8a3516f6eb66
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1 /* Micro-C Code Generatation Part for Power PC (Mac OS X) */
917947ffeb7c power pc version
kono
parents:
diff changeset
2 /* $Id$ */
917947ffeb7c power pc version
kono
parents:
diff changeset
3
917947ffeb7c power pc version
kono
parents:
diff changeset
4 #define EXTERN extern
917947ffeb7c power pc version
kono
parents:
diff changeset
5 #include "mc.h"
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
6 #include "mc-code.h"
89
917947ffeb7c power pc version
kono
parents:
diff changeset
7 #include "mc-codegen.h"
917947ffeb7c power pc version
kono
parents:
diff changeset
8
173
3b33c7daae95 *** empty log message ***
kono
parents: 172
diff changeset
9 char *l_include_path[] = {
3b33c7daae95 *** empty log message ***
kono
parents: 172
diff changeset
10 "/usr/include/",
3b33c7daae95 *** empty log message ***
kono
parents: 172
diff changeset
11 0
3b33c7daae95 *** empty log message ***
kono
parents: 172
diff changeset
12 };
3b33c7daae95 *** empty log message ***
kono
parents: 172
diff changeset
13
89
917947ffeb7c power pc version
kono
parents:
diff changeset
14 #define TEXT_EMIT_MODE 0
917947ffeb7c power pc version
kono
parents:
diff changeset
15 #define DATA_EMIT_MODE 1
917947ffeb7c power pc version
kono
parents:
diff changeset
16 #define RODATA_EMIT_MODE 2
917947ffeb7c power pc version
kono
parents:
diff changeset
17
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
18 static void data_mode(char *name);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
19 static void init_ptr_cache();
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
20 static void ld_indexx(int byte, int n, int xreg,int sign);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
21 static void local_table(void);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
22 static void shift(char *op, int reg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
23 static int struct_push(int e4,int t,int arg);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
24
89
917947ffeb7c power pc version
kono
parents:
diff changeset
25 static int output_mode = TEXT_EMIT_MODE;
917947ffeb7c power pc version
kono
parents:
diff changeset
26 static int data_alignment = 0;
917947ffeb7c power pc version
kono
parents:
diff changeset
27
917947ffeb7c power pc version
kono
parents:
diff changeset
28 static int code_disp_label;
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
29 static int code_setup;
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
30 static int r1_offset_label;
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
31 static int lvar_offset_label;
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
32
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
33 static int reg_save;
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
34 static int freg_save;
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
35
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
36 static int freg,ireg,lreg;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
37
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
38 int size_of_int = 4;
165
kono
parents: 164
diff changeset
39 int size_of_short = 2;
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
40 int size_of_float = 4;
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
41 int size_of_double = 8;
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
42 int size_of_longlong = 8;
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
43 int endian = 1;
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
44
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
45 static int reg_sp; /* REGister Stack-Pointer */
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
46 static int reg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
47
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
48 /* floating point registers */
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
49
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
50 static int freg_sp; /* floating point REGister Stack-Pointer */
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
51 static int freg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
89
917947ffeb7c power pc version
kono
parents:
diff changeset
52
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
53 static int lreg_sp; /* longlong REGister Stack-Pointer */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
54 static int lreg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
55
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
56 #define REG_fp 1
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
57 #define REG_sp 30
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
58 #define REG_VAR_BASE 29
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
59 #define REG_VAR_MIN 18
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
60 #define MIN_TMP_REG 3
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
61 #define MAX_TMP_REG 11
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
62
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
63 #define PTRC_REG 3
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
64
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
65 #define FREG_VAR_BASE 31
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
66 #define FREG_VAR_MIN 20
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
67 #define MIN_TMP_FREG 1
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
68 #define MAX_TMP_FREG 14
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
69
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
70 #define RET_REGISTER regv[3]
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
71 #define RET_FREGISTER regv[(1+FREG_OFFSET)]
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
72 #define RET_LREGISTER_L 4 /* low word */
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
73 #define RET_LREGISTER_H 3 /* high word */
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
74 static int lreg_ret;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
75 #define RET_LREGISTER lreg_ret
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
76
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
77 int MAX_REGISTER=30; /* PowerPCのレジスタを10個まで使う*/
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
78 int MAX_FREGISTER=31;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
79 #define REAL_MAX_REGISTER 32 /* PowerPCのレジスタが32ということ*/
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
80 #define REAL_MAX_FREGISTER 32 /* PowerPCのレジスタが32ということ*/
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
81
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
82 #define FREG_OFFSET REAL_MAX_REGISTER
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
83
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
84 int MAX_INPUT_REGISTER_VAR = 11-MIN_TMP_REG;
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
85 int MAX_CODE_INPUT_REGISTER_VAR = 11-MIN_TMP_REG;
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
86 int MAX_INPUT_DREGISTER_VAR = 14-MIN_TMP_FREG;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
87 int MAX_INPUT_FREGISTER_VAR = 14-MIN_TMP_FREG;
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
88 int MAX_CODE_INPUT_DREGISTER_VAR = 14-MIN_TMP_FREG;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
89 int MAX_CODE_INPUT_FREGISTER_VAR = 14-MIN_TMP_FREG;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
90
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
91 static int powerpc_regs[REAL_MAX_REGISTER+REAL_MAX_FREGISTER];
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
92 static int regv[REAL_MAX_REGISTER+REAL_MAX_FREGISTER];
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
93
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
94 static int *regs = powerpc_regs;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
95
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
96 #define CREG_REGISTER regv[MAX_TMP_REG]
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
97 #define FREG_FREGISTER regv[MAX_TMP_FREG+FREG_OFFSET]
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
98
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
99
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
100 static int max_reg_var, max_freg_var;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
101
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
102 static char *reg_name[] = {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
103 "r0","r1","r2","r3","r4","r5","r6","r7","r8","r9",
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
104 "r10","r11","r12","r13","r14","r15","r16","r17","r18","r19",
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
105 "r20","r21","r22","r23","r24","r25","r26","r27","r28","r29",
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
106 "r30","r31",
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
107 "f0","f1","f2","f3","f4","f5","f6","f7","f8","f9",
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
108 "f10","f11","f12","f13","f14","f15","f16","f17","f18","f19",
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
109 "f20","f21","f22","f23","f24","f25","f26","f27","f28","f29",
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
110 "f30","f31"
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
111 };
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
112
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
113 #define register_name(i) reg_name[cadr(i)]
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
114 #define fregister_name(i) reg_name[cadr(i)]
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
115 #define lregister_name_low(i) reg_name[cadr(i)]
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
116 #define lregister_name_high(i) reg_name[caddr(i)]
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
117
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
118 #define is_int_reg_0(i) (0<=i&&i<REAL_MAX_REGISTER)
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
119 #define is_float_reg_0(i) (REAL_MAX_REGISTER<=i&&i<REAL_MAX_FREGISTER+REAL_MAX_REGISTER)
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
120
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
121 #define is_int_reg(i) (car(i)==REGISTER)
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
122 #define is_float_reg(i) (car(i)==DREGISTER)
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
123 #define is_longlong_reg(i) (car(i)==LREGISTER)
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
124
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
125
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
126 int use_int(int i) {
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
127 if (lreg) {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
128 free_register(lreg); lreg = 0;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
129 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
130 if (!is_int_reg(i)) {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
131 if (!ireg) ireg = get_register();
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
132 i = ireg;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
133 }
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
134 return i;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
135 }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
136
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
137 int use_float(int i) {
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
138 if (!is_float_reg(i)) i = freg;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
139 if (!regs[cadr(i)]) regs[cadr(i)]=1;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
140 return i;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
141 }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
142
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
143 int use_double(int i) {
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
144 if (!is_float_reg(i)) i = freg;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
145 if (!regs[cadr(i)]) regs[cadr(i)]=1;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
146 return i;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
147 }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
148
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
149 int use_longlong(int i) {
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
150 if (ireg) {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
151 free_register(ireg); ireg = 0;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
152 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
153 if (!is_longlong_reg(i)) {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
154 if (!lreg) lreg = get_lregister();
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
155 i = lreg;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
156 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
157 return i;
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
158 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
159
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
160
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
161 #if FLOAT_CODE
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
162 static
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
163 NMTBL float_zero = {"_float_zero",STATIC,FLOAT,0};
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
164 static
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
165 NMTBL float_one = {"_float_one",STATIC,FLOAT,0};
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
166
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
167
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
168 static char * fload(int d);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
169 static int code_d1(double d);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
170 static int code_d2(double d);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
171 #endif
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
172 #if LONGLONG_CODE
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
173 static int code_l1(long long ll);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
174 static int code_l2(long long ll);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
175 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
176
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
177 static void code_save_stacks();
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
178 static void code_save_input_registers();
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
179 static void clear_ptr_cache_reg(int r);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
180 static void set_creg(int,int);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
181 static void set_freg(int,int);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
182 static void set_lreg(int,int);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
183
153
33b39002ac58 MIPS continue
kono
parents: 148
diff changeset
184 static int max_func_args;
33b39002ac58 MIPS continue
kono
parents: 148
diff changeset
185 static int my_func_args;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
186 #define ARG_LVAR_OFFSET 0x10000000
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
187
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
188 /*
89
917947ffeb7c power pc version
kono
parents:
diff changeset
189
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
190 r0 return value etc.
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
191 r3-r10 input register
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
192 r22-r29 saved register variable (input register for code segement)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
193 r30 stack pointer
917947ffeb7c power pc version
kono
parents:
diff changeset
194 r31 0
917947ffeb7c power pc version
kono
parents:
diff changeset
195 r1 frame pointer
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
196
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
197 f0 return value etc.
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
198 f1-r8 input register
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
199 f24-f31 saved register variable
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
200
202
601301152d9c *** empty log message ***
kono
parents: 196
diff changeset
201 function call stack frame
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
202 <------r1_offset------------------------------>
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
203 <------------lvar_offset------->
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
204 r+ +------------+---+---------------+----------+--------------+----+ -
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
205 callee arg xx register save local caller arg xx
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
206 reg_save disp max_func_args*size_of_int
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
207 lvar>0 lvar<0 lvar>0x1000 0000
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
208
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
209 code segment stack frame
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
210
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
211 * gotoを呼び出した関数のr1 ! r1(goto前のr1)
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
212 # * r30 <---r1_offset---------> r1
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
213 r+ +----------+--+----------+----------------+-----------+----------+----+
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
214 cousin arg xx reg save !callee arg !code local caller arg xx
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
215 r20-r29 lvar>0 lvar<0 lvar>0x1000 000
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
216 f20-f31 <-my_func_args--><--disp-----><-max_func_arg->
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
217 *size_of_int *size_of_int
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
218
89
917947ffeb7c power pc version
kono
parents:
diff changeset
219 */
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
220 int arg_offset = 24; int arg_offset1 = 24; int disp_offset = -12;
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
221 #define func_disp_offset 60
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
222 #define r1_offset func_disp_offset+12
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
223 int code_disp_offset = 0; int jump_offset = 0;
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
224 #define CODE_LVAR l+code_disp_offset
129
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
225 #define CODE_CALLER_ARG (l-ARG_LVAR_OFFSET)+arg_offset1
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
226 #define FUNC_LVAR l+disp_offset
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
227 #define CALLER_ARG (l-ARG_LVAR_OFFSET)+arg_offset1
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
228 #define CALLEE_ARG l+arg_offset
89
917947ffeb7c power pc version
kono
parents:
diff changeset
229
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
230 void
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
231 code_offset_set()
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
232 {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
233 #if 0
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
234 int l;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
235 #endif
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
236 int lvar_offsetv = -disp+max_func_args*size_of_int+func_disp_offset;
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
237 int r1_offsetv = -disp+max_func_args*size_of_int-reg_save+r1_offset;
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
238 printf(".set L_%d,%d\n",lvar_offset_label,lvar_offsetv);
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
239 printf(".set L_%d,%d\n",r1_offset_label,r1_offsetv);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
240 #if 0
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
241 printf("# function %s\n",fnptr->nm);
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
242 l = ARG_LVAR_OFFSET;
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
243 printf("# offset call0\t%d\n",CALLER_ARG);
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
244 l = ARG_LVAR_OFFSET+max_func_args*size_of_int;
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
245 printf("# offset calln\t%d %d\n",CALLER_ARG,max_func_args*size_of_int);
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
246 l = disp;
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
247 printf("# offset lvarn\t%d %d\n",FUNC_LVAR+lvar_offsetv,disp);
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
248 l = 0;
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
249 printf("# offset lvar0\t%d\n",FUNC_LVAR+lvar_offsetv);
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
250 l = -reg_save;
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
251 printf("# offset regs\t%d\n",FUNC_LVAR+lvar_offsetv);
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
252 printf("# offset r1off\t%d\n",r1_offsetv);
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
253 l = 0;
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
254 printf("# offset carg0\t%d\n",CALLEE_ARG+r1_offsetv);
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
255 l = my_func_args;
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
256 printf("# offset cargn\t%d %d\n",CALLEE_ARG+r1_offsetv,my_func_args);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
257 #endif
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
258 }
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
259
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
260
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
261 static void
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
262 lvar8(int l)
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
263 {
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
264 if (fnptr->sc==CODE) {
129
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
265 if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
266 printf("lo16(%d)(r1)\n",CODE_CALLER_ARG);
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
267 } else
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
268 printf("lo16(%d)(r30)\n",CODE_LVAR);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
269 } else if (l<0) { /* local variable */
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
270 printf("lo16(%d+L_%d)(r30)\n",FUNC_LVAR,lvar_offset_label);
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
271 } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
272 printf("lo16(%d)(r30)\n",CALLER_ARG);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
273 } else { /* callee's arguments */
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
274 printf("lo16(%d+L_%d)(r30)\n",CALLEE_ARG,r1_offset_label);
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
275 }
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
276 }
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
277
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
278 /* if size of local variables / input variables is more then 64k,
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
279 lo16 does not work. We have to use ha16 also. But we can't know
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
280 the exact size in one path compile. We may safely use lvar16ha
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
281 if disp or max_func_args > 32k. Of course this is reduantant for
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
282 smaller offset. But who cares who use very large local variables?
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
283 */
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
284
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
285 #define LARGE_LVAR (disp<-32765||max_func_args>32765)
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
286
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
287 static void
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
288 lvar16ha(int l)
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
289 {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
290 if (fnptr->sc==CODE) {
129
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
291 if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
292 printf("la r0,ha16(%d)(r1)\n",CODE_CALLER_ARG);
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
293 } else
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
294 printf("la r0,ha16(%d)(r30)\n",CODE_LVAR);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
295 } else if (l<0) { /* local variable */
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
296 printf("la r0,ha16(%d+L_%d)(r30)\n",FUNC_LVAR,lvar_offset_label);
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
297 } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
298 if (CALLER_ARG>32765)
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
299 printf("la r0,ha16(%d)(r30)\n",CALLER_ARG);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
300 } else { /* callee's arguments */
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
301 printf("la r0,ha16(%d+L_%d)(r30)\n",CALLEE_ARG,r1_offset_label);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
302 }
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
303 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
304
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
305 static void
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
306 lvar16lo(int l)
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
307 {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
308 if (fnptr->sc==CODE) {
129
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
309 if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
310 printf("lo16(%d)(r0)\n",CODE_CALLER_ARG);
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
311 } else
948977254fa6 fix long argument call in code segement
kono
parents: 128
diff changeset
312 printf("lo16(%d)(r0)\n",CODE_LVAR);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
313 } else if (l<0) { /* local variable */
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
314 printf("lo16(%d+L_%d)(r0)\n",FUNC_LVAR,lvar_offset_label);
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
315 } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
316 if (CALLER_ARG>32765)
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
317 printf("lo16(%d)(r0)\n",CALLER_ARG);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
318 else
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
319 printf("lo16(%d)(r30)\n",CALLER_ARG);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
320 } else { /* callee's arguments */
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
321 printf("lo16(%d+L_%d)(r0)\n",CALLEE_ARG,r1_offset_label);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
322 }
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
323 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
324
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
325 #define lvar_intro(i) if (LARGE_LVAR) lvar16ha(i)
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
326
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
327 #define lvar(i) if (LARGE_LVAR) lvar16lo(i); else lvar8(i)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
328
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
329 void
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
330 code_lvar(int e2,int creg) {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
331 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
332 printf("\tla %s,",register_name(creg));
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
333 lvar(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
334 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
335
89
917947ffeb7c power pc version
kono
parents:
diff changeset
336 void
917947ffeb7c power pc version
kono
parents:
diff changeset
337 code_init(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
338 {
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
339 int i;
173
3b33c7daae95 *** empty log message ***
kono
parents: 172
diff changeset
340 macro_define("__ppc__ 1\n");
177
352feeae4b0a macro else/ccout
kono
parents: 173
diff changeset
341 macro_define("__BIG_ENDIAN__ 1\n");
182
e1e9ec8c96a7 some fix
kono
parents: 178
diff changeset
342 // macro_define("_BSD_CT_RUNE_T_ int\n");
185
427008a06333 comment
kono
parents: 182
diff changeset
343 macro_define("__STDC__ 1\n");
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
344 init_ptr_cache();
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
345 lreg_ret = glist3(LREGISTER, RET_LREGISTER_L,RET_LREGISTER_H);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
346 for(i=0;i<MAX_REGISTER;i++) { regv[i]=glist2(REGISTER,i); }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
347 for(i=0;i<MAX_FREGISTER;i++) { regv[i+FREG_OFFSET]=glist2(DREGISTER,i+FREG_OFFSET); }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
348 }
917947ffeb7c power pc version
kono
parents:
diff changeset
349
917947ffeb7c power pc version
kono
parents:
diff changeset
350 void
917947ffeb7c power pc version
kono
parents:
diff changeset
351 gexpr_code_init(void){
172
096559f07a70 some check
kono
parents: 168
diff changeset
352 #if 0
096559f07a70 some check
kono
parents: 168
diff changeset
353 int new_reg,old_reg,dm;
096559f07a70 some check
kono
parents: 168
diff changeset
354 /* register shuffling */
096559f07a70 some check
kono
parents: 168
diff changeset
355 if (is_int_reg(creg)) {
096559f07a70 some check
kono
parents: 168
diff changeset
356 dm = get_register();
096559f07a70 some check
kono
parents: 168
diff changeset
357 new_reg = get_register();
096559f07a70 some check
kono
parents: 168
diff changeset
358 old_reg = creg;
096559f07a70 some check
kono
parents: 168
diff changeset
359 ireg = creg = new_reg;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
360 free_register(old_reg);
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
361 free_register(dm);
172
096559f07a70 some check
kono
parents: 168
diff changeset
362 } else if (is_float_reg(creg)) {
096559f07a70 some check
kono
parents: 168
diff changeset
363 dm = get_dregister(1);
096559f07a70 some check
kono
parents: 168
diff changeset
364 new_reg = get_dregister(1);
096559f07a70 some check
kono
parents: 168
diff changeset
365 old_reg = creg;
096559f07a70 some check
kono
parents: 168
diff changeset
366 freg = creg = new_reg;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
367 free_register(old_reg);
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
368 free_register(dm);
172
096559f07a70 some check
kono
parents: 168
diff changeset
369 }
096559f07a70 some check
kono
parents: 168
diff changeset
370 #endif
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
371 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
372
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
373 void
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
374 code_gexpr(int e){
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
375 if (is_int_reg(creg) && creg!=ireg) error(-1);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
376 }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
377
89
917947ffeb7c power pc version
kono
parents:
diff changeset
378
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
379 void
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
380 code_arg_register(NMTBL *fnptr)
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
381 {
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
382 int args = fnptr->dsp;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
383 NMTBL *n;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
384 int reg_var = 0;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
385 int freg_var = 0;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
386 int type;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
387 int reg;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
388 int is_code0 = is_code(fnptr);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
389
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
390 while (args) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
391 /* process in reverse order */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
392 n = (NMTBL*)caddr(args);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
393 type = n->ty;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
394 if (scalar(type)) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
395 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
396 n->sc = REGISTER;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
397 n->dsp = reg;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
398 regs[cadr(n->dsp)]= INPUT_REG;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
399 reg_var++;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
400 cadddr(args)=size_of_int;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
401 }
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
402 } else if (type==FLOAT) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
403 if ((reg = get_input_dregister_var(freg_var,n,is_code0,0))) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
404 n->sc = DREGISTER;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
405 n->dsp = reg;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
406 regs[cadr(n->dsp)]= INPUT_REG;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
407 freg_var++;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
408 cadddr(args)=size(type);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
409 }
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
410 } else if (type==DOUBLE) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
411 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
412 n->sc = DREGISTER;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
413 n->dsp = reg;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
414 regs[cadr(n->dsp)]= INPUT_REG;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
415 freg_var++;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
416 cadddr(args)=size(type);
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
417 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
418 } else if (type==LONGLONG||type==ULONGLONG) {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
419 if ((reg = get_input_lregister_var(reg_var,n,is_code0))) {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
420 n->sc = LREGISTER;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
421 n->dsp = reg;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
422 regs[cadr(n->dsp)]= INPUT_REG;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
423 regs[caddr(n->dsp)]= INPUT_REG;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
424 reg_var+=2;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
425 cadddr(args)=size(type);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
426 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
427 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
428 args = cadr(args);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
429 }
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
430 if (is_function(fnptr))
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
431 code_save_input_registers();
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
432 }
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
433
89
917947ffeb7c power pc version
kono
parents:
diff changeset
434 int
917947ffeb7c power pc version
kono
parents:
diff changeset
435 get_register(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
436 { /* 使われていないレジスタを調べる */
120
099518ea9cc1 input args offset (continue..)
kono
parents: 119
diff changeset
437 int i,reg;
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
438 for(i=MAX_TMP_REG;i>MIN_TMP_REG;i--) {
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
439 if (regs[i]) continue; /* 使われている */
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
440 regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
441 return regv[i]; /* その場所を表す番号を返す */
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
442 }
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
443 /* PTR_CACHE をつぶす */
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
444 for(i=MAX_TMP_REG;i>MIN_TMP_REG;i--) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
445 if (regs[i]==PTRC_REG) {
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
446 clear_ptr_cache_reg(i);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
447 } else
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
448 continue;
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
449 regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
450 return regv[i]; /* その場所を表す番号を返す */
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
451 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
452 /* search register stack */
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
453 for(i=0;i<reg_sp;i++) {
120
099518ea9cc1 input args offset (continue..)
kono
parents: 119
diff changeset
454 if ((reg=reg_stack[i])>=0) {
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
455 code_assign_lvar(
120
099518ea9cc1 input args offset (continue..)
kono
parents: 119
diff changeset
456 (reg_stack[i]=new_lvar(size_of_int)),reg,0);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
457 reg_stack[i]= reg_stack[i]-REG_LVAR_OFFSET;
120
099518ea9cc1 input args offset (continue..)
kono
parents: 119
diff changeset
458 return reg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
459 }
917947ffeb7c power pc version
kono
parents:
diff changeset
460 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
461 #if LONGLONG_CODE
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
462 /* search register stack */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
463 for(i=0;i<lreg_sp;i++) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
464 if ((reg=lreg_stack[i])>=0) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
465 code_assign_lvar(
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
466 (lreg_stack[i]=new_lvar(size_of_longlong)),reg,0);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
467 lreg_stack[i]= lreg_stack[i]-REG_LVAR_OFFSET;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
468 free_register(reg);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
469 return get_register();
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
470 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
471 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
472 #endif
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
473 for(i=0;i<REG_VAR_BASE-REG_VAR_MIN;i++) {
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
474 reg =REG_VAR_BASE-i;
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
475 if (! regs[reg]) { /* 使われていないなら */
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
476 regs[reg]=USING_REG; /* そのレジスタを使うことを宣言し */
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
477 if (i>max_reg_var) max_reg_var=i;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
478 return regv[reg]; /* その場所を表す番号を返す */
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
479 }
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
480 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
481 /* 空いている場所がないなら、エラー (いったい誰が使ってるの?) */
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
482 error(HPERR); return creg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
483 }
917947ffeb7c power pc version
kono
parents:
diff changeset
484
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
485 int
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
486 pop_register(void)
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
487 { /* レジスタから値を取り出す */
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
488 return reg_stack[--reg_sp];
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
489 }
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
490
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
491 #if FLOAT_CODE
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
492 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
493 get_dregister(int d)
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
494 { /* 使われていないレジスタを調べる */
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
495 int i,reg;
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
496 for(i=MAX_TMP_FREG+FREG_OFFSET;i>MIN_TMP_FREG+FREG_OFFSET;i--) {
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
497 if (regs[i]) continue; /* 使われている */
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
498 regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
499 return regv[i]; /* その場所を表す番号を返す */
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
500 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
501 /* search register stack */
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
502 for(i=0;i<freg_sp;i++) {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
503 if ((reg=freg_stack[i])>=0) {
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
504 code_dassign_lvar(
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
505 (freg_stack[i]=new_lvar(size_of_double)),reg,1);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
506 freg_stack[i]= freg_stack[i]-REG_LVAR_OFFSET;
120
099518ea9cc1 input args offset (continue..)
kono
parents: 119
diff changeset
507 return reg;
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
508 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
509 }
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
510 for(i=0;i<FREG_VAR_BASE-REG_VAR_MIN;i++) {
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
511 reg =FREG_VAR_BASE-i+FREG_OFFSET;
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
512 if (! regs[reg]) { /* 使われていないなら */
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
513 regs[reg]=USING_REG; /* そのレジスタを使うことを宣言し */
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
514 if (i>max_freg_var) max_freg_var=i;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
515 return regv[reg]; /* その場所を表す番号を返す */
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
516 }
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
517 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
518 /* 空いている場所がないなら、エラー (いったい誰が使ってるの?) */
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
519 error(REG_ERR); return freg;
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
520 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
521
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
522 int
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
523 pop_fregister(void)
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
524 { /* レジスタから値を取り出す */
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
525 return freg_stack[--freg_sp];
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
526 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
527 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
528
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
529 int
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
530 get_lregister()
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
531 {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
532 int h,l,h0,l0;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
533 h = get_register(); h0 = cadr(h);
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
534 l = get_register(); l0 = cadr(l);
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
535 return glist3(LREGISTER,l0,h0);
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
536 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
537
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
538 int
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
539 get_lregister_var(NMTBL *n)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
540 {
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
541 int i,j;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
542 int max_reg_var_save=max_reg_var;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
543 for(i=0;i<REG_VAR_BASE-REG_VAR_MIN;i++) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
544 if (! regs[REG_VAR_BASE-i]) { /* 使われていないなら */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
545 /* そのレジスタを使うことを宣言し */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
546 regs[REG_VAR_BASE-i]=USING_REG;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
547 if (i>max_reg_var) max_reg_var=i;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
548 for(j=0;j<REG_VAR_BASE-REG_VAR_MIN;j++) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
549 if (! regs[REG_VAR_BASE-j]) { /* 使われていないなら */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
550 /* そのレジスタを使うことを宣言し */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
551 regs[REG_VAR_BASE-j]=USING_REG;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
552 if (j>max_reg_var) max_reg_var=j;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
553 /* その場所を表す番号を返す */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
554 return list3(LREGISTER,
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
555 glist3(LREGISTER,REG_VAR_BASE-j,REG_VAR_BASE-i),
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
556 (int)n);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
557 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
558 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
559 /* ひとつしかなかった */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
560 regs[REG_VAR_BASE-i]=0;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
561 max_reg_var=max_reg_var_save;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
562 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
563 }
204
4c614334f3d0 long long test parse
kono
parents: 203
diff changeset
564 return list2(LVAR,new_lvar(size_of_longlong));
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
565 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
566
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
567 void
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
568 emit_pop_free(int xreg)
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
569 {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
570 if (xreg>=0)
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
571 free_register(xreg);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
572 }
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
573
89
917947ffeb7c power pc version
kono
parents:
diff changeset
574 void
917947ffeb7c power pc version
kono
parents:
diff changeset
575 free_register(int i) { /* いらなくなったレジスタを開放 */
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
576 int j;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
577 if (i==0) return;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
578 j = cadr(i); regs[j]=0;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
579 if (car(i)==LREGISTER) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
580 j = caddr(i); regs[j]=0;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
581 free_glist3(i);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
582 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
583 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
584
89
917947ffeb7c power pc version
kono
parents:
diff changeset
585 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
586 get_input_dregister_var(int i,NMTBL *n,int is_code,int d)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
587 {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
588 if (is_code) {
148
e0eba2993c37 MIPS version (incomplete)
kono
parents: 147
diff changeset
589 if(!(i<FREG_VAR_BASE-FREG_VAR_MIN)) return 0;
e0eba2993c37 MIPS version (incomplete)
kono
parents: 147
diff changeset
590 i = FREG_VAR_BASE-i+FREG_OFFSET;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
591 } else {
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
592 if (i<0||i>=MAX_INPUT_DREGISTER_VAR) return 0;
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
593 i = i+MIN_TMP_FREG+FREG_OFFSET;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
594 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
595 return list3(DREGISTER,regv[i],(int)n);
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
596 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
597
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
598 int
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
599 get_input_lregister_var(int i,NMTBL *n,int is_code)
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
600 {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
601 if (is_code) {
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
602 if(!(i+1<REG_VAR_BASE-REG_VAR_MIN)) return 0;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
603 i = REG_VAR_BASE-i;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
604 } else {
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
605 if (i<0||i+1>=MAX_INPUT_REGISTER_VAR) return 0;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
606 i = i+MIN_TMP_REG;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
607 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
608 return list3(LREGISTER,list3(LREGISTER,i+1,i),(int)n);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
609 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
610
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
611 int
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
612 get_input_register_var(int i,NMTBL *n,int is_code)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
613 {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
614 if (is_code) {
131
09379ec2a74b *** empty log message ***
kono
parents: 130
diff changeset
615 if(!(i<REG_VAR_BASE-REG_VAR_MIN)) return 0;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
616 i = REG_VAR_BASE-i;
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
617 } else {
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
618 if (i<0||i>=MAX_INPUT_REGISTER_VAR) return 0;
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
619 i = i+MIN_TMP_REG;
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
620 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
621 return list3(REGISTER,regv[i],(int)n);
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
622 }
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
623
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
624 /* double register case? */
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
625
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
626 int
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
627 get_input_register_var_1(int i,NMTBL *n,int is_code)
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
628 {
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
629 if (is_code) {
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
630 if(!(i<REG_VAR_BASE-REG_VAR_MIN)) return 0;
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
631 i = REG_VAR_BASE-i;
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
632 } else {
4cfd24d1b929 fix power-pc basic test
kono
parents: 134
diff changeset
633 if (i<0||i>=MAX_INPUT_REGISTER_VAR+1) return 0;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
634 i = i+MIN_TMP_REG;
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
635 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
636 return list3(REGISTER,regv[i],(int)n);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
637 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
638
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
639 int
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
640 free_register_count(int d)
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
641 {
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
642 int i,count,fcount;
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
643 fcount = count = 0;
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
644 for(i=0;i<MAX_REGISTER;i++) {
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
645 if (! regs[i]) count++;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
646 }
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
647 for(i=0;i<MAX_FREGISTER;i++) {
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
648 if (! regs[i+FREG_OFFSET]) fcount++;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
649 }
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
650 printf("# free reg %d freg %d\n",count,fcount);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
651 return d?fcount:count;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
652 }
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
653
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
654 #if 0
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
655 static int
89
917947ffeb7c power pc version
kono
parents:
diff changeset
656 register_full(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
657 {
917947ffeb7c power pc version
kono
parents:
diff changeset
658 int i;
917947ffeb7c power pc version
kono
parents:
diff changeset
659 for(i=0;i<MAX_REGISTER;i++) {
917947ffeb7c power pc version
kono
parents:
diff changeset
660 if (! regs[i]) {
917947ffeb7c power pc version
kono
parents:
diff changeset
661 return 0;
917947ffeb7c power pc version
kono
parents:
diff changeset
662 }
917947ffeb7c power pc version
kono
parents:
diff changeset
663 }
917947ffeb7c power pc version
kono
parents:
diff changeset
664 return 1;
917947ffeb7c power pc version
kono
parents:
diff changeset
665 }
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
666 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
667
917947ffeb7c power pc version
kono
parents:
diff changeset
668 void
917947ffeb7c power pc version
kono
parents:
diff changeset
669 free_all_register(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
670 {
917947ffeb7c power pc version
kono
parents:
diff changeset
671 int i;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
672 #if LONGLONG_CODE
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
673 if (lreg) free_register(lreg);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
674 lreg = 0;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
675 #endif
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
676 for(i=0;i<MAX_REGISTER;i++) { regs[i]=0; }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
677 for(i=0;i<MAX_FREGISTER;i++) { regs[i+FREG_OFFSET]=0; }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
678 #if FLOAT_CODE
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
679 freg = get_dregister(1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
680 set_freg(FREG_FREGISTER,0);
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
681 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
682 ireg = creg = get_register();
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
683 set_creg(CREG_REGISTER,0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
684 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
685 }
917947ffeb7c power pc version
kono
parents:
diff changeset
686
917947ffeb7c power pc version
kono
parents:
diff changeset
687 void
917947ffeb7c power pc version
kono
parents:
diff changeset
688 register_usage(char *s)
917947ffeb7c power pc version
kono
parents:
diff changeset
689 {
141
kono
parents: 139
diff changeset
690 #if 0
89
917947ffeb7c power pc version
kono
parents:
diff changeset
691 int i;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
692 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
693 if (chk) return;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
694 if (!lsrc) return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
695 printf("# %d: %s:",lineno,s);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
696 if (ireg) printf(" creg=%s",register_name(ireg));
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
697 if (freg) printf(" freg=%s",fregister_name(freg));
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
698 if (lreg) printf(" lreg=%s,%s",lregister_name_high(lreg),
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
699 lregister_name_low(lreg));
141
kono
parents: 139
diff changeset
700 #if 0
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
701 printf("\n# regs:");
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
702 for(i=0;i<MAX_REGISTER;i++) { printf("%d",regs[i]); }
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
703 printf("\n# freg:");
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
704 for(i=0;i<MAX_FREGISTER;i++) { printf("%d",regs[i+FREG_OFFSET]); }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
705 for(i=reg_sp;i>=0;i--) {
917947ffeb7c power pc version
kono
parents:
diff changeset
706 if(reg_stack[i]>=0)
134
7a55819b0482 *** empty log message ***
kono
parents: 133
diff changeset
707 printf(" %s",register_name(reg_stack[i]));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
708 }
917947ffeb7c power pc version
kono
parents:
diff changeset
709 #endif
917947ffeb7c power pc version
kono
parents:
diff changeset
710 printf("\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
711 }
917947ffeb7c power pc version
kono
parents:
diff changeset
712
917947ffeb7c power pc version
kono
parents:
diff changeset
713 void
917947ffeb7c power pc version
kono
parents:
diff changeset
714 gexpr_init(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
715 {
917947ffeb7c power pc version
kono
parents:
diff changeset
716 while(reg_sp > 0) {
917947ffeb7c power pc version
kono
parents:
diff changeset
717 free_register(reg_stack[--reg_sp]);
917947ffeb7c power pc version
kono
parents:
diff changeset
718 }
148
e0eba2993c37 MIPS version (incomplete)
kono
parents: 147
diff changeset
719 while(freg_sp > 0) {
e0eba2993c37 MIPS version (incomplete)
kono
parents: 147
diff changeset
720 free_register(freg_stack[--freg_sp]);
e0eba2993c37 MIPS version (incomplete)
kono
parents: 147
diff changeset
721 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
722 while(lreg_sp > 0) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
723 free_register(lreg_stack[--lreg_sp]);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
724 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
725 text_mode();
917947ffeb7c power pc version
kono
parents:
diff changeset
726 gexpr_code_init();
917947ffeb7c power pc version
kono
parents:
diff changeset
727 register_usage("gexpr_init");
917947ffeb7c power pc version
kono
parents:
diff changeset
728 }
917947ffeb7c power pc version
kono
parents:
diff changeset
729
917947ffeb7c power pc version
kono
parents:
diff changeset
730
917947ffeb7c power pc version
kono
parents:
diff changeset
731 void
917947ffeb7c power pc version
kono
parents:
diff changeset
732 emit_init(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
733 {
917947ffeb7c power pc version
kono
parents:
diff changeset
734 free_all_register();
110
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
735 max_reg_var=-1; max_freg_var=-1;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
736 reg_sp = 0;
123
5f180dc8d84e intel fix.
kono
parents: 122
diff changeset
737 freg_sp = 0;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
738 text_mode();
917947ffeb7c power pc version
kono
parents:
diff changeset
739 }
917947ffeb7c power pc version
kono
parents:
diff changeset
740
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
741
89
917947ffeb7c power pc version
kono
parents:
diff changeset
742 int
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
743 get_register_var(NMTBL *n)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
744 {
917947ffeb7c power pc version
kono
parents:
diff changeset
745 int i;
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
746 for(i=0;i<REG_VAR_BASE-REG_VAR_MIN;i++) {
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
747 if (! regs[REG_VAR_BASE-i]) { /* 使われていないなら */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
748 /* そのレジスタを使うことを宣言し */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
749 regs[REG_VAR_BASE-i]=USING_REG;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
750 if (i>max_reg_var) max_reg_var=i;
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
751 /* その場所を表す番号を返す */
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
752 return list3(REGISTER,glist2(REGISTER,REG_VAR_BASE-i),(int)n);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
753 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
754 }
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
755 return list2(LVAR,new_lvar(size_of_int));
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
756 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
757
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
758 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
759 get_dregister_var(NMTBL *n,int d)
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
760 {
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
761 int i;
148
e0eba2993c37 MIPS version (incomplete)
kono
parents: 147
diff changeset
762 for(i=0;i<FREG_VAR_BASE-FREG_VAR_MIN;i++) {
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
763 if (! regs[FREG_VAR_BASE-i+FREG_OFFSET]) { /* 使われていないなら */
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
764 regs[FREG_VAR_BASE-i+FREG_OFFSET]=USING_REG; /*そのレジスタを使うことを宣言し*/
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
765 if (i>max_freg_var) max_freg_var=i;
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
766 /* その場所を表す番号を返す */
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
767 return list3(DREGISTER,
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
768 glist2(DREGISTER,FREG_VAR_BASE-i+FREG_OFFSET),(int)n);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
769 }
917947ffeb7c power pc version
kono
parents:
diff changeset
770 }
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
771 return list2(LVAR,new_lvar(size_of_double));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
772 }
917947ffeb7c power pc version
kono
parents:
diff changeset
773
917947ffeb7c power pc version
kono
parents:
diff changeset
774 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
775 emit_push()
89
917947ffeb7c power pc version
kono
parents:
diff changeset
776 {
917947ffeb7c power pc version
kono
parents:
diff changeset
777 int new_reg;
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
778 if (reg_sp>MAX_MAX) error(-1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
779 new_reg = get_register();
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
780 reg_stack[reg_sp++] = creg; /* push するかわりにレジスタを使う */
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
781 ireg = creg = new_reg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
782 }
917947ffeb7c power pc version
kono
parents:
diff changeset
783
917947ffeb7c power pc version
kono
parents:
diff changeset
784 int
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
785 emit_pop(int type)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
786 {
112
fc7de4faedfd *** empty log message ***
kono
parents: 111
diff changeset
787 int xreg,reg;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
788 xreg=pop_register();
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
789 if (xreg<= -REG_LVAR_OFFSET) {
112
fc7de4faedfd *** empty log message ***
kono
parents: 111
diff changeset
790 reg = get_register();
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
791 code_rlvar(REG_LVAR_OFFSET+xreg,reg);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
792 free_lvar(REG_LVAR_OFFSET+xreg);
112
fc7de4faedfd *** empty log message ***
kono
parents: 111
diff changeset
793 xreg = reg;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
794 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
795 return xreg;
917947ffeb7c power pc version
kono
parents:
diff changeset
796 }
917947ffeb7c power pc version
kono
parents:
diff changeset
797
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
798 int
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
799 stack_top(int type)
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
800 {
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
801 int xreg;
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
802 if (type==INT) {
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
803 xreg = reg_stack[reg_sp];
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
804 if (xreg<= -REG_LVAR_OFFSET) {
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
805 return list2(LVAR,REG_LVAR_OFFSET+xreg);
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
806 } else {
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
807 return xreg;
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
808 }
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
809 } else {
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
810 xreg = freg_stack[freg_sp];
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
811 if (xreg<= -REG_LVAR_OFFSET) {
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
812 return list2(LVAR,REG_LVAR_OFFSET+xreg);
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
813 } else {
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
814 return xreg;
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
815 }
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
816 }
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
817 return xreg;
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
818 }
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
819
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
820 static int code_base;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
821
917947ffeb7c power pc version
kono
parents:
diff changeset
822 #define MAX_PTR_CACHE 10
917947ffeb7c power pc version
kono
parents:
diff changeset
823
917947ffeb7c power pc version
kono
parents:
diff changeset
824 int ptr_cache=0;
917947ffeb7c power pc version
kono
parents:
diff changeset
825
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
826 void
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
827 init_ptr_cache()
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
828 {
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
829 int i;
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
830 for(i=0;i<MAX_PTR_CACHE;i++) {
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
831 ptr_cache=glist3(0,ptr_cache,0);
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
832 }
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
833 }
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
834
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
835 void
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
836 clear_ptr_cache_reg(int r)
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
837 {
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
838 int ptcptr=ptr_cache;
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
839 while(ptcptr) {
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
840 if(car(ptcptr)&&caddr(ptcptr)==r) {
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
841 car(ptcptr)=0;
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
842 caddr(ptcptr)=0;
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
843 free_register(r);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
844 return;
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
845 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
846 ptcptr=cadr(ptcptr);
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
847 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
848 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
849
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
850 void
89
917947ffeb7c power pc version
kono
parents:
diff changeset
851 clear_ptr_cache()
917947ffeb7c power pc version
kono
parents:
diff changeset
852 {
917947ffeb7c power pc version
kono
parents:
diff changeset
853 int ptcptr=ptr_cache;
917947ffeb7c power pc version
kono
parents:
diff changeset
854 while(ptcptr) {
917947ffeb7c power pc version
kono
parents:
diff changeset
855 if(car(ptcptr))
917947ffeb7c power pc version
kono
parents:
diff changeset
856 free_register(caddr(ptcptr));
917947ffeb7c power pc version
kono
parents:
diff changeset
857 car(ptcptr)=0;
917947ffeb7c power pc version
kono
parents:
diff changeset
858 caddr(ptcptr)=0;
917947ffeb7c power pc version
kono
parents:
diff changeset
859 ptcptr=cadr(ptcptr);
917947ffeb7c power pc version
kono
parents:
diff changeset
860 }
917947ffeb7c power pc version
kono
parents:
diff changeset
861 }
917947ffeb7c power pc version
kono
parents:
diff changeset
862
917947ffeb7c power pc version
kono
parents:
diff changeset
863
917947ffeb7c power pc version
kono
parents:
diff changeset
864 int
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
865 get_ptr_cache(NMTBL *nptr)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
866 {
917947ffeb7c power pc version
kono
parents:
diff changeset
867 int r;
917947ffeb7c power pc version
kono
parents:
diff changeset
868 int ptcptr=ptr_cache;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
869 int g = (int)nptr;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
870 int p,p1;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
871 char *rrn;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
872
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
873 p1 = ptcptr; p = cadr(p1); /* unnecesary, if ptcptr is initialized */
89
917947ffeb7c power pc version
kono
parents:
diff changeset
874 while(ptcptr) {
917947ffeb7c power pc version
kono
parents:
diff changeset
875 if(car(ptcptr)==g) return caddr(ptcptr);
917947ffeb7c power pc version
kono
parents:
diff changeset
876 p1=p; p=ptcptr;
917947ffeb7c power pc version
kono
parents:
diff changeset
877 ptcptr=cadr(ptcptr);
917947ffeb7c power pc version
kono
parents:
diff changeset
878 }
917947ffeb7c power pc version
kono
parents:
diff changeset
879 cadr(p1)=0; /* remove the last one */
917947ffeb7c power pc version
kono
parents:
diff changeset
880 cadr(p) = ptr_cache; /* connect current queue to the last one */
917947ffeb7c power pc version
kono
parents:
diff changeset
881 ptr_cache = p; /* now the last one is the top */
917947ffeb7c power pc version
kono
parents:
diff changeset
882 if (!caddr(p)) {
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
883 if((r=get_register())) {
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
884 caddr(p)=r; regs[cadr(r)]=PTRC_REG;
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
885 } else {
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
886 error(-1);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
887 r=creg; /* this can't happen */
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
888 }
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
889 car(p)=g;
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
890 } else {
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
891 r = caddr(p);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
892 }
917947ffeb7c power pc version
kono
parents:
diff changeset
893 rrn = register_name(r);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
894 if (nptr->sc==STATIC) {
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
895 printf("\taddis %s,r31,ha16(_%s-L_%d)\n",
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
896 rrn,nptr->nm,code_base);
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
897 printf("\tla %s,lo16(_%s-L_%d)(%s)\n",
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
898 rrn,nptr->nm,code_base,rrn);
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
899 } else {
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
900 printf("\taddis %s,r31,ha16(L_%s$non_lazy_ptr-L_%d)\n",
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
901 rrn,nptr->nm,code_base);
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
902 printf("\tlwz %s,lo16(L_%s$non_lazy_ptr-L_%d)(%s)\n",
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
903 rrn,nptr->nm,code_base,rrn);
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
904 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
905 return r;
917947ffeb7c power pc version
kono
parents:
diff changeset
906 }
917947ffeb7c power pc version
kono
parents:
diff changeset
907
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
908 static char *cload(int sz) { return sz==1?"lbz":sz==size_of_short?"lhz":"lwz"; }
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
909 static char *cstore(int sz) { return sz==1?"stb":sz==size_of_short?"sth":"stw"; }
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
910 static char *cext(int sz) { return sz==size_of_short?"extsh":"extsb"; }
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
911
89
917947ffeb7c power pc version
kono
parents:
diff changeset
912 void
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
913 code_label(int labelno)
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
914 {
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
915 clear_ptr_cache();
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
916 printf("L_%d:\n",labelno);
92
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
917 }
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
918
e7f8515ba882 *** empty log message ***
kono
parents: 91
diff changeset
919 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
920 code_gvar(int e1,int creg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
921 int r;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
922 r = get_ptr_cache((NMTBL*)cadr(e1));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
923 if(r!=creg)
917947ffeb7c power pc version
kono
parents:
diff changeset
924 printf("\tmr %s,%s\n",register_name(creg),register_name(r));
917947ffeb7c power pc version
kono
parents:
diff changeset
925 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
926 }
917947ffeb7c power pc version
kono
parents:
diff changeset
927
917947ffeb7c power pc version
kono
parents:
diff changeset
928 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
929 code_rgvar(int e1,int creg) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
930 if (!is_int_reg(creg)) error(-1);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
931 printf("\tlwz %s,0(%s)\n",register_name(creg),
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
932 register_name(get_ptr_cache((NMTBL*)cadr(e1))));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
933 }
917947ffeb7c power pc version
kono
parents:
diff changeset
934
917947ffeb7c power pc version
kono
parents:
diff changeset
935 void
165
kono
parents: 164
diff changeset
936 code_crgvar(int e1,int creg,int sign,int sz){
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
937 char *crn = register_name(creg);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
938 printf("\t%s %s,0(%s)\n",cload(sz),crn,
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
939 register_name(get_ptr_cache((NMTBL*)cadr(e1))));
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
940 if (sign)
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
941 printf("\t%s %s,%s\n",cext(sz),crn,crn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
942 }
917947ffeb7c power pc version
kono
parents:
diff changeset
943
165
kono
parents: 164
diff changeset
944
kono
parents: 164
diff changeset
945
89
917947ffeb7c power pc version
kono
parents:
diff changeset
946 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
947 code_register(int e2,int creg) {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
948 if (creg!=e2)
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
949 printf("\tmr %s,%s\n",register_name(creg),register_name(e2));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
950 }
917947ffeb7c power pc version
kono
parents:
diff changeset
951
917947ffeb7c power pc version
kono
parents:
diff changeset
952
917947ffeb7c power pc version
kono
parents:
diff changeset
953 void
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
954 code_rlvar(int e2,int reg) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
955 lvar_intro(e2);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
956 if (!is_int_reg(reg)) error(-1);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
957 printf("\tlwz %s,",register_name(reg));
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
958 lvar(e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
959 }
917947ffeb7c power pc version
kono
parents:
diff changeset
960
917947ffeb7c power pc version
kono
parents:
diff changeset
961 void
165
kono
parents: 164
diff changeset
962 code_crlvar(int e2,int reg,int sign,int sz) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
963 lvar_intro(e2);
165
kono
parents: 164
diff changeset
964 printf("\t%s %s,",cload(sz),register_name(reg));
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
965 lvar(e2);
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
966 if (sign)
165
kono
parents: 164
diff changeset
967 printf("\t%s %s,%s\n",cext(sz),register_name(reg),register_name(reg));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
968 }
917947ffeb7c power pc version
kono
parents:
diff changeset
969
165
kono
parents: 164
diff changeset
970
kono
parents: 164
diff changeset
971
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
972
89
917947ffeb7c power pc version
kono
parents:
diff changeset
973
917947ffeb7c power pc version
kono
parents:
diff changeset
974 void
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
975 code_fname(NMTBL *n,int creg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
976 int r;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
977 r = get_ptr_cache(n);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
978 if(r!=creg)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
979 printf("\tmr %s,%s\n",register_name(creg),register_name(r));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
980 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
981 }
917947ffeb7c power pc version
kono
parents:
diff changeset
982
917947ffeb7c power pc version
kono
parents:
diff changeset
983
917947ffeb7c power pc version
kono
parents:
diff changeset
984 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
985 code_const(int e2,int creg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
986 char *crn = register_name(creg);
917947ffeb7c power pc version
kono
parents:
diff changeset
987 if (-32768<e2&&e2<32768)
917947ffeb7c power pc version
kono
parents:
diff changeset
988 printf("\tli %s,%d\n",crn,e2);
917947ffeb7c power pc version
kono
parents:
diff changeset
989 else {
917947ffeb7c power pc version
kono
parents:
diff changeset
990 printf("\tlis %s,ha16(%d)\n",crn,e2);
917947ffeb7c power pc version
kono
parents:
diff changeset
991 printf("\taddi %s,%s,lo16(%d)\n",crn,crn,e2);
917947ffeb7c power pc version
kono
parents:
diff changeset
992 }
917947ffeb7c power pc version
kono
parents:
diff changeset
993 }
917947ffeb7c power pc version
kono
parents:
diff changeset
994
917947ffeb7c power pc version
kono
parents:
diff changeset
995
917947ffeb7c power pc version
kono
parents:
diff changeset
996 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
997 code_neg(int creg) {
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
998 printf("\tneg %s,%s\n", register_name(creg), register_name(creg));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
999 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1000
917947ffeb7c power pc version
kono
parents:
diff changeset
1001
917947ffeb7c power pc version
kono
parents:
diff changeset
1002 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1003 code_not(int creg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1004 printf("\tnor %s,%s,%s\n",
917947ffeb7c power pc version
kono
parents:
diff changeset
1005 register_name(creg), register_name(creg),register_name(creg));
917947ffeb7c power pc version
kono
parents:
diff changeset
1006 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1007
917947ffeb7c power pc version
kono
parents:
diff changeset
1008
917947ffeb7c power pc version
kono
parents:
diff changeset
1009 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1010 code_lnot(int creg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1011 printf("\tsubfic r0,%s,0\n", register_name(creg));
917947ffeb7c power pc version
kono
parents:
diff changeset
1012 printf("\tadde %s,r0,%s\n", register_name(creg),register_name(creg));
917947ffeb7c power pc version
kono
parents:
diff changeset
1013 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1014
917947ffeb7c power pc version
kono
parents:
diff changeset
1015 void
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1016 code_preinc(int e1,int e2,int dir,int sign,int sz,int reg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1017 char *xrn,*drn;
917947ffeb7c power pc version
kono
parents:
diff changeset
1018 int i,dreg;
917947ffeb7c power pc version
kono
parents:
diff changeset
1019 if (car(e2)==REGISTER) {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1020 printf("\taddi %s,%s,%d\n",
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1021 register_name(cadr(e2)),register_name(cadr(e2)), dir);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1022 if (cadr(reg)!=e2)
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1023 printf("\tmr %s,%s\n",register_name(cadr(reg)),register_name(e2));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1024 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
1025 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1026 g_expr(e2);
917947ffeb7c power pc version
kono
parents:
diff changeset
1027 xrn = register_name(creg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1028 dreg=get_register(); if (!dreg) error(-1);
917947ffeb7c power pc version
kono
parents:
diff changeset
1029 drn = register_name(dreg);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1030 printf("\t%s %s,0(%s)\n",cload(sz),drn,xrn);
172
096559f07a70 some check
kono
parents: 168
diff changeset
1031 if (use && sign && sz!=size_of_int)
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1032 printf("\t%s %s,%s\n",cext(sz),drn,drn);
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1033 printf("\taddi %s,%s,%d\n",drn,drn,dir);
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1034 printf("\t%s %s,0(%s)\n",cstore(sz),drn,xrn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1035 i=creg;creg=dreg;dreg=i;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1036 ireg=creg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1037 free_register(dreg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1038 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1039
917947ffeb7c power pc version
kono
parents:
diff changeset
1040
917947ffeb7c power pc version
kono
parents:
diff changeset
1041 void
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1042 code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1043 char *xrn,*crn,*nrn;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1044 int dreg,nreg,i;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1045 if (car(e2)==REGISTER) {
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1046 printf("\tmr %s,%s\n",register_name(reg),register_name(cadr(e2)));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1047 printf("\taddi %s,%s,%d\n",
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1048 register_name(cadr(e2)),register_name(cadr(e2)),dir);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1049 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
1050 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1051 g_expr(e2);
917947ffeb7c power pc version
kono
parents:
diff changeset
1052 crn = register_name(creg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1053 dreg=get_register(); if (!dreg) error(-1);
917947ffeb7c power pc version
kono
parents:
diff changeset
1054 xrn = register_name(dreg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1055 nreg=get_register(); if (!nreg) error(-1);
917947ffeb7c power pc version
kono
parents:
diff changeset
1056 nrn = register_name(nreg);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1057 printf("\t%s %s,0(%s)\n",cload(sz),xrn,crn);
172
096559f07a70 some check
kono
parents: 168
diff changeset
1058 if (use && sign && sz!=size_of_int)
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1059 printf("\t%s %s,%s\n",cext(sz),xrn,xrn);
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1060 printf("\taddi %s,%s,%d\n",nrn,xrn,dir);
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1061 printf("\t%s %s,0(%s)\n",cstore(sz),nrn,crn);
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1062 i=creg;creg=dreg;dreg=i;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1063 free_register(nreg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1064 free_register(dreg);
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
1065 ireg=creg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1066 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1067
917947ffeb7c power pc version
kono
parents:
diff changeset
1068
917947ffeb7c power pc version
kono
parents:
diff changeset
1069 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1070 code_return(int creg) {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1071 char *crn = register_name(creg);
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
1072 printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",crn,retcont,code_base);
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
1073 printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",crn,retcont,code_base,crn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1074 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1075
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1076 #define R1SAVE 1
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1077
917947ffeb7c power pc version
kono
parents:
diff changeset
1078 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1079 code_environment(int creg) {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1080 /* save frame pointer */
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1081 #if R1SAVE
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1082 printf("\tlwz %s,0(r1)\n",register_name(creg));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1083 #else
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1084 int l = 0;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1085 printf("\tla %s,",register_name(creg));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1086 printf("lo16(%d+L_%d)(r30)\n",FUNC_LVAR,lvar_offset_label);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1087 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1088 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1089
917947ffeb7c power pc version
kono
parents:
diff changeset
1090 void
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1091 code_bool(int e1) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1092 char *xrn;
917947ffeb7c power pc version
kono
parents:
diff changeset
1093 int e2,e3;
917947ffeb7c power pc version
kono
parents:
diff changeset
1094 b_expr(e1,1,e2=fwdlabel(),1); /* including > < ... */
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
1095 creg = use_int(creg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1096 xrn = register_name(creg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1097 printf("\tli %s,0\n",xrn);
917947ffeb7c power pc version
kono
parents:
diff changeset
1098 jmp(e3=fwdlabel());
917947ffeb7c power pc version
kono
parents:
diff changeset
1099 fwddef(e2);
917947ffeb7c power pc version
kono
parents:
diff changeset
1100 printf("\tli %s,1\n",xrn);
917947ffeb7c power pc version
kono
parents:
diff changeset
1101 fwddef(e3);
917947ffeb7c power pc version
kono
parents:
diff changeset
1102 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1103
917947ffeb7c power pc version
kono
parents:
diff changeset
1104 char *
917947ffeb7c power pc version
kono
parents:
diff changeset
1105 code_gt(int cond) {
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
1106 return (cond?"gt":"le");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1107 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1108
917947ffeb7c power pc version
kono
parents:
diff changeset
1109 char *
917947ffeb7c power pc version
kono
parents:
diff changeset
1110 code_ugt(int cond) {
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
1111 return (cond?"gt":"le");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1112 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1113
917947ffeb7c power pc version
kono
parents:
diff changeset
1114 char *
917947ffeb7c power pc version
kono
parents:
diff changeset
1115 code_ge(int cond) {
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
1116 return (cond?"ge":"lt");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1117 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1118
917947ffeb7c power pc version
kono
parents:
diff changeset
1119 char *
917947ffeb7c power pc version
kono
parents:
diff changeset
1120 code_uge(int cond) {
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
1121 return (cond?"ge":"lt");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1122 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1123
917947ffeb7c power pc version
kono
parents:
diff changeset
1124 char *
917947ffeb7c power pc version
kono
parents:
diff changeset
1125 code_eq(int cond) {
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
1126 return (cond?"eq":"ne");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1127 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1128
917947ffeb7c power pc version
kono
parents:
diff changeset
1129 void
167
0197ca125567 mips short
kono
parents: 165
diff changeset
1130 code_cmp_crgvar(int e1,int sz) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1131 int r;
917947ffeb7c power pc version
kono
parents:
diff changeset
1132 char *crn = register_name(creg);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1133 r = get_ptr_cache((NMTBL*)cadr(e1));
167
0197ca125567 mips short
kono
parents: 165
diff changeset
1134 printf("\t%s %s,0(%s)\n",cload(sz),crn,register_name(r));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1135 printf("\tcmpwi cr0,%s,0\n",crn);
917947ffeb7c power pc version
kono
parents:
diff changeset
1136 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1137
917947ffeb7c power pc version
kono
parents:
diff changeset
1138
917947ffeb7c power pc version
kono
parents:
diff changeset
1139 void
167
0197ca125567 mips short
kono
parents: 165
diff changeset
1140 code_cmp_crlvar(int e2,int sz) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1141 char *crn = register_name(creg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1142 lvar_intro(e2);
167
0197ca125567 mips short
kono
parents: 165
diff changeset
1143 printf("\t%s %s,",cload(sz),crn);
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1144 lvar(e2);
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1145 code_cmp_register(creg);
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1146 }
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1147
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1148
917947ffeb7c power pc version
kono
parents:
diff changeset
1149 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1150 code_cmp_rgvar(int e1) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1151 int r;
917947ffeb7c power pc version
kono
parents:
diff changeset
1152 char *crn = register_name(creg);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
1153 if (!is_int_reg(creg)) error(-1);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1154 r = get_ptr_cache((NMTBL*)cadr(e1));
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1155 printf("\tlwz %s,0(%s)\n",crn,register_name(r));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1156 code_cmp_register(creg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1157 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1158
917947ffeb7c power pc version
kono
parents:
diff changeset
1159
917947ffeb7c power pc version
kono
parents:
diff changeset
1160 void
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1161 code_cmp_rlvar(int e2) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1162 char *crn = register_name(creg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1163 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1164 printf("\tlwz %s,",crn);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1165 lvar(e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1166 code_cmp_register(creg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1167 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1168
917947ffeb7c power pc version
kono
parents:
diff changeset
1169
917947ffeb7c power pc version
kono
parents:
diff changeset
1170 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1171 code_cmp_register(int e2) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1172 printf("\tcmpwi cr0,%s,0\n",register_name(e2));
917947ffeb7c power pc version
kono
parents:
diff changeset
1173 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1174
917947ffeb7c power pc version
kono
parents:
diff changeset
1175
917947ffeb7c power pc version
kono
parents:
diff changeset
1176 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1177 ascii(char *s)
917947ffeb7c power pc version
kono
parents:
diff changeset
1178 {
917947ffeb7c power pc version
kono
parents:
diff changeset
1179 printf("\t.ascii \"");
917947ffeb7c power pc version
kono
parents:
diff changeset
1180 while(*s) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1181 if (*s=='\n')
917947ffeb7c power pc version
kono
parents:
diff changeset
1182 printf("%cn",92);
917947ffeb7c power pc version
kono
parents:
diff changeset
1183 else if (*s<' ')
917947ffeb7c power pc version
kono
parents:
diff changeset
1184 printf("%c%03o",92,*s);
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1185 else if (*s=='\\')
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1186 printf("\\\\");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1187 else if (*s==34)
917947ffeb7c power pc version
kono
parents:
diff changeset
1188 printf("%c%c",92,34);
917947ffeb7c power pc version
kono
parents:
diff changeset
1189 else
917947ffeb7c power pc version
kono
parents:
diff changeset
1190 printf("%c",*s);
917947ffeb7c power pc version
kono
parents:
diff changeset
1191 s++;
917947ffeb7c power pc version
kono
parents:
diff changeset
1192 }
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1193 printf("\\0%c\n\t.align 2\n",34);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1194 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1195
917947ffeb7c power pc version
kono
parents:
diff changeset
1196 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1197 code_string(int e1,int creg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1198 {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1199 char *s,*crn;
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1200 int lb;
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1201 crn=register_name(creg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1202
917947ffeb7c power pc version
kono
parents:
diff changeset
1203 s=(char *)cadr(e1);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1204 printf(".data\t\n.cstring\n\t.align 2\n");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1205 lb=fwdlabel();
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
1206 printf("L_%d:\n",lb);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1207 ascii(s);
917947ffeb7c power pc version
kono
parents:
diff changeset
1208 if (output_mode==TEXT_EMIT_MODE) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1209 printf(".text\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
1210 } else {
917947ffeb7c power pc version
kono
parents:
diff changeset
1211 text_mode();
917947ffeb7c power pc version
kono
parents:
diff changeset
1212 }
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
1213 printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",crn,lb,code_base);
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
1214 printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",crn,lb,code_base,crn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1215 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1216
917947ffeb7c power pc version
kono
parents:
diff changeset
1217 #define MAX_COPY_LEN 20
917947ffeb7c power pc version
kono
parents:
diff changeset
1218
917947ffeb7c power pc version
kono
parents:
diff changeset
1219 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1220 emit_copy(int from,int to,int length,int offset,int value,int det)
917947ffeb7c power pc version
kono
parents:
diff changeset
1221 {
917947ffeb7c power pc version
kono
parents:
diff changeset
1222 char *frn = register_name(from);
917947ffeb7c power pc version
kono
parents:
diff changeset
1223 char *trn = register_name(to);
917947ffeb7c power pc version
kono
parents:
diff changeset
1224 char *drn;
917947ffeb7c power pc version
kono
parents:
diff changeset
1225 int fix = 0;
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
1226 char *memmove = "memmove";
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1227 int dreg = get_register(); if (!dreg) error(-1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1228 drn = register_name(dreg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1229
917947ffeb7c power pc version
kono
parents:
diff changeset
1230 /* length <0 means upward direction copy */
917947ffeb7c power pc version
kono
parents:
diff changeset
1231 switch (length) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1232 case 0: break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1233 case 1: case -1:
917947ffeb7c power pc version
kono
parents:
diff changeset
1234 printf("\tlbz %s,%d(%s)\n",drn,offset,frn);
917947ffeb7c power pc version
kono
parents:
diff changeset
1235 printf("\tstb %s,%d(%s)\n",drn,offset,trn);
917947ffeb7c power pc version
kono
parents:
diff changeset
1236 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1237 case 2: case -2:
917947ffeb7c power pc version
kono
parents:
diff changeset
1238 printf("\tlhz %s,%d(%s)\n",drn,offset,frn);
917947ffeb7c power pc version
kono
parents:
diff changeset
1239 printf("\tsth %s,%d(%s)\n",drn,offset,trn);
917947ffeb7c power pc version
kono
parents:
diff changeset
1240 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1241 case 4: case -4:
917947ffeb7c power pc version
kono
parents:
diff changeset
1242 printf("\tlwz %s,%d(%s)\n",drn,offset,frn);
917947ffeb7c power pc version
kono
parents:
diff changeset
1243 printf("\tstw %s,%d(%s)\n",drn,offset,trn);
917947ffeb7c power pc version
kono
parents:
diff changeset
1244 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1245 default:
917947ffeb7c power pc version
kono
parents:
diff changeset
1246 if (-MAX_COPY_LEN<length && length <0) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1247 for(;length<=4;length+=4,offset-=4)
917947ffeb7c power pc version
kono
parents:
diff changeset
1248 emit_copy(from,to,4,offset,0,det);
917947ffeb7c power pc version
kono
parents:
diff changeset
1249 for(;length<=2;length+=2,offset-=2)
917947ffeb7c power pc version
kono
parents:
diff changeset
1250 emit_copy(from,to,2,offset,0,det);
917947ffeb7c power pc version
kono
parents:
diff changeset
1251 if(length>0)
917947ffeb7c power pc version
kono
parents:
diff changeset
1252 emit_copy(from,to,length,offset,0,det);
917947ffeb7c power pc version
kono
parents:
diff changeset
1253 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1254 } else if (length <=MAX_COPY_LEN) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1255 for(;length>=4;length-=4,offset+=4)
917947ffeb7c power pc version
kono
parents:
diff changeset
1256 emit_copy(from,to,4,offset,0,det);
917947ffeb7c power pc version
kono
parents:
diff changeset
1257 for(;length>=2;length-=2,offset+=2)
917947ffeb7c power pc version
kono
parents:
diff changeset
1258 emit_copy(from,to,2,offset,0,det);
917947ffeb7c power pc version
kono
parents:
diff changeset
1259 if(length>0)
917947ffeb7c power pc version
kono
parents:
diff changeset
1260 emit_copy(from,to,length,offset,0,det);
917947ffeb7c power pc version
kono
parents:
diff changeset
1261 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1262 }
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
1263 clear_ptr_cache();
e537da31dce3 struct push
kono
parents: 123
diff changeset
1264 code_save_stacks();
e537da31dce3 struct push
kono
parents: 123
diff changeset
1265 printf("\tli r5,%d\n",length);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1266 printf("\tmr r4,%s\n",frn);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1267 printf("\tmr r3,%s\n",trn);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1268 /* overrap must be allowed */
e537da31dce3 struct push
kono
parents: 123
diff changeset
1269 printf("\tbl L_%s$stub\n",memmove);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1270 extern_define(memmove,0,FUNCTION,1);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1271 fix=0;
e537da31dce3 struct push
kono
parents: 123
diff changeset
1272 set_creg(RET_REGISTER,0);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1273 if (creg!=to) {
e537da31dce3 struct push
kono
parents: 123
diff changeset
1274 free_register(to); to = creg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1275 }
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
1276 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1277 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1278 if (value) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1279 /* creg must point top of the destination data */
917947ffeb7c power pc version
kono
parents:
diff changeset
1280 /* this code is necessary for the value of assignment or function call */
917947ffeb7c power pc version
kono
parents:
diff changeset
1281 /* otherwise we don't need this */
917947ffeb7c power pc version
kono
parents:
diff changeset
1282 if (fix) printf("\taddi %s,%s,%d\n",trn,trn,fix);
917947ffeb7c power pc version
kono
parents:
diff changeset
1283 if(creg!=to) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1284 free_register(creg); creg=to;
917947ffeb7c power pc version
kono
parents:
diff changeset
1285 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1286 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1287 free_register(dreg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1288 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1289
917947ffeb7c power pc version
kono
parents:
diff changeset
1290 int
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1291 struct_push(int e4,int t,int arg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1292 {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1293 int length,count;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1294 int dreg,sreg; char *drn,*crn,*srn;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1295 g_expr(e4);
917947ffeb7c power pc version
kono
parents:
diff changeset
1296 length=size(t);
917947ffeb7c power pc version
kono
parents:
diff changeset
1297 if(length%size_of_int) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1298 length += size_of_int - (length%size_of_int);
917947ffeb7c power pc version
kono
parents:
diff changeset
1299 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1300 dreg = get_register(); if (!dreg) error(-1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1301 drn = register_name(dreg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1302 crn = register_name(creg);
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
1303 if (length<MAX_COPY_LEN) {
e537da31dce3 struct push
kono
parents: 123
diff changeset
1304 sreg = get_register(); if (!sreg) error(-1);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1305 srn = register_name(sreg);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1306 code_lvar(cadr(arg),sreg);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1307 for(count=0;length<MAX_COPY_LEN;count++,length-=size_of_int) {
e537da31dce3 struct push
kono
parents: 123
diff changeset
1308 if (length==0) {
e537da31dce3 struct push
kono
parents: 123
diff changeset
1309 free_register(sreg);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1310 free_register(dreg);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1311 return count;
e537da31dce3 struct push
kono
parents: 123
diff changeset
1312 } else {
e537da31dce3 struct push
kono
parents: 123
diff changeset
1313 printf("\tlwz %s,%d(%s)\n",drn,length-size_of_int,crn);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1314 printf("\tstwu %s,%d(%s)\n",drn,-size_of_int,srn);
e537da31dce3 struct push
kono
parents: 123
diff changeset
1315 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1316 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1317 }
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
1318 code_lvar(cadr(arg),dreg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1319 /* downward direction copy */
917947ffeb7c power pc version
kono
parents:
diff changeset
1320 emit_copy(creg,dreg,length,0,0,1);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1321 if (dreg) free_register(dreg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1322 return length/size_of_int;
917947ffeb7c power pc version
kono
parents:
diff changeset
1323 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1324
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1325 void
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1326 set_creg(int reg,int mode)
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1327 {
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1328 if (reg!=creg) {
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
1329 clear_ptr_cache_reg(reg);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1330 if (ireg && reg!=ireg && mode) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
1331 printf("\tmr %s,%s\n",register_name(reg),register_name(ireg));
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1332 }
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1333 free_register(creg);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1334 regs[cadr(creg)]=USING_REG;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1335 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1336 creg = ireg = reg;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1337 }
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1338
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1339 void
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1340 set_freg(int reg,int mode)
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1341 {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
1342 if (reg!=creg) {
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
1343 if (reg!=freg && mode) {
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1344 printf("\tfmr %s,%s\n",fregister_name(reg),fregister_name(freg));
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
1345 }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
1346 free_register(creg);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1347 regs[cadr(freg)]=USING_REG;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1348 }
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1349 creg = freg = reg;
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1350 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1351
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1352 void
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1353 set_lreg(int reg,int mode)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
1354 {
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1355 if (reg!=creg) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1356 if (reg!=lreg && mode) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1357 printf("\tmr %s,%s\n",
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1358 lregister_name_low(reg),lregister_name_low(lreg));
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1359 printf("\tmr %s,%s\n",
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1360 lregister_name_high(reg),lregister_name_high(lreg));
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1361 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1362 regs[cadr(lreg)]=USING_REG;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1363 regs[caddr(lreg)]=USING_REG;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1364 free_register(creg);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1365 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1366 creg = lreg = reg;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1367 }
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1368
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1369 void
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1370 use_var(int arg)
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1371 {
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1372 if (car(arg)==REGISTER)
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1373 regs[cadr(arg)]=USING_REG;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1374 else if (car(arg)==DREGISTER)
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
1375 regs[cadr(arg)]=USING_REG;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1376 else if (car(arg)==LREGISTER) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1377 regs[cadr(arg)]=USING_REG;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1378 regs[caddr(arg)]=USING_REG;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1379 }
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1380 }
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1381
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1382 void
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1383 code_save_input_registers()
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1384 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1385 int args;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1386 NMTBL *n;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1387 int reg;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1388 int tag;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1389 int lvar;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1390 int t;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1391 /* fnptr->dsp=list4(type,fnptr->dsp,(int)n,0); */
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1392 int reg_offset = 0;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1393 int offset = 0;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1394
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1395 for(args = fnptr->dsp;args;args = cadr(args)) {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1396 n = (NMTBL *)caddr(args);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1397 tag = n->sc;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1398 reg = n->dsp;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1399 if (!n||n==&null_nptr) error(REG_ERR);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1400 if (tag==REGISTER) {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1401 /* regs[reg]==INPUT_REG case should be considered */
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1402 n->dsp = offset;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1403 offset+=size_of_int;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1404 t = INT;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1405 reg += reg_offset; /* for duplicated floating point argument */
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1406 } else if (tag==DREGISTER) {
145
fb61020a9b48 fix macro
kono
parents: 144
diff changeset
1407 /* regs[reg]==INPUT_REG case should be considered */
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1408 n->dsp = offset;
120
099518ea9cc1 input args offset (continue..)
kono
parents: 119
diff changeset
1409 t = n->ty;
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
1410 if(t==FLOAT) { offset+=size_of_float; reg_offset+=1; }
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
1411 else if(t==DOUBLE) { offset+=size_of_double; reg_offset+=2; }
120
099518ea9cc1 input args offset (continue..)
kono
parents: 119
diff changeset
1412 else error(-1);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1413 } else if (tag==LREGISTER) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1414 /* regs[reg]==INPUT_REG case should be considered */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1415 n->dsp = offset;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1416 t = n->ty;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1417 offset+=size_of_longlong; reg_offset+=2;
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
1418 } else {
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
1419 offset += size(n->ty);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1420 continue;
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
1421 }
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1422 n->sc = LVAR;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1423 lvar = list2(LVAR,n->dsp);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1424 g_expr_u(assign_expr0(list2(LVAR,n->dsp),list3(tag,reg,(int)n),n->ty,t));
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1425 if (tag==REGISTER||tag==DREGISTER||tag==FREGISTER||tag==LREGISTER) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1426 free_register(reg);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1427 }
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1428 }
121
00df510bc116 *** empty log message ***
kono
parents: 120
diff changeset
1429 my_func_args = offset;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1430 }
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1431
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1432 int
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1433 simple_args(int e3)
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1434 {
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1435 return
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1436 !contains_in_list(e3,FUNCTION) &&
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1437 !contains_in_list(e3,CONV) &&
125
e537da31dce3 struct push
kono
parents: 123
diff changeset
1438 !contains_in_list(e3,RSTRUCT) &&
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
1439 !contains_in_list(e3,STASS)
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1440 ;
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1441 }
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1442
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1443 int
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1444 caller_arg_offset_v(int arg)
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1445 {
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1446 return ARG_LVAR_OFFSET+arg*size_of_int;
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1447 }
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
1448
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1449 int
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1450 function(int e1)
917947ffeb7c power pc version
kono
parents:
diff changeset
1451 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1452 int e2,e3,e4,e5,nargs,t,r0,r1;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1453 int arg,reg_arg,freg_arg,arg_assign;
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1454 int dots;
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
1455 int reg_arg_list=0,ret_type,special_lvar;
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
1456 NMTBL *fn = 0;
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1457 int jmp = 0;
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1458 char *jrn;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1459
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
1460 special_lvar = -1;
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1461 ret_type = cadr(cadddr(e1));
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1462 if (ret_type==CHAR) ret_type=INT;
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1463
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1464 /* check argments type is DOTS? */
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1465 t = caddr(cadddr(e1));
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1466 if (t==0 || t==DOTS) dots = 1;
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1467 else {
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1468 dots = 0;
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1469 for(t = caddr(cadddr(e1));t;t = cadr(t)) {
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1470 if (car(t)==DOTS) dots = 1;
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1471 }
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1472 }
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1473
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1474 e2 = cadr(e1);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1475 if (car(e2) == FNAME) {
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1476 fn=(NMTBL *)cadr(e2);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1477 } else {
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1478 jmp = get_register_var(0);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1479 if (car(jmp)!=REGISTER) error(-1);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1480 reg_arg_list = list2(jmp,reg_arg_list);
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1481 g_expr(e2);
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1482 code_register(creg,cadr(jmp));
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1483 /* g_expr(assign_expr0(jmp,e2,INT,INT)); functions are lvalue */
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1484 }
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1485
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1486 /* now all input register vars are free */
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1487 code_save_stacks();
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1488 set_creg(CREG_REGISTER,0);
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1489 set_freg(FREG_FREGISTER,0);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1490
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1491 nargs = reg_arg = freg_arg = arg_assign = 0;
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1492 for (e3 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1493 t=caddr(e3);
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
1494 e4 = car(e3);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1495 if(scalar(t)) {
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
1496 if (reg_arg>=MAX_INPUT_REGISTER_VAR) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1497 arg = list2(LVAR,caller_arg_offset_v(nargs));
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1498 } else if (!simple_args(e3) && cadr(e3)) {
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1499 arg = get_register_var(0);
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1500 arg_assign = list2(
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1501 assign_expr0(get_input_register_var(reg_arg,0,0),
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1502 arg,t,t),
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1503 arg_assign);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1504 } else {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1505 arg = get_input_register_var(reg_arg,0,0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1506 }
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1507 use_var(arg); /* protect from input register free */
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1508 reg_arg_list = list2(arg,reg_arg_list);
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1509 g_expr_u(assign_expr0(arg,e4,t,t));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1510 nargs ++ ; reg_arg++;
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1511 continue;
202
601301152d9c *** empty log message ***
kono
parents: 196
diff changeset
1512 } else if (t==LONGLONG||t==ULONGLONG) {
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1513 if (reg_arg>=MAX_INPUT_REGISTER_VAR) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1514 arg = list2(LVAR,caller_arg_offset_v(nargs));
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1515 } else if (!simple_args(e3) && cadr(e3)) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1516 arg = get_register_var(0);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1517 arg_assign = list2(
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1518 assign_expr0(get_input_lregister_var(reg_arg,0,0),
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1519 arg,t,t),
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1520 arg_assign);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1521 } else {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1522 arg = get_input_lregister_var(reg_arg,0,0);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1523 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1524 use_var(arg); /* protect from input register free */
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1525 reg_arg_list = list2(arg,reg_arg_list);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1526 g_expr_u(assign_expr0(arg,e4,t,t));
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1527 nargs ++ ; reg_arg++;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1528 nargs ++ ; reg_arg++;
202
601301152d9c *** empty log message ***
kono
parents: 196
diff changeset
1529 continue;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1530 } else if (t==DOUBLE||t==FLOAT) {
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1531 if (reg_arg<MAX_INPUT_REGISTER_VAR) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1532 /* sigh...
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1533 printf requies floating value in integer registers
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1534 */
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1535 if (dots) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1536 if (car(e4)==DRLVAR) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1537 special_lvar = cadr(e4);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1538 e5 = list2(LVAR,special_lvar);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1539 } else {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1540 special_lvar = new_lvar(size_of_double);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1541 g_expr(assign_expr0(
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1542 (e5=list2(LVAR,special_lvar)),e4,DOUBLE,t));
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1543 reg_arg_list = list2(e5,reg_arg_list);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1544 e4 = list2(DREGISTER,freg);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1545 /* freg should not change until XXX */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1546 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1547 r0=get_input_register_var(reg_arg,0,0);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1548 r1 = reg_arg+1+MIN_TMP_REG;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1549 if (regs[r1]==PTRC_REG)
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1550 clear_ptr_cache_reg(list2(REGISTER,r1));
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1551 /* else if (regs[r1]) error(-1); */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1552 r1=get_input_register_var_1(reg_arg+1,0,0);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1553
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1554 use_var(r0); /* protect from input register free */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1555 use_var(r1); /* protect from input register free */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1556 reg_arg_list = list2(r0,reg_arg_list);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1557 reg_arg_list = list2(r1,reg_arg_list);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1558 arg_assign = list2( assign_expr0(r0,e5,INT,INT), arg_assign);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1559 arg_assign = list2( assign_expr0(r1,
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1560 list2(LVAR,special_lvar+size_of_int),
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1561 INT,INT), arg_assign);
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
1562 }
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
1563 reg_arg += 2;
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
1564 }
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
1565 if (dots && freg_arg>=4 && freg_arg<MAX_INPUT_DREGISTER_VAR) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1566 /* oh my god!
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1567 it requies integer register and floating register and
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1568 stack value. You are crazy.
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1569 */
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1570 arg_assign = list2(
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1571 assign_expr0(list2(LVAR,caller_arg_offset_v(nargs)),
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1572 get_input_dregister_var(freg_arg,0,0,1),t,t),
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1573 arg_assign);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1574 }
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
1575 if (freg_arg>=MAX_INPUT_DREGISTER_VAR) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1576 arg = list2(LVAR,caller_arg_offset_v(nargs));
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1577 } else if (!simple_args(e3) && cadr(e3)) {
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1578 arg = get_dregister_var(0,1);
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1579 arg_assign = list2(
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1580 assign_expr0(get_input_dregister_var(freg_arg,0,0,1),
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1581 arg,t,t),
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1582 arg_assign);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1583 } else {
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1584 arg = get_input_dregister_var(freg_arg,0,0,1);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1585 }
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
1586 use_var(arg); /* protect from input register free */
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1587 reg_arg_list = list2(arg,reg_arg_list);
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1588 g_expr_u(assign_expr0(arg,e4,t,t)); /* XXX */
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1589 freg_arg++;
122
b884271bcab2 input registers (long arguments )
kono
parents: 121
diff changeset
1590 nargs += size(t)/size_of_int;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1591 continue;
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
1592 } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1593 arg = list2(LVAR,caller_arg_offset_v(nargs));
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1594 nargs += struct_push(e4,t,arg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1595 continue;
917947ffeb7c power pc version
kono
parents:
diff changeset
1596 } else {
917947ffeb7c power pc version
kono
parents:
diff changeset
1597 error(TYERR);
917947ffeb7c power pc version
kono
parents:
diff changeset
1598 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1599 ++nargs;
917947ffeb7c power pc version
kono
parents:
diff changeset
1600 }
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1601 if (max_func_args<nargs) max_func_args=nargs;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1602 for(;arg_assign;arg_assign=cadr(arg_assign)) {
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1603 g_expr_u(car(arg_assign));
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1604 }
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1605 clear_ptr_cache();
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1606 if (car(e2) == FNAME) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1607 printf("\tbl\tL_%s$stub\n",fn->nm);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1608 } else {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1609 jrn = register_name(cadr(jmp));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1610 printf("\tmtctr %s\n",jrn);
917947ffeb7c power pc version
kono
parents:
diff changeset
1611 printf("\tbctrl\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
1612 }
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1613 for(;reg_arg_list;reg_arg_list=cadr(reg_arg_list)) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1614 arg = car(reg_arg_list);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1615 if (car(arg)==REGISTER||car(arg)==DREGISTER||car(arg)==FREGISTER
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1616 ||car(arg)==LREGISTER)
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
1617 free_register(cadr(arg));
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1618 else if (car(arg)==LVAR&&cadr(arg)<0) free_lvar(cadr(arg));
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
1619 }
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1620 if (ret_type==DOUBLE||ret_type==FLOAT) {
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1621 set_freg(RET_FREGISTER,0);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1622 } else if (ret_type==ULONGLONG||ret_type==LONGLONG) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1623 set_lreg(RET_LREGISTER,0);
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1624 } else if (ret_type==VOID) {
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1625 } else {
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1626 set_creg(RET_REGISTER,0);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
1627 }
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1628 return ret_type;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1629 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1630
917947ffeb7c power pc version
kono
parents:
diff changeset
1631 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1632 code_frame_pointer(int e3) {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1633 #if R1SAVE
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1634 printf("\tmr r1,%s\n",register_name(e3));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1635 #else
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
1636 printf("\tmr r30,%s\n",register_name(e3));
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1637 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1638 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1639
917947ffeb7c power pc version
kono
parents:
diff changeset
1640
917947ffeb7c power pc version
kono
parents:
diff changeset
1641 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1642 code_fix_frame_pointer(int disp_offset) {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1643 int l = 0;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1644 printf("\tla r30,");
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1645 printf("lo16(%d+L_%d)(r30)\n",FUNC_LVAR,lvar_offset_label);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1646 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1647
917947ffeb7c power pc version
kono
parents:
diff changeset
1648 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1649 code_jmp(char *s) {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1650 max_reg_var = REG_VAR_BASE-REG_VAR_MIN;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1651 max_freg_var = FREG_VAR_BASE-FREG_VAR_MIN;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1652 printf("\tb L_%s$stub\n",s);
917947ffeb7c power pc version
kono
parents:
diff changeset
1653 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1654
917947ffeb7c power pc version
kono
parents:
diff changeset
1655
917947ffeb7c power pc version
kono
parents:
diff changeset
1656 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1657 code_indirect_jmp(int e2) {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1658 max_reg_var = REG_VAR_BASE-REG_VAR_MIN;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
1659 max_freg_var = FREG_VAR_BASE-FREG_VAR_MIN;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1660 printf("\tmtctr %s\n",register_name(e2));
917947ffeb7c power pc version
kono
parents:
diff changeset
1661 printf("\tbctr\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
1662 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1663
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1664 int
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1665 code_rindirect(int e1, int offset, int us)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1666 {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1667 char *crn;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1668 g_expr(e1);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1669 crn=register_name(creg);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1670 printf("\tlwz %s,%d(%s)\n",crn,offset,crn);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1671 return us?UNSIGNED:INT;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1672 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1673
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1674 int
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1675 code_crindirect(int e1, int offset, int us)
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1676 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1677 char *crn;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1678 g_expr(e1);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1679 crn=register_name(creg);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1680 if (us) {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1681 printf("\tlbz %s,%d(%s)\n",crn,offset,crn);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1682 return UCHAR;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1683 } else {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1684 printf("\tlbz %s,%d(%s)\n",crn,offset,crn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1685 printf("\textsb %s,%s\n",crn,crn);
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1686 return CHAR;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1687 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1688 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1689
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1690 int
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1691 code_srindirect(int e1, int offset, int us)
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1692 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1693 char *crn;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1694 g_expr(e1);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1695 crn=register_name(creg);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1696 if (us) {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1697 printf("\tlhz %s,%d(%s)\n",crn,offset,crn);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1698 return USHORT;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1699 } else {
165
kono
parents: 164
diff changeset
1700 printf("\tlhz %s,%d(%s)\n",crn,offset,crn);
kono
parents: 164
diff changeset
1701 printf("\textsh %s,%s\n",crn,crn);
kono
parents: 164
diff changeset
1702 return SHORT;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1703 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1704 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1705
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1706 #if FLOAT_CODE
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1707 int
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1708 code_drindirect(int e1, int offset, int d)
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1709 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1710 char *crn;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1711 g_expr(e1);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1712 crn=register_name(creg);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1713 printf("\t%s %s,%d(%s)\n",fload(d),
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1714 fregister_name(freg),offset,crn);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1715 creg = freg;
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1716 return d?DOUBLE:FLOAT;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1717 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1718 #endif
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1719
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1720 #if LONGLONG_CODE
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1721 int
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1722 code_lrindirect(int e1, int offset, int us)
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1723 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1724 char *crn;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1725 g_expr(e1);
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1726 crn=register_name(creg);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1727 if (!lreg) lreg = get_lregister();
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1728 printf("\tlwz %s,%d(%s)\n",crn,offset,lregister_name_low(lreg));
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1729 printf("\tlwz %s,%d(%s)\n",crn,offset+size_of_int,lregister_name_high(lreg));
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1730 creg = lreg;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
1731 return us?ULONGLONG:LONGLONG;
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1732 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1733 #endif
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1734
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
1735
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1736 void
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1737 code_assign_gvar(int e2,int creg,int byte) {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1738 int r;
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1739 char *crn,*rrn;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1740 r = get_ptr_cache((NMTBL*)cadr(e2));
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1741 rrn=register_name(r);
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1742 crn=register_name(creg);
165
kono
parents: 164
diff changeset
1743 if (byte==1) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1744 printf("\tstb %s,0(%s)\n",crn,rrn);
165
kono
parents: 164
diff changeset
1745 } else if (byte==size_of_short) {
kono
parents: 164
diff changeset
1746 printf("\tsth %s,0(%s)\n",crn,rrn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1747 } else {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1748 printf("\tstw %s,0(%s)\n",crn,rrn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1749 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1750 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1751
917947ffeb7c power pc version
kono
parents:
diff changeset
1752 void
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1753 code_assign_lvar(int e2,int creg,int byte) {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1754 char *crn;
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1755 crn=register_name(creg);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1756 lvar_intro(e2);
165
kono
parents: 164
diff changeset
1757 if (byte==1) {
kono
parents: 164
diff changeset
1758 printf("\tstb %s,",crn);
kono
parents: 164
diff changeset
1759 } else if (byte==size_of_short) {
kono
parents: 164
diff changeset
1760 printf("\tsth %s,",crn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1761 } else {
165
kono
parents: 164
diff changeset
1762 printf("\tstw %s,",crn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1763 }
165
kono
parents: 164
diff changeset
1764 lvar(e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1765 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1766
917947ffeb7c power pc version
kono
parents:
diff changeset
1767 void
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
1768 code_assign_register(int e2,int byte,int creg) {
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1769 if (e2!=creg)
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1770 printf("\tmr %s,%s\n",register_name(e2),register_name(creg));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1771 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1772
917947ffeb7c power pc version
kono
parents:
diff changeset
1773 void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
1774 code_assign(int e2,int byte,int creg) {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1775 char *drn=register_name(e2);
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1776 char *crn=register_name(creg);
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1777
165
kono
parents: 164
diff changeset
1778 if (byte==1) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1779 printf("\tstb %s,0(%s)\n",crn,drn);
165
kono
parents: 164
diff changeset
1780 } else if (byte==size_of_short) {
kono
parents: 164
diff changeset
1781 printf("\tsth %s,0(%s)\n",crn,drn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1782 } else {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1783 printf("\tstw %s,0(%s)\n",crn,drn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1784 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1785 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1786
917947ffeb7c power pc version
kono
parents:
diff changeset
1787
917947ffeb7c power pc version
kono
parents:
diff changeset
1788 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1789 code_register_assop(int e2,int op,int byte) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1790 int reg;
917947ffeb7c power pc version
kono
parents:
diff changeset
1791 int xreg = creg;
917947ffeb7c power pc version
kono
parents:
diff changeset
1792 creg = reg = e2;
917947ffeb7c power pc version
kono
parents:
diff changeset
1793 tosop(op,xreg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1794 creg = xreg;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1795 if (creg!=reg)
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1796 printf("\tmr %s,%s\n",register_name(creg),register_name(reg));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1797 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1798
917947ffeb7c power pc version
kono
parents:
diff changeset
1799
917947ffeb7c power pc version
kono
parents:
diff changeset
1800 void
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1801 code_assop(int op,int byte,int sign) {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1802 char *xrn,*crn,*drn;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1803 int xreg;
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1804 int edx = get_register(); if(!edx) error(-1);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1805 xrn = register_name(xreg = emit_pop(0)); /* pop e3 value */
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
1806 printf("# assop\n\tmr %s,%s\n",register_name(edx),register_name(creg));
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1807 ld_indexx(byte,0,edx,sign);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1808 tosop(op,xreg);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1809 crn = register_name(creg);
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1810 drn = register_name(edx);
165
kono
parents: 164
diff changeset
1811 if (byte==1) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1812 printf("\tstb %s,0(%s)\n",crn,drn);
165
kono
parents: 164
diff changeset
1813 } else if (byte==size_of_short) {
kono
parents: 164
diff changeset
1814 printf("\tsth %s,0(%s)\n",crn,drn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1815 } else {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1816 printf("\tstw %s,0(%s)\n",crn,drn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1817 }
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1818 free_register(edx);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1819 emit_pop_free(xreg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1820 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1821
917947ffeb7c power pc version
kono
parents:
diff changeset
1822
917947ffeb7c power pc version
kono
parents:
diff changeset
1823 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1824 tosop(int op,int oreg)
917947ffeb7c power pc version
kono
parents:
diff changeset
1825 {
917947ffeb7c power pc version
kono
parents:
diff changeset
1826 int dx;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1827 char *orn,*crn,*drn;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1828
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1829 if(oreg==-1) {
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1830 error(-1);
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1831 } else if (oreg<= -REG_LVAR_OFFSET) {
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1832 dx = get_register(); if (dx<0) error(-1);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
1833 code_rlvar(oreg+REG_LVAR_OFFSET,dx);
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1834 oreg = dx;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1835 }
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1836
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1837 switch(op) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1838 case LSHIFT:
917947ffeb7c power pc version
kono
parents:
diff changeset
1839 case ULSHIFT:
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1840 shift("slw",oreg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1841 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
1842 case RSHIFT:
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
1843 shift("sraw",oreg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1844 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
1845 case URSHIFT:
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
1846 shift("srw",oreg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1847 return;
917947ffeb7c power pc version
kono
parents:
diff changeset
1848 }
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1849 orn = register_name(oreg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1850 crn = register_name(creg);
917947ffeb7c power pc version
kono
parents:
diff changeset
1851 switch(op) {
917947ffeb7c power pc version
kono
parents:
diff changeset
1852 case ADD:
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1853 printf("\tadd %s,%s,%s\n",crn,crn,orn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1854 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1855 case SUB:
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1856 printf("\tsub %s,%s,%s\n",crn,crn,orn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1857 break;
112
fc7de4faedfd *** empty log message ***
kono
parents: 111
diff changeset
1858 case CMP:
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
1859 printf("\tcmpw cr0,%s,%s\n",crn,orn);
112
fc7de4faedfd *** empty log message ***
kono
parents: 111
diff changeset
1860 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1861 case BAND:
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1862 printf("\tand %s,%s,%s\n",crn,crn,orn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1863 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1864 case EOR:
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1865 printf("\txor %s,%s,%s\n",crn,crn,orn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1866 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1867 case BOR:
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1868 printf("\tor %s,%s,%s\n",crn,crn,orn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1869 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1870 case MUL:
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1871 printf("\tmullw %s,%s,%s\n",crn,crn,orn);
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1872 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1873 case UMUL:
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1874 printf("\tmullw %s,%s,%s\n",crn,crn,orn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1875 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1876 case DIV:
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1877 printf("\tdivw %s,%s,%s\n",crn,crn,orn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1878 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1879 case UDIV:
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1880 printf("\tdivwu %s,%s,%s\n",crn,crn,orn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1881 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
1882 case MOD:
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1883 dx=get_register();
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1884 drn = register_name(dx);
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1885 printf("\tdivw %s,%s,%s\n",drn,crn,orn);
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1886 printf("\tmullw %s,%s,%s\n",drn,drn,orn);
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1887 printf("\tsubf %s,%s,%s\n",crn,drn,crn);
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1888 free_register(dx);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1889 break;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1890 case UMOD:
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1891 dx=get_register();
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1892 drn = register_name(dx);
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1893 printf("\tdivwu %s,%s,%s\n",drn,crn,orn);
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1894 printf("\tmullw %s,%s,%s\n",drn,drn,orn);
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
1895 printf("\tsubf %s,%s,%s\n",crn,drn,crn);
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
1896 free_register(dx);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1897 break;
112
fc7de4faedfd *** empty log message ***
kono
parents: 111
diff changeset
1898 default:
fc7de4faedfd *** empty log message ***
kono
parents: 111
diff changeset
1899 error(-1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1900 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1901 if(oreg!=creg) free_register(oreg);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1902 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1903
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1904 int
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1905 code_const_op_p(int op,int v)
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1906 {
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1907 if (op==BAND||op==DIV||op==UDIV||op==MOD||op==UMOD) return 0;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1908 return (-127<v&&v<128);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1909 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1910
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1911 void
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1912 oprtc(int op,int v)
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1913 {
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1914 char *crn = register_name(creg);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1915
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1916 switch(op) {
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1917 case LSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1918 case ULSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1919 printf("\tslwi %s,%s,%d\n",crn,crn,v);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1920 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1921 case RSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1922 printf("\tsrawi %s,%s,%d\n",crn,crn,v);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1923 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1924 case URSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1925 printf("\tsrwi %s,%s,%d\n",crn,crn,v);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1926 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1927 case ADD:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1928 printf("\taddi %s,%s,lo16(%d)\n",crn,crn,v);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1929 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1930 case SUB:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1931 printf("\tsubi %s,%s,lo16(%d)\n",crn,crn,v);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1932 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1933 case CMP:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1934 printf("\tcmpwi cr0,%s,lo16(%d)\n",crn,v);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1935 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1936 case EOR:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1937 printf("\txori %s,%s,lo16(%d)\n",crn,crn,v);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1938 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1939 case BOR:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1940 printf("\tori %s,%s,lo16(%d)\n",crn,crn,v);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1941 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1942 case MUL:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1943 printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1944 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1945 case UMUL:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1946 printf("\tmulli %s,%s,lo16(%d)\n",crn,crn,v);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1947 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1948 default:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1949 error(-1);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1950 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
1951 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1952
917947ffeb7c power pc version
kono
parents:
diff changeset
1953 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1954 shift(char *op, int reg)
917947ffeb7c power pc version
kono
parents:
diff changeset
1955 {
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1956 char *crn = register_name(creg);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
1957 char *rrn = register_name(reg);
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
1958 printf("\t%s %s,%s,%s\n",op,crn,crn,rrn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1959 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1960
917947ffeb7c power pc version
kono
parents:
diff changeset
1961 void
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1962 ld_indexx(int byte, int n, int xreg,int sign)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1963 {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1964 char *crn = register_name(creg);
165
kono
parents: 164
diff changeset
1965 if (byte==1) {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1966 printf("\tlbz %s,%d(%s)\n",register_name(creg),n,
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1967 register_name(xreg));
162
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1968 if (sign)
0c604d2ff585 *** empty log message ***
kono
parents: 160
diff changeset
1969 printf("\textsb %s,%s\n",crn,crn);
165
kono
parents: 164
diff changeset
1970 } else if (byte==size_of_short) {
kono
parents: 164
diff changeset
1971 printf("\tlhz %s,%d(%s)\n",register_name(creg),n,
kono
parents: 164
diff changeset
1972 register_name(xreg));
kono
parents: 164
diff changeset
1973 if (sign)
kono
parents: 164
diff changeset
1974 printf("\textsh %s,%s\n",crn,crn);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1975 } else
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1976 printf("\tlwz %s,%d(%s)\n",register_name(creg),n,
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
1977 register_name(xreg));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1978 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1979
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1980 int
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1981 code_csvalue()
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1982 {
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1983 return creg;
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1984 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1985
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1986 void
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
1987 code_cmpdimm(int e, int csreg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1988 {
917947ffeb7c power pc version
kono
parents:
diff changeset
1989 /* used in dosiwtch() */
917947ffeb7c power pc version
kono
parents:
diff changeset
1990 if(chk) return;
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1991 printf("\tcmpwi cr0,%s,%d\n",register_name(csreg),e);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1992 }
917947ffeb7c power pc version
kono
parents:
diff changeset
1993
917947ffeb7c power pc version
kono
parents:
diff changeset
1994 void
917947ffeb7c power pc version
kono
parents:
diff changeset
1995 code_opening(char *filename)
917947ffeb7c power pc version
kono
parents:
diff changeset
1996 {
917947ffeb7c power pc version
kono
parents:
diff changeset
1997 printf("\t.file \"%s\"\n",filename);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
1998 /* printf("\t.version\t\"01.01\"\n"); */
89
917947ffeb7c power pc version
kono
parents:
diff changeset
1999 /* printf("gcc2_compiled.:\n"); */
917947ffeb7c power pc version
kono
parents:
diff changeset
2000 printf(".text\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
2001 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2002
917947ffeb7c power pc version
kono
parents:
diff changeset
2003 void
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2004 rexpr(int e1, int l1, char *s,int t)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2005 {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
2006 g_expr(list3(CMP,cadr(e1),caddr(e1)));
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2007 printf("\tb%s cr0,L_%d\n",s,l1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2008 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2009
917947ffeb7c power pc version
kono
parents:
diff changeset
2010
917947ffeb7c power pc version
kono
parents:
diff changeset
2011 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2012 jcond(int l, char cond)
917947ffeb7c power pc version
kono
parents:
diff changeset
2013 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2014 if (chk) return;
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2015 printf("\tb%s cr0,L_%d\n",cond?"ne":"eq",l);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2016 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2017
917947ffeb7c power pc version
kono
parents:
diff changeset
2018 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2019 jmp(int l)
917947ffeb7c power pc version
kono
parents:
diff changeset
2020 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2021 control=0;
917947ffeb7c power pc version
kono
parents:
diff changeset
2022 if (chk) return;
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2023 printf("\tb\tL_%d\n",l);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2024 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2025
917947ffeb7c power pc version
kono
parents:
diff changeset
2026 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2027 gen_comment(char *s)
917947ffeb7c power pc version
kono
parents:
diff changeset
2028 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2029 if (chk) return;
917947ffeb7c power pc version
kono
parents:
diff changeset
2030 printf("## %s",s);
917947ffeb7c power pc version
kono
parents:
diff changeset
2031 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2032
917947ffeb7c power pc version
kono
parents:
diff changeset
2033 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2034 code_enter(char *name)
917947ffeb7c power pc version
kono
parents:
diff changeset
2035 {
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2036 if (output_mode!=TEXT_EMIT_MODE)
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2037 text_mode();
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2038 else
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2039 printf("\t.align 2\n");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2040 if (stmode!=STATIC)
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2041 printf(".globl _%s\n",name);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2042 #ifdef DOT_SIZE
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2043 printf("\t.type\t%s,@function\n",name);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2044 #endif
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
2045 printf("_%s:\n",name);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2046 code_disp_label=fwdlabel();
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2047 printf("\tla r1,lo16(L_%d)(r30)\n",code_disp_label);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2048 printf("\tbcl 20,31,L_%d\n",code_base = fwdlabel());
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2049 fwddef(code_base);
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2050 printf("\tmflr r31\n");
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2051 max_func_args = 0;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2052 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2053
917947ffeb7c power pc version
kono
parents:
diff changeset
2054
917947ffeb7c power pc version
kono
parents:
diff changeset
2055 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2056 code_enter1(int args)
917947ffeb7c power pc version
kono
parents:
diff changeset
2057 {
106
3618c0efe9d3 fix save_input_register
kono
parents: 105
diff changeset
2058 set_creg(CREG_REGISTER,0);
3618c0efe9d3 fix save_input_register
kono
parents: 105
diff changeset
2059 set_freg(FREG_FREGISTER,0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2060 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2061
917947ffeb7c power pc version
kono
parents:
diff changeset
2062 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2063 code_leave(char *name)
917947ffeb7c power pc version
kono
parents:
diff changeset
2064 {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2065 int r1_offsetv;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2066 disp&= -size_of_int;
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2067 r1_offsetv = -disp+max_func_args*size_of_int+code_disp_offset;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2068
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2069 printf(".set L_%d,%d\n",code_disp_label,-r1_offsetv);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2070 local_table();
917947ffeb7c power pc version
kono
parents:
diff changeset
2071 free_all_register();
917947ffeb7c power pc version
kono
parents:
diff changeset
2072 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2073
917947ffeb7c power pc version
kono
parents:
diff changeset
2074 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2075 enter(char *name)
917947ffeb7c power pc version
kono
parents:
diff changeset
2076 {
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2077 if (output_mode!=TEXT_EMIT_MODE)
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2078 text_mode();
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2079 else
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2080 printf("\t.align 2\n");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2081 if (stmode!=STATIC)
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
2082 printf(".globl _%s\n",name);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2083 /*
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2084 printf("\t.type\t%s,@function\n",name);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2085 */
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
2086 printf("_%s:\n",name);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2087 code_setup=fwdlabel();
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2088 printf("\tmflr r0\n");
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2089 printf("\tbl L_%d\n",code_setup);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2090 code_base=fwdlabel();
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2091 fwddef(code_base);
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2092 r1_offset_label = fwdlabel();
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2093 lvar_offset_label = fwdlabel();
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2094 printf("\tstwu r1,lo16(-L_%d)(r1)\n",r1_offset_label);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2095 printf("\tmr r30,r1\n");
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2096 printf("\tmflr r31\n");
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2097 max_func_args = 0;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2098 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2099
917947ffeb7c power pc version
kono
parents:
diff changeset
2100 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2101 enter1()
917947ffeb7c power pc version
kono
parents:
diff changeset
2102 {
182
e1e9ec8c96a7 some fix
kono
parents: 178
diff changeset
2103 text_mode();
106
3618c0efe9d3 fix save_input_register
kono
parents: 105
diff changeset
2104 set_creg(CREG_REGISTER,0);
3618c0efe9d3 fix save_input_register
kono
parents: 105
diff changeset
2105 set_freg(FREG_FREGISTER,0);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2106 }
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2107
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2108 int
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2109 reg_save_offset()
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2110 {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2111 return -(
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2112 (REAL_MAX_REGISTER-(REG_VAR_BASE-max_reg_var))*size_of_int+
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2113 (REAL_MAX_FREGISTER-(FREG_VAR_BASE-max_freg_var))*size_of_double
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2114 );
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2115 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2116
917947ffeb7c power pc version
kono
parents:
diff changeset
2117 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2118 leave(int control, char *name)
917947ffeb7c power pc version
kono
parents:
diff changeset
2119 {
130
fea1b499d47b fix register var save
kono
parents: 129
diff changeset
2120 int retcont1=0,sz;
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2121
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2122 if (max_freg_var>=0 && max_freg_var<=3) max_freg_var=3;
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2123 reg_save = reg_save_offset();
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2124
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2125 if (control) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2126 code_set_return_register(1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2127 }
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2128 if (retcont) {
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2129 if (control) jmp(retlabel);
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2130 retcont1 = fwdlabel();
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2131 fwddef(retcont);
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2132 if (cadr(fnptr->ty)==FLOAT||cadr(fnptr->ty)==DOUBLE) {
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2133 printf("\tfmr f1,f31\n");
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2134 } else if (cadr(fnptr->ty)>0&&(
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2135 car(cadr(fnptr->ty))==STRUCT ||
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2136 car(cadr(fnptr->ty))==UNION)) {
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2137 sz = size(cadr(fnptr->ty));
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2138 printf("\tli r7,%d\n",sz);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2139 printf("\tsubl r6,r7,r30\n");
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2140 printf("\tlwz r3,lo16(%d)(r30)\n",(my_func_args-1)*size_of_int);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2141 emit_copy(6,3,sz,0,1,1);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2142 } else if (cadr(fnptr->ty)!=VOID) {
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2143 printf("\tmr r3,r29\n");
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2144 }
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2145 #if !R1SAVE
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2146 printf("\tla r1,lo16(%d)(r30)\n",
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2147 -reg_save+my_func_args*size_of_int);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2148 #endif
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2149 printf("\tb L_%d\n",retcont1);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2150 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2151 fwddef(retlabel);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2152 printf("\tlwz r1,0(r1)\n");
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2153 if (retcont) {
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2154 fwddef(retcont1);
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2155 }
110
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
2156 if (max_freg_var>=0) {
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
2157 printf("\tlmw r%d,%d(r1)\n",
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2158 REG_VAR_BASE-max_reg_var,reg_save);
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2159 freg_save = 72-(REAL_MAX_FREGISTER-(FREG_VAR_BASE-max_freg_var))*4;
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2160 printf("\tb restFP+%d ; restore f%d-f31\n",
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2161 freg_save,
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2162 FREG_VAR_BASE-max_freg_var);
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2163 } else {
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2164 printf("\tlwz r0,8(r1)\n");
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2165 printf("\tmtlr r0\n");
110
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
2166 printf("\tlmw r%d,%d(r1)\n",
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2167 REG_VAR_BASE-max_reg_var,reg_save);
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2168 printf("\tblr\n");
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2169 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2170
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2171 disp &= -size_of_int;
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2172 fwddef(code_setup);
110
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
2173 printf("\tstmw r%d,%d(r1)\n",
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2174 REG_VAR_BASE-max_reg_var,reg_save);
110
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
2175 printf("\tstw r0,8(r1)\n");
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
2176 if (max_freg_var>=0)
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2177 printf("\tb saveFP+%d ; save f%d-f31\n",
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2178 freg_save,
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2179 FREG_VAR_BASE-max_freg_var);
110
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
2180 else {
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2181 printf("\tblr\n");
110
fb502a0071f8 first binary run
kono
parents: 109
diff changeset
2182 }
100
a9e6f2a2946f Wrote all code for PowerPC and no compile error. Let's fix all bugs...
kono
parents: 99
diff changeset
2183
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2184 code_offset_set();
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2185 local_table();
917947ffeb7c power pc version
kono
parents:
diff changeset
2186 labelno++;
917947ffeb7c power pc version
kono
parents:
diff changeset
2187 free_all_register();
917947ffeb7c power pc version
kono
parents:
diff changeset
2188 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2189
917947ffeb7c power pc version
kono
parents:
diff changeset
2190
917947ffeb7c power pc version
kono
parents:
diff changeset
2191 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
2192 code_set_return_register(int mode) {
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2193 if (cadr(fnptr->ty)==DOUBLE||cadr(fnptr->ty)==FLOAT) {
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
2194 set_freg(RET_FREGISTER,mode);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2195 } else if (cadr(fnptr->ty)==LONGLONG||cadr(fnptr->ty)==ULONGLONG) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2196 set_lreg(RET_LREGISTER,mode);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2197 } else if (cadr(fnptr->ty)==VOID) {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2198 } else {
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
2199 set_creg(RET_REGISTER,mode);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2200 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2201 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2202
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2203 int
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2204 code_get_fixed_creg(int reg,int type) {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2205 return creg;
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2206 }
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2207
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2208 void
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2209 code_set_fixed_creg(int reg,int mode,int type) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2210 if (type==FLOAT||type==DOUBLE) {
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2211 set_freg(reg,mode);
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2212 } else if (type==LONGLONG||type==ULONGLONG) {
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2213 set_lreg(reg,mode);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2214 } else {
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2215 set_creg(reg,mode);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2216 }
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
2217 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
2218
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
2219 void
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2220 gen_gdecl(char *n, int gpc)
917947ffeb7c power pc version
kono
parents:
diff changeset
2221 {
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2222 /*
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2223 if (stmode!=STATIC)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2224 printf(".globl _%s\n",n);
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2225 */
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2226 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2227
917947ffeb7c power pc version
kono
parents:
diff changeset
2228 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2229 align(int t)
917947ffeb7c power pc version
kono
parents:
diff changeset
2230 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2231 if (t!=CHAR) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2232 if (data_alignment & 1)
917947ffeb7c power pc version
kono
parents:
diff changeset
2233 printf("\t.align 2\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
2234 data_alignment = 0;
917947ffeb7c power pc version
kono
parents:
diff changeset
2235 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2236 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2237
917947ffeb7c power pc version
kono
parents:
diff changeset
2238 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2239 emit_data(int e, int t, NMTBL *n)
917947ffeb7c power pc version
kono
parents:
diff changeset
2240 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2241 int l;
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2242 #if FLOAT_CODE
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2243 double d;
917947ffeb7c power pc version
kono
parents:
diff changeset
2244 float f;
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2245 #endif
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2246 #if LONGLONG_CODE
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2247 long long ll;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2248 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2249 char *name;
917947ffeb7c power pc version
kono
parents:
diff changeset
2250 name = n->nm;
156
da529eab5618 static initialization
kono
parents: 153
diff changeset
2251 if(mode!=GDECL && mode!=STADECL) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2252 error(-1); return;
917947ffeb7c power pc version
kono
parents:
diff changeset
2253 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2254 if (chk) return;
917947ffeb7c power pc version
kono
parents:
diff changeset
2255 if (n->dsp != -1) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2256 n->dsp = -1; /* initiallized flag */
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2257 printf(".globl\t_%s\n",name);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2258 data_mode(name);
917947ffeb7c power pc version
kono
parents:
diff changeset
2259 align(t);
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2260 printf("_%s:\n",name);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2261 } else {
917947ffeb7c power pc version
kono
parents:
diff changeset
2262 data_mode(0);
917947ffeb7c power pc version
kono
parents:
diff changeset
2263 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2264 if(car(e)==CONST) {
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
2265 if (t==CHAR||t==UCHAR) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2266 printf("\t.byte %d\n",cadr(e));
917947ffeb7c power pc version
kono
parents:
diff changeset
2267 if (data_alignment>0)
917947ffeb7c power pc version
kono
parents:
diff changeset
2268 data_alignment++;
917947ffeb7c power pc version
kono
parents:
diff changeset
2269 gpc += 1;
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
2270 } else if (t==SHORT||t==USHORT) {
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
2271 printf("\t.short %d\n",cadr(e));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2272 if (data_alignment>0) data_alignment++;
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
2273 gpc += size_of_short;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2274 } else {
917947ffeb7c power pc version
kono
parents:
diff changeset
2275 printf("\t.long %d\n",cadr(e));
917947ffeb7c power pc version
kono
parents:
diff changeset
2276 gpc += size_of_int;
917947ffeb7c power pc version
kono
parents:
diff changeset
2277 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2278 #if LONGLONG_CODE
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2279 } else if(t==LONGLONG||t==ULONGLONG) {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2280 ll = lcadr(e);
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
2281 printf("\t.long\t0x%x,0x%x\n",code_l2(ll),code_l1(ll));
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2282 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2283 #if FLOAT_CODE
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2284 } else if(t==DOUBLE) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2285 d = dcadr(e);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2286 printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2287 } else if(t==FLOAT) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2288 f = dcadr(e);
917947ffeb7c power pc version
kono
parents:
diff changeset
2289 printf("\t.long\t0x%x\n",*(int *)&f);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2290 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2291 } else if(t!=CHAR) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2292 gpc += size_of_int;
917947ffeb7c power pc version
kono
parents:
diff changeset
2293 if(car(e)==ADDRESS&&car(cadr(e))==GVAR) {
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2294 printf("\t.long _%s\n",((NMTBL *)cadr(cadr(e)))->nm);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2295 } else if(car(e)==FNAME) {
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2296 printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2297 } else if(car(e)==GVAR) {
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2298 printf("\t.long _%s\n",((NMTBL *)cadr(e))->nm);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2299 } else if(car(e)==STRING) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2300 if (car(n->ty)!=ARRAY || cadr(n->ty)!=CHAR) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2301 l = fwdlabel();
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2302 printf("\t.long L_%d\n",l);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2303 printf(".cstring\n\t.align 2\n");
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2304 printf("L_%d:\n",l);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2305 output_mode = RODATA_EMIT_MODE;
917947ffeb7c power pc version
kono
parents:
diff changeset
2306 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2307 ascii((char *)cadr(e));
917947ffeb7c power pc version
kono
parents:
diff changeset
2308 } else error(TYERR);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
2309 } else error(TYERR);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2310 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2311
917947ffeb7c power pc version
kono
parents:
diff changeset
2312 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2313 emit_data_closing(NMTBL *n)
917947ffeb7c power pc version
kono
parents:
diff changeset
2314 {
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2315 #ifdef DOT_SIZE
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2316 int lb;
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2317 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2318 if (chk) return;
917947ffeb7c power pc version
kono
parents:
diff changeset
2319 if (mode==GDECL) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2320 data_mode(0);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2321 #ifdef DOT_SIZE
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2322 lb=fwdlabel();
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2323 printf("L_%d:\n",lb);
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2324 printf("\t.size\t%s,L_%d-%s\n",n->nm,lb,n->nm);
126
1d1612fe705a *** empty log message ***
kono
parents: 125
diff changeset
2325 #endif
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2326 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2327 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2328
917947ffeb7c power pc version
kono
parents:
diff changeset
2329 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2330 global_table(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
2331 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2332 NMTBL *n;
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2333 int init; char *extrn;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2334 init=0;
917947ffeb7c power pc version
kono
parents:
diff changeset
2335 for(n=ntable;n < &ntable[GSYMS];n++) {
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2336 if ((n->sc == GVAR) && n->dsp != -1) {
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2337 /* n->dsp = -1 means initialized global */
917947ffeb7c power pc version
kono
parents:
diff changeset
2338 if (init==0) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2339 data_mode(0);
917947ffeb7c power pc version
kono
parents:
diff changeset
2340 init=1;
917947ffeb7c power pc version
kono
parents:
diff changeset
2341 }
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2342 printf(".comm _%s,%d\n",n->nm,size(n->ty));
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2343 } else if ((n->sc==STATIC) && n->dsp != -1) {
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2344 /* n->dsp = -1 means initialized global */
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2345 if (init==0) {
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2346 data_mode(0);
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2347 init=1;
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2348 }
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2349 printf(".lcomm _%s,%d\n",n->nm,size(n->ty));
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2350 }
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2351 }
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2352 for(n=ntable;n < &ntable[GSYMS];n++) {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2353 if (is_code(n)||is_function(n)) {
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2354 extrn = n->nm;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2355 if (n->sc==EXTRN1) {
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2356 data_mode(0);
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2357 printf(".picsymbol_stub\n");
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2358 printf("L_%s$stub:\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2359 printf("\t.indirect_symbol _%s\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2360 printf("\tmflr r0\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2361 printf("\tbcl 20,31,L0$_%s\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2362 printf("L0$_%s:\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2363 printf("\tmflr r11\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2364 printf("\taddis r11,r11,ha16(L_%s$lazy_ptr-L0$_%s)\n",extrn,extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2365 printf("\tmtlr r0\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2366 printf("\tlwz r12,lo16(L_%s$lazy_ptr-L0$_%s)(r11)\n",extrn,extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2367 printf("\tmtctr r12\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2368 printf("\taddi r11,r11,lo16(L_%s$lazy_ptr-L0$_%s)\n",extrn,extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2369 printf("\tbctr\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2370 printf(".data\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2371 printf(".lazy_symbol_pointer\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2372 printf("L_%s$lazy_ptr:\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2373 printf("\t.indirect_symbol _%s\n",extrn);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2374 printf("\t.long dyld_stub_binding_helper\n");
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2375 } else if (n->sc==FUNCTION||n->sc==CODE) {
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2376 text_mode();
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2377 printf("\t.set L_%s$stub,_%s\n",extrn,extrn);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2378 data_mode(0);
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2379 printf("L_%s$non_lazy_ptr:\n\t.long\t_%s\n",extrn,extrn);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2380 }
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2381 }
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2382 }
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2383 init=0;
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2384 for(n=ntable;n < &ntable[GSYMS];n++) {
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2385 if (n->sc == GVAR) {
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2386 if (init==0) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2387 printf(".data\n");
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2388 init=1;
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2389 }
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2390 printf("L_%s$non_lazy_ptr:\n\t.long\t_%s\n",n->nm,n->nm);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2391 }
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2392 }
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2393 init = 0;
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2394 for(n=ntable;n < &ntable[GSYMS];n++) {
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2395 if (is_code(n)||is_function(n)) continue;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2396 if (n->sc==EXTRN1) {
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2397 if(init==0) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2398 printf(".data\n");
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2399 printf(".non_lazy_symbol_pointer\n");
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2400 init=1;
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2401 }
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2402 printf("L_%s$non_lazy_ptr:\n",n->nm);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2403 printf("\t.indirect_symbol _%s\n",n->nm);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2404 printf("\t.long\t0\n");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2405 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2406 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2407 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2408
917947ffeb7c power pc version
kono
parents:
diff changeset
2409 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2410 local_table(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
2411 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2412 NMTBL *n;
917947ffeb7c power pc version
kono
parents:
diff changeset
2413 int init;
917947ffeb7c power pc version
kono
parents:
diff changeset
2414 init=0;
917947ffeb7c power pc version
kono
parents:
diff changeset
2415 /* static local variables */
917947ffeb7c power pc version
kono
parents:
diff changeset
2416 for(n=ntable+GSYMS;n < &ntable[GSYMS+LSYMS];n++) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2417 if (n->sc == GVAR) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2418 if (init==0) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2419 data_mode(0);
917947ffeb7c power pc version
kono
parents:
diff changeset
2420 init=1;
917947ffeb7c power pc version
kono
parents:
diff changeset
2421 }
156
da529eab5618 static initialization
kono
parents: 153
diff changeset
2422 if (n->dsp != -1) /* initialized static */
da529eab5618 static initialization
kono
parents: 153
diff changeset
2423 printf(".lcomm _%s,%d\n",n->nm,size(n->ty));
da529eab5618 static initialization
kono
parents: 153
diff changeset
2424 printf("L_%s$non_lazy_ptr:\n\t.long\t_%s\n",n->nm,n->nm);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2425 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2426 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2427 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2428
917947ffeb7c power pc version
kono
parents:
diff changeset
2429 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2430 text_mode(void)
917947ffeb7c power pc version
kono
parents:
diff changeset
2431 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2432 if (output_mode!=TEXT_EMIT_MODE) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2433 printf(".text\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
2434 printf("\t.align 2\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
2435 output_mode = TEXT_EMIT_MODE;
917947ffeb7c power pc version
kono
parents:
diff changeset
2436 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2437 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2438
917947ffeb7c power pc version
kono
parents:
diff changeset
2439 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2440 data_mode(char *name)
917947ffeb7c power pc version
kono
parents:
diff changeset
2441 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2442 if (output_mode!=DATA_EMIT_MODE) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2443 printf(".data\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
2444 output_mode = DATA_EMIT_MODE;
917947ffeb7c power pc version
kono
parents:
diff changeset
2445 }
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2446 /*
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2447 if (name)
917947ffeb7c power pc version
kono
parents:
diff changeset
2448 printf("\t.type\t%s,@object\n",name);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2449 */
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2450 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2451
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2452 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2453
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2454 /* floating point */
917947ffeb7c power pc version
kono
parents:
diff changeset
2455
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2456 static int float_one_lib_used=0;
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2457 static char *float_one_lib[] = {
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2458 ".data",
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2459 /* ".literal8", */
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2460 " .align 3",
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2461 "__float_one:",
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2462 " .long 1065353216",
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2463 ".text",
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2464 /* ".set L__float_one$non_lazy_ptr,__float_one", */
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2465 0
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2466 };
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2467 static int float_zero_lib_used=0;
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2468 static char *float_zero_lib[] = {
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2469 ".data",
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2470 /* ".literal8", */
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2471 " .align 3",
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2472 "__float_zero:",
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2473 " .long 0",
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2474 ".text",
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2475 /* ".set L__float_zero$non_lazy_ptr,__float_zero", */
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2476 0
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2477 };
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2478
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2479 char *
917947ffeb7c power pc version
kono
parents:
diff changeset
2480 fstore(int d)
917947ffeb7c power pc version
kono
parents:
diff changeset
2481 {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
2482 return (d?"stfd":"stfs");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2483 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2484
917947ffeb7c power pc version
kono
parents:
diff changeset
2485 char *
917947ffeb7c power pc version
kono
parents:
diff changeset
2486 fload(int d)
917947ffeb7c power pc version
kono
parents:
diff changeset
2487 {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
2488 return d?"lfd":"lfs";
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2489 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2490
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2491 void
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2492 code_cmp_dregister(int e2,int d)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2493 {
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2494 char *frn,*rrn,*grn;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2495 int greg,r;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2496 grn = register_name(greg = get_dregister(d));
132
07eb1249f07a *** empty log message ***
kono
parents: 131
diff changeset
2497 frn = register_name(e2);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2498 float_zero_lib_used=1;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2499 r = get_ptr_cache(&float_zero);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2500 rrn = register_name(r);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2501 printf("\tlfs %s,0(%s)\n",grn,rrn);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2502 printf("\tfcmpu cr0,%s,%s\n",grn,frn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2503 free_register(greg);
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2504 return;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2505 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2506
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2507 void
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2508 code_dregister(int e2,int freg,int d)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2509 {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2510 if (freg!=e2) {
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2511 if (is_int_reg(e2)) error(-1);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2512 printf("\tfmr %s,%s\n",fregister_name(freg),fregister_name(e2));
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2513 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2514 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2515
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2516 void code_dassign_gvar(int e2,int freg,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2517 {
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
2518 int r;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2519 r = get_ptr_cache((NMTBL*)cadr(e2));
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2520 if (!is_float_reg(freg)) error(-1);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2521 printf("\t%s %s,0(%s)\n",fstore(d),fregister_name(freg),register_name(r));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2522 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2523
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2524 void code_dassign_lvar(int e2,int freg,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2525 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2526 lvar_intro(e2);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2527 if (!is_float_reg(freg)) error(-1);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2528 printf("\t%s %s,",fstore(d),fregister_name(freg));
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2529 lvar(e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2530 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2531
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2532 void code_dassign(int e2,int freg,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2533 {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2534 if (!is_float_reg(freg)) error(-1);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2535 printf("\t%s %s,0(%s)\n",fstore(d),fregister_name(freg),register_name(e2));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2536 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2537
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2538 void
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2539 code_dassign_dregister(int e2,int d,int freg) {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2540 if (e2!=freg) {
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2541 if (is_int_reg(freg)) error(-1);
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2542 printf("\tfmr %s,%s\n",fregister_name(e2),fregister_name(freg));
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2543 }
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2544 }
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2545
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2546 static double d0 = 1.0;
917947ffeb7c power pc version
kono
parents:
diff changeset
2547
917947ffeb7c power pc version
kono
parents:
diff changeset
2548 int
917947ffeb7c power pc version
kono
parents:
diff changeset
2549 code_d1(double d)
917947ffeb7c power pc version
kono
parents:
diff changeset
2550 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2551 int *i = (int *)&d0; int *j = (int *)&d;
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2552 return (i[1] == 0x3ff00000)?j[0]:j[1];
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2553 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2554
917947ffeb7c power pc version
kono
parents:
diff changeset
2555 int
917947ffeb7c power pc version
kono
parents:
diff changeset
2556 code_d2(double d)
917947ffeb7c power pc version
kono
parents:
diff changeset
2557 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2558 int *i = (int *)&d0; int *j = (int *)&d;
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
2559 return (i[1] == 0x3ff00000)?j[1]:j[0];
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2560 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2561
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2562 int
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2563 code_f(double d)
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2564 {
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2565 float f = d;
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2566 int *j = (int *)&f;
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2567 return *j;
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2568 }
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2569
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2570 void
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2571 code_dconst(int e2,int freg,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2572 {
917947ffeb7c power pc version
kono
parents:
diff changeset
2573 int lb;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2574 double value = dcadr(e2);
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
2575 int r;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2576 char *rrn,*frn;
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2577 frn = fregister_name(freg);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2578 if (value==0.0) {
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2579 float_zero_lib_used=1;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2580 r = get_ptr_cache(&float_zero);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2581 rrn = register_name(r);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2582 printf("\tlfs %s,0(%s)\n",frn,rrn);
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2583 return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2584 }
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2585 if (value==1.0) {
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2586 float_one_lib_used=1;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2587 r = get_ptr_cache(&float_one);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2588 rrn = register_name(r);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2589 printf("\tlfs %s,0(%s)\n",frn,rrn);
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2590 return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2591 }
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2592 rrn = register_name((r=get_register()));
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2593 printf(" \t.data\n\t.align 3\n");
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2594 lb=fwdlabel();
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2595 printf("L_%d:\n",lb);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2596 if (d) {
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2597 printf("\t.long\t0x%x,0x%x\n",code_d2(value),code_d1(value));
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2598 } else {
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2599 printf("\t.long\t0x%x\n",code_f(value));
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2600 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2601 if (output_mode==TEXT_EMIT_MODE) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2602 printf(".text\n");
917947ffeb7c power pc version
kono
parents:
diff changeset
2603 } else {
917947ffeb7c power pc version
kono
parents:
diff changeset
2604 text_mode();
917947ffeb7c power pc version
kono
parents:
diff changeset
2605 }
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2606 printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",rrn,lb,code_base);
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2607 printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",rrn,lb,code_base,rrn);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2608 if (d) {
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2609 printf("\tlfd %s,0(%s)\n",frn,rrn);
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2610 } else {
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2611 printf("\tlfs %s,0(%s)\n",frn,rrn);
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2612 }
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
2613 free_register(r);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2614 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2615
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2616
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2617 void code_dneg(int freg,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2618 {
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2619 char *frn = fregister_name(freg);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2620 if (is_int_reg(freg)) error(-1);
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2621 printf("\tfneg %s,%s\n",frn,frn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2622 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2623
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2624 void code_d2i(int freg0)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2625 {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2626 char *frn;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2627 char *crn;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2628 int e2 = new_lvar(size_of_double);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2629
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2630 freg0 = use_double(freg0);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2631 frn = fregister_name(freg0);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2632 creg = use_int(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2633 crn = register_name(creg);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2634
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2635 freg = freg0;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2636 free_lvar(e2);
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
2637 printf("\tfctiwz %s,%s\n",frn,frn);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2638 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2639 printf("\tstfd %s,",frn); lvar(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2640 lvar_intro(e2+size_of_double-size_of_int);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2641 printf("\tlwz %s,",crn); lvar(e2+size_of_double-size_of_int);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2642 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2643
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2644 static int i2d_lib_used=0;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2645 static char *i2d_lib[] = {
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2646 ".data",
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2647 /* ".literal8", */
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2648 " .align 3",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2649 "__i2dLC0:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2650 " .long 1127219200",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2651 " .long -2147483648",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2652 ".text",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2653 " .align 2",
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2654 "i2d_:",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2655 " mflr r0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2656 " bcl 20,31,__i2dL1$pb",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2657 "__i2dL1$pb:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2658 " mflr r10",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2659 " mtlr r0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2660 " xoris r3,r3,0x8000",
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2661 " stw r3,-28(r30)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2662 " lis r0,0x4330",
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2663 " stw r0,-32(r30)",
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2664 " lfd f0,-32(r30)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2665 " addis r9,r10,ha16(__i2dLC0-__i2dL1$pb)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2666 " lfd f1,lo16(__i2dLC0-__i2dL1$pb)(r9)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2667 " fsub f1,f0,f1",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2668 " blr",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2669 0
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2670 };
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2671
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2672 void code_i2d(int creg0)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2673 {
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
2674 i2d_lib_used = 1;
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
2675 clear_ptr_cache();
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
2676 code_save_stacks();
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2677 set_creg(RET_REGISTER,1);
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2678 printf("\tbl i2d_\n");
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2679 set_freg(RET_FREGISTER,0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2680 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2681
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2682 static int d2u_lib_used=0;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2683 static char *d2u_lib[] = {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2684 /* ".literal8", */
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2685 " .align 3",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2686 "__d2uLC0:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2687 " .long 1105199104",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2688 " .long 0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2689 ".text",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2690 " .align 2",
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2691 "d2u_:",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2692 " mflr r0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2693 " bcl 20,31,__d2uL1$pb",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2694 "__d2uL1$pb:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2695 " mflr r10",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2696 " mtlr r0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2697 " addis r9,r10,ha16(__d2uLC0-__d2uL1$pb)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2698 " lfd f0,lo16(__d2uLC0-__d2uL1$pb)(r9)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2699 " fcmpu cr0,f1,f0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2700 " cror 2,1,2",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2701 " beq- cr0,__d2uL2",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2702 " fctiwz f0,f1",
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2703 " stfd f0,-32(r30)",
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2704 " lwz r3,-28(r30)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2705 " blr",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2706 "__d2uL2:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2707 " addis r9,r10,ha16(__d2uLC0-__d2uL1$pb)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2708 " lfd f0,lo16(__d2uLC0-__d2uL1$pb)(r9)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2709 " fsub f0,f1,f0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2710 " fctiwz f0,f0",
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2711 " stfd f0,-24(r30)",
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2712 " lwz r3,-20(r30)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2713 " xoris r3,r3,0x8000",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2714 " blr",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2715 0
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2716 };
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2717
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2718 void code_d2u(int freg0)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2719 {
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
2720 code_save_stacks();
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
2721 clear_ptr_cache();
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2722 d2u_lib_used=1;
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2723 set_freg(RET_FREGISTER,1);
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2724 printf("\tbl d2u_\n");
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
2725 set_creg(RET_REGISTER,0);
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2726 }
90
07e3113c3c13 *** empty log message ***
kono
parents: 89
diff changeset
2727
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2728 static int u2d_lib_used=0;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2729 static char *u2d_lib[] = {
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2730 ".data",
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2731 /* ".literal8", */
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2732 " .align 3",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2733 "__u2dLC1:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2734 " .long 1127219200",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2735 " .long 0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2736 ".text",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2737 " .align 2",
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2738 "u2d_:",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2739 " mflr r0",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2740 " bcl 20,31,__u2dL2$pb",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2741 "__u2dL2$pb:",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2742 " mflr r10",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2743 " mtlr r0",
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2744 " stw r3,-28(r30)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2745 " lis r0,0x4330",
116
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2746 " stw r0,-32(r30)",
b14ff9671c90 register offset fix
kono
parents: 115
diff changeset
2747 " lfd f0,-32(r30)",
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2748 " addis r9,r10,ha16(__u2dLC1-__u2dL2$pb)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2749 " lfd f1,lo16(__u2dLC1-__u2dL2$pb)(r9)",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2750 " fsub f1,f0,f1",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2751 " blr",
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2752 0
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2753 };
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2754
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2755 void code_u2d(int creg0)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2756 {
113
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
2757 code_save_stacks();
a9261154cde9 integer operation debug
kono
parents: 112
diff changeset
2758 clear_ptr_cache();
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2759 u2d_lib_used = 1;
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2760 set_creg(RET_REGISTER,1);
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2761 printf("\tbl u2d_\n");
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2762 set_freg(FREG_FREGISTER,0);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2763 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2764
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2765 void code_d2f(int freg) { }
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2766 void code_f2d(int freg) { }
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2767 void code_f2i(int freg) { code_d2i(freg); }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2768 void code_f2u(int freg) { code_d2u(freg); }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2769 void code_i2f(int creg) { code_i2d(creg); }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2770 void code_u2f(int creg) { code_u2d(creg); }
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2771
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
2772 void code_drgvar(int e2,int d,int freg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2773 {
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2774 int r;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2775 r = get_ptr_cache((NMTBL*)cadr(e2));
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2776 printf("\t%s %s,0(%s)\n",fload(d),fregister_name(freg),register_name(r));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2777 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2778
917947ffeb7c power pc version
kono
parents:
diff changeset
2779
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
2780 void code_drlvar(int e2,int d,int freg)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2781 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2782 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2783 printf("\t%s %s,",fload(d),fregister_name(freg)); lvar(e2);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2784 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2785
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2786 void code_cmp_drgvar(int e2,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2787 {
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2788 int r;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2789 char *frn=fregister_name(freg);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2790 int g=get_dregister(d);
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2791 char *grn=fregister_name(g);
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2792 r = get_ptr_cache((NMTBL*)cadr(e2));
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2793 printf("\t%s %s,0(%s)\n",fload(1),grn,register_name(r));
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2794 printf("\tfcmpu cr0,%s,%s\n",frn,grn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2795 free_register(g);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2796 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2797
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2798 void code_cmp_drlvar(int e2,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2799 {
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2800 char *frn=fregister_name(freg);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2801 int g=get_dregister(d);
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2802 char *grn=fregister_name(g);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2803
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2804 lvar_intro(e2);
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2805 printf("\t%s %s,",fload(1),grn); lvar(e2);
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2806 printf("\tfcmpu cr0,%s,%s\n",frn,grn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2807 free_register(g);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2808 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2809
917947ffeb7c power pc version
kono
parents:
diff changeset
2810 void dtosop(int op,int e1)
917947ffeb7c power pc version
kono
parents:
diff changeset
2811 {
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
2812 char *opn="";
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2813 char *frn=fregister_name(freg);
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2814 char *grn=fregister_name(e1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2815 switch(op) {
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2816 case FADD:
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2817 case DADD: opn="fadd"; break;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2818 case FSUB:
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
2819 case DSUB: opn="fsub"; break;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2820 case FDIV:
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
2821 case DDIV: opn="fdiv"; break;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2822 case FMUL:
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
2823 case DMUL: opn="fmul"; break;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2824 case FCMP:
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2825 case DCMP:
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2826 printf("\tfcmpu cr0,%s,%s\n",frn,grn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2827 free_register(e1);
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
2828 return;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2829 case FCMPGE:
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2830 case DCMPGE:
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2831 printf("\tfcmpu cr7,%s,%s\n",frn,grn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2832 free_register(e1);
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
2833 return;
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2834 default:
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2835 error(-1); return;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2836 }
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2837 printf("\t%s %s,%s,%s\n",opn,frn,frn,grn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2838 free_register(e1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2839 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2840
917947ffeb7c power pc version
kono
parents:
diff changeset
2841 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2842 code_dassop(int op,int d) {
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2843 /* we have lvalue in creg, applied floating value is in freg */
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2844 char *frn=fregister_name(freg);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2845 int xreg=emit_dpop(d);
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2846 char *crn=register_name(creg);
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2847
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2848 if (!is_float_reg(freg)) error(-1);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2849 printf("\t%s %s,0(%s)\n",fload(d),frn,crn);
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2850 dtosop(op,xreg);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2851 printf("\t%s %s,0(%s)\n",fstore(d),frn,crn);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2852 emit_dpop_free(xreg,d);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2853 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2854
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2855
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2856 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
2857 code_dpreinc(int e1,int e2,int d,int reg) {
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2858 char *frn;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2859 char *crn;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2860 int g;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2861 char *grn,*drn;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2862 int r;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2863 r = get_ptr_cache(&float_one);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2864 float_one_lib_used=1;
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2865
144
56211702f298 creg/freg continue
kono
parents: 141
diff changeset
2866 if (car(e2)==DREGISTER||car(e2)==FREGISTER) {
56211702f298 creg/freg continue
kono
parents: 141
diff changeset
2867 error(-1); /* unspported now */
56211702f298 creg/freg continue
kono
parents: 141
diff changeset
2868 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2869 g_expr(e2);
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2870
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2871 crn=register_name(creg);
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2872 frn=fregister_name(freg);
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2873 drn=register_name(r);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2874 grn=fregister_name(g=get_dregister(d));
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2875
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2876 printf("\t%s %s,0(%s)\n",fload(d),frn,crn);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2877 printf("\tlfs %s,0(%s)\n",grn,drn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2878 if (caddr(e1)>0)
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2879 printf("\tfadd %s,%s,%s\n",frn,frn,grn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2880 else
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2881 printf("\tfsub %s,%s,%s\n",frn,frn,grn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2882 if (!is_float_reg(freg)) error(-1);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2883 printf("\t%s %s,0(%s)\n",fstore(d),frn,crn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2884 free_register(g);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2885 creg = freg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2886 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2887
917947ffeb7c power pc version
kono
parents:
diff changeset
2888 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 106
diff changeset
2889 code_dpostinc(int e1,int e2,int d,int reg) {
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2890 char *frn;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2891 char *crn;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2892 int g;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2893 char *grn,*drn;
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2894 int r;
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2895 r = get_ptr_cache(&float_one);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2896 float_one_lib_used=1;
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2897
144
56211702f298 creg/freg continue
kono
parents: 141
diff changeset
2898 if (car(e2)==DREGISTER||car(e2)==FREGISTER) {
56211702f298 creg/freg continue
kono
parents: 141
diff changeset
2899 error(-1); /* unspported now */
56211702f298 creg/freg continue
kono
parents: 141
diff changeset
2900 }
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2901 g_expr(e2);
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2902
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2903 crn=register_name(creg);
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2904 frn=fregister_name(freg);
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2905 drn=register_name(r);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2906 grn=fregister_name(g=get_dregister(d));
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2907
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2908 printf("\t%s %s,0(%s)\n",fload(d),frn,crn);
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2909 printf("\tlfs %s,0(%s)\n",grn,drn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2910 if (caddr(e1)>0)
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2911 printf("\tfadd %s,%s,%s\n",grn,frn,grn);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2912 else
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2913 printf("\tfsub %s,%s,%s\n",grn,frn,grn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2914 if (!is_float_reg(freg)) error(-1);
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2915 printf("\t%s %s,0(%s)\n",fstore(d),grn,crn);
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2916 free_register(g);
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2917 creg = freg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2918 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2919
917947ffeb7c power pc version
kono
parents:
diff changeset
2920 void
917947ffeb7c power pc version
kono
parents:
diff changeset
2921 drexpr(int e1, int e2,int l1, int op)
917947ffeb7c power pc version
kono
parents:
diff changeset
2922 {
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2923 g_expr(list3(((op==DOP+GE)?DCMPGE:DCMP),e1,e2));
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2924 switch(op) {
917947ffeb7c power pc version
kono
parents:
diff changeset
2925 case DOP+GE:
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2926 case FOP+GE:
91
9b1aeb62e0b9 powerpc continue... (floating point)
kono
parents: 90
diff changeset
2927 printf("\tcror 2,29,30\n");
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2928 printf("\tbne\tcr0,L_%d\n",l1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2929 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
2930 case DOP+GT:
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2931 case FOP+GT:
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2932 printf("\tble\tcr0,L_%d\n",l1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2933 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
2934 case DOP+EQ:
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2935 case FOP+EQ:
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2936 printf("\tbne\tcr0,L_%d\n",l1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2937 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
2938 case DOP+NEQ:
133
7d436c08e949 separate float / double flow
kono
parents: 132
diff changeset
2939 case FOP+NEQ:
111
7aa449aff3e6 floating point
kono
parents: 110
diff changeset
2940 printf("\tbeq\tcr0,L_%d\n",l1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2941 break;
917947ffeb7c power pc version
kono
parents:
diff changeset
2942 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2943 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2944
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2945 int emit_dpop(int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2946 {
114
e6cb1e293b35 float/int passed.
kono
parents: 113
diff changeset
2947 int xreg,reg;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2948 xreg=pop_fregister();
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2949 if (xreg<= -REG_LVAR_OFFSET) {
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2950 reg = get_dregister(d);
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
2951 code_drlvar(REG_LVAR_OFFSET+xreg,1,reg);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
2952 free_lvar(REG_LVAR_OFFSET+xreg);
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
2953 xreg=reg;
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2954 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
2955 return xreg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2956 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2957
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2958 void emit_dpop_free(int e1,int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2959 {
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2960 free_register(e1);
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2961 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2962
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2963 void emit_dpush(int d)
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2964 {
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2965 int new_reg;
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 101
diff changeset
2966 if (freg_sp>MAX_MAX) error(-1);
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
2967 new_reg = get_dregister(1);
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
2968 freg_stack[freg_sp++] = freg; /* push するかわりにレジスタを使う */
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 145
diff changeset
2969 creg = freg = new_reg;
89
917947ffeb7c power pc version
kono
parents:
diff changeset
2970 }
917947ffeb7c power pc version
kono
parents:
diff changeset
2971
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2972 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2973
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2974 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2975
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2976
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2977 /* 64bit int part */
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2978
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2979 void lrexpr(int e1, int e2,int l1, int op)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2980 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2981 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2982
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2983 int lpop_register()
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2984 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2985 return 0;
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2986 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2987
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2988 int emit_lpop()
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2989 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2990 return 0;
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2991 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2992
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2993 void code_lregister(int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2994 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2995
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2996 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2997
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2998 void code_cmp_lregister(int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
2999 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3000
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3001 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3002
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3003 void code_cmp_lrgvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3004 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3005
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3006 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3007
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3008 void code_cmp_lrlvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3009 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3010
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3011 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3012
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3013 void code_lassign(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3014 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3015
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3016 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3017
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3018 void code_lassign_gvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3019 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3020
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3021 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3022
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3023 void code_lassign_lvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3024 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3025
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3026 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3027
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3028 void code_lassign_lregister(int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3029 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3030
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3031 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3032
206
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3033 static long long ll = 1LL;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3034
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3035 static int
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3036 code_l1(long long d)
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3037 {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3038 int *i = (int *)&ll; int *j = (int *)&d;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3039 return (i[1] == 1)?j[1]:j[0];
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3040 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3041
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3042 static int
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3043 code_l2(long long d)
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3044 {
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3045 int *i = (int *)&ll; int *j = (int *)&d;
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3046 return (i[1] == 1)?j[0]:j[1];
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3047 }
4170cefb48f6 *** empty log message ***
kono
parents: 205
diff changeset
3048
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3049 void code_lconst(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3050 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3051
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3052 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3053
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3054 void code_lneg(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3055 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3056
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3057 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3058
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3059 void code_lrgvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3060 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3061
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3062 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3063
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3064 void code_lrlvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3065 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3066
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3067 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3068
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3069 void ltosop(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3070 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3071
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3072 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3073
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3074 void emit_lpop_free(int e1)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3075 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3076
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3077 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3078
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3079 void emit_lpush()
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3080 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3081
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3082 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3083
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3084 void code_i2ll(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3085 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3086
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3087 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3088
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3089 void code_i2ull(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3090 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3091
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3092 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3093
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3094 void code_u2ll(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3095 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3096
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3097 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3098
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3099 void code_u2ull(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3100 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3101
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3102 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3103
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3104 void code_ll2i(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3105 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3106
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3107 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3108
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3109 void code_ll2u(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3110 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3111
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3112 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3113
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3114 void code_ull2i(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3115 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3116
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3117 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3118
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3119 void code_ull2u(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3120 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3121
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3122 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3123
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3124 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3125 void code_d2ll(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3126 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3127
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3128 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3129
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3130 void code_d2ull(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3131 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3132
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3133 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3134
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3135 void code_f2ll(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3136 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3137
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3138 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3139
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3140 void code_f2ull(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3141 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3142
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3143 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3144
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3145 void code_ll2d(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3146 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3147
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3148 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3149
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3150 void code_ll2f(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3151 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3152
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3153 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3154
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3155 void code_ull2d(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3156 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3157
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3158 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3159
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3160 void code_ull2f(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3161 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3162
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3163 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3164
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3165 void code_ull2ll(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3166 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3167
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3168 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3169
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3170 void code_ull2ull(int creg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3171 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3172
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3173 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3174
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3175 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3176
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3177
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3178 void code_lpreinc(int e1,int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3179 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3180
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3181 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3182
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3183 void code_lpostinc(int e1,int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3184 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3185
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3186 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3187
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3188 void code_lassop(int op)
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3189 {
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3190
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3191 }
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3192
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3193
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3194 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3195
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3196 void
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3197 code_save_stacks()
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3198 {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3199 int i,reg;
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3200 for(i=0;i<reg_sp;i++) {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3201 if ((reg=reg_stack[i])>=0) {
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3202 code_assign_lvar(
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
3203 (reg_stack[i]=new_lvar(size_of_int)),reg,0);
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3204 reg_stack[i]= reg_stack[i]-REG_LVAR_OFFSET;
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3205 }
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3206 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3207 #if FLOAT_CODE
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3208 for(i=0;i<freg_sp;i++) {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3209 if ((reg=freg_stack[i])>=0) {
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3210 code_dassign_lvar(
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
3211 (freg_stack[i]=new_lvar(size_of_double)),reg,1);
101
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3212 freg_stack[i]= freg_stack[i]-REG_LVAR_OFFSET;
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3213 }
05f197a4573a *** empty log message ***
kono
parents: 100
diff changeset
3214 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3215 #endif
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3216 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3217
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3218 void
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3219 emit_lib(char *p[])
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3220 {
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
3221 while(*p) {
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
3222 printf("%s\n",*p++);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3223 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3224 }
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3225
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3226 void
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3227 code_closing()
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3228 {
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3229 #if FLOAT_CODE
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3230 if (d2u_lib_used) emit_lib(d2u_lib);
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3231 if (u2d_lib_used) emit_lib(u2d_lib);
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3232 if (float_one_lib_used) emit_lib(float_one_lib);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
3233 if (float_zero_lib_used) emit_lib(float_zero_lib);
96
7d8de41390d8 *** empty log message ***
kono
parents: 95
diff changeset
3234 if (i2d_lib_used) emit_lib(i2d_lib);
195
c193120ee2a6 *** empty log message ***
kono
parents: 189
diff changeset
3235 #endif
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
3236 global_table();
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
3237 /* printf("\t.ident \"Micro-C compiled\"\n"); */
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3238 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 93
diff changeset
3239
89
917947ffeb7c power pc version
kono
parents:
diff changeset
3240 /* end */
917947ffeb7c power pc version
kono
parents:
diff changeset
3241