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