source: dev/trunk/abdev/BasicCompiler64/Compile_Calc_PushVar.cpp@ 225

Last change on this file since 225 was 206, checked in by dai_9181, 17 years ago

コード全体のリファクタリングを実施

File size: 7.5 KB
Line 
1#include "stdafx.h"
2
3#include "../BasicCompiler_Common/common.h"
4#include "Opcode.h"
5
6
7void SetXmmReg_DoubleVariable(RELATIVE_VAR *pRelativeVar,int xmm_reg){
8 if(pRelativeVar->dwKind==VAR_GLOBAL){
9 if(pRelativeVar->bOffsetOffset){
10 //movlpd xmm_reg,qword ptr[r11+offset]
11 OpBuffer[obp++]=(char)0x66;
12 OpBuffer[obp++]=(char)0x41;
13 OpBuffer[obp++]=(char)0x0F;
14 OpBuffer[obp++]=(char)0x12;
15 OpBuffer[obp++]=(char)(0x83 | REGISTER_OPERAND(xmm_reg)<<3);
16 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
17 pobj_GlobalVarSchedule->add();
18 obp+=sizeof(long);
19 }
20 else{
21 //movlpd xmm_reg,qword ptr[offset]
22 OpBuffer[obp++]=(char)0x66;
23 OpBuffer[obp++]=(char)0x0F;
24 OpBuffer[obp++]=(char)0x12;
25 OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3);
26 OpBuffer[obp++]=(char)0x25;
27 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
28 pobj_GlobalVarSchedule->add();
29 obp+=sizeof(long);
30 }
31 }
32 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
33 SetError(300,NULL,cp);
34 }
35 else if(pRelativeVar->dwKind==VAR_LOCAL){
36 if(pRelativeVar->bOffsetOffset){
37 //movlpd xmm_reg,qword ptr[rsp+r11+offset]
38 OpBuffer[obp++]=(char)0x66;
39 OpBuffer[obp++]=(char)0x42;
40 OpBuffer[obp++]=(char)0x0F;
41 OpBuffer[obp++]=(char)0x12;
42 OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3);
43 OpBuffer[obp++]=(char)0x1C;
44 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
45 AddLocalVarAddrSchedule();
46 obp+=sizeof(long);
47 }
48 else{
49 //movlpd xmm_reg,qword ptr[rsp+offset]
50 OpBuffer[obp++]=(char)0x66;
51 OpBuffer[obp++]=(char)0x0F;
52 OpBuffer[obp++]=(char)0x12;
53 OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3);
54 OpBuffer[obp++]=(char)0x24;
55 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
56 AddLocalVarAddrSchedule();
57 obp+=sizeof(long);
58 }
59 }
60 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
61 if(pRelativeVar->bOffsetOffset){
62 //add r11,qword ptr[rsp+offset]
63 OpBuffer[obp++]=(char)0x4C;
64 OpBuffer[obp++]=(char)0x03;
65 OpBuffer[obp++]=(char)0x9C;
66 OpBuffer[obp++]=(char)0x24;
67 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
68 AddLocalVarAddrSchedule();
69 obp+=sizeof(long);
70 }
71 else{
72 //mov r11,qword ptr[rsp+offset]
73 op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
74 obp-=sizeof(long);
75 AddLocalVarAddrSchedule();
76 obp+=sizeof(long);
77 }
78
79 goto directmem;
80 }
81 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
82directmem:
83 //movlpd xmm_reg,qword ptr[r11]
84 OpBuffer[obp++]=(char)0x66;
85 OpBuffer[obp++]=(char)0x41;
86 OpBuffer[obp++]=(char)0x0F;
87 OpBuffer[obp++]=(char)0x12;
88 OpBuffer[obp++]=(char)(0x03 | REGISTER_OPERAND(xmm_reg)<<3);
89 }
90}
91void SetXmmReg_SingleVariable(RELATIVE_VAR *pRelativeVar,int xmm_reg){
92 if(pRelativeVar->dwKind==VAR_GLOBAL){
93 if(pRelativeVar->bOffsetOffset){
94 //movss xmm_reg,dword ptr[r11+offset]
95 OpBuffer[obp++]=(char)0xF3;
96 OpBuffer[obp++]=(char)0x41;
97 OpBuffer[obp++]=(char)0x0F;
98 OpBuffer[obp++]=(char)0x10;
99 OpBuffer[obp++]=(char)(0x83 | REGISTER_OPERAND(xmm_reg)<<3);
100 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
101 pobj_GlobalVarSchedule->add();
102 obp+=sizeof(long);
103 }
104 else{
105 //movss xmm_reg,dword ptr[offset]
106 OpBuffer[obp++]=(char)0xF3;
107 OpBuffer[obp++]=(char)0x0F;
108 OpBuffer[obp++]=(char)0x10;
109 OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3);
110 OpBuffer[obp++]=(char)0x25;
111 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
112 pobj_GlobalVarSchedule->add();
113 obp+=sizeof(long);
114 }
115 }
116 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
117 SetError(300,NULL,cp);
118 }
119 else if(pRelativeVar->dwKind==VAR_LOCAL){
120 if(pRelativeVar->bOffsetOffset){
121 //movss xmm_reg,dword ptr[rsp+r11+offset]
122 OpBuffer[obp++]=(char)0xF3;
123 OpBuffer[obp++]=(char)0x42;
124 OpBuffer[obp++]=(char)0x0F;
125 OpBuffer[obp++]=(char)0x10;
126 OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3);
127 OpBuffer[obp++]=(char)0x1C;
128 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
129 AddLocalVarAddrSchedule();
130 obp+=sizeof(long);
131 }
132 else{
133 //movss xmm_reg,dword ptr[rsp+offset]
134 OpBuffer[obp++]=(char)0xF3;
135 OpBuffer[obp++]=(char)0x0F;
136 OpBuffer[obp++]=(char)0x10;
137 OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3);
138 OpBuffer[obp++]=(char)0x24;
139 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
140 AddLocalVarAddrSchedule();
141 obp+=sizeof(long);
142 }
143 }
144 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
145 if(pRelativeVar->bOffsetOffset){
146 //add r11,qword ptr[rsp+offset]
147 OpBuffer[obp++]=(char)0x4C;
148 OpBuffer[obp++]=(char)0x03;
149 OpBuffer[obp++]=(char)0x9C;
150 OpBuffer[obp++]=(char)0x24;
151 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
152 AddLocalVarAddrSchedule();
153 obp+=sizeof(long);
154 }
155 else{
156 //mov r11,qword ptr[rsp+offset]
157 op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
158 obp-=sizeof(long);
159 AddLocalVarAddrSchedule();
160 obp+=sizeof(long);
161 }
162
163 goto directmem;
164 }
165 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
166directmem:
167 //movss xmm_reg,dword ptr[r11]
168 OpBuffer[obp++]=(char)0xF3;
169 OpBuffer[obp++]=(char)0x41;
170 OpBuffer[obp++]=(char)0x0F;
171 OpBuffer[obp++]=(char)0x10;
172 OpBuffer[obp++]=(char)(0x03 | REGISTER_OPERAND(xmm_reg)<<3);
173 }
174}
175
176
177void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg){
178 int varSize;
179
180 varSize=GetTypeSize(type,-1);
181
182 if(pRelativeVar->dwKind==VAR_GLOBAL){
183 if(pRelativeVar->bOffsetOffset){
184 //mov reg, ptr[r11+offset]
185 op_mov_RM(varSize,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32);
186 obp-=sizeof(long);
187 pobj_GlobalVarSchedule->add();
188 obp+=sizeof(long);
189 }
190 else{
191 //mov reg, ptr[offset]
192 op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32);
193 obp-=sizeof(long);
194 pobj_GlobalVarSchedule->add();
195 obp+=sizeof(long);
196 }
197 }
198 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
199 if(pRelativeVar->bOffsetOffset){
200 //add r11,qword ptr[offset]
201 op_add_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32);
202 obp-=sizeof(long);
203 pobj_GlobalVarSchedule->add();
204 obp+=sizeof(long);
205 }
206 else{
207 //mov r11,qword ptr[offset]
208 op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32);
209 obp-=sizeof(long);
210 pobj_GlobalVarSchedule->add();
211 obp+=sizeof(long);
212 }
213
214 goto directmem;
215 }
216 else if(pRelativeVar->dwKind==VAR_LOCAL){
217 if(pRelativeVar->bOffsetOffset){
218 //mov reg, ptr[rsp+r11+offset]
219 op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET);
220 obp-=sizeof(long);
221 AddLocalVarAddrSchedule();
222 obp+=sizeof(long);
223 }
224 else{
225 //mov reg, ptr[rsp+offset]
226 op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
227 obp-=sizeof(long);
228 AddLocalVarAddrSchedule();
229 obp+=sizeof(long);
230 }
231 }
232 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
233 if(pRelativeVar->bOffsetOffset){
234 //add r11,qword ptr[rsp+offset]
235 op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
236 obp-=sizeof(long);
237 AddLocalVarAddrSchedule();
238 obp+=sizeof(long);
239 }
240 else{
241 //mov r11,qword ptr[rsp+offset]
242 op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
243 obp-=sizeof(long);
244 AddLocalVarAddrSchedule();
245 obp+=sizeof(long);
246 }
247
248 goto directmem;
249 }
250 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
251directmem:
252 //mov reg, ptr[r11]
253 op_mov_RM(varSize,reg,REG_R11,0,MOD_BASE);
254 }
255}
Note: See TracBrowser for help on using the repository browser.