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_LOCAL){
|
---|
31 | if(pRelativeVar->bOffsetOffset){
|
---|
32 | //movlpd xmm_reg,qword ptr[rsp+r11+offset]
|
---|
33 | OpBuffer[obp++]=(char)0x66;
|
---|
34 | OpBuffer[obp++]=(char)0x42;
|
---|
35 | OpBuffer[obp++]=(char)0x0F;
|
---|
36 | OpBuffer[obp++]=(char)0x12;
|
---|
37 | OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3);
|
---|
38 | OpBuffer[obp++]=(char)0x1C;
|
---|
39 | *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
|
---|
40 | AddLocalVarAddrSchedule();
|
---|
41 | obp+=sizeof(long);
|
---|
42 | }
|
---|
43 | else{
|
---|
44 | //movlpd xmm_reg,qword ptr[rsp+offset]
|
---|
45 | OpBuffer[obp++]=(char)0x66;
|
---|
46 | OpBuffer[obp++]=(char)0x0F;
|
---|
47 | OpBuffer[obp++]=(char)0x12;
|
---|
48 | OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3);
|
---|
49 | OpBuffer[obp++]=(char)0x24;
|
---|
50 | *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
|
---|
51 | AddLocalVarAddrSchedule();
|
---|
52 | obp+=sizeof(long);
|
---|
53 | }
|
---|
54 | }
|
---|
55 | else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
|
---|
56 | if(pRelativeVar->bOffsetOffset){
|
---|
57 | //add r11,qword ptr[rsp+offset]
|
---|
58 | OpBuffer[obp++]=(char)0x4C;
|
---|
59 | OpBuffer[obp++]=(char)0x03;
|
---|
60 | OpBuffer[obp++]=(char)0x9C;
|
---|
61 | OpBuffer[obp++]=(char)0x24;
|
---|
62 | *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
|
---|
63 | AddLocalVarAddrSchedule();
|
---|
64 | obp+=sizeof(long);
|
---|
65 | }
|
---|
66 | else{
|
---|
67 | //mov r11,qword ptr[rsp+offset]
|
---|
68 | op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
|
---|
69 | obp-=sizeof(long);
|
---|
70 | AddLocalVarAddrSchedule();
|
---|
71 | obp+=sizeof(long);
|
---|
72 | }
|
---|
73 |
|
---|
74 | goto directmem;
|
---|
75 | }
|
---|
76 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
77 | directmem:
|
---|
78 | //movlpd xmm_reg,qword ptr[r11]
|
---|
79 | OpBuffer[obp++]=(char)0x66;
|
---|
80 | OpBuffer[obp++]=(char)0x41;
|
---|
81 | OpBuffer[obp++]=(char)0x0F;
|
---|
82 | OpBuffer[obp++]=(char)0x12;
|
---|
83 | OpBuffer[obp++]=(char)(0x03 | REGISTER_OPERAND(xmm_reg)<<3);
|
---|
84 | }
|
---|
85 | }
|
---|
86 | void SetXmmReg_SingleVariable(RELATIVE_VAR *pRelativeVar,int xmm_reg){
|
---|
87 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
88 | if(pRelativeVar->bOffsetOffset){
|
---|
89 | //movss xmm_reg,dword ptr[r11+offset]
|
---|
90 | OpBuffer[obp++]=(char)0xF3;
|
---|
91 | OpBuffer[obp++]=(char)0x41;
|
---|
92 | OpBuffer[obp++]=(char)0x0F;
|
---|
93 | OpBuffer[obp++]=(char)0x10;
|
---|
94 | OpBuffer[obp++]=(char)(0x83 | REGISTER_OPERAND(xmm_reg)<<3);
|
---|
95 | *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
|
---|
96 | pobj_GlobalVarSchedule->add();
|
---|
97 | obp+=sizeof(long);
|
---|
98 | }
|
---|
99 | else{
|
---|
100 | //movss xmm_reg,dword ptr[offset]
|
---|
101 | OpBuffer[obp++]=(char)0xF3;
|
---|
102 | OpBuffer[obp++]=(char)0x0F;
|
---|
103 | OpBuffer[obp++]=(char)0x10;
|
---|
104 | OpBuffer[obp++]=(char)(0x04 | REGISTER_OPERAND(xmm_reg)<<3);
|
---|
105 | OpBuffer[obp++]=(char)0x25;
|
---|
106 | *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
|
---|
107 | pobj_GlobalVarSchedule->add();
|
---|
108 | obp+=sizeof(long);
|
---|
109 | }
|
---|
110 | }
|
---|
111 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
112 | if(pRelativeVar->bOffsetOffset){
|
---|
113 | //movss xmm_reg,dword ptr[rsp+r11+offset]
|
---|
114 | OpBuffer[obp++]=(char)0xF3;
|
---|
115 | OpBuffer[obp++]=(char)0x42;
|
---|
116 | OpBuffer[obp++]=(char)0x0F;
|
---|
117 | OpBuffer[obp++]=(char)0x10;
|
---|
118 | OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3);
|
---|
119 | OpBuffer[obp++]=(char)0x1C;
|
---|
120 | *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
|
---|
121 | AddLocalVarAddrSchedule();
|
---|
122 | obp+=sizeof(long);
|
---|
123 | }
|
---|
124 | else{
|
---|
125 | //movss xmm_reg,dword ptr[rsp+offset]
|
---|
126 | OpBuffer[obp++]=(char)0xF3;
|
---|
127 | OpBuffer[obp++]=(char)0x0F;
|
---|
128 | OpBuffer[obp++]=(char)0x10;
|
---|
129 | OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3);
|
---|
130 | OpBuffer[obp++]=(char)0x24;
|
---|
131 | *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
|
---|
132 | AddLocalVarAddrSchedule();
|
---|
133 | obp+=sizeof(long);
|
---|
134 | }
|
---|
135 | }
|
---|
136 | else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
|
---|
137 | if(pRelativeVar->bOffsetOffset){
|
---|
138 | //add r11,qword ptr[rsp+offset]
|
---|
139 | OpBuffer[obp++]=(char)0x4C;
|
---|
140 | OpBuffer[obp++]=(char)0x03;
|
---|
141 | OpBuffer[obp++]=(char)0x9C;
|
---|
142 | OpBuffer[obp++]=(char)0x24;
|
---|
143 | *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
|
---|
144 | AddLocalVarAddrSchedule();
|
---|
145 | obp+=sizeof(long);
|
---|
146 | }
|
---|
147 | else{
|
---|
148 | //mov r11,qword ptr[rsp+offset]
|
---|
149 | op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
|
---|
150 | obp-=sizeof(long);
|
---|
151 | AddLocalVarAddrSchedule();
|
---|
152 | obp+=sizeof(long);
|
---|
153 | }
|
---|
154 |
|
---|
155 | goto directmem;
|
---|
156 | }
|
---|
157 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
158 | directmem:
|
---|
159 | //movss xmm_reg,dword ptr[r11]
|
---|
160 | OpBuffer[obp++]=(char)0xF3;
|
---|
161 | OpBuffer[obp++]=(char)0x41;
|
---|
162 | OpBuffer[obp++]=(char)0x0F;
|
---|
163 | OpBuffer[obp++]=(char)0x10;
|
---|
164 | OpBuffer[obp++]=(char)(0x03 | REGISTER_OPERAND(xmm_reg)<<3);
|
---|
165 | }
|
---|
166 | }
|
---|
167 |
|
---|
168 |
|
---|
169 | void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg){
|
---|
170 | int var_size;
|
---|
171 |
|
---|
172 | var_size=GetTypeSize(type,-1);
|
---|
173 |
|
---|
174 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
175 | if(pRelativeVar->bOffsetOffset){
|
---|
176 | //mov reg, ptr[r11+offset]
|
---|
177 | op_mov_RM(var_size,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32);
|
---|
178 | obp-=sizeof(long);
|
---|
179 | pobj_GlobalVarSchedule->add();
|
---|
180 | obp+=sizeof(long);
|
---|
181 | }
|
---|
182 | else{
|
---|
183 | //mov reg, ptr[offset]
|
---|
184 | op_mov_RM(var_size,reg,0,(int)pRelativeVar->offset,MOD_DISP32);
|
---|
185 | obp-=sizeof(long);
|
---|
186 | pobj_GlobalVarSchedule->add();
|
---|
187 | obp+=sizeof(long);
|
---|
188 | }
|
---|
189 | }
|
---|
190 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
191 | if(pRelativeVar->bOffsetOffset){
|
---|
192 | //mov reg, ptr[rsp+r11+offset]
|
---|
193 | op_mov_RM_ex(var_size,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET);
|
---|
194 | obp-=sizeof(long);
|
---|
195 | AddLocalVarAddrSchedule();
|
---|
196 | obp+=sizeof(long);
|
---|
197 | }
|
---|
198 | else{
|
---|
199 | //mov reg, ptr[rsp+offset]
|
---|
200 | op_mov_RM(var_size,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
|
---|
201 | obp-=sizeof(long);
|
---|
202 | AddLocalVarAddrSchedule();
|
---|
203 | obp+=sizeof(long);
|
---|
204 | }
|
---|
205 | }
|
---|
206 | else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
|
---|
207 | if(pRelativeVar->bOffsetOffset){
|
---|
208 | //add r11,qword ptr[rsp+offset]
|
---|
209 | op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
|
---|
210 | obp-=sizeof(long);
|
---|
211 | AddLocalVarAddrSchedule();
|
---|
212 | obp+=sizeof(long);
|
---|
213 | }
|
---|
214 | else{
|
---|
215 | //mov r11,qword ptr[rsp+offset]
|
---|
216 | op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32);
|
---|
217 | obp-=sizeof(long);
|
---|
218 | AddLocalVarAddrSchedule();
|
---|
219 | obp+=sizeof(long);
|
---|
220 | }
|
---|
221 |
|
---|
222 | goto directmem;
|
---|
223 | }
|
---|
224 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
225 | directmem:
|
---|
226 | //mov reg, ptr[r11]
|
---|
227 | op_mov_RM(var_size,reg,REG_R11,0,MOD_BASE);
|
---|
228 | }
|
---|
229 | }
|
---|