annotate mc-code-powerpc.c @ 181:4beb7f079055

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