annotate mc-code-ia32.c @ 852:4640447d80ef

fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 21 Nov 2011 19:52:25 +0900 (2011-11-21)
parents 1547193bddde
children c005a392e27e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
326
e5d40f8c4cce bit-field continue.
kono
parents: 320
diff changeset
1 /* Micro-C Code Generation Part for intel386 */
608
c3ba27861c83 fix struct alignment in local init.
kono
parents: 607
diff changeset
2
c3ba27861c83 fix struct alignment in local init.
kono
parents: 607
diff changeset
3 /************************************************************************
607
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
4 ** Copyright (C) 2006 Shinji Kono
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
5 ** 連絡先: 琉球大学情報工学科 河野 真治
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
6 ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp)
607
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
7 **
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
8 ** このソースのいかなる複写,改変,修正も許諾します。ただし、
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
9 ** その際には、誰が貢献したを示すこの部分を残すこと。
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
10 ** 再配布や雑誌の付録などの問い合わせも必要ありません。
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
11 ** 営利利用も上記に反しない範囲で許可します。
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
12 ** バイナリの配布の際にはversion messageを保存することを条件とします。
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
13 ** このプログラムについては特に何の保証もしない、悪しからず。
607
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
14 **
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
15 ** Everyone is permitted to do anything on this program
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
16 ** including copying, modifying, improving,
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
17 ** as long as you don't try to pretend that you wrote it.
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
18 ** i.e., the above copyright notice has to appear in all copies.
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
19 ** Binary distribution requires original version messages.
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
20 ** You don't have to ask before copying, redistribution or publishing.
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
21 ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
22 ***********************************************************************/
608
c3ba27861c83 fix struct alignment in local init.
kono
parents: 607
diff changeset
23
607
e055df7c1082 *** empty log message ***
kono
parents: 605
diff changeset
24
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
25
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
26 #include <stdio.h>
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
27 #include "mc.h"
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
28 #include "mc-parse.h"
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
29 #include "mc-codegen.h"
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
30 #include "mc-code.h"
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
31
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
32 #ifdef __APPLE__
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
33 #define USE_SSE2
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
34 #define USE_PIC
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
35 #endif
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
36
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
37 #if defined(__GNUC__) && __GNUC__ >= 4
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
38
615
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
39 #include "mc-include.c"
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
40
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
41 static
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
42 char *init_src0 = "\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
43 #define __builtin_va_list int\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
44 #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
45 #define __builtin_va_arg(ap,type) (*((type *)ap)++)\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
46 #define alloca __builtin_alloca\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
47 #define __STDC__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
48 #define __extension__\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
49 #define __flexarr\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
50 #define __const const\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
51 #define __THORW\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
52 #define __inline__ inline\n\
570
266ded1a8fef *** empty log message ***
kono
parents: 569
diff changeset
53 #define __inline inline\n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
54 \n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
55 #define __DBL_MIN_EXP__ (-1021)\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
56 #define __FLT_MIN__ 1.17549435e-38F\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
57 #define __CHAR_BIT__ 8\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
58 #define __WCHAR_MAX__ 2147483647\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
59 #define __DBL_DENORM_MIN__ 4.9406564584124654e-324\n\
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
60 #define __FLT_EVAL_METHOD__ 0\n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
61 #define __DBL_MIN_10_EXP__ (-307)\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
62 #define __FINITE_MATH_ONLY__ 0\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
63 #define __SHRT_MAX__ 32767\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
64 #define __LDBL_MAX__ 1.18973149535723176502e+4932L\n\
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
65 #define __APPLE_CC__ 5367\n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
66 #define __UINTMAX_TYPE__ long long unsigned int\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
67 #define __SCHAR_MAX__ 127\n\
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
68 #define __USER_LABEL_PREFIX__ _\n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
69 #define __STDC_HOSTED__ 1\n\
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
70 #define __DBL_DIG__ 15\n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
71 #define __FLT_EPSILON__ 1.19209290e-7F\n\
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
72 #define __LDBL_MIN__ 3.36210314311209350626e-4932L\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
73 #define __strong \n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
74 #define __DECIMAL_DIG__ 21\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
75 #define __LDBL_HAS_QUIET_NAN__ 1\n\
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
76 #define __DYNAMIC__ 1\n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
77 #define __GNUC__ 4\n\
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
78 #define __MMX__ 1\n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
79 #define __DBL_MAX__ 1.7976931348623157e+308\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
80 #define __DBL_HAS_INFINITY__ 1\n\
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
81 #define __weak \n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
82 #define __DBL_MAX_EXP__ 1024\n\
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
83 #define __SSE2_MATH__ 1\n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
84 #define __LONG_LONG_MAX__ 9223372036854775807LL\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
85 #define __GXX_ABI_VERSION 1002\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
86 #define __FLT_MIN_EXP__ (-125)\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
87 #define __DBL_MIN__ 2.2250738585072014e-308\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
88 #define __DBL_HAS_QUIET_NAN__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
89 #define __REGISTER_PREFIX__ \n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
90 #define __NO_INLINE__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
91 #define __i386 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
92 #define __FLT_MANT_DIG__ 24\n\
664
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
93 #define __tune_nocona__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
94 #define i386 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
95 #define __i386__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
96 #define __SIZE_TYPE__ long unsigned int\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
97 #define __FLT_RADIX__ 2\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
98 #define __LDBL_EPSILON__ 1.08420217248550443401e-19L\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
99 #define __SSE_MATH__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
100 #define __FLT_HAS_QUIET_NAN__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
101 #define __FLT_MAX_10_EXP__ 38\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
102 #define __LONG_MAX__ 2147483647L\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
103 #define __FLT_HAS_INFINITY__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
104 #define __LITTLE_ENDIAN__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
105 #define __LDBL_MANT_DIG__ 64\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
106 #define __CONSTANT_CFSTRINGS__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
107 #define __WCHAR_TYPE__ int\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
108 #define __FLT_DIG__ 6\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
109 #define __INT_MAX__ 2147483647\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
110 #define __nocona 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
111 #define __FLT_MAX_EXP__ 128\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
112 #define __DBL_MANT_DIG__ 53\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
113 #define __WINT_TYPE__ int\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
114 #define __SSE__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
115 #define __LDBL_MIN_EXP__ (-16381)\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
116 #define __MACH__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
117 #define __LDBL_MAX_EXP__ 16384\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
118 #define __LDBL_MAX_10_EXP__ 4932\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
119 #define __DBL_EPSILON__ 2.2204460492503131e-16\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
120 #define __GNUC_PATCHLEVEL__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
121 #define __LDBL_HAS_INFINITY__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
122 #define __INTMAX_MAX__ 9223372036854775807LL\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
123 #define __FLT_DENORM_MIN__ 1.40129846e-45F\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
124 #define __PIC__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
125 #define __FLT_MAX__ 3.40282347e+38F\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
126 #define __SSE2__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
127 #define __FLT_MIN_10_EXP__ (-37)\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
128 #define __INTMAX_TYPE__ long long int\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
129 #define __nocona__ 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
130 #define __GNUC_MINOR__ 0\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
131 #define __DBL_MAX_10_EXP__ 308\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
132 #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
133 #define __PTRDIFF_TYPE__ int\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
134 #define __LDBL_MIN_10_EXP__ (-4931)\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
135 #define __LDBL_DIG__ 18\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
136 #define __i386 1\n\
ec1bac997e50 fix 387 floating point stack overflow
kono
parents: 638
diff changeset
137 #define __FLT_MANT_DIG__ 24\n\
672
3f559c67bc86 *** empty log message ***
kono
parents: 671
diff changeset
138 #define __VERSION__ \"micro-c mc-code-ia32.c kono Exp $\"\n\
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
139 #define i386 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
140 #define __i486__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
141 #define unix 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
142 #define __i386__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
143 #define __SIZE_TYPE__ unsigned int\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
144 #define __ELF__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
145 #define __FLT_RADIX__ 2\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
146 #define __FLT_HAS_QUIET_NAN__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
147 #define __FLT_MAX_10_EXP__ 38\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
148 #define __LONG_MAX__ 2147483647L\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
149 #define __FLT_HAS_INFINITY__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
150 #define linux 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
151 #define __LDBL_MANT_DIG__ 64\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
152 #define __WCHAR_TYPE__ int\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
153 #define __FLT_DIG__ 6\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
154 #define __INT_MAX__ 2147483647\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
155 #define __i486 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
156 #define __FLT_MAX_EXP__ 128\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
157 #define __DBL_MANT_DIG__ 53\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
158 #define __WINT_TYPE__ unsigned int\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
159 #define __LDBL_MIN_EXP__ (-16381)\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
160 #define __LDBL_MAX_10_EXP__ 4932\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
161 #define __DBL_EPSILON__ 2.2204460492503131e-16\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
162 #define __tune_i486__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
163 #define __INTMAX_MAX__ 9223372036854775807LL\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
164 #define __FLT_DENORM_MIN__ 1.40129846e-45F\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
165 #define __FLT_MAX__ 3.40282347e+38F\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
166 #define __FLT_MIN_10_EXP__ (-37)\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
167 #define __INTMAX_TYPE__ long long int\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
168 #define __GNUC_MINOR__ 0\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
169 #define __DBL_MAX_10_EXP__ 308\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
170 #define __PTRDIFF_TYPE__ int\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
171 #define __LDBL_MIN_10_EXP__ (-4931)\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
172 #define __LDBL_DIG__ 18\n\
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
173 "
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
174 #ifdef __APPLE__
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
175 "#define __APPLE__ 1\n"
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
176 "#define __GNUC__ 4\n"
635
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
177 "#define __BIG_ENDIAN__ 1\n"
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
178 #endif
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
179 ;
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
180
615
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
181 /*
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
182
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
183 #define size_t int\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
184
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
185 */
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
186
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
187 #else
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
188
615
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
189 #include "mc-include.c"
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
190
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
191 #if defined(__GNUC__) && __GNUC__ >= 3
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
192 static
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
193 char *init_src0 = "\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
194 #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
195 #define __builtin_va_arg(ap,type) (*((type *)ap)++)\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
196 #define __builtin_va_end\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
197 #define __i386__ 1\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
198 #define __LITTLE_ENDIAN__ 1\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
199 #define __STDC__ 1\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
200 #define __extension__\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
201 // #define __restrict\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
202 #define __flexarr\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
203 #define __const const\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
204 #define __THORW\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
205 // #define __attribute__(a)\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
206 #define __inline__ inline\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
207 #define __inline inline\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
208 #define __GNUC__ 3\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
209 #define __builtin_va_list int\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
210 typedef long unsigned int __SIZE_TYPE__ ;\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
211 "
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
212
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
213 #else
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
214 static
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
215 char *init_src0 = "\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
216 #define va_list int\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
217 #define va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
218 #define va_arg(ap,type) (*((type *)ap)++)\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
219 #define va_end\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
220 #define __i386__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
221 #define __LITTLE_ENDIAN__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
222 #define __STDC__ 1\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
223 #define __extension__\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
224 // #define __restrict\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
225 #define __flexarr\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
226 #define __const const\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
227 #define __THORW\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
228 // #define __attribute__(a)\n\
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
229 #define __inline__ inline\n\
615
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
230 #define __SIZE_TYPE__ long unsigned int\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
231 #define __GNUC__ 3\n\
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
232 "
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
233
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
234 #endif
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
235
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
236
2dee957ef988 test case on undeclared name
kono
parents: 608
diff changeset
237 ;
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
238
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
239 #endif
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
240
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
241 int data_alignment = 0;
173
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
242
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
243 #define SIZE_OF_INT 4
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
244 #define SIZE_OF_SHORT 2
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
245 #define SIZE_OF_FLOAT 4
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
246 #define SIZE_OF_DOUBLE 8
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
247 #define SIZE_OF_LONGLONG 8
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
248 #define ENDIAN 0
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
249 #define ENDIAN_L 0
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
250 #define ENDIAN_D 0
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
251
555
ac181d7f9c82 IA32 eval order
kono
parents: 553
diff changeset
252 int eval_order = REVERSE;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
253
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
254 #define TEXT_EMIT_MODE 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
255 #define DATA_EMIT_MODE 1
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
256 #define RODATA_EMIT_MODE 2
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
257
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
258 #ifdef __APPLE__
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
259 #else
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
260 #define DOT_SIZE 1
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
261 #endif
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
262
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
263 static int output_mode = TEXT_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
264
224
82a55cc6b5fc *** empty log message ***
kono
parents: 219
diff changeset
265 static int creg;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
266 static int ireg;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
267 static int lreg;
224
82a55cc6b5fc *** empty log message ***
kono
parents: 219
diff changeset
268
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
269 #define regv_l(r) (r==REG_L?REG_ESI:REG_EAX)
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
270 #define regv_h(r) (r==REG_L?REG_EDI:REG_EDX)
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
271
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
272 int code_lassop_p = 0;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
273
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
274 #define MAX_REGISTER 6 /* intel386のレジスタを6つまで使う*/
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
275 #define REAL_MAX_REGISTER 8 /* intel386のレジスタが8つということ*/
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
276 static int MAX_DATA_REG=4;
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
277 static int MAX_POINTER=3;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
278 int MAX_REGISTER_VAR=2;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
279 // static int MAX_FREGISTER=1;
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
280
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
281 #define MAX_FPU_STACK 7
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
282
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
283 // static int MAX_INPUT_REGISTER_VAR = 0;
466
7c3d8237b625 *** empty log message ***
kono
parents: 458
diff changeset
284 int MAX_CODE_INPUT_REGISTER_VAR = 2;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
285 // static int MAX_INPUT_DREGISTER_VAR = 0;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
286 // static int MAX_INPUT_FREGISTER_VAR = 0;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
287 // static int MAX_CODE_INPUT_DREGISTER_VAR = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
288
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
289 static int reg_sp; /* REGister Stack-Pointer */
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
290 static int reg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
291 static int stack_depth = 0;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
292
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
293 /* floating point registers */
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
294
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
295 static int freg_sp; /* floating point REGister Stack-Pointer */
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
296 static int freg_stack[MAX_MAX]; /* 実際のレジスタの領域 */
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
297
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
298 static int reg_var;
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
299
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
300
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
301 /*
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
302 -28 -8 local2
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
303 -24 -4 local1
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
304 -20 8 arg3
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
305 -16 4 arg2
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
306 -12 0 arg1
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
307 local2 -20 4 -8 (%edi)
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
308 local1 <-- -16 0 local variable -4 (%esi)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
309 %edi -12 <- disp_offset %ebp
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
310 %esi -8
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
311 %ebx -4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
312 %ebp = %esp 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
313 %eip 4 <- arg_offset
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
314 arg1 8 0
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
315 arg2 12 4
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
316 see enter/enter1/leave see code_enter
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
317 */
670
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
318 // static int arg_offset;
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
319
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
320 static int code_disp_label;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
321
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
322 #ifdef __APPLE__
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
323 static int goffset_label;
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
324 #endif
263
c922bade771d MIPS go on...
kono
parents: 258
diff changeset
325
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
326
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
327 /*
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
328 creg current register
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
329 ireg current register for integer (int mode)
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
330 lreg current register for long long (long long mode)
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
331
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
332 regs[] register usage
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
333
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
334 freg current floating point register
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
335 kept in FPU stack (no register)
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
336 */
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
337
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
338 #define REAL_MAX_LREGISTER 2
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
339 static int ia32regs[1+REAL_MAX_REGISTER+REAL_MAX_LREGISTER];
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
340
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
341
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
342 static int *regs = ia32regs;
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
343
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
344 static int ia32fregs[1];
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
345 static int *fregs = ia32fregs;
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
346 static int freg;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
347
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
348 // register number should start 1
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
349 // regs[] value
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
350 // 0 for not ready
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
351 // -1 use currrent register
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
352 // 1 used
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
353 // 2 (REG_VAR) register variable
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
354 // 3 pointer cache (not used in ia32)
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
355
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
356 #define REG_EAX 1
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
357 #define REG_EBX 2
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
358 #define REG_ECX 3 // for strange reason (code_assop)
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
359 #define REG_EDX 4
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
360 #define REG_ESI 5
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
361 #define REG_EDI 6
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
362 #define REG_EBP 7
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
363 #define REG_ESP 8
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
364 #define is_int_reg(reg) (1<=reg&&reg<REG_EBP)
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
365 #define REG_LCREG 9
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
366 #define REG_L 10
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 570
diff changeset
367 #define REG_fp REG_EBP
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
368
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
369 // return value register
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
370 #define RET_FREGISTER
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
371 #define RET_DREGISTER
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
372 #define RET_LREGISTER REG_LCREG
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
373 #define RET_REGISTER REG_EAX
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
374
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
375 // defalut current register
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
376 #define CREG_REGISTER REG_ECX
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
377 #define FREG_FREGISTER 0
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
378
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
379 static char *reg_name[8+1];
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
380 static char *reg_name_l[4+1];
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
381 static char *reg_name_w[4+1];
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
382
518
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
383 static void ascii(char *s);
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
384
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
385 static int use_register(int virt, int real, int move);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
386 static void shift(char *op, int reg,int creg);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
387 static void ld_indexx(int byte, int n, int xreg,int reg,int sign);
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
388 //static void data_mode(char *name);
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
389 // static void text_mode(int align);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
390 static int get_data_register(void);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
391
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
392 static void local_table(void);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
393 static int push_struct(int e4,int t, int arg) ;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
394 static void code_clear_stack_reg(int reg1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
395 #if FLOAT_CODE
93
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
396 static char * fload(int d);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
397 static int code_d1(double d);
8f5d61239b93 *** empty log message ***
kono
parents: 92
diff changeset
398 static int code_d2(double d);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
399 static void code_save_fstacks();
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
400 #endif
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
401 static void jcond(int l, char cond);
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
402 #if LONGLONG_CODE
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
403 static int code_l1(long long d);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
404 static int code_l2(long long d);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
405 #endif
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
406
716
21f770a3b298 *** empty log message ***
kono
parents: 715
diff changeset
407 #define round16(i) align(i,16)
21f770a3b298 *** empty log message ***
kono
parents: 715
diff changeset
408 #define round4(i) align(i,4)
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
409
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
410
676
5e71527f9fd6 *** empty log message ***
kono
parents: 675
diff changeset
411 #define func_disp_offset (16)
5e71527f9fd6 *** empty log message ***
kono
parents: 675
diff changeset
412 #define code_disp_offset (16)
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
413
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
414 #define arg_offset 8
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
415 #define arg_offset1 0
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
416 #define ARG_LVAR_OFFSET 0x10000000
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
417
676
5e71527f9fd6 *** empty log message ***
kono
parents: 675
diff changeset
418 #define code_disp_offset0 (-16)
671
85e0509832f1 *** empty log message ***
kono
parents: 670
diff changeset
419 // disp_offset
85e0509832f1 *** empty log message ***
kono
parents: 670
diff changeset
420 int disp_offset = code_disp_offset0;
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
421
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
422 #define CODE_LVAR(l) ((l)+code_disp_offset0)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
423 #define CODE_CALLER_ARG(l) ((l)+arg_offset1)
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
424 #define FUNC_LVAR(l) ((l)-func_disp_offset)
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
425 #define CALLER_ARG(l) ((l)+arg_offset1)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
426 #define CALLEE_ARG(l) ((l)+arg_offset)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
427 static int r1_offset_label;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
428 static const char lpfx[] = "_";
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
429 // static int lvar_offset_label;
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
430 static int max_func_args,max_func_arg_label;
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
431
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
432 /*
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
433 function call stack frame
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
434 prev esp
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
435 <-------r1_offset------------------------------>
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
436 <----- ebp--> <----- esp
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
437 r+ +------------+---+---------------+----------+-------------------+ -
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
438 callee arg xx register save local caller arg
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
439 reg_save disp max_func_args*SIZE_OF_INT
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
440 lvar>0 lvar<0 lvar>0x1000 0000
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
441
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
442 code segment stack frame
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
443
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
444 * gotoを呼び出した関数のr1 ! r1(goto前のr1)
671
85e0509832f1 *** empty log message ***
kono
parents: 670
diff changeset
445 disp_offset
85e0509832f1 *** empty log message ***
kono
parents: 670
diff changeset
446 # * ebp <---r1_offset---------> esp
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
447 r+ +----------+--+----------+----------------+-----------+----------+----+
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
448 cousin arg xx reg save !callee arg !code local caller arg xx
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
449 r20-r29 lvar>0 lvar<0 lvar>0x1000 000
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
450 f20-f31 <-my_func_args--><--disp-----><-max_func_arg->
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
451 *SIZE_OF_INT *SIZE_OF_INT
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
452
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
453 %esp should be alignment 16
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
454
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
455 */
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
456
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
457 void
670
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
458 code_offset_set(NMTBL *fnptr)
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
459 {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
460 #if 0
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
461 int l;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
462 #endif
670
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
463 int code_f = is_code(fnptr);
676
5e71527f9fd6 *** empty log message ***
kono
parents: 675
diff changeset
464 int lvar_offsetv = round16(-disp);
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
465 int r1_offsetv = round16(lvar_offsetv+max_func_args*SIZE_OF_INT+func_disp_offset)+8;
670
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
466
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
467 if (code_f) {
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
468 printf("\t.set _%d,%d\n",code_disp_label,r1_offsetv);
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
469 } else {
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
470 // +8 makes esp alignment 16
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
471 // printf(".set %s%d,%d\n",lpfx,lvar_offset_label,lvar_offsetv);
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
472 if (r1_offsetv-lvar_offsetv > 65000) error(-1);
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
473 // too large function arguments?
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
474 printf(".set %s%d,%d\n",lpfx,r1_offset_label,r1_offsetv);
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
475 }
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
476 if (max_func_arg_label) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
477 printf(".set %s%d,%d\n",lpfx,max_func_arg_label,
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
478 round16(max_func_args*SIZE_OF_INT));
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
479 max_func_arg_label = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
480 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
481
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
482 #if 0
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
483 printf("## reg_save %d\n",reg_save);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
484 printf("## function %s\n",fnptr->nm);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
485 l = ARG_LVAR_OFFSET;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
486 printf("## offset call0\t%d\n",CALLER_ARG);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
487 l = ARG_LVAR_OFFSET+max_func_args*SIZE_OF_INT;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
488 printf("## offset calln\t%d %d\n",CALLER_ARG,max_func_args*SIZE_OF_INT);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
489 l = disp;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
490 printf("## offset lvarn\t%d %d\n",FUNC_LVAR+lvar_offsetv,disp);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
491 l = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
492 printf("## offset lvar0\t%d\n",FUNC_LVAR+lvar_offsetv);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
493 l = -reg_save;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
494 printf("## offset regs\t%d\n",FUNC_LVAR+lvar_offsetv);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
495 printf("## offset r1off\t%d\n",r1_offsetv);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
496 l = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
497 printf("## offset carg0\t%d\n",CALLEE_ARG+r1_offsetv);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
498 l = my_func_args;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
499 printf("## offset cargn\t%d %d\n",CALLEE_ARG+r1_offsetv,my_func_args);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
500 #endif
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
501 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
502
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
503
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
504 static void
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
505 lvar(int l)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
506 {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
507 if (is_code(fnptr)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
508 if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
509 printf("%d(%%esp)",CODE_CALLER_ARG(l-ARG_LVAR_OFFSET));
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
510 } else
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
511 printf("%d(%%ebp)",CODE_LVAR(l));
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
512 } else if (l<0) { /* local variable */
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
513 printf("%d(%%ebp)",FUNC_LVAR(l));
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
514 } else if (l>=ARG_LVAR_OFFSET) { /* caller's arguments */
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
515 printf("%d(%%esp)",CALLER_ARG(l-ARG_LVAR_OFFSET));
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
516 } else { /* callee's arguments */
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
517 printf("%d(%%ebp)",CALLEE_ARG(l));
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
518 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
519 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
520
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
521
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
522 #define use_int(reg) if (reg==-1) reg=use_int0()
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
523
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
524 static int
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
525 use_int0() {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
526 int i = creg;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
527 if (!i||!ireg||!is_int_reg(i)) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
528 if (lreg) { if (regs[lreg]) free_register(lreg); lreg = 0; }
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
529 if (!ireg) {
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
530 ireg = get_register();
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
531 }
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
532 i = ireg;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
533 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
534 if (!regs[i]) regs[i]=USING_REG;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
535 creg = ireg = i;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
536 return i;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
537 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
538
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
539 #define is_data_reg(reg) (REG_EAX<=reg&&reg<=REG_EDX)
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
540 #define is_pointer_reg(reg) (REG_ESI<=reg&&reg<=REG_EBP)
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
541
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
542 static int
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
543 use_register(int reg0, int reg1, int move)
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
544 {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
545 /*
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
546 reg0 becomes reg1, if (move) copy the content.
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
547 if reg1 is used, reg0 contains old value.
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
548 */
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
549
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
550 char *move_op;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
551 code_clear_stack_reg(reg1);
756
e333c95586bd i64 continue...
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 740
diff changeset
552 move_op = (regs[reg1])?"\txchg %s,%s\n":"\tmovl %s,%s\n";
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
553 if (move && reg0!=reg1) {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
554 printf(move_op,reg_name[reg0],reg_name[reg1]);
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
555 if (!regs[reg1]) regs[reg1]=USING_REG;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
556 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
557 return reg0;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
558 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
559
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
560 #define use_data_reg(reg,keep) \
635
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
561 if (reg==-1||!is_data_reg(reg)) reg=use_data_reg0(keep,reg)
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
562
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
563 int
635
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
564 use_data_reg0(int keep,int reg)
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
565 {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
566 int ptreg =0;
635
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
567 int i;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
568 if (is_pointer_reg(creg)) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
569 free_register(ptreg=creg);
635
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
570 ireg = creg = 0;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
571 }
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
572 if (is_pointer_reg(ireg)) {
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
573 free_register(ireg);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
574 ireg = 0;
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
575 }
635
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
576 i = reg==USING_REG?creg:reg;
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
577 #ifdef __APPLE__
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
578 if (regs[i]==PTRC_REG) clear_ptr_cache_reg(i);
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
579 #endif
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
580 if (!i||!ireg||!is_data_reg(i)) {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
581 if (lreg) { if (regs[lreg]) free_register(lreg); lreg = 0; }
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
582 if (!ireg) {
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
583 ireg = get_data_register();
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
584 }
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
585 i = ireg;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
586 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
587 if (!regs[i]) regs[i]=USING_REG;
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
588 creg = ireg = i;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
589 if (ptreg && keep) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
590 printf("\tmovl %s,%s\n",reg_name[ptreg],reg_name[creg]);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
591 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
592 return i;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
593 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
594
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
595 static void
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
596 set_freg(int reg,int mode)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
597 {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
598 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
599
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
600 static void
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
601 set_ireg(int reg,int mode)
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
602 {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
603 if (!is_int_reg(reg)) error(-1);
700
22e0330a6d5b *** empty log message ***
kono
parents: 693
diff changeset
604 if (reg!=creg) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
605 #ifdef __APPLE__
635
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
606 if (regs[reg]==PTRC_REG)
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
607 clear_ptr_cache_reg(reg);
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
608 #endif
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
609 if (ireg && reg!=ireg ) {
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
610 if (regs[ireg]!=REG_VAR) free_register(ireg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
611 if (mode) {
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
612 printf("\tmovl %s,%s\n",reg_name[ireg],reg_name[reg]);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
613 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
614 }
700
22e0330a6d5b *** empty log message ***
kono
parents: 693
diff changeset
615 if (creg>0 && regs[creg]!=REG_VAR) free_register(creg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
616 if (creg==lreg) lreg = 0;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
617 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
618 creg = ireg = reg;
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
619 if (!regs[reg]) regs[reg]=USING_REG;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
620 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
621
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
622 #define is_long_reg(reg) (reg==REG_LCREG||reg==REG_L)
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
623 #define use_longlong(reg) \
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
624 if (reg==-1||is_long_reg(reg)) reg=use_longlong0(reg)
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
625
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
626 static int
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
627 use_longlong0(int reg)
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
628 {
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
629 int i = reg==USING_REG?creg:reg;
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
630 if (ireg) { if (regs[ireg]!=REG_VAR) free_register(ireg); ireg=0; }
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
631 if (!lreg||!regs[lreg]) {
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
632 // long long mode use all registers
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
633 code_save_stacks();
633
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
634 #ifdef __APPLE__
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
635 clear_ptr_cache();
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
636 #endif
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
637 }
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
638 i = lreg = (reg==USE_CREG)?REG_LCREG:reg;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
639 if (!regs[i]) regs[i]=USING_REG;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
640 if (!regs[regv_l(i)]) regs[regv_l(i)]=USING_REG;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
641 if (!regs[regv_h(i)]) regs[regv_h(i)]=USING_REG;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
642 creg = lreg = i;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
643 return i;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
644 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
645
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
646 static void
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
647 set_lreg(int reg,int mode)
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
648 {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
649 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
650 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
651
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
652 char *
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
653 l_edx(int i) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
654 return i==REG_L?"%edi":"%edx";
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
655 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
656 char *
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
657 l_eax(int i) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
658 return i==REG_L?"%esi":"%eax";
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
659 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
660
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
661 extern void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
662 code_init(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
663 {
173
3b33c7daae95 *** empty log message ***
kono
parents: 168
diff changeset
664
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
665 /* called only once */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
666
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
667 init_src = init_src0;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
668 size_of_int = SIZE_OF_INT;
715
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
669 size_of_pointer = SIZE_OF_INT;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
670 size_of_short = SIZE_OF_SHORT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
671 size_of_float = SIZE_OF_FLOAT;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
672 size_of_double = SIZE_OF_DOUBLE;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
673 size_of_longlong = SIZE_OF_LONGLONG;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
674 endian = ENDIAN;
717
c1542a2482b1 *** empty log message ***
kono
parents: 716
diff changeset
675 struct_align = size_of_int;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
676
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
677
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
678 // MAX_REGISTER=6;
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
679 MAX_DATA_REG=4;
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
680 MAX_POINTER=3;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
681 MAX_REGISTER_VAR=2;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
682
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
683 reg_name[REG_EAX] = "%eax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
684 reg_name[REG_EBX] = "%ebx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
685 reg_name[REG_ECX] = "%ecx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
686 reg_name[REG_EDX] = "%edx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
687 reg_name[REG_ESI] = "%esi";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
688 reg_name[REG_EDI] = "%edi";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
689 reg_name[REG_EBP] = "%ebp";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
690 reg_name[REG_ESP] = "%esp";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
691 reg_name_l[REG_EAX] = "%al";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
692 reg_name_l[REG_EBX] = "%bl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
693 reg_name_l[REG_ECX] = "%cl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
694 reg_name_l[REG_EDX] = "%dl";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
695 reg_name_w[REG_EAX] = "%ax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
696 reg_name_w[REG_EBX] = "%bx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
697 reg_name_w[REG_ECX] = "%cx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
698 reg_name_w[REG_EDX] = "%dx";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
699
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
700 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
701
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
702 extern void
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
703 emit_reinit()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
704 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
705 /* called for each file */
605
1078c7e3bfb0 minor fixes
kono
parents: 599
diff changeset
706 output_mode = -1;
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
707 #ifdef __APPLE__
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
708 init_ptr_cache();
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
709 #endif
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
710 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
711
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
712
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
713 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
714 register_name(int i,int byte)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
715 {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
716 if (i<=0) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
717 error(REG_ERR);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
718 return "%eax";
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
719 }
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
720 if (byte==1 && i <= REG_EDX) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
721 return reg_name_l[i];
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
722 } else if (byte==SIZE_OF_SHORT && i <= REG_EDX) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
723 return reg_name_w[i];
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
724 } else {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
725 return reg_name[i]; /* 0 or 4 means int */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
726 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
727 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
728
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
729 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
730 gexpr_code_init(void){
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
731 // use_register(creg,REG_EAX,0);
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
732 set_ireg(CREG_REGISTER,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
733 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
734
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
735 void
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
736 code_gexpr(int e){
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
737 if ((is_int_reg(creg))&&regs[creg]==REG_VAR)
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
738 creg = ireg = 0;
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
739 else if ((creg==REG_L)&&regs[creg]==REG_VAR)
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
740 creg = lreg = 0;
147
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
741 }
cb7aa0089681 creg/ireg done for powerpc.
kono
parents: 144
diff changeset
742
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
743 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
744 get_register(void)
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
745 { /* 使われていないレジスタを調べる */
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
746 int i,reg,j;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
747 for(i=1;i<MAX_REGISTER+1;i++) {
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
748 if (! regs[i]) { /* 使われていないなら */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
749 regs[i]=1; /* そのレジスタを使うことを宣言し */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
750 return i; /* その場所を表す番号を返す */
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
751 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
752 }
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
753 #ifdef __APPLE__
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
754 /* PTR_CACHE をつぶす */
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
755 if ((i=last_ptr_cache())) {
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
756 clear_ptr_cache_reg(i);
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
757 regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
758 return i; /* その場所を表す番号を返す */
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
759 }
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
760 #endif
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
761 /* search register stack */
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
762 for(i=0;i<reg_sp;i++) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
763 if ((reg=reg_stack[i])>=0) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
764 code_assign_lvar(
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
765 (j=new_lvar(SIZE_OF_INT)),reg,0);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
766 reg_stack[i]= j-REG_LVAR_OFFSET;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
767 return reg;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
768 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
769 }
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
770 error(RGERR);
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
771 return -1; /* 空いている場所がないなら、それを表す -1 を返す */
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
772 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
773
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
774 static int
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
775 get_data_register(void)
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
776 { /* 使われていないレジスタを調べる */
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
777 int i,reg,j;
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
778 for(i=REG_EAX;i<=REG_EDX;i++) {
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
779 if (! regs[i]) { /* 使われていないなら */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
780 regs[i]=1; /* そのレジスタを使うことを宣言し */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
781 return i; /* その場所を表す番号を返す */
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
782 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
783 }
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
784 #ifdef __APPLE__
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
785 /* PTR_CACHE をつぶす */
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
786 while ((i=last_ptr_cache())) {
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
787 clear_ptr_cache_reg(i);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
788 if (is_data_reg(i)) {
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
789 regs[i]=USING_REG; /* そのレジスタを使うことを宣言し */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
790 return i; /* その場所を表す番号を返す */
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
791 }
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
792 }
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
793 #endif
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
794 /* search register stack */
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
795 for(i=0;i<reg_sp;i++) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
796 if (is_data_reg(i) && (reg=reg_stack[i])>=0) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
797 code_assign_lvar(
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
798 (j=new_lvar(SIZE_OF_INT)),reg,0);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
799 reg_stack[i]= j-REG_LVAR_OFFSET;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
800 return reg;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
801 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
802 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
803 error(-1);
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
804 return -1; /* 空いている場所がないなら、それを表す -1 を返す */
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
805 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
806
917947ffeb7c power pc version
kono
parents: 87
diff changeset
807 void
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
808 free_register(int i) { /* いらなくなったレジスタを開放 */
534
0f24e1dba811 *** empty log message ***
kono
parents: 527
diff changeset
809 if (i==REG_L) {
0f24e1dba811 *** empty log message ***
kono
parents: 527
diff changeset
810 reg_var=0;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
811 regs[REG_ESI]=regs[REG_EDI]=0;
534
0f24e1dba811 *** empty log message ***
kono
parents: 527
diff changeset
812 } else if (regs[i]==REG_VAR) { reg_var--;
0f24e1dba811 *** empty log message ***
kono
parents: 527
diff changeset
813 } else if(i==REG_LCREG) { //? REG_L?
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
814 regs[REG_EAX]=regs[REG_EDX]=0;
534
0f24e1dba811 *** empty log message ***
kono
parents: 527
diff changeset
815 }
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
816 regs[i]=0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
817 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
818
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
819 extern void
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
820 use_ptr_cache(int r)
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
821 {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
822 #ifdef __APPLE__
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
823 regs[r]=PTRC_REG;
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
824 #else
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
825 error(-1);
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
826 #endif
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
827 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
828
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
829 extern void
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
830 code_ptr_cache_def(int r,NMTBL *nptr)
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
831 {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
832 #ifdef __APPLE__
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
833 char *rrn = register_name(r,0);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
834 if (nptr->sc==STATIC && !(is_code(nptr)||is_function(nptr))) {
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
835 printf("\tleal _%s-_%d(%%ebx),%s\n",nptr->nm,
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
836 goffset_label,rrn);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
837 } else {
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
838 printf("\tmovl L_%s$non_lazy_ptr-_%d(%%ebx),%s\n",
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
839 nptr->nm,
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
840 goffset_label,rrn);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
841 }
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
842 #else
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
843 error(-1);
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
844 #endif
341
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
845 }
ca34f02b2056 ptr cache speed up
kono
parents: 340
diff changeset
846
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
847 /*
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
848 ESI,EDI are used as register variable
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
849 (both in integer and long long mode)
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
850 */
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
851
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
852 int
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
853 get_input_register_var(int i,NMTBL *nptr,int is_code)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
854 {
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
855 if (is_code) {
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
856 if (i>=MAX_CODE_INPUT_REGISTER_VAR) return 0;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
857 i += REG_ESI;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
858 regs[i]=INPUT_REG;
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
859 return list3n(REGISTER,i,nptr);
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
860 } else {
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
861 return 0;
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
862 }
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
863 }
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
864
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
865 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
866 get_input_dregister_var(int i,NMTBL *nptr,int is_code,int d)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
867 {
126
1d1612fe705a *** empty log message ***
kono
parents: 123
diff changeset
868 return 0;
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
869 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
870
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
871 int
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
872 get_input_lregister_var(int i,NMTBL *nptr,int is_code)
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
873 {
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
874 int h,l;
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
875 if (is_code) {
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
876 if (i+1>=MAX_CODE_INPUT_REGISTER_VAR) return 0;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
877 h = REG_ESI;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
878 l = REG_EDI;
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
879 regs[h]=regs[l]=INPUT_REG;
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
880 return list2(LREGISTER,REG_L);
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
881 }
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
882 return 0;
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
883 }
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
884
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
885 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
886 get_dregister(int d)
99
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
887 {
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
888 return -1;
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
889 }
53899975154c *** empty log message ***
kono
parents: 98
diff changeset
890
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
891 int
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
892 get_lregister_var(NMTBL *n)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
893 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
894 int h,l;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
895 h = REG_ESI;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
896 l = REG_EDI;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
897 if (regs[h]==0&&regs[l]==0) {
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
898 regs[h]=regs[l]=REG_VAR; regs[REG_L]=REG_VAR;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
899 reg_var=2;
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
900 return list2(LREGISTER,REG_L);
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
901 }
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
902 return list3n(LVAR,new_lvar(SIZE_OF_LONGLONG),0);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
903 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
904
205
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
905 int
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
906 get_lregister()
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
907 {
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
908 return -1;
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
909 }
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
910
a50f90d0b63a *** empty log message ***
kono
parents: 204
diff changeset
911
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
912 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
913 register_full(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
914 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
915 int i;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
916 for(i=1;i<MAX_REGISTER+1;i++) {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
917 if (! regs[i]) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
918 return 0;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
919 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
920 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
921 return 1;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
922 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
923
917947ffeb7c power pc version
kono
parents: 87
diff changeset
924 int
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
925 free_register_count(int d)
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
926 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
927 int i,count;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
928 count = 0;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
929 for(i=1;i<MAX_REGISTER+1;i++) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
930 if (! regs[i]) count++;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
931 }
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
932 return d?0:count;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
933 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
934
917947ffeb7c power pc version
kono
parents: 87
diff changeset
935 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
936 free_all_register(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
937 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
938 int i;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
939 for(i=1;i<MAX_REGISTER+REAL_MAX_LREGISTER+1;i++) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
940 regs[i]=0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
941 }
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
942 lreg = creg = ireg = 0;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
943 reg_var = 0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
944 return;
917947ffeb7c power pc version
kono
parents: 87
diff changeset
945 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
946
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
947 extern int
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
948 code_register_overlap(int s,int t)
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
949 {
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
950 if (car(s)==REGISTER) {
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
951 if (car(t)==REGISTER) return cadr(s)==cadr(t);
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
952 if (car(t)==LREGISTER)
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
953 return cadr(s)==REG_ESI|| cadr(s)==REG_EDI;
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
954 } else if (car(s)==LREGISTER) {
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
955 if (car(t)==LREGISTER) return 1;
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
956 if (car(t)==REGISTER)
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
957 return cadr(t)==REG_ESI|| cadr(t)==REG_EDI;
345
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
958 }
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
959 return 0;
2b3946ee4fc9 *** empty log message ***
kono
parents: 341
diff changeset
960 }
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
961
917947ffeb7c power pc version
kono
parents: 87
diff changeset
962 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
963 register_usage(char *s)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
964 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
965 int i;
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
966 printf("## %d: %s:",lineno,s);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
967 if (creg) printf(" creg=%s ",register_name(creg,0));
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
968 for(i=1;i<MAX_REGISTER+1;i++) {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
969 printf("%d",regs[i]);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
970 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
971 #if 0
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
972 printf(" regs_stack",register_name(creg,0);
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
973 for(i=reg_sp;i>=0;i--) {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
974 if(reg_stack[i]>=0)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
975 printf(" %s",register_name(reg_stack[i],0));
917947ffeb7c power pc version
kono
parents: 87
diff changeset
976 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
977 #endif
527
6b0fd56848e6 inline continue....
kono
parents: 518
diff changeset
978 printf("## f:%d",freg_sp);
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
979 printf("\n");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
980 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
981
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
982 void
794
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 784
diff changeset
983 code_arg_register(NMTBL *fnptr, int in)
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
984 {
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
985 int args = fnptr->dsp;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
986 NMTBL *n;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
987 int reg_var = 0;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
988 int freg_var = 0;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
989 int type;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
990 int reg;
534
0f24e1dba811 *** empty log message ***
kono
parents: 527
diff changeset
991 int offset = 0;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
992 int is_code0 = is_code(fnptr);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
993
794
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 784
diff changeset
994 if (in) return;
032dc03be02e i64 arg_register in inline mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 784
diff changeset
995
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
996 while (args) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
997 /* process in reverse order */
712
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
998 n = ncadddr(args);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
999 type = n->ty;
825
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
1000 int sz = size(type);
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
1001 offset = code_arg_alignment(offset,n,type,sz,is_code0);
534
0f24e1dba811 *** empty log message ***
kono
parents: 527
diff changeset
1002 // n->dsp = offset;
527
6b0fd56848e6 inline continue....
kono
parents: 518
diff changeset
1003 // printf("### %s %d %d\n",n->nm,n->dsp,n->ty);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1004 if (scalar(type)) {
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1005 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
1006 n->sc = REGISTER;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1007 n->dsp = cadr(reg);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1008 regs[n->dsp]= INPUT_REG;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1009 reg_var++;
712
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
1010 caddr(args)=SIZE_OF_INT; /* why we need this? */
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1011 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1012 } else if (type==FLOAT||type==DOUBLE) {
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1013 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
1014 n->sc = DREGISTER;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1015 n->dsp = cadr(reg);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1016 fregs[n->dsp]= INPUT_REG;
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1017 freg_var++;
712
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
1018 caddr(args)=size(type); /* why we need this? */
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1019 }
825
425768eb5e9e code segment fix for non parse mode
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 794
diff changeset
1020 }
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1021 args = cadr(args);
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1022 }
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1023 }
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1024
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1025 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1026 gexpr_init(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1027 {
685
3e3cf02297e4 before intel function call order fix
kono
parents: 677
diff changeset
1028 text_mode(0);
292
6d4231b6f9fe switch statement prepare
kono
parents: 291
diff changeset
1029 if (reg_sp>0) error(-1);
6d4231b6f9fe switch statement prepare
kono
parents: 291
diff changeset
1030 if (freg_sp>0) error(-1);
6d4231b6f9fe switch statement prepare
kono
parents: 291
diff changeset
1031 reg_sp = 0;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1032 freg_sp = 0;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
1033 stack_depth = 0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1034 gexpr_code_init();
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1035 regs[creg]=1;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1036 register_usage("gexpr_init");
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1037 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1038
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1039
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1040 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1041 emit_init(void)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1042 {
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1043 int i;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1044 for(i=1;i<REAL_MAX_REGISTER+1;i++) regs[i]=0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1045 free_all_register();
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1046 reg_sp = 0;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1047 freg_sp = 0;
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1048 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1049
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1050 int
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1051 pop_register(void)
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1052 { /* レジスタから値を取り出す */
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1053 return reg_stack[--reg_sp];
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1054 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1055
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1056 void
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1057 emit_pop_free(int xreg)
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1058 {
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
1059 if (xreg>=0 && xreg!=creg && regs[xreg]!=REG_VAR) {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1060 free_register(xreg);
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1061 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1062 }
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1063
917947ffeb7c power pc version
kono
parents: 87
diff changeset
1064
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1065 int
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1066 get_register_var(NMTBL *nptr)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1067 {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1068 int i;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1069 for(i=REG_ESI;i<REG_EBP;i++) {
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1070 if (! regs[i]) { /* 使われていないなら */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1071 regs[i]=REG_VAR; /* そのレジスタを使うことを宣言し */
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1072 return list3n(REGISTER,i,nptr); /* その場所を表す番号を返す */
534
0f24e1dba811 *** empty log message ***
kono
parents: 527
diff changeset
1073 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1074 }
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1075 return list3n(LVAR,new_lvar(SIZE_OF_INT),0);
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1076 }
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1077
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1078 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
1079 get_dregister_var(NMTBL *nptr,int d)
104
c21aeb12b78b *** empty log message ***
kono
parents: 103
diff changeset
1080 {
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1081 return list3n(LVAR,new_lvar(d?SIZE_OF_DOUBLE:SIZE_OF_FLOAT),0);
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1082 }
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
1083
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1084
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
1085 int
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1086 emit_push()
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1087 {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
1088 int new_reg,old;
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1089 new_reg = get_register(); /* 絶対に取れる */
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1090 // who free new_reg?
159
b80e9737c3ce regs[creg]==0 in ia32
kono
parents: 156
diff changeset
1091 if (new_reg==creg) error(-1);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
1092 old = creg;
724
e60c3d8dadd6 convert to UTF-8
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 717
diff changeset
1093 reg_stack[reg_sp++] = creg; /* push するかわりにレジスタを使う */
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
1094 ireg = creg = new_reg;
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
1095 if (!regs[creg]) regs[creg]=USING_REG;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
1096 return old;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1097 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1098
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1099 int
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1100 emit_pop(int type)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1101 {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1102 int xreg,reg;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1103 xreg=pop_register();
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1104 if (xreg<= -REG_LVAR_OFFSET) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1105 reg = get_register();
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1106 code_rlvar(REG_LVAR_OFFSET+xreg,reg);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1107 free_lvar(REG_LVAR_OFFSET+xreg);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1108 xreg = reg;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1109 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1110 return xreg;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1111 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1112
92
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
1113 void
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
1114 code_label(int labelno)
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
1115 {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1116 #ifdef __APPLE__
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1117 clear_ptr_cache();
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1118 #endif
92
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
1119 printf("_%d:\n",labelno);
e7f8515ba882 *** empty log message ***
kono
parents: 89
diff changeset
1120 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1121
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1122 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1123 code_gvar(int e1,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1124 use_int(creg);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1125 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1126 int r = get_ptr_cache(ncaddr(e1));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1127 if (cadr(e1)) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1128 printf("\tleal %d(%s),%s\n", cadr(e1),register_name(r,0),
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1129 register_name(creg,0));
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1130 } else {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1131 printf("\tmovl %s,%s\n", register_name(r,0), register_name(creg,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1132 }
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1133 #else
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1134 if (cadr(e1)) {
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1135 printf("\tmovl $%s+%d,%s\n",(ncaddr(e1))->nm,cadr(e1),
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1136 register_name(creg,0));
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1137 } else {
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1138 printf("\tmovl $%s,%s\n",(ncaddr(e1))->nm,register_name(creg,0));
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1139 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1140 #endif
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1141
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1142 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1143
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1144 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1145 code_rgvar(int e1,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1146 use_int(creg);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1147 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1148 int r = get_ptr_cache(ncaddr(e1));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1149 if (cadr(e1)) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1150 printf("\tmovl %d(%s),%s\n", cadr(e1),register_name(r,0),
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1151 register_name(creg,0));
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1152 } else {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1153 printf("\tmovl (%s),%s\n", register_name(r,0), register_name(creg,0));
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1154 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1155 #else
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1156 if (cadr(e1)) {
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1157 printf("\tmovl %s+%d,%s\n",(ncaddr(e1))->nm,cadr(e1),
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1158 register_name(creg,0));
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1159 } else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1160 printf("\tmovl %s,%s\n",(ncaddr(e1))->nm,register_name(creg,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1161 #endif
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1162
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1163 }
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1164
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
1165 static char *
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
1166 cload(int sign,int sz) {
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
1167 return sz==1?(sign?"movsbl":"movzbl"):
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
1168 sz==SIZE_OF_SHORT?(sign?"movswl":"movzwl"):"movl";
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
1169 }
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1170
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1171 void
165
kono
parents: 163
diff changeset
1172 code_crgvar(int e1,int creg,int sign,int sz){
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1173 use_int(creg);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1174 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1175 int r = get_ptr_cache(ncaddr(e1));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1176 if (cadr(e1)) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1177 printf("\t%s %d(%s),%s\n", cload(sign,sz),cadr(e1),register_name(r,0),
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1178 register_name(creg,0));
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1179 } else {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1180 printf("\t%s (%s),%s\n", cload(sign,sz),
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1181 register_name(r,0), register_name(creg,0));
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1182 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1183 #else
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1184 if (cadr(e1)) {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1185 printf("\t%s %s+%d,%s\n",cload(sign,sz),
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1186 (ncaddr(e1))->nm,cadr(e1),register_name(creg,0));
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1187 } else
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1188 printf("\t%s %s,%s\n",cload(sign,sz),
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1189 (ncaddr(e1))->nm,register_name(creg,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1190 #endif
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1191
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1192 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1193
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1194
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1195 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1196 code_lvar(int e2,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1197 use_int(creg);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1198 printf("\tlea "); lvar(e2);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1199 printf(",%s\n",register_name(creg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1200 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1201
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1202
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1203 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1204 code_register(int e2,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1205 use_int(creg);
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
1206 if (e2!=creg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1207 printf("\tmovl %s,%s\n",register_name(e2,0),register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1208 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1209
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1210
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1211 void
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1212 code_rlvar(int e2,int reg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1213 use_int(reg);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1214 printf("\tmovl "); lvar(e2);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1215 printf(",%s\n",register_name(reg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1216 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1217
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1218 extern void
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1219 code_i2c(int reg)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1220 {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1221 use_data_reg(reg,1);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1222 printf("\t%s %s,%s\n",cload(1,1),
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1223 register_name(reg,1),register_name(reg,0));
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1224 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1225
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1226 extern void
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1227 code_i2s(int reg)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1228 {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1229 use_data_reg(reg,1);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1230 printf("\t%s %s,%s\n",cload(1,SIZE_OF_SHORT),
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1231 register_name(reg,2),register_name(reg,0));
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1232 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1233
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1234 extern void
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1235 code_u2uc(int reg)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1236 {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1237 use_data_reg(reg,1);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1238 printf("\t%s %s,%s\n",cload(0,1),
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1239 register_name(reg,1),register_name(reg,0));
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1240 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1241
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1242 extern void
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1243 code_u2us(int reg)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1244 {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1245 use_data_reg(reg,1);
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1246 printf("\t%s %s,%s\n",cload(0,SIZE_OF_SHORT),
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1247 register_name(reg,2),register_name(reg,0));
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 348
diff changeset
1248 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1249
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1250 void
165
kono
parents: 163
diff changeset
1251 code_crlvar(int e2,int reg,int sign,int sz) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1252 use_int(reg);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1253 printf("\t%s ",cload(sign,sz)); lvar(e2);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1254 printf(",%s\n",register_name(reg,0));
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1255
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1256 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1257
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1258
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1259 void
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1260 code_fname(NMTBL *n,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1261 use_int(creg);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1262 #ifdef __APPLE__
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
1263 if (n->sc==STATIC) {
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
1264 printf("\tleal _%s-_%d(%%ebx),%s\n", n->nm, goffset_label,
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
1265 register_name(creg,0));
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
1266 return;
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
1267 }
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1268 int r = get_ptr_cache(n);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1269 printf("\tmovl %s,%s\n", register_name(r,0), register_name(creg,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1270 #else
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
1271 printf("\tmovl $%s,%s\n",n->nm,register_name(creg,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1272 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1273 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1274
363
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1275 void
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1276 code_label_value(int label,int reg) {
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1277 use_int(reg);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1278 #ifdef __APPLE__
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1279 printf("\tleal _%d-_%d(%%ebx),%s\n",
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1280 label,goffset_label,register_name(reg,0));
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1281 #else
363
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1282 printf("\tleal _%d,%s\n",label,register_name(reg,0));
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1283 #endif
363
f3f2b7906d50 label extension
kono
parents: 355
diff changeset
1284 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1285
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1286 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1287 code_const(int e2,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1288 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1289 printf("\tmovl $%d,%s\n",e2,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1290 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1291
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1292 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1293 code_neg(int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1294 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1295 printf("\tnegl %s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1296 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1297
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1298
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1299 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1300 code_not(int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1301 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1302 printf("\tnotl %s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1303 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1304
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1305
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1306 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1307 code_lnot(int creg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1308 char *xrn;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1309
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1310 use_data_reg(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1311 xrn = register_name(creg,1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1312 printf("\tcmpl $0,%s\n", register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1313 printf("\tsete %s\n", xrn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1314 printf("\tmovzbl %s,%s\n", xrn,register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1315 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1316
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1317 void
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1318 code_preinc(int e1,int e2,int dir,int sign,int sz,int reg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1319 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1320 if (car(e2)==REGISTER) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1321 use_int(reg);
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1322 printf("\taddl $%d,%s\n",dir,register_name(cadr(e2),0));
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
1323 if (use)
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
1324 printf("\tmovl %s,%s\n",register_name(cadr(e2),0),register_name(reg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1325 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1326 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1327 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1328 xrn = register_name(creg,0);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1329 use_int(reg);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1330 printf("\t%s $%d,(%s)\n",(sz==1)?"addb":(sz==SIZE_OF_SHORT)?"addw":"addl",dir,xrn);
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
1331 if (use)
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
1332 printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(reg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1333 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1334
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1335
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1336 void
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1337 code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1338 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1339 if (car(e2)==REGISTER) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1340 use_int(reg);
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
1341 if (use)
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
1342 printf("\tmovl %s,%s\n",register_name(cadr(e2),0),register_name(reg,0));
168
b1297c82e926 cpostinc removal
kono
parents: 167
diff changeset
1343 printf("\taddl $%d,%s\n",dir,register_name(cadr(e2),0));
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1344
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1345 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1346 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1347 g_expr(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1348 emit_push();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1349 xrn = register_name((e2=emit_pop(0)),0);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1350 use_int(reg);
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
1351 if (use)
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
1352 printf("\t%s (%s),%s\n",cload(sign,sz),xrn,register_name(reg,0));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1353 printf("\t%s $%d,(%s)\n",(sz==1)?"addb":(sz==SIZE_OF_SHORT)?"addw":"addl",dir,xrn);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1354 emit_pop_free(e2);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1355 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1356
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1357
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1358
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1359 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1360 code_return(int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1361 use_int(creg);
733
116d4701d097 i64 continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
1362 #ifdef __APPLE__
116d4701d097 i64 continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
1363 // printf("\tleal _%d(%%rip),%s\n",retcont,register_name(creg,0));
116d4701d097 i64 continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
1364 printf("\tleal _%d-_%d(%%ebx),%s\n",
740
8cd40338aee6 minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 733
diff changeset
1365 retcont,goffset_label,register_name(creg,0));
733
116d4701d097 i64 continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
1366 #else
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1367 printf("\tleal _%d,%s\n",retcont,register_name(creg,0));
733
116d4701d097 i64 continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
1368 #endif
116d4701d097 i64 continue
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 725
diff changeset
1369 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1370
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1371 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1372 code_environment(int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1373 use_int(creg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1374 printf("\tmovl %%ebp,%s\n",register_name(creg,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1375 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1376
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1377 static int rexpr_bool(int e1,int reg);
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
1378 #if FLOAT_CODE
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1379 static int drexpr_bool(int e1,int reg);
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
1380 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1381
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1382 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
1383 code_bool(int e1,int reg) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1384 char *xrn;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1385 int e2,e3;
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1386 if (rexpr_bool(e1,reg)) return;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1387 #if FLOAT_CODE
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1388 if (drexpr_bool(e1,reg)) return;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
1389 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1390 b_expr(e1,1,e2=fwdlabel(),1); /* including > < ... */
289
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1391 if (use) {
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1392 use_int(reg);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1393 xrn = register_name(reg,0);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1394 printf("\txorl %s,%s\n",xrn,xrn);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1395 jmp(e3=fwdlabel());
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1396 fwddef(e2);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1397 printf("\tmovl $1,%s\n",xrn);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1398 fwddef(e3);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1399 } else {
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1400 fwddef(e2);
55e611476cba *** empty log message ***
kono
parents: 287
diff changeset
1401 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1402 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1403
433
b9566a04b6e2 *** empty log message ***
kono
parents: 427
diff changeset
1404 static char *
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1405 code_gt(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1406 return (cond?"g":"le");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1407 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1408
433
b9566a04b6e2 *** empty log message ***
kono
parents: 427
diff changeset
1409 static char *
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1410 code_ugt(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1411 return (cond?"a":"be");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1412 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1413
433
b9566a04b6e2 *** empty log message ***
kono
parents: 427
diff changeset
1414 static char *
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1415 code_ge(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1416 return (cond?"ge":"l");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1417 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1418
433
b9566a04b6e2 *** empty log message ***
kono
parents: 427
diff changeset
1419 static char *
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1420 code_uge(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1421 return (cond?"ae":"b");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1422 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1423
433
b9566a04b6e2 *** empty log message ***
kono
parents: 427
diff changeset
1424 static char *
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1425 code_eq(int cond) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1426 return (cond?"e":"ne");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1427 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1428
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1429 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1430 code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1431 use_int(reg);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1432 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1433 int r = get_ptr_cache(ncaddr(e1));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1434 if (cadr(e1)) {
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1435 if (sz==1)
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1436 printf("\tcmpb $0,%d(%s)\n",cadr(e1),register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1437 else if (sz==SIZE_OF_SHORT)
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1438 printf("\tcmpw $0,%d(%s)\n",cadr(e1),register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1439 } else {
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1440 if (sz==1)
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1441 printf("\tcmpb $0,(%s)\n",register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1442 else if (sz==SIZE_OF_SHORT)
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1443 printf("\tcmpw $0,(%s)\n",register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1444 }
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1445 #else
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1446 if (cadr(e1)) {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1447 if (sz==1)
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1448 printf("\tcmpb $0,%s+%d\n",(ncaddr(e1))->nm,cadr(e1));
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1449 else if (sz==SIZE_OF_SHORT)
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1450 printf("\tcmpw $0,%s+%d\n",(ncaddr(e1))->nm,cadr(e1));
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1451 } else {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1452 if (sz==1)
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1453 printf("\tcmpb $0,%s\n",(ncaddr(e1))->nm);
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1454 else if (sz==SIZE_OF_SHORT)
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1455 printf("\tcmpw $0,%s\n",(ncaddr(e1))->nm);
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1456 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1457 #endif
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1458 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1459 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1460
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1461
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1462 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1463 code_cmp_crlvar(int e1,int reg,int sz,int label,int cond) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1464 use_int(reg);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1465 if (sz==1) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1466 printf("\tcmpb $0,"); lvar(e1); printf("\n");
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1467 } else if (sz==SIZE_OF_SHORT) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1468 printf("\tcmpw $0,"); lvar(e1); printf("\n");
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1469 }
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1470 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1471 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1472
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1473
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1474 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1475 code_cmp_rgvar(int e1,int reg,int label,int cond) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1476 use_int(reg);
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
1477 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1478 int r = get_ptr_cache(ncaddr(e1));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1479 if (cadr(e1))
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1480 printf("\tcmpl $0,%d(%s)\n",cadr(e1),register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1481 else
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1482 printf("\tcmpl $0,(%s)\n",register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1483 #else
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1484 if (cadr(e1))
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1485 printf("\tcmpl $0,%s+%d\n",(ncaddr(e1))->nm,cadr(e1));
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
1486 else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1487 printf("\tcmpl $0,%s\n",(ncaddr(e1))->nm);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
1488 #endif
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1489 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1490 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1491
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1492
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1493 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1494 code_cmp_rlvar(int e1,int reg,int label,int cond) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1495 use_int(reg);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1496 printf("\tcmpl $0,"); lvar(e1); printf("\n");
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1497 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1498 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1499
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1500
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1501 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1502 code_cmp_register(int e2,int label,int cond) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1503 use_int(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1504 printf("\tcmpl $0,%s\n",register_name(e2,0));
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
1505 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1506 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1507
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1508
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1509 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
1510 code_string(int e1,int creg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1511 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1512 char *s;
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
1513 int lb;
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1514 NMTBL *n = ncaddr(e1);
560
d6ff45d719a5 string sharing
kono
parents: 555
diff changeset
1515 if ((lb=attr_value(n,LABEL))) {
d6ff45d719a5 string sharing
kono
parents: 555
diff changeset
1516 // already defined
d6ff45d719a5 string sharing
kono
parents: 555
diff changeset
1517 return code_label_value(lb,creg) ;
d6ff45d719a5 string sharing
kono
parents: 555
diff changeset
1518 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1519
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1520 use_int(creg);
560
d6ff45d719a5 string sharing
kono
parents: 555
diff changeset
1521 s=n->nm;
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
1522 lb = emit_string_label();
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
1523 ascii(s);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
1524 if (output_mode==TEXT_EMIT_MODE) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
1525 printf(".text\n");
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1526 } else {
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
1527 text_mode(0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1528 }
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1529 #ifdef __APPLE__
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
1530 printf("\tleal _%d-_%d(%%ebx),%s\n",lb,
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1531 goffset_label,
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1532 register_name(creg,0));
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1533 #else
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
1534 printf("\tlea _%d,%s\n",lb,register_name(creg,0));
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
1535 #endif
560
d6ff45d719a5 string sharing
kono
parents: 555
diff changeset
1536 set_attr(n,LABEL,lb);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1537 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1538
778
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1539 void
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1540 emit_strings(NMTBL *n)
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1541 {
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1542 int l = emit_string_label();
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1543 int i;
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1544 for(i = n->dsp; i; i = cadr(i)) {
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1545 ascii(scaddr(i));
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1546 }
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1547 emit_label(l);
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1548 }
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1549
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1550 void
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1551 code_strings(int e2,int reg)
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1552 {
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1553 int l = emit_string_label();
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1554 int i;
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1555 for(i = e2; i; i = cadr(i)) {
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1556 ascii(scaddr(i));
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1557 }
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1558 if (output_mode==TEXT_EMIT_MODE) {
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1559 printf(".text\n");
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1560 } else {
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1561 text_mode(0);
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1562 }
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1563 code_label_value(l,reg);
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1564 }
a177c65f3e37 large string (STRINGS)
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 756
diff changeset
1565
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1566 #define MAX_COPY_LEN 20
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1567
689
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1568 /* ARG_ORDER==1 case do not allow library call in emit_copy
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1569 */
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1570
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1571 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1572 emit_copy(int from,int to,int length,int offset,int value,int det)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1573 {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1574 int dreg;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1575 char *drn,*frn;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1576 char *trn;
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1577 use_int(from);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
1578 use_int(to);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1579 frn = register_name(from,0);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1580 trn = register_name(to,0);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1581
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1582 /* length <0 means upward direction copy */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1583 switch (length) {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1584 case 0: break;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1585 case 1: case -1:
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1586 drn = register_name(dreg = get_data_register(),1);
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
1587 printf("\tmovb %d(%s),%s\n",offset,frn,drn);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1588 printf("\tmovb %s,%d(%s)\n",drn,offset,trn);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1589 free_register(dreg);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1590 break;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1591 case 2: case -2:
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1592 drn = register_name(dreg = get_data_register(),2);
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
1593 printf("\tmovw %d(%s),%s\n",offset,frn,drn);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1594 printf("\tmovw %s,%d(%s)\n",drn,offset,trn);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1595 free_register(dreg);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1596 break;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1597 case 4: case -4:
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1598 drn = register_name(dreg = get_register(),0);
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
1599 printf("\tmovl %d(%s),%s\n",offset,frn,drn);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1600 printf("\tmovl %s,%d(%s)\n",drn,offset,trn);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1601 free_register(dreg);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1602 break;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1603 default:
258
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1604 if (length <0) {
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1605 if (length > -MAX_COPY_LEN) {
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1606 for(;length<=-4;length+=4,offset-=4)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1607 emit_copy(from,to,-4,offset-4,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1608 for(;length<=-2;length+=2,offset-=2)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1609 emit_copy(from,to,-2,offset-2,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1610 if(length<0)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1611 emit_copy(from,to,length,offset-1,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1612 break;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1613 }
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1614 } else if (length <=MAX_COPY_LEN) {
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1615 for(;length>=4;length-=4,offset+=4)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1616 emit_copy(from,to,4,offset,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1617 for(;length>=2;length-=2,offset+=2)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1618 emit_copy(from,to,2,offset,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1619 if(length>0)
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1620 emit_copy(from,to,length,offset,0,det);
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1621 break;
22949117768f Complex function argments. Struct is done. Long long is odd.
kono
parents: 254
diff changeset
1622 }
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1623 // should be parallel_rassign....
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1624 // clear_ptr_cache();
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1625 // code_save_stacks();
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1626
418
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1627 printf("\tpushl %%esi\n");
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1628 printf("\tpushl %%edi\n");
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1629 printf("\tpushl %%ecx\n");
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1630 printf("\tpushl %s\n",register_name(from,0));
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1631 printf("\tpushl %s\n",register_name(to,0));
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1632 printf("\tpopl %%edi\n");
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1633 printf("\tpopl %%esi\n");
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1634 if (length<0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1635 printf("\tmovl $%d,%%ecx\n",-length/4);
418
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1636 printf("\taddl $%d,%%esi\n",-length-4);
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
1637 printf("\taddl $%d,%%edi\n",-length-4
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
1638 +(to==REG_ESP?4*4:0)
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
1639 );
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1640 printf("\tstd\n\trep\n\tmovsl\n");
418
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1641 printf("\tpopl %%ecx\n");
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1642 printf("\tpopl %%edi\n");
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1643 printf("\tpopl %%esi\n");
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1644 if(length%4) {
476
034436187add *** empty log message ***
kono
parents: 468
diff changeset
1645 offset = offset+length/SIZE_OF_INT;
034436187add *** empty log message ***
kono
parents: 468
diff changeset
1646 length=length%4;
034436187add *** empty log message ***
kono
parents: 468
diff changeset
1647 emit_copy(from,to,length,offset,0,det);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1648 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1649 } else {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1650 printf("\tmovl $%d,%%ecx\n",length/4);
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
1651 if (to==REG_ESP)
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
1652 printf("\taddl $%d,%%edi\n",4*4);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1653 printf("\tcld\n\trep\n\tmovsl\n");
418
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1654 printf("\tpopl %%ecx\n");
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1655 printf("\tpopl %%edi\n");
c73f013d07d7 ARM complete. PowerPC, MIPS, IA32 checked.
kono
parents: 417
diff changeset
1656 printf("\tpopl %%esi\n");
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1657 if(length%4) {
476
034436187add *** empty log message ***
kono
parents: 468
diff changeset
1658 offset = offset+length/SIZE_OF_INT;
034436187add *** empty log message ***
kono
parents: 468
diff changeset
1659 length=length%4;
034436187add *** empty log message ***
kono
parents: 468
diff changeset
1660 emit_copy(from,to,length,offset,0,det);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1661 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1662 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1663 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1664 if (value) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1665 /* creg must point top of the destination data */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1666 /* this code is necessary for the value of assignment or function call */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1667 /* otherwise we don't need this */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1668 if(creg!=to) {
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
1669 if (regs[creg]!=REG_VAR) free_register(creg); creg=to;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1670 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1671 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1672 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1673
444
8bec605d1701 small sized struct
kono
parents: 443
diff changeset
1674 static int
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1675 push_struct(int e4,int t, int arg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1676 {
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1677 int length,dreg;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1678 g_expr(e4);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1679 length=size(t);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1680 if(length%SIZE_OF_INT) {
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
1681 length += SIZE_OF_INT - (length%SIZE_OF_INT);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1682 }
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1683 emit_push();
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1684 code_lvar(cadr(arg),USE_CREG);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1685 dreg = emit_pop(0);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1686
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1687 // copy dreg to creg with length
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
1688 // try small amount copy
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1689 /* downward direction copy */
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1690 emit_copy(dreg,creg,length,0,0,1);
670
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
1691 emit_pop_free(dreg);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1692 /* we have value in creg, it may be changed */
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1693 return length/SIZE_OF_INT;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1694 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1695
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1696 static int
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1697 simple_arg(int e3)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1698 {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1699 return !contains_p(e3,not_simple_p);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1700 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1701
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1702 #define caller_arg_offset_v(arg) (ARG_LVAR_OFFSET+(arg)*SIZE_OF_INT)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1703
689
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1704 /*
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1705 Eary implementation uses pushl arg for function call. gcc
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1706 use the same arguement evaluation order. Of course, the
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1707 order is unspecified in C language, but it is better to
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1708 use same argument evaluation order. Especially for test
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1709 program.
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1710 */
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1711 #define ARG_ORDER 1
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1712 #if (ARG_ORDER==1)
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1713
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1714 static int delayed_arg;
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1715
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1716 #endif
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1717
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1718 static int
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1719 compute_complex_arg(int e3,int reg_arg_list,int arg) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1720 int t=caddr(e3);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1721 int e4 = car(e3);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1722 reg_arg_list = list2(arg,reg_arg_list);
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1723 #if ARG_ORDER==1
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1724 delayed_arg = list2(assign_expr0(arg,e4,t,t),delayed_arg);
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1725 #else
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1726 g_expr_u(assign_expr0(arg,e4,t,t));
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1727 #endif
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1728
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1729
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1730
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1731 car(e3) = arg;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1732 return reg_arg_list;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1733 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1734
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1735
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1736 static void
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1737 increment_function_arg(int e3,int *pnargs,int *preg_arg,int *pfreg_arg) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1738 int nargs=0,reg_arg=0,freg_arg=0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1739 int t=caddr(e3);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1740 if(scalar(t)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1741 nargs ++ ; reg_arg++; freg_arg++;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1742 } else if (t==LONGLONG||t==ULONGLONG||t==DOUBLE) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1743 nargs ++ ; reg_arg++;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1744 nargs ++ ; reg_arg++;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1745 } else if (t==FLOAT) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1746 reg_arg ++ ; freg_arg++;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1747 nargs += size(t)/SIZE_OF_INT;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1748 } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1749 nargs += round4(size(t))/SIZE_OF_INT;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1750 } else {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1751 error(TYERR);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1752 nargs ++ ;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1753 }
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1754 *pnargs += nargs;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1755 *preg_arg += reg_arg;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1756 *pfreg_arg += freg_arg;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1757 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1758
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1759 #define AS_SAVE 1
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1760 #define AS_ARG 0
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1761
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1762 static int
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1763 get_input_arg(int t,int mode,int nargs,int reg_arg,int freg_arg)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1764 {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1765 if(scalar(t)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1766 if (mode==AS_SAVE) {
714
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1767 if (parse_mode)
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1768 return get_register_var(0);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1769 return list3n(LVAR,new_lvar(size(t)),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1770 } else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1771 return list3n(LVAR,caller_arg_offset_v(nargs),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1772 } else if (t==LONGLONG||t==ULONGLONG) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1773 if (mode==AS_SAVE) {
714
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1774 if (parse_mode)
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1775 return get_lregister_var(0);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1776 return list3n(LVAR,new_lvar(size(t)),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1777 } else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1778 return list3n(LVAR,caller_arg_offset_v(nargs),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1779 } else if (t==FLOAT) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1780 if (mode==AS_SAVE) {
714
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1781 if (parse_mode)
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1782 return get_dregister_var(0,0);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1783 return list3n(LVAR,new_lvar(size(t)),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1784 } else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1785 return list3n(LVAR,caller_arg_offset_v(nargs),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1786 } else if (t==DOUBLE) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1787 if (mode==AS_SAVE) {
714
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1788 if (parse_mode)
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1789 return get_dregister_var(0,1);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1790 return list3n(LVAR,new_lvar(size(t)),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1791 } else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1792 return list3n(LVAR,caller_arg_offset_v(nargs),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1793 } else if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1794 if (mode==AS_SAVE) {
714
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1795 if (parse_mode)
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1796 return get_register_var(0);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1797 return list3n(LVAR,new_lvar(size(t)),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1798 } else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1799 return list3n(LVAR,caller_arg_offset_v(nargs),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1800 } else {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1801 error(-1);
714
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1802 if (parse_mode)
5fad4649bed8 *** empty log message ***
kono
parents: 712
diff changeset
1803 return get_register_var(0);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1804 return list3n(LVAR,new_lvar(size(t)),0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1805 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1806 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1807
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1808 static void
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1809 code_call(int e2,NMTBL *fn,int jmp)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1810 {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1811 if (car(e2) == FNAME) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1812 #ifdef __APPLE__
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1813 printf("\tcall\tL_%s$stub\n",fn->nm);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1814 #else
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1815 printf("\tcall\t%s\n",fn->nm);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1816 #endif
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1817 } else {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1818 printf("\tcall\t*%s\n",register_name(REG_EAX,0));
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1819 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1820 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1821
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1822 int
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1823 function(int e1)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1824 {
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1825
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1826 int e2,e3,e4,e5,nargs,t;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1827 int arg,reg_arg,freg_arg,arg_assign;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1828 int dots;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1829 int reg_arg_list=0,ret_type,special_lvar;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1830 NMTBL *fn = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1831 int jmp = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1832 int complex_;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1833 int pnargs,preg_arg,pfreg_arg;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1834 int stargs;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1835 int half_register = 0;
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1836 #if (ARG_ORDER==1)
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1837 int save_delayed_arg = delayed_arg;
689
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1838 int as_save = AS_ARG; // 1st pushed argment will evaluate at the last
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1839 delayed_arg = 0;
689
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1840 #else
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1841 const int as_save = AS_SAVE;
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1842 #endif
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1843
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1844 special_lvar = -1;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1845 ret_type = function_type(cadddr(e1),&dots);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1846 if (caddr(cadddr(e1))==0) dots=1;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1847
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1848 arg_assign = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1849 e2 = cadr(e1);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1850 if (car(e2) == FNAME) {
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
1851 fn=ncaddr(e2);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1852 } else {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1853 if (car(e2)==INDIRECT) e2=cadr(e2); // (*func)(i) case
670
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
1854 jmp = list3(REGISTER,REG_EAX,0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1855
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1856 if (!simple_arg(e2)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1857 e3=get_register_var(0);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1858 reg_arg_list = list2(e3,reg_arg_list);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1859 g_expr_u(assign_expr0(e3,e2,INT,INT));
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1860 e2=e3;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1861 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1862 arg_assign = list2(assign_expr0(jmp,e2,INT,INT),arg_assign);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1863 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1864 /* First we execute complex argument to avoid interaction with
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1865 input variables. Remain the last complex argument in complex_. */
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1866 stargs = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1867 complex_ = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1868 nargs = reg_arg = freg_arg = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1869 pnargs = preg_arg = pfreg_arg = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1870 for (e3 = e1 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1871 t=caddr(e3);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1872 if (reg_arg==3 && (t==DOUBLE||t==LONGLONG||t==ULONGLONG)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1873 half_register=1;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1874 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1875 if ((e5= !simple_arg(car(e3)))) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1876 if (complex_) {
689
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1877 arg = get_input_arg(caddr(complex_),as_save,
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1878 pnargs,preg_arg,pfreg_arg);
689
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1879 #if ARG_ORDER==1
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1880 as_save = AS_SAVE;
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1881 #endif
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1882 reg_arg_list = compute_complex_arg(complex_,reg_arg_list,arg);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1883 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1884 // memorise last complex arg parameter
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1885 pnargs=nargs;preg_arg=reg_arg;pfreg_arg=freg_arg;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1886 complex_ = e3;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1887 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1888 if (t>=0&&(car(t)==STRUCT||car(t)==UNION)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1889 // The struct should be pushed after complex arguments.
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1890 if (e5) { // compute address only, complex_ is me now. Clear it.
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1891 complex_ = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1892 e4 = car(e3);
693
e5a498eab0f4 *** empty log message ***
kono
parents: 689
diff changeset
1893 if (car(e4)==RSTRUCT) e4 = cadr(e4);
784
3bc6c34bfa2e i64 obsf2
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 782
diff changeset
1894 else if (car(e4)==INDIRECT) e4 = cadr(e4);
693
e5a498eab0f4 *** empty log message ***
kono
parents: 689
diff changeset
1895 if (!simple_arg(e4)) {
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1896 // Calculate complex struct address here.
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1897 // If simple, leave it.
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1898 arg = get_register_var(0);
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1899 #if ARG_ORDER==1
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1900 delayed_arg = list2(
693
e5a498eab0f4 *** empty log message ***
kono
parents: 689
diff changeset
1901 assign_expr0(arg,e4,INT,INT),
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1902 delayed_arg);
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1903 #else
693
e5a498eab0f4 *** empty log message ***
kono
parents: 689
diff changeset
1904 g_expr_u(assign_expr0(arg,e4,INT,INT));
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1905 #endif
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1906 car(e3)=arg;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1907 reg_arg_list = list2(arg,reg_arg_list);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1908
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1909 car(e3) = rvalue_t(arg,INT);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1910 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1911 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1912 stargs = list4(e3,stargs,nargs,reg_arg);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1913 }
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1914 increment_function_arg(e3,&nargs,&reg_arg,&freg_arg);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1915 }
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1916 #if (ARG_ORDER==1)
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1917 if (complex_) {
689
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1918 arg = get_input_arg(caddr(complex_),as_save,
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1919 pnargs,preg_arg,pfreg_arg);
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1920 reg_arg_list = compute_complex_arg(complex_,reg_arg_list,arg);
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1921 }
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1922 for(;delayed_arg;delayed_arg = cadr(delayed_arg)) {
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1923 g_expr_u(car(delayed_arg));
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1924 }
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1925 #endif
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1926
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1927 /* now all input register vars are free */
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
1928 code_save_stacks();
536
a349f9c2aef5 MIPS set_ireg/lreg interferance
kono
parents: 534
diff changeset
1929
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1930 // set_lreg(LREG_LREGISTER,0);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1931 set_freg(FREG_FREGISTER,0);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1932 set_ireg(CREG_REGISTER,0);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1933
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1934 // Struct arguments need emit_copy. it destructs 3 input registers.
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1935 // But it returns no value on a register. So calculate it here.
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1936 // We cannot do this in the previous loop, because the copied struct may be
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1937 // override by other complex arguments. But before this we have to check
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1938 // complex_.
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1939
689
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1940 // ARG_ORDER==1 case put the last value on the top of stack.
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1941 // emit_copy/push_struct must preserve argument stack, i.e.
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1942 // no library call is allowed.
baa67e2e54d2 *** empty log message ***
kono
parents: 686
diff changeset
1943
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1944 if (stargs) {
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1945 #if (ARG_ORDER!=1)
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1946 if (complex_) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1947 arg = get_input_arg(caddr(complex_),AS_SAVE,
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1948 pnargs,preg_arg,pfreg_arg);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1949 reg_arg_list = compute_complex_arg(complex_,reg_arg_list,arg);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1950 }
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1951 #endif
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1952 for(stargs=reverse0(stargs);stargs;stargs = cadr(stargs)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1953 e3 = car(stargs);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1954 e4 = car(e3);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1955 t = caddr(e3);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1956 arg = get_input_arg(t,AS_ARG,caddr(stargs),cadddr(stargs),0);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1957 push_struct(e4,t,arg);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1958 car(e3)=0; // done
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1959
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1960
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1961 }
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1962 #if (ARG_ORDER!=1)
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1963 } else {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1964 // last complex argument can use input register
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1965 if (complex_) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1966 arg = get_input_arg(caddr(complex_),AS_ARG,pnargs,preg_arg,pfreg_arg)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1967 ;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1968 reg_arg_list = compute_complex_arg(complex_,reg_arg_list,arg);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1969
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1970 car(complex_) = 0; // done.
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1971
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1972
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1973 }
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
1974 #endif
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
1975 }
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1976
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1977 nargs = reg_arg = freg_arg = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1978 // calc stack arguments first, it may requires extra registers,
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1979 // and we can still use input registers now.
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1980 for (e3 = e1; e3;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1981 increment_function_arg(e3,&nargs,&reg_arg,&freg_arg),
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1982 e3 = cadr(e3)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1983 if (!(e4=car(e3))) continue;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1984 t=caddr(e3);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1985 arg = get_input_arg(t,AS_ARG,nargs,reg_arg,freg_arg);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1986 if (car(arg)!=LVAR) continue;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1987 g_expr_u(assign_expr0(arg,e4,t,t));
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1988 car(e3)=0; // done
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1989 }
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1990 if (max_func_args<nargs) max_func_args=nargs;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1991 for(;arg_assign;arg_assign=cadr(arg_assign)) {
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1992 g_expr_u(car(arg_assign));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
1993 }
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
1994 clear_ptr_cache();
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1995 code_call(e2,fn,jmp);
716
21f770a3b298 *** empty log message ***
kono
parents: 715
diff changeset
1996 free_register_var(reg_arg_list);
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
1997 if (ret_type==DOUBLE||ret_type==FLOAT) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
1998 } else if (ret_type==LONGLONG||ret_type==ULONGLONG) {
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
1999 use_longlong0(USE_CREG);
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
2000 } else if (ret_type==VOID) {
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2001 } else {
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2002 if (use)
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2003 set_ireg(RET_REGISTER,0);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2004 else
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2005 set_ireg(CREG_REGISTER,0);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
2006 }
686
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
2007 #if (ARG_ORDER==1)
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
2008 delayed_arg = save_delayed_arg;
7e0c5c1f1e97 IA32 arg evaluation order
kono
parents: 685
diff changeset
2009 #endif
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
2010 return ret_type;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2011 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2012
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2013 void
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2014 code_alloca(int e1,int reg)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2015 {
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2016 char *crn;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2017
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
2018 if (!is_const(e1)) {
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
2019 g_expr(list3(BAND,list3(ADD,e1,list2(CONST,15)),list2(CONST,~15)));
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
2020 use_int(reg);
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
2021 } else {
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
2022 use_int(reg);
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
2023 code_const(round16(cadr(e1)),reg);
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
2024 }
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2025 crn = register_name(reg,0);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2026 printf("\tsubl\t%s, %%esp\n",crn);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2027 if (!max_func_arg_label) max_func_arg_label = fwdlabel();
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2028 printf("\tmovl $%s%d,%s\n",lpfx,max_func_arg_label ,crn);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2029 printf("\tadd\t%%esp, %s\n",crn);
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2030 }
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2031
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2032 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2033 code_frame_pointer(int e3) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2034 use_int(e3);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2035 printf("\tmovl %s,%%ebp\n",register_name(e3,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2036 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2037
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 570
diff changeset
2038 int
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 570
diff changeset
2039 code_frame_pointer_register()
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 570
diff changeset
2040 {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2041 return list2(REGISTER,REG_fp);
578
dbde3b869a0f try to remove code_fix_frame_pointer(); PowerPC fixed.
kono
parents: 570
diff changeset
2042 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2043
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2044 void
62
129f4802b027 separation done
kono
parents: 61
diff changeset
2045 code_fix_frame_pointer(int disp_offset) {
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
2046 // must be empty
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2047 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2048
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2049 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2050 code_jmp(char *s) {
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2051 #ifdef __APPLE__
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2052 printf("\tjmp\tL_%s$stub\n",s);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2053 #else
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2054 printf("\tjmp %s\n",s);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2055 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2056 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2057
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2058
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2059 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2060 code_indirect_jmp(int e2) {
364
c29eebf3eaf4 local label and indirect goto.
kono
parents: 363
diff changeset
2061 use_int(e2);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2062 printf("\tjmp *%s\n",register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2063 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2064
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2065 void
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2066 code_rindirect(int e1, int reg,int offset, int sign,int byte)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2067 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2068 char *crn,*op;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2069 g_expr(e1);
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2070 op=cload(sign,byte);
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2071 crn = register_name(creg,0);
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2072 use_int(reg);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2073 printf("\t%s %d(%s),%s\n",op,offset,crn,register_name(reg,0));
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2074 }
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2075
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2076 #if FLOAT_CODE
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2077 int
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2078 code_drindirect(int e1, int reg,int offset, int d)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2079 {
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2080 g_expr(e1);
477
308192c08e0a *** empty log message ***
kono
parents: 476
diff changeset
2081 printf("\t%s %d(%s)\n",fload(d),offset,register_name(creg,0));
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2082 return DOUBLE;
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2083 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
2084 #endif
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2085
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2086 #if LONGLONG_CODE
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2087
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2088 static void
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2089 lload(int creg,int offset,int reg)
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2090 {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2091 char *crn = register_name(creg,0);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2092 use_longlong(reg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2093 if((reg==REG_L&&creg==REG_ESI)||(creg==REG_EAX)) {
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2094 printf("\tmovl %d(%s),%s\n",offset+SIZE_OF_INT,crn,l_edx(reg));
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2095 printf("\tmovl %d(%s),%s\n",offset,crn,l_eax(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2096 } else {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2097 printf("\tmovl %d(%s),%s\n",offset,crn,l_eax(reg));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2098 printf("\tmovl %d(%s),%s\n",offset+SIZE_OF_INT,crn,l_edx(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2099 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2100 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2101
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2102 int
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2103 code_lrindirect(int e1, int reg, int offset, int us)
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2104 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2105 int reg0;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2106 g_expr(e1);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2107 reg0=creg;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
2108 use_longlong(reg);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2109 lload(reg0,offset,reg);
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 196
diff changeset
2110 return LONGLONG;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2111 }
196
5f70abd9453d *** empty log message ***
kono
parents: 195
diff changeset
2112 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2113
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2114 char *
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2115 move(int byte)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2116 {
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2117 return byte==1?"movb":byte==SIZE_OF_SHORT?"movw":"movl";
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2118 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2119
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2120 void
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2121 code_assign_gvar(int e2,int creg,int byte) {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2122 if (byte) { use_data_reg(creg,1);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2123 } else { use_int(creg); }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2124 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
2125 int r = get_ptr_cache(ncaddr(e2));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2126 if (cadr(e2))
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
2127 printf("\t%s %s,%d(%s)\n",move(byte),register_name(creg,byte),
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2128 cadr(e2),register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2129 else
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
2130 printf("\t%s %s,(%s)\n",move(byte),register_name(creg,byte),
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2131 register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2132 #else
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
2133 if (cadr(e2))
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
2134 printf("\t%s %s,%s+%d\n",move(byte),register_name(creg,byte),(ncaddr(e2))->nm,cadr(e2));
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
2135 else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
2136 printf("\t%s %s,%s\n",move(byte),register_name(creg,byte),(ncaddr(e2))->nm);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2137 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2138 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2139
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2140 void
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2141 code_assign_lvar(int e2,int creg,int byte) {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2142 if (byte) { use_data_reg(creg,1);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2143 } else { use_int(creg); }
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2144 printf("\t%s %s,",move(byte),register_name(creg,byte));
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2145 lvar(e2); printf("\n");
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2146 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2147
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2148 void
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
2149 code_assign_register(int e2,int byte,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2150 use_int(creg);
286
179e22f166ef register assop fix
kono
parents: 280
diff changeset
2151 if (creg!=e2)
179e22f166ef register assop fix
kono
parents: 280
diff changeset
2152 printf("\tmovl %s,%s\n",register_name(creg,0),register_name(e2,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2153 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2154
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2155 void
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
2156 code_assign(int e2,int byte,int creg) {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2157 use_int(e2);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2158 if (byte) { use_data_reg(creg,1);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2159 } else { use_int(creg); }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2160 printf("\t%s %s,(%s)\n",move(byte),register_name(creg,byte),register_name(e2,0));
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2161 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2162
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2163 void
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2164 code_register_assop(int e2,int reg, int op,int byte) {
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2165 // reg <= reg(e2) op=reg
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2166 use_int(reg);
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2167 tosop(op,e2,reg);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2168 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2169
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2170 void
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2171 code_assop(int op,int creg,int byte,int sign) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2172 int xreg;
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
2173 // (*pop()) op = creg
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
2174 // creg should be ecx
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2175
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2176 use_int(creg);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2177 xreg = emit_pop(0); /* pop e3 value */
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2178 emit_push();
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2179 ld_indexx(byte,0,creg,ireg,sign);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2180 tosop(op,ireg,xreg);
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2181 emit_pop_free(xreg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2182 if (byte) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2183 use_data_reg(ireg,1);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2184 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2185 xreg = emit_pop(0); /* pop e3 value */
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2186 printf("\t%s %s,(%s)\n",move(byte),register_name(ireg,byte),register_name(xreg,0));
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2187 emit_pop_free(xreg);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2188 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2189
594
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2190 int
599
df04bc5fd5fe *** empty log message ***
kono
parents: 594
diff changeset
2191 tosop_operand_safe_p(int op)
594
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2192 {
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2193 switch(op) {
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2194 case ADD: case SUB: case CMP:
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2195 case BAND: case EOR: case BOR:
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2196 case MUL: case UMUL:
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2197 return 1;
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2198 default: return 0;
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2199 }
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2200 }
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2201
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2202 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2203 tosop(int op,int reg,int oreg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2204 {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2205 int ox=0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2206 char *orn,*crn;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2207 // creg = creg op oreg
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2208
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2209 use_int(reg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2210
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2211 if(oreg==-1) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2212 error(-1);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2213 } else if (oreg<= -REG_LVAR_OFFSET) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2214 ox = get_register(); if (ox<0) error(-1);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2215 code_rlvar(oreg+REG_LVAR_OFFSET,ox);
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
2216 free_lvar(oreg+REG_LVAR_OFFSET);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2217 oreg = ox;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2218 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2219
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2220 switch(op) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2221 case LSHIFT:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2222 case ULSHIFT:
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2223 shift("sall",oreg,reg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2224 if(ox) free_register(ox);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2225 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2226 case RSHIFT:
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2227 shift("sarl",oreg,reg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2228 if(ox) free_register(ox);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2229 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2230 case URSHIFT:
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2231 shift("shrl",oreg,reg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2232 if(ox) free_register(ox);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2233 return;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2234 }
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2235 // regs[oreg]=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2236 orn = register_name(oreg,0);
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2237 crn = register_name(reg,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2238 switch(op) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2239 case ADD:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2240 printf("\taddl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2241 break;
594
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2242 case SUB:
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2243 printf("\tsubl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2244 break;
594
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2245 case CMP:
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2246 printf("\tcmpl %s,%s\n",orn,crn);
f49c825920c4 tosop optimize buf fix
kono
parents: 590
diff changeset
2247 break;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2248 case BAND:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2249 printf("\tandl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2250 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2251 case EOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2252 printf("\txorl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2253 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2254 case BOR:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2255 printf("\torl %s,%s\n",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2256 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2257 case MUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2258 case UMUL:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2259 printf("\t%s %s,%s\n","imull",orn,crn);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2260 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2261 case DIV:
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2262 case UDIV:
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
2263 case MOD:
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
2264 case UMOD:
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
2265 #ifdef __APPLE__
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
2266 if (regs[REG_EDX]==PTRC_REG)
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
2267 clear_ptr_cache_reg(REG_EDX);
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
2268 #endif
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2269 use_register(reg,REG_EAX,1);
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2270 if (oreg==REG_EAX) oreg=reg;
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
2271 if (oreg==REG_EDX) {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2272 use_register(oreg,REG_ECX,1);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2273 oreg = REG_ECX;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2274 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2275 orn = register_name(oreg,0);
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
2276 printf((op==DIV||op==MOD)?
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
2277 "\tcltd\n\tidivl %s\n":
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
2278 "\txor %%edx,%%edx\n\tdivl %s\n",orn);
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
2279 set_ireg((op==MOD||op==UMOD)?REG_EDX:REG_EAX,0);
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2280 set_ireg(reg,1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2281 break;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2282 }
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
2283 if(ox && ox!=ireg) free_register(ox);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2284 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2285
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2286 int
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2287 code_const_op_p(int op,int e)
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2288 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2289 if (car(e)!=CONST) return 0;
366
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
2290 if (op==DIV||op==UDIV) return ilog(cadr(e));
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
2291 if (op==MOD||op==UMOD) return 0;
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2292 else return 1;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2293 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2294
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2295 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
2296 oprtc(int op,int reg,int orn)
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2297 {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2298 char *crn;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2299 int datareg;
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2300 use_int(reg);
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2301 crn = register_name(reg,0);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
2302 orn = cadr(orn);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2303 datareg=is_data_reg(reg);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2304
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2305 switch(op) {
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2306 case LSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2307 case ULSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2308 printf("\tsall $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2309 return;
366
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
2310 case DIV:
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
2311 orn = ilog(orn);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2312 case RSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2313 printf("\tsarl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2314 return;
366
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
2315 case UDIV:
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
2316 orn = ilog(orn);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2317 case URSHIFT:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2318 printf("\tshrl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2319 return;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2320 case ADD:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2321 printf("\taddl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2322 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2323 case SUB: case CMP:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2324 printf("\tsubl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2325 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2326 case BAND:
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2327 if (datareg&&(orn & ~255)==~255)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2328 printf("\tandb $%d,%s\n",orn,register_name(reg,1));
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2329 else if (datareg&&(orn & ~65535)==~65535)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2330 printf("\tandw $%d,%s\n",orn,register_name(reg,2));
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2331 else
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2332 printf("\tandl $%d,%s\n",orn,crn);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2333 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2334 case EOR:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2335 printf("\txorl $%d,%s\n",orn,crn);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2336 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2337 case BOR:
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2338 if (datareg&&(orn & ~255)==0)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2339 printf("\tor $%d,%s\n",orn,register_name(reg,1));
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2340 else if (datareg&&(orn & ~65535)==0)
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2341 printf("\tor $%d,%s\n",orn,register_name(reg,2));
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2342 else
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
2343 printf("\torl $%d,%s\n",orn,crn);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2344 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2345 case MUL:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2346 case UMUL:
366
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
2347 if (ilog(orn)) {
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
2348 printf("\tsall $%d,%s\n",ilog(orn),crn);
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
2349 } else
2d510935c37d *** empty log message ***
kono
parents: 365
diff changeset
2350 printf("\t%s $%d,%s\n","imull",orn,crn);
189
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2351 break;
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2352 default:
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2353 error(-1);
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2354 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2355 }
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2356
f53d70110377 immediate instructions.
kono
parents: 187
diff changeset
2357
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2358 void
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2359 shift(char *op, int oreg,int reg)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2360 {
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2361 int dreg;
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2362 use_register(oreg,REG_ECX,1);
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2363 dreg = (reg==REG_ECX)?oreg:reg;
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2364 printf("\t%s %%cl,%s\n",op,register_name(dreg,0));
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2365 set_ireg(dreg,0);
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
2366 set_ireg(reg,1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2367 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2368
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2369 void
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
2370 ld_indexx(int byte, int n, int xreg,int reg,int sign)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2371 {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2372 if (byte) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2373 use_data_reg(reg,1);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2374 } else {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2375 use_int(reg);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2376 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2377 if (n)
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2378 printf("\t%s %d(%s),%s\n",cload(sign,byte),n,
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2379 register_name(xreg,0),register_name(reg,0));
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2380 else
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2381 printf("\t%s (%s),%s\n",cload(sign,byte),
6188f66c0c0b cond op, and arg scope.
kono
parents: 353
diff changeset
2382 register_name(xreg,0),register_name(reg,0));
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2383 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2384
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2385 int
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2386 code_csvalue()
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
2387 {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2388 return glist2(REGISTER,creg); /* for switch value */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2389 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2390
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2391 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2392 code_cmpdimm(int e, int csreg,int label,int cond)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2393 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2394 /* used in dosiwtch() */
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
2395 set_ireg(csreg,0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2396 printf("\tcmpl $%d,%s\n",e,register_name(creg,0));
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2397 jcond(label,cond);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2398 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2399
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2400 void
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
2401 code_opening(char *filename)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2402 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2403 printf("\t.file \"%s\"\n",filename);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2404 printf("\t.version\t\"01.01\"\n");
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
2405 /* printf("gcc2_compiled.:\n"); */
605
1078c7e3bfb0 minor fixes
kono
parents: 599
diff changeset
2406 // printf(".text\n");
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2407 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2408
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2409 void
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
2410 code_closing()
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2411 {
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
2412 global_table();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2413 printf("\t.ident \"Micro-C compiled\"\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2414 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2415
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2416 static char *
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2417 code_cond(int op,int cond)
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2418 {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2419 switch(op) {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2420 case GT: return code_gt(cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2421 case UGT: return code_ugt(cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2422 case GE: return code_ge(cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2423 case UGE: return code_uge(cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2424 case LT: return code_ge(!cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2425 case ULT: return code_uge(!cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2426 case LE: return code_gt(!cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2427 case ULE: return code_ugt(!cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2428 case EQ: return code_eq(cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2429 case NEQ: return code_eq(!cond);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2430 default: return 0;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2431 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2432 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2433
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2434 static int
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2435 rexpr_bool(int e1,int reg)
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2436 {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2437 char *s;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2438 if (!(s=code_cond(car(e1),1))) return 0;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2439 g_expr(list3(CMP,cadr(e1),caddr(e1)));
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2440 use_data_reg(reg,1);
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2441 printf("\tset%s\t%s\n",s,register_name(reg,1));
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2442 printf("\tmovzbl %s,%s\n",register_name(reg,1),register_name(reg,0));
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2443 return 1;
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2444 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2445
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
2446 int
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2447 rexpr(int e1, int l1, int cond,int t)
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
2448 {
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
2449 g_expr(list3(CMP,cadr(e1),caddr(e1)));
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
2450 printf("\tj%s\t_%d\n",code_cond(car(e1),cond),l1);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
2451 return l1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2452 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2453
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2454
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
2455 static void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2456 jcond(int l, char cond)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2457 {
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
2458 printf("\tj%s\t_%d\n",cond==LT?code_ge(0):cond?"ne":"e",l);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2459 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2460
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2461 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2462 jmp(int l)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2463 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2464 printf("\tjmp\t_%d\n",l);
709
8b54c40081de *** empty log message ***
kono
parents: 705
diff changeset
2465 control = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2466 /* align? */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2467 /*
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2468 this is not allowed because of ? operator
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2469 use_register(creg,REG_EAX,0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2470 */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2471 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2472
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2473 void
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 451
diff changeset
2474 code_comment(char *s)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2475 {
66
0b068058dd67 *** empty log message ***
kono
parents: 63
diff changeset
2476 printf("## %s",s);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2477 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2478
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2479
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2480 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2481 code_enter(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2482 {
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
2483 text_mode(0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2484 printf("\t.align 4\n");
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2485 #ifndef __APPLE__
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2486 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2487 printf(".globl %s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2488 printf("\t.type\t%s,@function\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2489 printf("%s:\n",name);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2490 #else
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2491 if (stmode!=STATIC)
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2492 printf(".globl _%s\n",name);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2493 printf("_%s:\n",name);
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2494 clear_ptr_cache();
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2495 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2496 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2497
77
2b8ba655e572 fix arg type
kono
parents: 66
diff changeset
2498
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2499 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2500 code_enter1(int args)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2501 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2502 code_disp_label=fwdlabel();
670
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
2503 printf("\tlea -_%d(%%ebp),%%esp\n",code_disp_label);
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
2504
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
2505 // printf("## args %d disp %d code_disp_offset=%d\n",args,disp,code_disp_offset);
633
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
2506 #ifdef __APPLE__
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
2507 printf("\tcall\t___i686.get_pc_thunk.bx\n");
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
2508 printf("_%d:\n",labelno);
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
2509 goffset_label = labelno;
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
2510 labelno++;
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
2511 regs[REG_EBX] = 1;
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
2512 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2513 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2514
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2515 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2516 code_leave(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2517 {
670
bce312f3c0cb *** empty log message ***
kono
parents: 669
diff changeset
2518 code_offset_set(fnptr);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2519 #ifndef __APPLE__
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2520 printf("_%d:\n",labelno);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2521 printf("\t.size\t%s,_%d-%s\n",name,labelno,name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2522 local_table();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2523 labelno++;
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2524 #else
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2525 local_table();
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2526 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2527 free_all_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2528 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2529
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2530 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2531 enter(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2532 {
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
2533 text_mode(0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2534 printf("\t.align 2\n");
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2535 #ifndef __APPLE__
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2536 if (stmode!=STATIC)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2537 printf(".globl %s\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2538 printf("%s:\n",name);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2539 printf("\t.type\t%s,@function\n",name);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2540 #else
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2541 if (stmode!=STATIC)
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2542 printf(".globl _%s\n",name);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2543 printf("_%s:\n",name);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2544 #endif
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2545
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
2546 // lvar_offset_label = fwdlabel();
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2547 r1_offset_label = fwdlabel();
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2548 max_func_args = 0;
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2549
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2550 printf("\tpushl %%ebp\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2551 printf("\tmovl %%esp,%%ebp\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2552 printf("\tpushl %%ebx\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2553 printf("\tpushl %%esi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2554 printf("\tpushl %%edi\n");
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
2555 printf("\tlea -%s%d(%%ebp),%%esp\n",lpfx,r1_offset_label);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2556 #ifdef __APPLE__
627
65eb070e731c Intel Mac continue...
kono
parents: 626
diff changeset
2557 printf("\tcall\t___i686.get_pc_thunk.bx\n");
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2558 printf("_%d:\n",labelno);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2559 goffset_label = labelno;
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2560 labelno++;
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
2561 regs[REG_EBX] = 1;
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2562 clear_ptr_cache();
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2563 #endif
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2564
451
656ec59cd79f ia32 fix
kono
parents: 450
diff changeset
2565 control=1;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2566 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2567
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2568 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2569 enter1()
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2570 {
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
2571 text_mode(0);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2572 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2573
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2574 void
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2575 code_label_call(int l)
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2576 {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2577 printf("\tcall\tL_%d\n",l);
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2578 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2579
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2580 void
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2581 code_ret()
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2582 {
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2583 printf("\tret\n");
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2584 control=0;
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2585 }
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2586
725
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2587 static void
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2588 make_return_continuation()
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2589 {
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2590 int ty = cadr(fnptr->ty);
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2591 fwddef(retcont);
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2592 if (ty==FLOAT||ty==DOUBLE) {
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2593 printf("\tfldl %d(%%ebp)\n",-SIZE_OF_DOUBLE);
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2594 printf("\tmovl %s,%%ebp\n",reg_name[REG_ESI]);
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2595 } else if (ty==LONGLONG||ty==ULONGLONG) {
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2596 set_lreg(RET_LREGISTER,0);
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2597 printf("\tmovl %d(%%ebp),%%ebp\n",disp-SIZE_OF_INT);
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2598 } else if (ty>0&&( car(ty)==STRUCT || car(ty)==UNION)) {
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2599 set_ireg(RET_REGISTER,0);
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2600 printf("\tmovl %d(%%ebp),%s\n",disp-SIZE_OF_INT,
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2601 register_name(creg,0));
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2602 printf("\tmovl %s,%%ebp\n",reg_name[REG_EDI]);
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2603 } else if (ty!=VOID) {
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2604 set_ireg(RET_REGISTER,0);
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2605 printf("\tmovl %s,%s\n",reg_name[REG_ESI],register_name(creg,0));
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2606 printf("\tmovl %s,%%ebp\n",reg_name[REG_EDI]);
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2607 }
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2608 }
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2609
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
2610 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2611 leave(int control, char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2612 {
128
d497c39add36 arg.c works (?)
kono
parents: 127
diff changeset
2613
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
2614 #ifdef __APPLE__
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
2615 disp &= -(SIZE_OF_INT*4); // 16byte alignment
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
2616 disp -= 12;
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
2617 #else
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
2618 disp &= -SIZE_OF_INT;
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
2619 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2620 if (control)
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2621 code_set_return_register(1);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2622 if (retcont) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2623 if (control)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2624 jmp(retlabel);
725
3f1f6c0610c1 goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 724
diff changeset
2625 make_return_continuation();
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2626 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2627 fwddef(retlabel);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
2628 code_offset_set(fnptr);
63
e13486b2c12e stack alignment
kono
parents: 62
diff changeset
2629
669
1530b1a636ac ato mouchotto...
kono
parents: 668
diff changeset
2630 printf("\tlea %d(%%ebp),%%esp\n",-12);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2631 printf("\tpopl %%edi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2632 printf("\tpopl %%esi\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2633 printf("\tpopl %%ebx\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2634 printf("\tleave\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2635 printf("\tret\n");
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2636 #ifndef __APPLE__
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2637 printf("_%d:\n",labelno);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2638 printf("\t.size\t%s,_%d-%s\n",name,labelno,name);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2639 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2640 local_table();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2641 labelno++;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2642 free_all_register();
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2643 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2644
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2645 int
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2646 code_get_fixed_creg(int reg,int type) {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2647 if (type==FLOAT||type==DOUBLE) {
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2648 return 0;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2649 } else if (type==LONGLONG||type==ULONGLONG) {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2650 use_longlong(reg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2651 return reg;
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2652 } else {
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
2653 if (reg==USE_CREG) {
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
2654 if (regs[CREG_REGISTER]==0) {
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
2655 set_ireg(CREG_REGISTER,is_int_reg(creg)&&regs[creg]==USING_REG);
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
2656 return CREG_REGISTER;
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
2657 }
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
2658 }
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
2659 use_int(reg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2660 return reg;
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2661 }
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2662 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2663
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2664 void
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2665 code_set_fixed_creg(int reg,int mode,int type) {
108
69e2e763cce5 object assemble first try.
kono
parents: 107
diff changeset
2666 if (type==FLOAT||type==DOUBLE) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2667 } else if (type==LONGLONG||type==ULONGLONG) {
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2668 } else {
585
a5b902b20300 ia32 reconfigure end (correct?)
kono
parents: 584
diff changeset
2669 set_ireg(reg,mode);
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
2670 }
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2671 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2672
705
0554b7f985ee parse mode done.
kono
parents: 700
diff changeset
2673 int
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2674 code_set_return_register(int mode) {
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
2675 // before goto leave code, set return register
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2676 if (cadr(fnptr->ty)==FLOAT) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2677 // set_freg(RET_FREGISTER,mode);
705
0554b7f985ee parse mode done.
kono
parents: 700
diff changeset
2678 return 0;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2679 } else if (cadr(fnptr->ty)==DOUBLE) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2680 // set_dreg(RET_DREGISTER,mode);
705
0554b7f985ee parse mode done.
kono
parents: 700
diff changeset
2681 return 0;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2682 } else if (cadr(fnptr->ty)==LONGLONG||cadr(fnptr->ty)==ULONGLONG) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2683 set_lreg(RET_LREGISTER,mode);
705
0554b7f985ee parse mode done.
kono
parents: 700
diff changeset
2684 return ireg;
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2685 } else if (cadr(fnptr->ty)==VOID) {
705
0554b7f985ee parse mode done.
kono
parents: 700
diff changeset
2686 return 0;
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2687 } else {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
2688 set_ireg(RET_REGISTER,mode);
705
0554b7f985ee parse mode done.
kono
parents: 700
diff changeset
2689 return ireg;
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2690 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2691 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2692
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
2693 void
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2694 gen_gdecl(char *n, int gpc)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2695 {
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
2696 // must be empty
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2697 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2698
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2699 extern void
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2700 ascii(char *s)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2701 {
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2702 #ifdef __APPLE__
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2703 printf("\t.ascii \"");
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2704 #else
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2705 printf("\t.string \"");
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2706 #endif
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2707 while(*s) {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2708 if (*s=='\n')
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2709 printf("%cn",92);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2710 else if (*s<' ')
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2711 printf("%c%03o",92,*s);
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
2712 else if (*s=='\\')
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
2713 printf("\\\\");
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2714 else if (*s==34)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2715 printf("%c%c",92,34);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2716 else
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2717 printf("%c",*s);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2718 s++;
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2719 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2720 #ifdef __APPLE__
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2721 printf("\\0%c\n",34);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2722 #else
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2723 printf("%c\n",34);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2724 #endif
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2725 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2726
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2727 extern int
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2728 emit_string_label()
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2729 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2730 int lb;
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
2731 cstring_mode();
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2732 lb=fwdlabel();
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2733 printf("_%d:\n",lb);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2734 return lb;
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2735 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2736
518
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2737 extern void
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2738 emit_string(char *s,int t)
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2739 {
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2740 t = type_value(t);
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2741 if (car(t)==ARRAY &&
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2742 (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) {
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2743 ascii(s);
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2744 } else {
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2745 int l = emit_string_label();
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2746 ascii(s);
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2747 emit_label(l);
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2748 }
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2749 return;
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2750 }
9f2d6aea201f cstring fix.... finally
kono
parents: 517
diff changeset
2751
415
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
2752 void
716
21f770a3b298 *** empty log message ***
kono
parents: 715
diff changeset
2753 code_align(int t)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2754 {
415
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
2755 int d;
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
2756 switch(t) {
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
2757 case CHAR: case UCHAR: return;
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
2758 case SHORT: case USHORT: d = data_alignment & 1; break;
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
2759 default: d = data_alignment & 3;
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
2760 }
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
2761 if (d) {
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
2762 printf("\t.align 2\n");
bdf900926f32 fix cpmd register
kono
parents: 411
diff changeset
2763 data_alignment = 0;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2764 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2765 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2766
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2767 extern void
517
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
2768 emit_global(NMTBL *n,int a,int e)
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2769 {
517
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
2770 int t = type_value(n->ty);
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
2771 if (e>0 && car(e)==STRING && t>0 && car(t)==ARRAY &&
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
2772 (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) {
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
2773 cstring_mode();
517
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
2774 } else
d686497e8fd2 cstring array fix.
kono
parents: 516
diff changeset
2775 data_mode(n->nm);
716
21f770a3b298 *** empty log message ***
kono
parents: 715
diff changeset
2776 code_align(a);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2777 #ifdef __APPLE__
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2778 if (n && n->sc!=STATIC)
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2779 printf(".globl\t_%s\n",n->nm);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2780 printf("_%s:\n",n->nm);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2781 #else
542
492f06738550 working... (struct init fix)
kono
parents: 536
diff changeset
2782 if (n && n->sc!=STATIC)
492f06738550 working... (struct init fix)
kono
parents: 536
diff changeset
2783 printf(".globl\t%s\n",n->nm);
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
2784 printf("%s:\n",n->nm);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2785 #endif
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2786 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2787
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2788 extern void
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2789 emit_space(int sp)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2790 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2791 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2792 printf("\t.space\t%d\n",sp);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2793 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2794
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2795 extern void
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2796 emit_char(int d)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2797 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2798 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2799 printf("\t.byte %d\n",d);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2800 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2801
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2802 extern void
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2803 emit_short(int d)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2804 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2805 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2806 printf("\t.short %d\n",d);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2807 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2808
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2809 extern void
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2810 emit_int(int d)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2811 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2812 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2813 printf("\t.long %d\n",d);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2814 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2815
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2816 extern void
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2817 emit_longlong(int e)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2818 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2819 #if LONGLONG_CODE
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2820 long long ll = lcadr(e);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2821 data_mode(0);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
2822 #if (ENDIAN_L==0)
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2823 printf("\t.long\t0x%x,0x%x\n",code_l1(ll),code_l2(ll));
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2824 #else
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2825 printf("\t.long\t0x%x,0x%x\n",code_l2(ll),code_l1(ll));
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2826 #endif
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2827 #endif
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2828 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2829
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2830 extern void
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2831 emit_double(int e)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2832 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2833 #if FLOAT_CODE
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2834 double d = dcadr(e);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2835 data_mode(0);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
2836 #if (ENDIAN_D==0)
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2837 printf("\t.long\t0x%x,0x%x\n",code_d1(d),code_d2(d));
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2838 #else
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2839 printf("\t.long\t0x%x,0x%x\n",code_d2(d),code_d1(d));
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2840 #endif
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2841 #endif
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2842 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2843
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2844 extern void
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2845 emit_float(int e)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2846 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2847 #if FLOAT_CODE
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2848 float f = dcadr(e);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2849 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2850 printf("\t.long\t0x%x\n",*(int *)&f);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2851 #endif
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2852 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2853
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2854 extern void
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
2855 emit_address(char *s,int offset)
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2856 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2857 data_mode(0);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2858 #ifdef __APPLE__
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2859 if (offset)
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2860 printf("\t.long _%s+%d\n",s,offset);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2861 else
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2862 printf("\t.long _%s\n",s);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2863 #else
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
2864 if (offset)
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
2865 printf("\t.long %s+%d\n",s,offset);
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
2866 else
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
2867 printf("\t.long %s\n",s);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2868 #endif
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2869 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2870
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2871 extern void
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2872 emit_label(int labelno)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2873 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2874 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2875 printf("\t.long _%d\n",labelno);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2876 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2877
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2878 extern void
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2879 emit_data_closing(NMTBL *n)
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2880 {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2881 #ifdef DOT_SIZE
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2882 int lb;
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2883 #endif
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2884 if (mode==GDECL) {
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2885 data_mode(0);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2886 #ifdef DOT_SIZE
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2887 lb=fwdlabel();
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2888 printf("_%d:\n",lb);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2889 printf("\t.size\t%s,_%d-%s\n",n->nm,lb,n->nm);
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2890 #endif
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2891 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2892 }
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
2893
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2894 #if LONGLONG_CODE
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2895 static long long ll0 = 1LL;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2896
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2897 static int
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2898 code_l1(long long d)
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2899 {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2900 int *i = (int *)&ll0; int *j = (int *)&d;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2901 return (i[1] == 1)?j[1]:j[0];
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2902 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2903
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2904 static int
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2905 code_l2(long long d)
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2906 {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2907 int *i = (int *)&ll0; int *j = (int *)&d;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2908 return (i[1] == 1)?j[0]:j[1];
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2909 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2910 #endif
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
2911
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2912 #ifndef __APPLE__
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2913 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2914 global_table(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2915 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2916 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2917 int init;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2918 init=0;
348
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 345
diff changeset
2919 for(n=global_list;n;n = n->next) {
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2920 if (is_code(n) || is_function(n)) {
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2921 }
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
2922 if ((n->sc == GVAR||n->sc == STATIC) && n->dsp != -1) {
544
dbfd6e88e2c3 s-dandy compile OK
kono
parents: 542
diff changeset
2923 if (is_code(n)||is_function(n)) continue;
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2924 /* n->dsp = -1 means initialized global */
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2925 if (init==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2926 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2927 init=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2928 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2929 printf(".comm %s,%d\n",n->nm,size(n->ty));
544
dbfd6e88e2c3 s-dandy compile OK
kono
parents: 542
diff changeset
2930 // .lcomm?
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2931 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
2932 }
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2933 }
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2934
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2935 #else
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2936
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2937 void
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2938 global_table(void)
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2939 {
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2940 NMTBL *n;
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2941 int init;
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2942 init=0;
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2943 for(n=global_list;n;n = n->next) {
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
2944 if ((n->sc == GVAR) && n->dsp != -1) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2945 if (is_code(n)||is_function(n)) continue;
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2946 /* n->dsp = -1 means initialized global */
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2947 if (init==0) {
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2948 data_mode(0);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2949 init=1;
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2950 }
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2951 printf(".comm _%s,%d\n",n->nm,size(n->ty));
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2952 } else if ((n->sc==STATIC) && n->dsp != -1) {
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2953 /* n->dsp = -1 means initialized global */
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
2954 if (is_code(n)||is_function(n)) {
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
2955 printf("\t.set L_%s$stub,_%s\n",n->nm,n->nm);
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
2956 continue;
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
2957 }
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2958 if (init==0) {
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2959 data_mode(0);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2960 init=1;
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2961 }
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2962 printf(".lcomm _%s,%d\n",n->nm,size(n->ty));
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2963 }
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2964 }
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2965 init=0;
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2966 for(n = global_list;n!=&null_nptr;n = n->next) {
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
2967 if (n->sc == GVAR ||
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
2968 ((is_code(n) || is_function(n)) &&has_attr(n,FNAME)) ) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2969 if (init==0) {
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
2970 printf("\t.section __IMPORT,__pointers,non_lazy_symbol_pointers\n");
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2971 init=1;
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2972 }
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
2973 printf("L_%s$non_lazy_ptr:\n\t.indirect_symbol _%s\n\t.long\t0\n",
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
2974 n->nm,n->nm);
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
2975 }
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2976 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2977 for(n = global_list;n!=&null_nptr;n = n->next) {
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
2978 if (n->sc==EXTRN1) {
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
2979 if (!(is_code(n) || is_function(n))) {
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
2980 printf("\t.section __IMPORT,__pointers,non_lazy_symbol_pointers\n");
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
2981 printf("L_%s$non_lazy_ptr:\n\t.indirect_symbol _%s\n\t.long\t0\n",
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
2982 n->nm,n->nm);
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
2983 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2984 printf("\t.section __IMPORT,__jump_table,symbol_stubs,self_modifying_code+pure_instructions,5\n");
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2985 printf("L_%s$stub:\n",n->nm);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2986 printf("\t.indirect_symbol _%s\n",n->nm);
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2987 printf("\thlt ; hlt ; hlt ; hlt ; hlt\n");
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
2988 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2989 }
627
65eb070e731c Intel Mac continue...
kono
parents: 626
diff changeset
2990 printf(" .subsections_via_symbols\n");
65eb070e731c Intel Mac continue...
kono
parents: 626
diff changeset
2991 printf(" .section __TEXT,__textcoal_nt,coalesced,pure_instructions\n");
65eb070e731c Intel Mac continue...
kono
parents: 626
diff changeset
2992 printf(".weak_definition ___i686.get_pc_thunk.bx\n");
65eb070e731c Intel Mac continue...
kono
parents: 626
diff changeset
2993 printf(".private_extern ___i686.get_pc_thunk.bx\n");
65eb070e731c Intel Mac continue...
kono
parents: 626
diff changeset
2994 printf("___i686.get_pc_thunk.bx:\n");
65eb070e731c Intel Mac continue...
kono
parents: 626
diff changeset
2995 printf(" movl (%%esp), %%ebx\n");
65eb070e731c Intel Mac continue...
kono
parents: 626
diff changeset
2996 printf(" ret\n");
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
2997 }
627
65eb070e731c Intel Mac continue...
kono
parents: 626
diff changeset
2998
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
2999 #endif
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3000
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3001 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3002 local_table(void)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3003 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3004 NMTBL *n;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3005 int init;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3006 init=0;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3007 /* static local variables */
348
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 345
diff changeset
3008 for(n=local_static_list;n;n = n->next) {
553
293f827ccfb2 Linux kernel source compiled.
kono
parents: 544
diff changeset
3009 if (n->sc == STATIC) {
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3010 if (init==0) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3011 data_mode(0);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3012 init=1;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3013 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3014 #ifdef __APPLE__
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3015 if (n->dsp!= -1) /* -1 means initialized global */
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3016 printf(".lcomm _%s,%d\n",n->nm,size(n->ty));
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3017 #else
156
da529eab5618 static initialization
kono
parents: 147
diff changeset
3018 if (n->dsp!= -1) /* -1 means initialized global */
da529eab5618 static initialization
kono
parents: 147
diff changeset
3019 printf(".lcomm %s,%d\n",n->nm,size(n->ty));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3020 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3021 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3022 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3023 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3024
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3025 void
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3026 cstring_mode(int align)
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3027 {
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3028 if (output_mode!=RODATA_EMIT_MODE) {
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3029 #ifndef __APPLE__
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3030 printf(".section\t.rodata\n\t.align 2\n");
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3031 #else
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3032 printf("\t.cstring\n");
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3033 #endif
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3034 output_mode = RODATA_EMIT_MODE;
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3035 }
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3036 }
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3037
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3038 void
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
3039 text_mode(int align)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3040 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3041 if (output_mode!=TEXT_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3042 printf(".text\n");
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
3043 // printf("\t.align 2\n");
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3044 output_mode = TEXT_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3045 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3046 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3047
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3048 void
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3049 data_mode(char *name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3050 {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3051 if (output_mode!=DATA_EMIT_MODE) {
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3052 printf(".data\n");
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3053 output_mode = DATA_EMIT_MODE;
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3054 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3055 #ifndef __APPLE__
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3056 if (name)
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3057 printf("\t.type\t%s,@object\n",name);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3058 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3059 }
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
3060
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3061 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3062
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3063 /* floating point */
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3064
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3065
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3066 char *
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3067 fstore(int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3068 {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3069 return use?
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3070 (d?"fstl":"fsts"):
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3071 (d?"fstpl":"fstps")
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3072 ;
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3073 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3074
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3075 char *
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3076 fstore_u(int d)
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3077 {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3078 return d?"fstpl":"fstps";
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3079 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3080
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3081 char *
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3082 fload(int d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3083 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3084 return d?"fldl":"flds";
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3085 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3086
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3087
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3088 void code_dassign_gvar(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3089 {
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3090 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3091 int r = get_ptr_cache(ncaddr(e2));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3092 if (cadr(e2))
630
557b2a266f75 Intel continue...
kono
parents: 629
diff changeset
3093 printf("\t%s %d(%s)\n",fstore(d),cadr(e2),register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3094 else
630
557b2a266f75 Intel continue...
kono
parents: 629
diff changeset
3095 printf("\t%s (%s)\n",fstore(d),register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3096 #else
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3097 if (cadr(e2))
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3098 printf("\t%s %s+%d\n",fstore(d),(ncaddr(e2))->nm,cadr(e2));
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3099 else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3100 printf("\t%s %s\n",fstore(d),(ncaddr(e2))->nm);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3101 #endif
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3102 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3103
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3104 void code_dassign_lvar(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3105 {
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
3106 printf("\t%s ",fstore(d)); lvar(e2); printf("\n");
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3107 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3108
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
3109 void code_dassign_dregister(int e,int d,int freg)
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
3110 {
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
3111 error(-1);
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
3112 }
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
3113
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
3114 void code_dassign(int e2,int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3115 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3116 printf("\t%s (%s)\n",fstore(d),register_name(e2,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3117 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3118
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3119 static double d0 = 1.0;
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3120
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
3121 static int
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3122 code_d1(double d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3123 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3124 int *i = (int *)&d0; int *j = (int *)&d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3125 return (i[1] == 0x3ff00000)?j[0]:j[1];
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3126 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3127
340
0150de6a3244 emit_data moved.
kono
parents: 338
diff changeset
3128 static int
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3129 code_d2(double d)
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3130 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3131 int *i = (int *)&d0; int *j = (int *)&d;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3132 return (i[1] == 0x3ff00000)?j[1]:j[0];
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3133 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3134
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3135 static void emit_dconst0(ValuePtr value, int lb, void *arg)
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3136 {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3137 long d_mode = (long) arg;
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3138 #ifdef __APPLE__
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3139 printf(" \t.literal8\n\t.align 3\n");
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3140 #else
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3141 printf(" \t.section\t.rodata\n\t.align 8\n");
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3142 #endif
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3143 printf("_%d:\n",lb);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3144 #if ENDIAN_D==0
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3145 if (d_mode)
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3146 printf("\t.long\t0x%x,0x%x\n",code_d1(value->d),code_d2(value->d));
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3147 else {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3148 printf("\t.long\t0x%x\n",value->i);
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3149 }
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3150 #endif
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3151 if (output_mode==TEXT_EMIT_MODE) {
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3152 printf(".text\n");
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3153 } else {
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3154 text_mode(0);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3155 }
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3156 }
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3157
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3158 /* load double / float const
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3159 we should keep what constant we have create
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3160 */
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3161 void code_dconst(int e2,int freg,int d)
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3162 {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3163 int sz;
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3164 Value value;
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3165 value.d = dcadr(e2);
780
c5315f472912 ia32/powerpc regression test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 779
diff changeset
3166 // use_float(d,freg);
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3167 if (value.d==0.0) {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3168 printf("\tfldz\n"); return;
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3169 }
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3170 if (value.d==1.0) {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3171 printf("\tfld1\n"); return;
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3172 }
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3173 if (d) {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3174 sz = sizeof(double);
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3175 } else {
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3176 value.f = (float) value.d;
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3177 sz = sizeof(float);
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3178 }
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3179
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3180 long d_mode = d;
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3181 int lb = get_data_label(&value,sz,emit_dconst0, (void*) d_mode);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
3182 #ifdef __APPLE__
780
c5315f472912 ia32/powerpc regression test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 779
diff changeset
3183 printf("\t%s _%d-_%d(%%ebx)\n",fload(d),lb,goffset_label);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
3184 #else
780
c5315f472912 ia32/powerpc regression test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 779
diff changeset
3185 printf("\t%s _%d\n",fload(d),lb);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
3186 #endif
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3187 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3188
779
a0f84a0a990a float value sharing
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 778
diff changeset
3189
616
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3190 void
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3191 code_builtin_fabsf(int e)
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3192 {
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3193 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3194 void
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3195 code_builtin_fabs(int e)
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3196 {
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3197 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3198 void
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3199 code_builtin_inff()
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3200 {
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3201 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3202 void
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3203 code_builtin_inf()
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3204 {
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3205 }
2ba903c8e749 builtin_fabs
kono
parents: 615
diff changeset
3206
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
3207 void code_dneg(int freg,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3208 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3209 printf("\tfchs\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3210 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3211
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3212 void code_d2i(int reg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3213 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3214 use_int(reg);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
3215 printf("\tlea -%d(%%esp),%%esp\n",SIZE_OF_INT*2);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3216 printf("\tfnstcw (%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3217 printf("\tmovl (%%esp), %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3218 printf("\tmovb $12, 1(%%esp)\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3219 printf("\tfldcw (%%esp)\n");
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
3220 printf("\tfistpl %d(%%esp)\n",SIZE_OF_INT);
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
3221 printf("\tmovl %s, (%%esp)\n",register_name(creg,0));
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
3222 printf("\tfldcw (%%esp)\n");
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3223 printf("\tpopl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3224 printf("\tpopl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3225 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3226
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3227 void code_i2d(int reg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3228 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3229 printf("\tpushl %s\n",register_name(creg,0));
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3230 printf("\tfildl (%%esp)\n");
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
3231 printf("\tlea %d(%%esp),%%esp\n",SIZE_OF_INT);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3232 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3233
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3234 void code_d2u(int reg)
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
3235 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3236 use_int(reg);
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
3237 printf("\tlea -%d(%%esp),%%esp\n",SIZE_OF_INT*3);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
3238 printf("\tfnstcw (%%esp)\n");
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3239 printf("\tmovl (%%esp), %s\n",register_name(reg,0));
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
3240 printf("\tmovb $12, 1(%%esp)\n");
3789aef7331d minor fix
kono
parents: 84
diff changeset
3241 printf("\tfldcw (%%esp)\n");
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3242 printf("\tmovl %s, (%%esp)\n",register_name(reg,0));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
3243 printf("\tfistpll %d(%%esp)\n",SIZE_OF_INT);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
3244 printf("\tfldcw (%%esp)\n");
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
3245 printf("\tmovl %d(%%esp),%s\n",SIZE_OF_INT,register_name(reg,0));
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
3246 printf("\tlea %d(%%esp),%%esp\n",SIZE_OF_INT*3);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
3247 }
3789aef7331d minor fix
kono
parents: 84
diff changeset
3248
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3249 void code_u2d(int reg)
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
3250 {
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
3251 printf("\tpushl %s\n",register_name(creg,0));
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
3252 printf("\tpushl %s\n",register_name(creg,0));
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
3253 printf("\tmovl $0, %d(%%esp)\n",SIZE_OF_INT);
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
3254 printf("\tfildll (%%esp)\n");
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
3255 printf("\tlea %d(%%esp),%%esp\n",SIZE_OF_INT*2);
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
3256 }
3789aef7331d minor fix
kono
parents: 84
diff changeset
3257
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3258 void code_d2f(int reg) { }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3259 void code_f2d(int reg) { }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3260 void code_f2i(int reg) { code_d2i(reg); }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3261 void code_f2u(int reg) { code_d2u(reg); }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3262 void code_i2f(int reg) { code_i2d(reg); }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3263 void code_u2f(int reg) { code_u2d(reg); }
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3264
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
3265 void code_drgvar(int e2,int d,int freg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3266 {
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3267 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3268 int r = get_ptr_cache(ncaddr(e2));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3269 if (cadr(e2))
630
557b2a266f75 Intel continue...
kono
parents: 629
diff changeset
3270 printf("\t%s %d(%s)\n",fload(d),cadr(e2),register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3271 else
630
557b2a266f75 Intel continue...
kono
parents: 629
diff changeset
3272 printf("\t%s (%s)\n",fload(d),register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3273 #else
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3274 if (cadr(e2))
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3275 printf("\t%s %s+%d\n",fload(d),(ncaddr(e2))->nm,cadr(e2));
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3276 else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3277 printf("\t%s %s\n",fload(d),(ncaddr(e2))->nm);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3278 #endif
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3279 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3280
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3281
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
3282 void code_drlvar(int e2,int d,int freg)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3283 {
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
3284 printf("\t%s ",fload(d)); lvar(e2); printf("\n");
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3285 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3286
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3287 void code_cmp_drgvar(int e2,int reg,int d,int label,int cond)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3288 {
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3289 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3290 int r = get_ptr_cache(ncaddr(e2));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3291 if (cadr(e2))
630
557b2a266f75 Intel continue...
kono
parents: 629
diff changeset
3292 printf("\tfcomp %d(%s)\n",cadr(e2),register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3293 else
630
557b2a266f75 Intel continue...
kono
parents: 629
diff changeset
3294 printf("\tfcomp (%s)\n",register_name(r,0));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3295 #else
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3296 if (cadr(e2))
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3297 printf("\tfcomp %s+%d\n",(ncaddr(e2))->nm,cadr(e2));
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3298 else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3299 printf("\tfcomp %s\n",(ncaddr(e2))->nm);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3300 #endif
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3301 jcond(label,cond);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3302 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3303
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3304 void code_cmp_drlvar(int e2,int reg,int d,int label,int cond)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3305 {
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
3306 printf("\tfcomp "); lvar(e2); printf("\n");
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3307 jcond(label,cond);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3308 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3309
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
3310 void dtosop(int op,int reg,int e1)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3311 {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3312 switch(op) {
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3313 case FADD:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3314 case DADD: printf("\tfaddp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3315 case FSUB:
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
3316 case DSUB: printf("\tfsubp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3317 case FDIV:
85
3789aef7331d minor fix
kono
parents: 84
diff changeset
3318 case DDIV: printf("\tfdivp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3319 case FMUL:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3320 case DMUL: printf("\tfmulp %%st,%%st(1)\n"); break;
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3321 case FCMP:
89
917947ffeb7c power pc version
kono
parents: 87
diff changeset
3322 case DCMP:
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3323 printf("\tfucompp\n");
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3324 printf("\tfnstsw\t%%ax\n");
634
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
3325 #ifdef __APPLE__
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
3326 if (regs[REG_EAX]==PTRC_REG)
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
3327 clear_ptr_cache_reg(REG_EAX);
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
3328 #endif
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3329 break;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3330 }
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3331 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3332
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3333 void
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
3334 code_dassop(int op,int reg,int d) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3335 /* we have lvalue in creg, applied floating value is in %st(0) */
102
3cf2f8c120b9 *** empty log message ***
kono
parents: 99
diff changeset
3336 emit_dpop(d); /* do nothing for 387 */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3337 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
3338 dtosop(op,reg,0);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3339 printf("\t%s (%s)\n",fstore(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3340 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3341
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3342 void
219
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
3343 code_register_dassop(int reg,int op,int d) {
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
3344 error(-1);
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
3345 }
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
3346
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
3347 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
3348 code_dpreinc(int e1,int e2,int d,int freg) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3349 g_expr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3350 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3351 printf("\tfld1\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
3352 if (caddr(e1)>0)
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3353 printf("\tfaddp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3354 else
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3355 printf("\tfsubrp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3356 printf("\t%s (%s)\n",fstore(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3357 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3358
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3359 void
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
3360 code_dpostinc(int e1,int e2,int d,int freg) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3361 g_expr(e2);
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3362 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3363 if (use)
86
4d1275f8a5b5 *** empty log message ***
kono
parents: 85
diff changeset
3364 printf("\t%s (%s)\n",fload(d),register_name(creg,0));
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3365 printf("\tfld1\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
3366 if (caddr(e1)>0)
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3367 printf("\tfaddp %%st,%%st(1)\n");
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3368 else
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3369 printf("\tfsubrp %%st,%%st(1)\n");
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
3370 printf("\t%s (%s)\n",(use?fstore_u(d):fstore(d)),register_name(creg,0));
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3371 }
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
3372
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3373 #define COND_BRANCH 1
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3374 #define COND_VALUE 2
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3375
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
3376 /* return 1 if boolean expression */
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
3377
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3378 int
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3379 drexpr0(int e1, int e2,int l1, int op,int cond,int reg,int mode)
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3380 {
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3381 char *s;
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3382 if (!cond) {
230
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
3383 switch(op) {
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3384 case FOP+GT:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3385 return drexpr0(e2,e1,l1,FOP+GE,1,reg,mode);
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3386 case FOP+GE:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3387 return drexpr0(e2,e1,l1,FOP+GT,1,reg,mode);
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3388 case FOP+EQ:
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3389 op=FOP+NEQ; break;
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3390 case FOP+NEQ:
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3391 op=FOP+EQ; break;
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3392 case DOP+GT:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3393 return drexpr0(e2,e1,l1,DOP+GE,1,reg,mode);
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3394 case DOP+GE:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3395 return drexpr0(e2,e1,l1,DOP+GT,1,reg,mode);
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3396 case DOP+EQ:
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3397 op=DOP+NEQ; break;
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3398 case DOP+NEQ:
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3399 op=DOP+EQ; break;
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3400 default: return 0;
230
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
3401 }
d60c6c31f63a *** empty log message ***
kono
parents: 225
diff changeset
3402 }
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3403 s = "e";
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3404 switch(op) {
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3405 case DOP+GE:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3406 case FOP+GE:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3407 g_expr(list3(DCMP,e1,e2));
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3408 printf("\ttestb\t$5,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3409 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3410 case DOP+GT:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3411 case FOP+GT:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3412 g_expr(list3(DCMP,e1,e2));
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3413 printf("\ttestb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3414 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3415 case DOP+EQ:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3416 case FOP+EQ:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3417 g_expr(list3(DCMP,e1,e2));
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3418 printf("\tandb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3419 printf("\txorb\t$64,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3420 break;
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3421 case DOP+NEQ:
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3422 case FOP+NEQ:
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3423 g_expr(list3(DCMP,e1,e2));
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3424 printf("\tandb\t$69,%%ah\n");
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3425 printf("\txorb\t$64,%%ah\n");
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3426 s = "ne";
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3427 break;
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3428 default:
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3429 return 0;
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3430 }
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3431 if (mode==COND_BRANCH) {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3432 printf("\tj%s\t_%d\n",s,l1);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3433 } else {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3434 use_data_reg(reg,0);
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3435 printf("\tset%s\t%s\n",s,register_name(reg,1));
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3436 printf("\tmovzbl\t%s,%s\n",
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3437 register_name(reg,1),register_name(reg,0));
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3438 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3439 return 1;
84
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3440 }
1a723130a2c7 condtional
kono
parents: 83
diff changeset
3441
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
3442 int
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3443 drexpr(int e1, int e2,int l1, int op,int cond)
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3444 {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3445 drexpr0(e1, e2,l1, op,cond,USE_CREG,COND_BRANCH);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
3446 return l1;
291
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3447 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3448
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3449 static int
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3450 drexpr_bool(int e1, int reg)
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3451 {
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3452 return drexpr0(cadr(e1), caddr(e1),0, car(e1),1,reg,COND_VALUE);
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3453 }
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3454
7b6df595b205 ia32 code_bool.
kono
parents: 289
diff changeset
3455
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3456 void
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
3457 code_dregister(int e2,int freg,int d)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3458 {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3459 error(-1);
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3460 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3461
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
3462 void
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3463 code_cmp_dregister(int e2,int d,int label,int cond)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3464 {
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
3465 if (e2!=USE_CREG)
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
3466 error(-1);
634
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
3467 #ifdef __APPLE__
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
3468 if (regs[REG_EAX]==PTRC_REG)
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
3469 clear_ptr_cache_reg(REG_EAX);
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
3470 #endif
236
7353a818858c ia32 code creg fix done
kono
parents: 235
diff changeset
3471 printf("\tfldz\n");
235
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
3472 printf("\tfucompp\n");
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
3473 printf("\tfnstsw\t%%ax\n");
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
3474 printf("\tandb\t$69,%%ah\n");
c575422d8b6e *** empty log message ***
kono
parents: 230
diff changeset
3475 printf("\txorb\t$64,%%ah\n");
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3476 jcond(label,cond);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3477 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3478
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
3479 int pop_fregister()
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3480 {
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3481 if (freg_sp<0) { error(-1); return -1;}
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
3482 // printf("## fpop: %d\n",freg_sp-1);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3483 return freg_stack[--freg_sp];
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3484 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3485
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3486 int
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
3487 emit_dpop(int d)
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3488 {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3489 int xreg;
97
6d42fcac07af *** empty log message ***
kono
parents: 96
diff changeset
3490 if ((xreg=pop_fregister())==-1) {
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3491 } else if (xreg<= -REG_LVAR_OFFSET) {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
3492 code_drlvar(REG_LVAR_OFFSET+xreg,1,freg);
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3493 free_lvar(xreg+REG_LVAR_OFFSET);
326
e5d40f8c4cce bit-field continue.
kono
parents: 320
diff changeset
3494 /* pushed order is reversed. We don't need this for commutable
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3495 operator, but it is ok to do this. */
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3496 printf("\tfxch\t%%st(1)\n");
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3497 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3498 return xreg;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3499 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3500
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3501
138
e6e77af048a1 float/dobule configuration
kono
parents: 137
diff changeset
3502 void emit_dpop_free(int e1,int d)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3503 {
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3504 }
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
3505
133
7d436c08e949 separate float / double flow
kono
parents: 128
diff changeset
3506 void emit_dpush(int type)
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3507 {
119
b815fcd57b9d input var ( incomplete )
kono
parents: 118
diff changeset
3508 if (freg_sp>=MAX_FPU_STACK) code_save_fstacks();
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3509 if (freg_sp>MAX_MAX) error(-1);
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
3510 freg_stack[freg_sp++]=-1;
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
3511 // printf("## fpush:%d\n",freg_sp);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3512 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3513
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3514 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3515
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3516 void
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3517 code_save_stacks()
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3518 {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3519 /* registers stacks are saved in local variable */
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3520 int i,reg;
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3521 for(i=0;i<reg_sp;i++) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3522 if ((reg=reg_stack[i])>=0) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3523 code_assign_lvar(
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3524 (reg_stack[i]=new_lvar(SIZE_OF_INT)),reg,0);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3525 reg_stack[i]= reg_stack[i]-REG_LVAR_OFFSET;
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
3526 if (regs[reg]!=REG_VAR) free_register(reg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3527 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3528 }
676
5e71527f9fd6 *** empty log message ***
kono
parents: 675
diff changeset
3529 #if FLOAT_CODE
5e71527f9fd6 *** empty log message ***
kono
parents: 675
diff changeset
3530 code_save_fstacks();
5e71527f9fd6 *** empty log message ***
kono
parents: 675
diff changeset
3531 #endif
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3532 }
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3533
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3534 static void
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3535 code_clear_stack_reg(int reg1)
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3536 {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3537 /* specified registers stacks are saved in local variable */
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
3538 /* temporal registers are saved in local variable */
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3539 int i,reg;
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
3540 if (regs[reg1]==PTRC_REG)
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
3541 clear_ptr_cache_reg(reg1);
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
3542
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3543 for(i=0;i<reg_sp;i++) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3544 if ((reg=reg_stack[i])>=0 && reg==reg1) {
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3545 code_assign_lvar(
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3546 (reg_stack[i]=new_lvar(SIZE_OF_INT)),reg,0);
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3547 reg_stack[i]= reg_stack[i]-REG_LVAR_OFFSET;
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
3548 if (regs[reg]!=REG_VAR) free_register(reg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
3549 }
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3550 }
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
3551 }
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
3552
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3553 #if FLOAT_CODE
107
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
3554 void
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
3555 code_save_fstacks()
06f72222d6b5 prevent destorying function argument (incomeplete)
kono
parents: 105
diff changeset
3556 {
586
3fb4081164bd *** empty log message ***
kono
parents: 585
diff changeset
3557 /* stacks in fpu are saved in local variable */
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
3558 int xreg,sp,uses;
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
3559 uses = use; use = 0;
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3560 sp=freg_sp;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3561 while(sp-->0) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3562 if ((xreg=freg_stack[sp])==-1) {
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3563 code_dassign_lvar(
245
8a72b0afccfc *** empty log message ***
kono
parents: 244
diff changeset
3564 (freg_stack[sp]=new_lvar(SIZE_OF_DOUBLE)),freg,1);
94
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3565 freg_stack[sp]= freg_stack[sp]-REG_LVAR_OFFSET;
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3566 }
1ad7045741a7 float dbinop fix
kono
parents: 93
diff changeset
3567 }
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
3568 use = uses;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
3569 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3570 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3571
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3572
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3573
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3574 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3575
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3576
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3577 /* 64bit int part */
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3578
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3579 static void
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3580 pcond(char *s,int l1)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3581 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3582 printf("\tj%s\t_%d\n",s,l1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3583 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3584
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
3585 int
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3586 lrexpr(int e1, int e2,int l1, int op,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3587 {
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3588 int l2;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3589 code_save_stacks();
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3590 g_expr(e1);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3591 emit_lpush();
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3592 g_expr(e2);
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
3593 // we are sure %ecx is free
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
3594 // %ebx is used in Intel Mac
633
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
3595 stack_depth -= SIZE_OF_INT * 2;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3596 printf("\tpopl %%ecx\n"); // LSW
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
3597 printf("\tcmpl %%edx,(%%esp)\n"); // MSW
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
3598 printf("\tpopl %%edx\n");
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3599 l2 = fwdlabel();
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3600 // cond==0 jump on false condtion ( if(x) => rexpr(.. cond=0 ...) )
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3601 switch(op) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3602 case LOP+GT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3603 case LOP+GE:
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3604 pcond(code_gt(1),cond?l1:l2);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3605 pcond(code_eq(0),cond?l2:l1);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3606 break;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3607 case LOP+UGT:
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3608 case LOP+UGE:
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3609 pcond(code_ugt(1),cond?l1:l2);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3610 pcond(code_eq(0), cond?l2:l1);
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3611 break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3612 case LOP+EQ:
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3613 pcond(code_eq(0),(cond?l2:l1));
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3614 break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3615 case LOP+NEQ:
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3616 pcond(code_eq(0),(cond?l1:l2));
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3617 break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3618 default:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3619 error(-1);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3620 }
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3621 printf("\tsubl %%eax,%%ecx\n");
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3622 switch(op) {
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3623 case LOP+GT: pcond(code_gt(cond), l1); break;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3624 case LOP+GE: pcond(code_ge(cond), l1); break;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3625 case LOP+UGT: pcond(code_ugt(cond), l1); break;
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3626 case LOP+UGE: pcond(code_uge(cond), l1); break;
443
f2d2e27a00a0 minor fix
kono
parents: 440
diff changeset
3627 case LOP+EQ: pcond(code_eq(cond),l1); break;
f2d2e27a00a0 minor fix
kono
parents: 440
diff changeset
3628 case LOP+NEQ: pcond(code_eq(!cond),l1); break;
280
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3629 }
affb054fe920 lrexpr fix. rexpr in MIPS fix.
kono
parents: 263
diff changeset
3630 fwddef(l2);
438
626d705471d5 Unexecuted code in conditional. Lazy jmp code generation.
kono
parents: 436
diff changeset
3631 return l1;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3632 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3633
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3634 int emit_lpop()
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3635 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3636 return 0;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3637 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3638
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3639 void code_lregister(int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3640 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
3641 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3642 if (reg!=REG_L) {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3643 printf("\tmovl %%esi,%s\n",l_eax(reg));
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3644 printf("\tmovl %%edi,%s\n",l_edx(reg));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3645 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3646 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3647
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3648 void code_cmp_lregister(int reg,int label,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3649 {
840
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3650 use_longlong(reg);
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3651 if (reg==REG_L) {
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3652 char *crn;
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3653 reg = get_register();
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3654 crn = register_name(reg,0);
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3655 printf("\tmovl %%esi,%s\n",crn);
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3656 printf("\torl %%edi,%s\n",crn);
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3657 printf("\ttestl %s,%s\n",crn,crn);
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3658 free_register(reg);
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3659 } else {
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3660 printf("\torl %s,%s\n",l_edx(reg),l_eax(reg));
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3661 printf("\ttestl %s,%s\n",l_eax(reg),l_eax(reg));
1547193bddde minor fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 825
diff changeset
3662 }
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3663 jcond(label,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3664 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3665
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3666 void code_cmp_lrgvar(int e1,int e2,int label,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3667 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3668 char *n,*crn;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3669 use_int(e2);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3670 crn = register_name(e2,0);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3671 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3672 int r = get_ptr_cache(ncaddr(e1));
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3673 n = register_name(r,0);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3674 if (cadr(e1)) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3675 printf("\tmovl %d(%s),%s\n",cadr(e1),n,crn);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3676 printf("\torl %d(%s),%s\n",cadr(e1)+4,n,crn);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3677 } else {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3678 printf("\tmovl (%s),%s\n",n,crn);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3679 printf("\torl 4(%s),%s\n",n,crn);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3680 }
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3681 #else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3682 n = (ncaddr(e1))->nm;
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3683 if (cadr(e1)) {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3684 printf("\tmovl %s+%d,%s\n",n,cadr(e1),crn);
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3685 printf("\torl %s+%d,%s\n",n,cadr(e1)+4,crn);
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3686 } else {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3687 printf("\tmovl %s,%s\n",n,crn);
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3688 printf("\torl %s+4,%s\n",n,crn);
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3689 }
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3690 #endif
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
3691 printf("\ttestl %s,%s\n",crn,crn);
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3692 jcond(label,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3693 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3694
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3695 void code_cmp_lrlvar(int e1,int e2,int label,int cond)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3696 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3697 char *crn;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3698 use_int(e2);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3699 crn = register_name(e2,0);
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
3700 printf("\tmovl "); lvar(e1); printf(",%s\n",crn);
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
3701 printf("\torl "); lvar(e1+4); printf(",%s\n",crn);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3702 printf("\ttestl %s,%s\n",crn,crn);
287
a0779a414855 *** empty log message ***
kono
parents: 286
diff changeset
3703 jcond(label,cond);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3704 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3705
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3706 void code_lassign(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3707 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3708 char *rn;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3709 // e1 = e2
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3710 use_longlong(e2);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3711 rn = register_name(e1,0);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3712 #if ENDIAN_L==0
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3713 printf("\tmovl %s,(%s)\n",l_eax(e2),rn);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3714 printf("\tmovl %s,4(%s)\n",l_edx(e2),rn);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3715 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3716 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3717
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3718 void code_lassign_gvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3719 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3720 char *n;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3721 use_longlong(e2);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3722 #if ENDIAN_L==0
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3723 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3724 int r = get_ptr_cache(ncaddr(e1));
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3725 n = register_name(r,0);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3726 if (cadr(e1)) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3727 printf("\tmovl %s,%d(%s)\n",l_eax(e2),cadr(e1),n);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3728 printf("\tmovl %s,%d(%s)\n",l_edx(e2),cadr(e1)+4,n);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3729 } else {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3730 printf("\tmovl %s,(%s)\n",l_eax(e2),n);
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3731 printf("\tmovl %s,4(%s)\n",l_edx(e2),n);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3732 }
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3733 #else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3734 n = (ncaddr(e1))->nm;
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3735 if (cadr(e1)) {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3736 printf("\tmovl %s,%s+%d\n",l_eax(e2),n,cadr(e1));
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3737 printf("\tmovl %s,%s+%d\n",l_edx(e2),n,cadr(e1)+4);
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3738 } else {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3739 printf("\tmovl %s,%s\n",l_eax(e2),n);
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3740 printf("\tmovl %s,%s+4\n",l_edx(e2),n);
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3741 }
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3742 #endif
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3743 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3744 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3745
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3746 void code_lassign_lvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3747 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3748 use_longlong(e2);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3749 #if ENDIAN_L==0
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
3750 printf("\tmovl %s,",l_eax(e2)); lvar(e1); printf("\n");
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
3751 printf("\tmovl %s,",l_edx(e2)); lvar(e1+4); printf("\n");
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3752 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3753 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3754
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3755 void code_lassign_lregister(int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3756 {
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3757 // e2 = reg
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
3758 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3759 if (e2!=reg) {
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3760 printf("\tmovl %s,%s\n",l_eax(reg),l_eax(e2));
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3761 printf("\tmovl %s,%s\n",l_edx(reg),l_edx(e2));
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3762 }
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3763 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3764
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3765 void
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3766 code_lconst(int e1,int creg)
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3767 {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3768 use_longlong(creg);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3769 #if ENDIAN_L==0
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3770 printf("\tmovl $%d,%s\n",code_l1(lcadr(e1)),l_eax(creg));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3771 printf("\tmovl $%d,%s\n",code_l2(lcadr(e1)),l_edx(creg));
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3772 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3773 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3774
212
32f54ab63b35 *** empty log message ***
kono
parents: 205
diff changeset
3775 void code_lneg(int e1)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3776 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3777 use_longlong(e1);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3778 printf("\tnegl %s\n",l_eax(e1));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3779 printf("\tadcl $0,%s\n",l_edx(e1));
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3780 printf("\tnegl %s\n",l_edx(e1));
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3781 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3782
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3783 void code_lrgvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3784 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3785 char *n;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3786 use_longlong(e2);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3787 #if ENDIAN_L==0
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3788 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3789 int r = get_ptr_cache(ncaddr(e1));
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3790 n = register_name(r,0);
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3791 if (cadr(e1)) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3792 printf("\tmovl %d(%s),%s\n",cadr(e1),n,l_eax(e2));
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3793 printf("\tmovl %d(%s),%s\n",cadr(e1)+4,n,l_edx(e2));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3794 } else {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3795 printf("\tmovl (%s),%s\n",n,l_eax(e2));
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3796 printf("\tmovl 4(%s),%s\n",n,l_edx(e2));
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3797 }
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3798 #else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
3799 n = (ncaddr(e1))->nm;
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3800 if (cadr(e1)) {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3801 printf("\tmovl %s+%d,%s\n",n,cadr(e1),l_eax(e2));
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3802 printf("\tmovl %s+%d,%s\n",n,cadr(e1)+4,l_edx(e2));
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3803 } else {
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3804 printf("\tmovl %s,%s\n",n,l_eax(e2));
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3805 printf("\tmovl %s+4,%s\n",n,l_edx(e2));
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
3806 }
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3807 #endif
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
3808 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3809 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3810
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3811 void code_lrlvar(int e1,int e2)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3812 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3813 use_longlong(e2);
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3814 #if ENDIAN_L==0
668
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
3815 printf("\tmovl "); lvar(e1); printf(",%s\n",l_eax(e2));
adbb9c25eb1a non push version of function call (half done)
kono
parents: 664
diff changeset
3816 printf("\tmovl "); lvar(e1+4); printf(",%s\n",l_edx(e2));
411
32c1914308db ENDIAN_L ENDIAN_D
kono
parents: 408
diff changeset
3817 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3818 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3819
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3820 #define check_lreg(reg) if (reg==REG_L) code_lassign_lregister(reg,REG_LCREG)
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3821
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3822 void
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3823 ltosop(int op,int reg,int e2)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3824 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3825 char *opl,*oph,*call;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3826 int lb;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3827
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3828 // e2 (operand) is on the top of the stack
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3829 use_longlong(reg);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3830 opl = 0; call=0;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
3831 stack_depth -= SIZE_OF_INT * 2;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3832
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3833 switch(op) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3834 case LLSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3835 case LULSHIFT:
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3836 printf("\tmovl %%ecx,4(%%esp)\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3837 printf("\tpopl %%ecx\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3838 printf("\tshldl %%eax,%%edx\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3839 printf("\tsall %%cl,%%eax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3840 printf("\ttestb $32,%%cl\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3841 printf("\tje\t_%d\n",(lb=fwdlabel()));
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3842 printf("\tmovl %%eax,%%edx\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3843 printf("\txorl %%eax,%%eax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3844 fwddef(lb);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3845 printf("\tpopl %%ecx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3846 check_lreg(reg);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3847 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3848 case LRSHIFT:
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3849 printf("\tmovl %%ecx,4(%%esp)\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3850 printf("\tpopl %%ecx\n");
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3851 printf("\tshrdl %%edx,%%eax\n");
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3852 printf("\tsarl %%cl,%%edx\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3853 printf("\ttestb $32,%%cl\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3854 printf("\tje\t_%d\n",(lb=fwdlabel()));
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3855 printf("\tmovl %%edx,%%eax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3856 printf("\tsarl $31,%%edx\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3857 fwddef(lb);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3858 printf("\tpopl %%ecx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3859 check_lreg(reg);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3860 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3861 case LURSHIFT:
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3862 printf("\tmovl %%ecx,4(%%esp)\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3863 printf("\tpopl %%ecx\n");
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3864 printf("\tshrdl %%edx,%%eax\n");
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3865 printf("\tshrl %%cl,%%edx\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3866 printf("\ttestb $32,%%cl\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3867 printf("\tje\t_%d\n",(lb=fwdlabel()));
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3868 printf("\tmovl %%edx,%%eax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3869 printf("\txorl %%edx,%%edx\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3870 fwddef(lb);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3871 printf("\tpopl %%ecx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3872 check_lreg(reg);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3873 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3874 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3875 switch(op) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3876 case LADD: opl="addl";oph="adcl"; break;
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3877 case LSUB: opl="subl";oph="sbbl"; break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3878 case LBAND: opl=oph="andl"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3879 case LEOR: opl=oph="xorl"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3880 case LBOR: opl=oph="orl"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3881 case LMUL:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3882 case LUMUL:
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3883 printf("\tpushl %%edx\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3884 printf("\tpushl %%eax\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3885 printf("\tpushl %%ecx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3886 // 0 saved ecx
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3887 // 4 c_l
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3888 // 8 c_h
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3889 // 12 o_l
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3890 // 16 o_h
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3891 printf("\tmull 12(%%esp)\n"); // c_l*o_l -> %edx,%eax
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3892 printf("\tmovl 4(%%esp),%%ecx\n"); // c_l->%ecx
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3893 printf("\timull 16(%%esp),%%ecx\n"); // c_l*o_h->%ecx
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3894 printf("\taddl %%ecx,%%edx\n"); // %edx+%ecx->%edx
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3895 printf("\tmovl 8(%%esp),%%ecx\n"); // c_h->%ecx
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3896 printf("\timull 12(%%esp),%%ecx\n"); // c_h*o_l->%ecx
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3897 printf("\taddl %%ecx,%%edx\n"); // %edx+%ecx->%edx
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3898 printf("\tpopl %%ecx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3899 // printf("\taddl $8,%%esp\n");
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3900 printf("\tlea 16(%%esp),%%esp\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3901 return;
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3902 #ifdef __APPLE__
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3903 case LDIV: call="L___divdi3$stub";
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3904 extern_define("__divdi3",0,FUNCTION,1); break;
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3905 case LUDIV: call="L___udivdi3$stub";
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3906 extern_define("__udivdi3",0,FUNCTION,1); break;
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3907 case LMOD: call="L___moddi3$stub";
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3908 extern_define("__moddi3",0,FUNCTION,1); break;
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3909 case LUMOD: call="L___umoddi3$stub";
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3910 extern_define("__umoddi3",0,FUNCTION,1); break;
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3911 #else
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3912 case LDIV: call="__divdi3"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3913 case LUDIV: call="__udivdi3"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3914 case LMOD: call="__moddi3"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3915 case LUMOD: call="__umoddi3"; break;
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
3916 #endif
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3917 default: error(-1);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3918 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3919 if (opl) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3920 printf("\t%s (%%esp),%%eax\n\t%s 4(%%esp),%%edx\n",opl,oph);
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3921 printf("\tlea 8(%%esp),%%esp\n");
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3922 check_lreg(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3923 } else if (call) {
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3924 #ifdef __APPLE__
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
3925 clear_ptr_cache();
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3926 printf("\tpushl %%edx\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3927 printf("\tpushl %%eax\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3928 printf("\tcall %s\n",call);
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3929 printf("\tlea 16(%%esp),%%esp\n");
633
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
3930 #else
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
3931 printf("\tpushl %%edx\n");
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
3932 printf("\tpushl %%eax\n");
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
3933 printf("\tcall %s\n",call);
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
3934 printf("\tlea 16(%%esp),%%esp\n");
fbd815a59787 Intel Mac all most done...
kono
parents: 632
diff changeset
3935 #endif
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
3936 check_lreg(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3937 } else {
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3938 error(-1);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3939 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3940 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
3941
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3942 int code_lconst_op_p(int op,int e) {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3943 long long l;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3944 if (car(e)==CONST) l = cadr(e);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3945 else if (car(e)==LCONST) l = lcadr(e);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3946 else return 0;
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3947
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3948 switch(op) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3949 case LLSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3950 case LULSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3951 case LRSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3952 case LURSHIFT:
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3953 return (0<=l&&l<=63);
436
kono
parents: 435
diff changeset
3954 case LMUL:
kono
parents: 435
diff changeset
3955 case LUMUL:
kono
parents: 435
diff changeset
3956 case LUDIV:
kono
parents: 435
diff changeset
3957 /* case LDIV: */
kono
parents: 435
diff changeset
3958 return -0x10000000LL<l&&l<0x10000000LL && ilog(l);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3959 case LADD:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3960 case LSUB:
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
3961 case LBAND:
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3962 case LEOR:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3963 case LBOR:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3964 return 1;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3965 default:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3966 return 0;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3967 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3968 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3969
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3970 void loprtc(int op,int reg,int e) {
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
3971 char *opl,*oph=0;
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3972 int vl,il;
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3973 int vh;
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
3974 long long l=0;
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3975
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3976 if (car(e)==CONST) l = cadr(e);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3977 else if (car(e)==LCONST) l = lcadr(e);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3978 else error(-1);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3979
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3980 vl = code_l1(l);
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
3981 vh = code_l2(l);
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3982 il = l;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3983
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3984 use_longlong(reg);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3985 opl = 0;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3986
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3987 switch(op) {
436
kono
parents: 435
diff changeset
3988 case LMUL: case LUMUL:
kono
parents: 435
diff changeset
3989 vl=il=ilog(il);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3990 case LLSHIFT:
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
3991 case LULSHIFT:
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3992 if (il==0) return;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3993 else if (il==32) {
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3994 code_register(regv_l(reg),regv_h(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3995 code_const(0,regv_l(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3996 return;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3997 } else if (il>32) {
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3998 code_register(regv_l(reg),regv_h(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
3999 printf("\tsall $%d,%s\n",(int)il-32,l_edx(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4000 code_const(0,regv_l(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4001 return;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4002 }
286
179e22f166ef register assop fix
kono
parents: 280
diff changeset
4003 printf("\tshldl $%d,%s,%s\n",vl,l_eax(reg),l_edx(reg));
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4004 printf("\tsall $%d,%s\n",(int)il,l_eax(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4005 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4006 case LRSHIFT:
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4007 if (il==0) return;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4008 else if (il==32) {
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4009 code_register(regv_h(reg),regv_l(reg));
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
4010 creg = ireg = REG_EAX;
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4011 code_i2ll(reg);
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4012 return;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4013 } else if (il>32) {
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4014 code_register(regv_h(reg),regv_l(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4015 printf("\tsarl $%d,%s\n",(int)il-32,l_eax(reg));
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
4016 creg = ireg = REG_EAX;
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4017 code_i2ll(reg);
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4018 return;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4019 }
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4020 printf("\tshrdl $%d,%s,%s\n",(int)il,l_edx(reg),l_eax(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4021 printf("\tsarl $%d,%s\n",(int)il,l_edx(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4022 return;
436
kono
parents: 435
diff changeset
4023 case LUDIV:
kono
parents: 435
diff changeset
4024 il=ilog(il);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4025 case LURSHIFT:
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4026 if (il==0) return;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4027 else if (il==32) {
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4028 code_register(regv_h(reg),regv_l(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4029 code_const(0,regv_h(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4030 return;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4031 } else if (il>32) {
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
4032 if (il>64) error(-1);
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4033 code_register(regv_h(reg),regv_l(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4034 printf("\tsarl $%d,%s\n",(int)il-32,l_eax(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4035 code_const(0,regv_h(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4036 return;
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4037 }
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4038 printf("\tshrdl $%d,%s,%s\n",(int)il,l_edx(reg),l_eax(reg));
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4039 printf("\tshrl $%d,%s\n",(int)il,l_edx(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4040 return;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4041 }
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4042 switch(op) {
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4043 case LADD: opl="addl";oph="adcl"; break;
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4044 case LSUB: opl="subl";oph="sbbl"; break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4045 case LEOR: opl=oph="xorl"; break;
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4046 case LBOR: opl=oph="orl"; break;
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
4047 case LBAND: opl=oph="andl"; break;
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4048 default: error(-1);
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4049 }
286
179e22f166ef register assop fix
kono
parents: 280
diff changeset
4050 printf("\t%s $%d,%s\n\t%s $%d,%s\n",opl,vl,l_eax(reg),oph,vh,l_edx(reg));
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4051 }
213
kono
parents: 212
diff changeset
4052
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4053 void emit_lpop_free(int e1)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4054 {
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
4055 // printf("\taddl $8,%%esp\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4056 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4057
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4058 void emit_lpush()
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4059 {
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 309
diff changeset
4060 stack_depth += SIZE_OF_INT * 2;
241
96b5ee862a41 *** empty log message ***
kono
parents: 240
diff changeset
4061 printf("\tpushl %%edx\n\tpushl %%eax\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4062 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4063
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4064 void code_i2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4065 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
4066 int reg0 = USE_CREG;
498
574856cee9da printf double/int mix
kono
parents: 477
diff changeset
4067 int creg0 = creg;
574856cee9da printf double/int mix
kono
parents: 477
diff changeset
4068
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
4069 use_longlong(reg0);
498
574856cee9da printf double/int mix
kono
parents: 477
diff changeset
4070 use_register(creg0,REG_EAX,1);
574856cee9da printf double/int mix
kono
parents: 477
diff changeset
4071
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4072 printf("\tcltd\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
4073 check_lreg(reg);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
4074 lreg = creg = reg0;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4075 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4076
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4077 void code_i2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4078 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4079 code_i2ll(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4080 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4081
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4082 void code_u2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4083 {
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
4084 int reg0 = USE_CREG;
498
574856cee9da printf double/int mix
kono
parents: 477
diff changeset
4085 int creg0 = creg;
574856cee9da printf double/int mix
kono
parents: 477
diff changeset
4086
574856cee9da printf double/int mix
kono
parents: 477
diff changeset
4087 use_longlong(reg0);
574856cee9da printf double/int mix
kono
parents: 477
diff changeset
4088 use_register(creg0,REG_EAX,1);
574856cee9da printf double/int mix
kono
parents: 477
diff changeset
4089
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
4090 use_longlong(reg0);
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4091 printf("\txorl %%edx,%%edx\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
4092 check_lreg(reg);
240
b59364f5b030 *** empty log message ***
kono
parents: 239
diff changeset
4093 lreg = creg = reg0;
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4094 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4095
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4096 void code_u2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4097 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4098 code_u2ll(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4099 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4100
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4101 void code_ll2i(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4102 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4103 use_int(reg);
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
4104 if (REG_EAX!=reg)
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4105 printf("\tmovl %%eax,%s\n",register_name(creg,0));
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4106 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4107
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4108 void code_ll2u(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4109 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4110 code_ll2i(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4111 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4112
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4113 void code_ull2i(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4114 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4115 code_ll2i(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4116 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4117
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4118 void code_ull2u(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4119 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4120 code_ll2i(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4121 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4122
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4123 #if FLOAT_CODE
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4124 void code_d2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4125 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4126 use_longlong(reg);
675
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4127 #if 1
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4128 printf("\tsubl $64, %%esp\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4129 printf("\tfnstcw 34(%%esp)\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4130 printf("\tmovzwl 34(%%esp), %%eax\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4131 printf("\tmovb $12, %%ah\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4132 printf("\tmovw %%ax, 32(%%esp)\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4133 printf("\tfldcw 32(%%esp)\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4134 printf("\tfistpll 52(%%esp)\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4135 printf("\tfldcw 34(%%esp)\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4136 printf("\tmovl 52(%%esp), %%eax\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4137 printf("\tmovl 56(%%esp), %%edx\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4138 printf("\taddl $64, %%esp\n");
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4139 #else
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4140 printf("\tsubl $40,%%esp\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4141 printf("\tfnstcw 2(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4142 printf("\tmovw 2(%%esp),%%ax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4143 printf("\torw $3072,%%ax\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4144 printf("\tmovw %%ax,0(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4145 printf("\tfldcw 0(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4146 printf("\tfistpll 12(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4147 printf("\tfldcw 2(%%esp)\n");
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4148 printf("\tmovl 12(%%esp),%%eax\n");
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4149 printf("\tmovl 16(%%esp),%%edx\n");
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4150 printf("\taddl $40,%%esp\n");
675
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4151 #endif
ba7110017db5 *** empty log message ***
kono
parents: 672
diff changeset
4152 check_lreg(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4153 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4154
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4155 void code_d2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4156 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4157 use_longlong(reg);
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
4158 #ifdef __APPLE__
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
4159 clear_ptr_cache();
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
4160 #endif
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4161 printf("\tsubl $16,%%esp\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4162 printf("\tfstpl (%%esp)\n");
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
4163 #ifdef __APPLE__
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
4164 printf("\tcall L___fixunsdfdi$stub\n");
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
4165 extern_define("__fixunsdfdi",0,FUNCTION,1);
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
4166 #else
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4167 printf("\tcall __fixunsdfdi\n");
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
4168 #endif
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4169 printf("\taddl $16,%%esp\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4170 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4171
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4172 void code_f2ll(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4173 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4174 code_d2ll(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4175 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4176
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4177 void code_f2ull(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4178 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4179 use_longlong(reg);
628
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
4180 #ifdef __APPLE__
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
4181 clear_ptr_cache();
c9b67b1c42f5 Intel Mac continue...
kono
parents: 627
diff changeset
4182 #endif
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4183 printf("\tsubl $16,%%esp\n");
242
c68f618b71f9 ia32 long long done. some error remains.
kono
parents: 241
diff changeset
4184 printf("\tfstps (%%esp)\n");
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
4185 #ifdef __APPLE__
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
4186 printf("\tcall L___fixunssfdi$stub\n");
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
4187 extern_define("__fixunssfdi",0,FUNCTION,1);
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
4188 #else
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4189 printf("\tcall __fixunssfdi\n");
629
d3067773659c *** empty log message ***
kono
parents: 628
diff changeset
4190 #endif
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4191 printf("\taddl $16,%%esp\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4192 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4193
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4194 void code_ll2d(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4195 {
237
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4196 printf("\tsubl $8,%%esp\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4197 printf("\tmovl %%eax,(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4198 printf("\tmovl %%edx,4(%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4199 printf("\tfildll (%%esp)\n");
1933266f1efa long long ia32 (imcomplete)
kono
parents: 236
diff changeset
4200 printf("\taddl $8,%%esp\n");
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4201 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4202
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4203 void code_ll2f(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4204 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4205 code_ll2d(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4206 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4207
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4208 void code_ull2d(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4209 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4210 code_ll2d(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4211 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4212
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4213 void code_ull2f(int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4214 {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4215 code_ll2d(reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4216 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4217
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4218 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4219
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4220
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4221 void code_lpreinc(int e1,int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4222 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4223 int dir = caddr(e1);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4224 int creg0;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4225 char *crn;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4226 if (car(e2)==LREGISTER) {
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4227 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4228 printf("\taddl $%d,%%esi\n",dir);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4229 printf("\tadcl $%d,%%edi\n",dir>0?0:-1);
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
4230 if (use && reg!=REG_L) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4231 code_lregister(REG_L,reg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4232 }
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4233 return;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4234 }
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4235 g_expr(e2);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4236 crn = register_name(creg0=creg,0);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4237 printf("\taddl $%d,(%s)\n",dir,crn);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4238 printf("\tadcl $%d,4(%s)\n",dir>0?0:-1,crn);
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4239 use_longlong(reg);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4240 lload(creg0,0,reg);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4241 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4242
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4243 void code_lpostinc(int e1,int e2,int reg)
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4244 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4245 int dir = caddr(e1);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4246 int creg0;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4247 char *crn;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4248 if (car(e2)==LREGISTER) {
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4249 use_longlong(reg);
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
4250 if (use && reg!=REG_L) {
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4251 code_lregister(REG_L,reg);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4252 }
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4253 printf("\taddl $%d,%%esi\n",dir);
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4254 printf("\tadcl $%d,%%edi\n",dir>0?0:-1);
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4255 return;
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4256 }
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4257 g_expr(e2);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4258 crn = register_name(creg0=creg,0);
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4259 printf("\taddl $%d,(%s)\n",dir,crn);
239
1849e0079f08 ia32 long long continue
kono
parents: 238
diff changeset
4260 printf("\tadcl $%d,4(%s)\n",dir>0?0:-1,crn);
587
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
4261 if (use) {
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
4262 use_longlong(reg);
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
4263 lload(creg0,0,reg);
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
4264 printf("\taddl $%d,%s\n",-dir,l_eax(reg));
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
4265 printf("\tadcl $%d,%s\n",-dir>0?0:-1,l_edx(reg));
c991b82e6849 *** empty log message ***
kono
parents: 586
diff changeset
4266 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4267 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4268
225
8675ea3d2c7f *** empty log message ***
kono
parents: 224
diff changeset
4269 void code_lassop(int op,int reg)
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4270 {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4271 error(-1);
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4272 }
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4273
219
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
4274 void
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
4275 code_register_lassop(int reg,int op) {
238
d64e9a6a66bd ia32 long long code written.
kono
parents: 237
diff changeset
4276 error(-1);
219
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
4277 }
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
4278
195
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4279
c193120ee2a6 *** empty log message ***
kono
parents: 190
diff changeset
4280 #endif
81
f94ca1168520 float first try...
kono
parents: 78
diff changeset
4281
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4282
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4283
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4284
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4285
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4286 #if CASE_CODE
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4287
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4288 int
382
832e1f6bba82 ARM wrote all code. Check compile error.
kono
parents: 368
diff changeset
4289 code_table_jump_p(int delta) { return 1; }
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4290
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4291 void
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4292 code_table_jump(int l,int csvalue,int delta,int max,int min,int dlabel)
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4293 {
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4294 char *crn;
705
0554b7f985ee parse mode done.
kono
parents: 700
diff changeset
4295 // use_register(creg,csvalue,0);
0554b7f985ee parse mode done.
kono
parents: 700
diff changeset
4296 set_ireg(csvalue,0);
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4297 crn = register_name(creg,0);
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4298 printf("\tsubl\t$%d,%s\n",min,crn);
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4299 printf("\tcmpl\t$%d,%s\n",max-min,crn);
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4300 printf("\tja\t_%d\n",dlabel);
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4301 if (delta==1) {
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4302 #ifdef __APPLE__
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4303 printf("\tmovl\t_%d-_%d(%%ebx,%s,4),%s\n",l,goffset_label,crn,crn);
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4304 printf("\taddl\t%%ebx,%s\n",crn);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4305 printf("\tjmp\t*%s\n",crn);
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4306 #else
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4307 printf("\tjmp\t*_%d(,%s,4)\n",l,crn);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4308 #endif
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4309 return;
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4310 }
634
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
4311 #ifdef __APPLE__
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
4312 if (regs[REG_EAX]==PTRC_REG)
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
4313 clear_ptr_cache_reg(REG_EAX);
62c4da637548 Intel Mac check-all-code done
kono
parents: 633
diff changeset
4314 #endif
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4315 use_register(creg,REG_EAX,1);
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4316 crn = "%eax";
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
4317
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4318 switch(delta) {
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4319 case 2:
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4320 printf("\tmovl\t$1,%%edx\n");
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4321 printf("\tandl\t%%eax,%%edx\n");
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4322 printf("\tjne\t_%d\n",dlabel);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4323 #ifdef __APPLE__
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4324 printf("\tmovl\t_%d-_%d(%%ebx,%s,2),%s\n",l,goffset_label,crn,crn);
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4325 printf("\taddl\t%%ebx,%s\n",crn);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4326 printf("\tjmp\t*%s\n",crn);
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4327 #else
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4328 printf("\tjmp\t*_%d(,%%eax,2)\n",l);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4329 #endif
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4330 break;
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4331 case 4:
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4332 printf("\tmovl\t$3,%%edx\n");
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4333 printf("\tandl\t%%eax,%%edx\n");
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4334 printf("\tjne\t_%d\n",dlabel);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4335 #ifdef __APPLE__
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4336 printf("\tmovl\t_%d-_%d(%%ebx,%s),%s\n",l,goffset_label,crn,crn);
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4337 printf("\taddl\t%%ebx,%s\n",crn);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4338 printf("\tjmp\t*%s\n",crn);
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4339 #else
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4340 printf("\tjmp\t*_%d(%%eax)\n",l);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4341 #endif
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4342 break;
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4343 default:
302
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4344 printf("\tmovl $%d,%%ecx\n",delta);
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4345 printf("\txor %%edx,%%edx\n\tdivl %%ecx\n");
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4346 printf("\tandl\t%%edx,%%edx\n");
bea7ab2fb218 switch table jump finished.
kono
parents: 301
diff changeset
4347 printf("\tjne\t_%d\n",dlabel);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4348 #ifdef __APPLE__
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4349 printf("\tmovl\t_%d-_%d(%%ebx,%s,4),%s\n",l,goffset_label,crn,crn);
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4350 printf("\taddl\t%%ebx,%s\n",crn);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4351 printf("\tjmp\t*%s\n",crn);
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4352 #else
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4353 printf("\tjmp\t*_%d(,%%eax,4)\n",l);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4354 #endif
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4355 break;
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4356 }
583
421be86892b3 ia32 reorganization
kono
parents: 582
diff changeset
4357
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4358 }
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4359
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4360 void
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4361 code_table_open(int l)
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4362 {
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4363 output_mode=DATA_EMIT_MODE;
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
4364 #ifdef __APPLE__
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4365 printf(" \t.align 2\n");
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
4366 #else
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4367 printf(" \t.section\t.rodata\n\t.align 4\n");
619
509d637a58b2 Intel Mac first try.
kono
parents: 616
diff changeset
4368 #endif
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4369 fwddef(l);
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4370 }
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4371
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4372 void
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4373 code_table_value(int label,int table_top)
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4374 {
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4375 #ifdef __APPLE__
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4376 printf("\t.long _%d-_%d\n",label,goffset_label);
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4377 #else
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4378 printf("\t.long _%d\n",label);
632
704b483c3122 Intel mac continue...
kono
parents: 631
diff changeset
4379 #endif
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4380 }
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4381
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4382 void
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4383 code_table_close()
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4384 {
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4385 text_mode(0);
301
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4386 }
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4387
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4388 #endif
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4389
60dba3ef1f69 ia32, mips case. incomplete.
kono
parents: 292
diff changeset
4390
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4391 #if ASM_CODE
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4392
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4393 /*
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4394 print an operand
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4395 */
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4396
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4397 static void
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4398 emit_asm_operand(int rstr)
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4399 {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4400 if (car(rstr)==REGISTER) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4401 printf("%s",register_name(cadr(rstr),0));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4402 } else if (car(rstr)==CONST) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4403 printf("%d",cadr(rstr));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4404 } else if (car(rstr)==FNAME) {
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
4405 #ifdef __APPLE__
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
4406 printf("_%s-_%d",ncaddr(rstr)->nm,goffset_label);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4407 #else
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
4408 printf("%s",ncaddr(rstr)->nm);
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4409 #endif
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
4410 } else if (car(rstr)==LABEL) {
631
76242dc0bbc9 Intel Mac continue....
kono
parents: 630
diff changeset
4411 #ifdef __APPLE__
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4412 printf("_%d-_%d",cadr(rstr),goffset_label);
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4413 #else
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4414 printf("_%d",cadr(rstr));
626
5bd74f52df62 Intel continue...
kono
parents: 619
diff changeset
4415 #endif
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4416 } else {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4417 error(-1);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4418 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4419 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4420
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4421 /*
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4422 prepare asm operands
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4423
326
e5d40f8c4cce bit-field continue.
kono
parents: 320
diff changeset
4424 char *constraints string
e5d40f8c4cce bit-field continue.
kono
parents: 320
diff changeset
4425 int operand expr
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4426 int mode (ASM_INPUT,ASM_OUTPUT)
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4427 int replacement list
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4428 int output operands count
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4429 int output operands replacement list
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4430
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4431 retrun replacement list
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4432 list3( operands, next, clobber )
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4433 0 can be shared in input/output
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4434 1 can't be used in input
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4435 */
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4436
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4437 int
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
4438 code_asm_operand(char *p,int e1,int mode,int repl,int n,int repl0)
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4439 {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4440 int r;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4441 int c;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4442 int val;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4443 int clobber = 0;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4444
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
4445 printf("## constraint %s\n",p);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4446 if (*p=='=') {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4447 // output register
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4448 p++;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4449 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4450 if (*p=='&') {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4451 // earlyclobber
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4452 p++;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4453 clobber = 1;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4454 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4455 c = *p;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4456 if (c=='r') {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4457 if (mode==ASM_INPUT) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4458 for(;repl0;repl0 = cadr(repl0)) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4459 if (car(car(repl0))==REGISTER && caddr(repl0)==0) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4460 r = cadr(car(repl0));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4461 caddr(repl0) = ASM_USED;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4462 break;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4463 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4464 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4465 r = get_register();
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4466 } else {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4467 r = get_register();
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4468 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4469 repl = list3(list2(REGISTER,r),repl,clobber);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4470 } else if (c=='m') {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4471 repl = list3(list2(0,0),repl,clobber);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4472 } else if (c=='i') {
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
4473 if (car(e1)==GVAR) {
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
4474 e1=list3n(FNAME,0,ncaddr(e1));
368
be56772ab12a global offset, parallel_rassign fix, save_stack fix.
kono
parents: 366
diff changeset
4475 } else if (car(e1)==FNAME) {
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
4476 e1=list3n(FNAME,0,ncaddr(e1));
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4477 } else if (car(e1)==STRING) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4478 val = emit_string_label();
711
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
4479 ascii(ncaddr(e1)->nm);
35e6841ba01a pointer fixes (partial)
kono
parents: 709
diff changeset
4480 e1=list2(LABEL,val);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4481 } else if (car(e1)==CONST) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4482 } else error(-1);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4483 repl = list3(e1,repl,clobber);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4484 } else if (digit(c)) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4485 val = 0;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4486 do { val = val*10 + c-'0'; } while (digit(c=*p++));
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4487 if (val>MAX_ASM_REG) error(-1); // too large register
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4488 if (n-val<0) error(-1);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4489 repl = list3(car(nth(n-val-1,repl0)),repl,clobber);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4490 } else error(-1);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4491 return repl;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4492 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4493
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4494 void
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
4495 code_free_asm_operand(int repl)
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4496 {
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
4497 int reg;
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4498 for(;repl;repl=cadr(repl)) {
584
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
4499 if (car(car(repl))==REGISTER) {
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
4500 reg = cadr(car(repl));
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
4501 if (regs[reg]!=REG_VAR) free_register(reg);
ef6e0e05137f ia32 reconfigure continue...
kono
parents: 583
diff changeset
4502 }
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4503 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4504 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4505
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4506
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4507 extern void
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
4508 code_asm(char *asm_str,int repl)
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4509 {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4510 int c,i,rstr,val;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4511 char *p;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4512 int reg[MAX_ASM_REG];
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4513
516
bfa4c834a3b8 data/text/rodata segment fix (incomplete)
kono
parents: 513
diff changeset
4514 text_mode(0);
320
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4515 c = *asm_str;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4516 if (c!='\t'&&c!=' ') printf("\t");
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4517 for(i=0;repl && i<MAX_ASM_REG;i++) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4518 reg[i] = car(repl);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4519 repl = cadr(repl);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4520 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4521 p = asm_str;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4522 while((c = *p++)) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4523 if (c=='%') {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4524 c = *p++;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4525 if (!c) { break;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4526 } else if (c=='%') {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4527 printf("%%"); continue;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4528 } else if (!digit(c)) {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4529 printf("%%%c",c); continue;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4530 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4531 val = 0;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4532 do { val = val*10 + c-'0'; } while (digit(c=*p++)) ;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4533 p--;
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4534 if (val>MAX_ASM_REG) error(-1); // too large register
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4535 rstr = reg[val];
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4536 emit_asm_operand(rstr);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4537 } else {
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4538 printf("%c",c);
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4539 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4540 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4541 printf("\n");
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4542 }
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4543
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4544 #endif
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4545
183726ccd83d asm minor fix. ia32 table jmp fix.
kono
parents: 315
diff changeset
4546
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4547 #if BIT_FIELD_CODE
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4548
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4549 /* bit field alignment calcuration */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4550
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4551 static void
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4552 set_bitsz(int type,int *pbitpos, int *pbitsize,
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4553 int *psign,int *pbitsz,int *palign,int *pl)
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4554 {
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
4555 int sign=0,bitsz=1;
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
4556 int align=4,l=0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4557 *pbitpos = cadr(caddr(type));
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4558 *pbitsize = caddr(caddr(type));
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4559
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4560 switch(cadr(type)) {
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4561 case INT: sign=1; bitsz=32; align=4;break;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4562 case UNSIGNED: bitsz=32; align=4;break;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4563 case CHAR: sign=1; bitsz= 8; align=1;break;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4564 case UCHAR: bitsz= 8; align=1;break;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4565 case SHORT: sign=1; bitsz=16; align=2;break;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4566 case USHORT: sign=1; bitsz=16; align=2;break;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4567 case LONGLONG: sign=1; bitsz=64; align=4;l=1; break;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4568 case ULONGLONG: bitsz=64; align=4;l=1; break;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4569 default: error(-1);
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4570 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4571 *psign = sign;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4572 *pbitsz = bitsz;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4573 *palign = align;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4574 *pl = l;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4575 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4576
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4577 /*
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4578 bit field alignment calcuration
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4579 this is architecture depenedent
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4580 */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4581
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4582 extern int
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4583 code_bit_field_disp(int type,int *poffset,int *bfd,int *sz)
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4584 {
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4585 int sign,bitsz,align;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4586 int i;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4587 int bitpos = *bfd;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4588 int bitpos0;
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4589 int bitsize;
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4590 int offset = *poffset;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4591 int l;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4592 set_bitsz(type,&bitpos0,&bitsize,&sign,&bitsz,&align,&l);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4593
569
1fcad06b264a gcc4 (ia32)
kono
parents: 560
diff changeset
4594 if (bitsize>bitsz) { error(BTERR); bitsize = bitsz; }
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4595
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4596 /* bfd means previous bit field bit offset */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4597 if (bitpos) {
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4598 /* previous field is bit field and spaces may remain */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4599 /* calc previsous offset */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4600
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4601 i= offset-(bitpos+7)/8;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4602
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4603 for(l = bitpos;l>0;l -= 8,i++) {
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4604 if ((i & (align-1))==0 && l+bitsize <= bitsz) {
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4605 /* alignment is correct and space remains */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4606 *poffset=offset=i;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4607 i = l+bitsize;
423
8b9136a06f56 bitfield continue...
kono
parents: 420
diff changeset
4608 *bfd = (i==bitsz)?0:i;
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4609 *sz = (i+7)/8;
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
4610 // printf("## bitpos=%d bitsize=%d bitsz=%d offset=%d\n",l,bitsize,bitsz,*poffset);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4611 return l;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4612 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4613 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4614 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4615
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4616 /* first bit-field */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4617
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4618 if ((i=(offset & (align-1)))) {
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4619 *poffset = (offset += (align-i));
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4620 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4621 bitpos = 0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4622 *bfd = (bitsize==bitsz)?0:bitsize;
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4623 *sz = (bitsize+7)/8;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4624
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
4625 // printf("## bitpos=%d bitsize=%d bitsz=%d offset=%d\n",bitpos,bitsize,bitsz,*poffset);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4626 return bitpos;
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4627 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4628
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4629 /* bit field value */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4630
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4631 extern void
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4632 code_bit_field(int type,int adr,int reg)
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4633 {
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4634 int sign,bitsz,l,align;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4635 int bitsize,bitpos;
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4636 int i,size;
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4637 set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4638 size=bitsz/8;
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
4639 // printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4640 /* this implementation returns -1 for int i:1; */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4641 if (l==1) {
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
4642 #if LONGLONG_CODE
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4643 use_int(adr);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4644 use_longlong(reg);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4645 lload(adr,0,reg);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4646 /* shift left */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4647 if ((i=bitsz-bitsize-bitpos))
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4648 loprtc(LLSHIFT,reg,list2(CONST,i));
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4649 /* shift right */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4650 if ((i=bitsz-bitsize))
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4651 loprtc(sign?LRSHIFT:LURSHIFT,reg,list2(CONST,i));
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
4652 #endif
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4653 } else {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4654 use_int(adr);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4655 use_int(reg);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4656 printf("\t%s %d(%s),%s\n",cload(sign,size),0,register_name(adr,0),
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4657 register_name(reg,0));
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4658 /* shift left */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4659 if ((i=32-bitsize-bitpos))
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4660 oprtc(LSHIFT,reg,list2(CONST,i));
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4661 /* shift right */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4662 if ((i=32-bitsize))
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4663 oprtc(sign?RSHIFT:URSHIFT,reg,list2(CONST,i));
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4664 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4665 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4666
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4667 /* bit field replacement */
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4668
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4669 static void
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4670 make_mask_and_or(int mask,int reg,int lreg)
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4671 {
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
4672 printf("## mask 0x%08x ~0x%08x\n",mask,~mask);
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4673 printf("\tpushl %s\n",register_name(reg,0));
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4674 /* make and-mask */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4675 oprtc(BOR,reg,list2(CONST,~mask));
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4676 /* do conjunction */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4677 if (lreg==-1) {
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4678 printf("\tandl %s,4(%%esp)\n",register_name(reg,0));
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4679 } else if (lreg==-2) {
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4680 printf("\tandl %s,8(%%esp)\n",register_name(reg,0));
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4681 } else {
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4682 printf("\tandl %s,%s\n",register_name(reg,0),register_name(lreg,0));
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4683 }
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4684 /* make or-mask */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4685 printf("\tpopl %s\n",register_name(reg,0));
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4686 oprtc(BAND,reg,list2(CONST,mask));
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4687 /* do disjunction */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4688 if (lreg==-1) {
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4689 printf("\torl %s,0(%%esp)\n",register_name(reg,0));
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4690 } else if (lreg==-2) {
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4691 printf("\torl %s,4(%%esp)\n",register_name(reg,0));
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4692 } else {
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4693 printf("\torl %s,%s\n",register_name(reg,0),register_name(lreg,0));
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4694 printf("\txchg %s,%s\n",register_name(reg,0),register_name(lreg,0));
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4695 }
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4696 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4697
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4698 extern void
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4699 code_bit_replace(int adr,int value,int type)
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4700 {
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4701 int sign,bitsz,l,align;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4702 int bitsize,bitpos;
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4703 int mask = 0;
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
4704 int size;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4705 set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4706 size = bitsz/8;
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
4707 // printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4708 if (l) {
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
4709 #if LONGLONG_CODE
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
4710 int push=0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4711 use_int(adr);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4712 use_longlong(value);
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4713 /* shift left */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4714 if (bitpos)
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4715 loprtc(LLSHIFT,value,list2(CONST,bitpos));
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4716 if (bitpos+bitsize>=32) {
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4717 /* make and-mask upper */
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4718 printf("\tpushl %s\n",register_name(adr,0)); push=1;
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4719 printf("\t%s %d(%s),%s\n",cload(sign,size),4,register_name(adr,0),
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4720 register_name(adr,0));
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4721 mask = make_mask(64-bitpos-bitsize,bitpos>=32?63-bitpos:31);
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4722 make_mask_and_or(mask,regv_h(value),adr);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4723 printf("\tmovl 0(%%esp),%s\n",register_name(adr,0));
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4724 printf("\t%s %s,4(%s)\n",move(0),
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4725 l_edx(value), register_name(adr,0));
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4726 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4727 if (bitpos<32) {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4728 if (!push) { printf("\tpushl %s\n",register_name(adr,0)); push=1;}
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4729 /* make and-mask lower */
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4730 printf("\t%s %d(%s),%s\n",cload(sign,size),0,register_name(adr,0),
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4731 register_name(adr,0));
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4732 mask = make_mask(bitpos+bitsize>=32?0:32-bitpos-bitsize,31-bitpos);
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4733 make_mask_and_or(mask,regv_l(value),adr);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4734 printf("\tpopl %s\n",register_name(adr,0)); push=0;
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4735 printf("\t%s %s,(%s)\n",move(0),
435
d3e6359f8501 loprtc LLSHIFT....
kono
parents: 433
diff changeset
4736 l_eax(value), register_name(adr,0));
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4737 }
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4738 if (push) printf("\taddl %%sp,$4\n");
440
a531bbf572e3 regression test (case, float, long long)
kono
parents: 438
diff changeset
4739 #endif
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4740 } else {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4741 use_int(adr);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4742 use_int(value);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4743 printf("\tpushl %s\n",register_name(adr,0));
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4744 printf("\t%s %d(%s),%s\n",cload(sign,size),0,register_name(adr,0),
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4745 register_name(adr,0));
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4746 /* shift left */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4747 if (bitpos)
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4748 oprtc(LSHIFT,value,list2(CONST,bitpos));
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4749 /* make and-mask */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
4750 mask = make_mask(32-bitpos-bitsize,31-bitpos);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4751 make_mask_and_or(mask,value,adr);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4752 printf("\tpopl %s\n",register_name(adr,0));
635
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
4753 code_assign(adr,size==4?0:size,value);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4754 }
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4755 if (use) {
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4756 code_bit_field(type,adr,USE_CREG);
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4757 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4758 }
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4759
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4760
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4761 static void
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4762 make_mask_and_or_const(int mask,int reg,int c)
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4763 {
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4764 int a;
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
4765 // printf("## mask 0x%08x ~0x%08x\n",mask,~mask);
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4766 a = ~mask|c;
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4767 if (a!=-1) {
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4768 /* do conjunction */
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
4769 if (reg<MAX_DATA_REG && ((a& ~0xffff)==~0xffff)) {
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4770 if ((a& ~0xff)==~0xff)
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4771 printf("\tandb $%d,%s\n",a&0xff,register_name(reg,1));
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4772 else
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4773 printf("\tandw $%d,%s\n",a&0xffff,register_name(reg,2));
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4774 } else
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4775 printf("\tandl $%d,%s\n",a,register_name(reg,0));
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4776 }
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4777 /* make or-mask */
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4778 c = mask&c;
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4779 if (c!=0) {
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4780 /* do disjunction */
590
cc2a83f98188 ia32 reorganization etc.
kono
parents: 589
diff changeset
4781 if (reg<MAX_DATA_REG && (!(c& ~0xffff))) {
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4782 if (!(c& ~0xff))
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4783 printf("\torb $%d,%s\n",c&0xff,register_name(reg,1));
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4784 else
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4785 printf("\torw $%d,%s\n",c&0xffff,register_name(reg,2));
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4786 } else
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4787 printf("\torl $%d,%s\n",c,register_name(reg,0));
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4788 }
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4789 }
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4790
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4791 extern void
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4792 code_bit_replace_const(int value,int adr,int type)
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4793 {
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4794 int sign,bitsz,l,align;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4795 int bitpos,bitsize,size;
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4796 int mask = 0;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4797 int c,lvalue;
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4798 #if LONGLONG_CODE
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4799 long long lc;
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4800 #endif
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4801 set_bitsz(type,&bitpos,&bitsize,&sign,&bitsz,&align,&l);
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4802 size = bitsz/8;
468
464e7480395c *** empty log message ***
kono
parents: 466
diff changeset
4803 // printf("## %d: bitpos=%d bitsize=%d bitsz=%d\n",lineno,bitpos,bitsize,bitsz);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4804 use_int(adr);
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4805 if (l) {
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4806 #if LONGLONG_CODE
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4807 lvalue = get_register();
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4808 /* shift left */
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4809 lc = lcadr(value);
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4810 lc <<= bitpos;
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4811
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4812 if (bitpos+bitsize>=32) {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4813 printf("\t%s %d(%s),%s\n",cload(sign,size),4,register_name(adr,0),
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4814 register_name(lvalue,0));
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4815 /* make and-mask upper */
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4816 mask = make_mask(64-bitpos-bitsize,bitpos>=32?63-bitpos:31);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4817 make_mask_and_or_const(mask,lvalue,(int)(lc>>32));
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4818 printf("\t%s %s,4(%s)\n",move(0),register_name(lvalue,0),
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4819 register_name(adr,0));
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4820 }
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4821 if (bitpos<32) {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4822 printf("\t%s %d(%s),%s\n",cload(sign,size),0,register_name(adr,0),
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4823 register_name(lvalue,0));
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4824 /* make and-mask lower */
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4825 mask = make_mask(bitpos+bitsize>=32?0:32-bitpos-bitsize,31-bitpos);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4826 make_mask_and_or_const(mask,lvalue,(int)(lc));
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4827 printf("\t%s %s,(%s)\n",move(0),
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4828 register_name(lvalue,0),register_name(adr,0));
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4829 }
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4830 free_register(lvalue);
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4831 #endif
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4832 } else {
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4833 lvalue = get_register();
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4834 printf("\t%s %d(%s),%s\n",cload(sign,size),0,register_name(adr,0),
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4835 register_name(lvalue,0));
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4836 /* shift left */
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4837 c = cadr(value);
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4838 c <<= bitpos;
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4839 /* make and-mask */
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4840 mask = make_mask(32-bitpos-bitsize,31-bitpos);
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4841 make_mask_and_or_const(mask,lvalue,c);
635
e4fffa4bf9cf Intel Mac complete
kono
parents: 634
diff changeset
4842 code_assign(adr,size==4?0:size,lvalue);
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4843 free_register(lvalue);
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4844 }
427
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4845 if (use)
0c256ea2a97e Bitfield left value for ia32
kono
parents: 423
diff changeset
4846 code_bit_field(type,adr,USE_CREG);
365
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4847 }
5ac17fa9d7e0 bit-field constant assignment
kono
parents: 364
diff changeset
4848
336
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4849 #endif
d488b72254fb bit-field done.
kono
parents: 328
diff changeset
4850
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4851 int
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4852 not_simple_p(int e3)
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4853 {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4854 switch(e3) {
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4855 case FUNCTION: case CONV: case STASS: case ALLOCA:
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4856 case LDIV: case LUDIV: case LMOD: case LUMOD:
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4857 case LMUL: case LUMUL:
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4858 case LLSHIFT: case LULSHIFT: case LRSHIFT: case LURSHIFT:
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4859 case DDIV: case DADD: case DSUB: case DMUL: case DMINUS:
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4860 case DPOSTINC : case DPREINC : case DASSOP :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4861 case DOP+LT : case DOP+LE : case DOP+GT : case DOP+GE :
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4862 case DOP+EQ : case DOP+NEQ:
450
eaf9e2746c83 parallel assign for simple expr. (too complex solution)
kono
parents: 449
diff changeset
4863 case RBIT_FIELD: case BASS: case BASSOP: case LCALL:
456
b8f95294eb77 inline continue... if test passed.
kono
parents: 451
diff changeset
4864 case INLINE:
449
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4865 return 1;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4866 }
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4867 return 0;
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4868 }
c55363eff5e5 parallel assignment (modify not completed)
kono
parents: 446
diff changeset
4869
715
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4870 extern int
782
003067098032 code argument offset in caller and callee
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 780
diff changeset
4871 code_arg_alignment(int args,NMTBL *n, int type0,int sz, int is_code)
715
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4872 {
782
003067098032 code argument offset in caller and callee
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 780
diff changeset
4873 return code_arg_alignment0(args,n, type0,sz, is_code);
715
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4874 }
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4875
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4876
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4877 extern int
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4878 code_lvar_alignment(int args,NMTBL *n, int type0,int sz)
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4879 {
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4880 return code_lvar_alignment0(args,n, type0,sz);
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4881 }
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4882
83e18db76c96 architecture depenedent argument alignment
kono
parents: 714
diff changeset
4883
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents:
diff changeset
4884 /* end */