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

Last change on this file since 277 was 254, checked in by dai_9181, 17 years ago
File size: 6.4 KB
Line 
1#include "stdafx.h"
2
3#include <Compiler.h>
4
5#include "../BasicCompiler_Common/common.h"
6#include "Opcode.h"
7
8
9void SetXmmReg_DoubleVariable(RELATIVE_VAR *pRelativeVar,int xmm_reg){
10 if(pRelativeVar->dwKind==VAR_GLOBAL){
11 if(pRelativeVar->bOffsetOffset){
12 //movlpd xmm_reg,qword ptr[r11+offset]
13 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_R11, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::GlobalVar );
14 }
15 else{
16 //movlpd xmm_reg,qword ptr[offset]
17 compiler.codeGenerator.op_movlpd_RM( xmm_reg, 0, (long)pRelativeVar->offset, MOD_DISP32, Schedule::GlobalVar );
18 }
19 }
20 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
21 SetError(300,NULL,cp);
22 }
23 else if(pRelativeVar->dwKind==VAR_LOCAL){
24 if(pRelativeVar->bOffsetOffset){
25 //movlpd xmm_reg,qword ptr[rsp+r11+offset]
26 compiler.codeGenerator.PutOld(
27 (char)0x66,
28 (char)0x42,
29 (char)0x0F,
30 (char)0x12,
31 (char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3),
32 (char)0x1C
33 );
34 compiler.codeGenerator.localVarPertialSchedules.push_back(
35 compiler.codeGenerator.PutOld( (long)pRelativeVar->offset, true )
36 );
37 }
38 else{
39 //movlpd xmm_reg,qword ptr[rsp+offset]
40 compiler.codeGenerator.localVarPertialSchedules.push_back(
41 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true )
42 );
43 }
44 }
45 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
46 if(pRelativeVar->bOffsetOffset){
47 //add r11,qword ptr[rsp+offset]
48 compiler.codeGenerator.localVarPertialSchedules.push_back(
49 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
50 );
51 }
52 else{
53 //mov r11,qword ptr[rsp+offset]
54 compiler.codeGenerator.localVarPertialSchedules.push_back(
55 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
56 );
57 }
58
59 goto directmem;
60 }
61 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
62directmem:
63 //movlpd xmm_reg,qword ptr[r11]
64 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_R11, 0, MOD_BASE);
65 }
66}
67void SetXmmReg_SingleVariable(RELATIVE_VAR *pRelativeVar,int xmm_reg){
68 if(pRelativeVar->dwKind==VAR_GLOBAL){
69 if(pRelativeVar->bOffsetOffset){
70 //movss xmm_reg,dword ptr[r11+offset]
71 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_R11, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::GlobalVar );
72 }
73 else{
74 //movss xmm_reg,dword ptr[offset]
75 compiler.codeGenerator.op_movss_RM( xmm_reg, 0, (long)pRelativeVar->offset, MOD_BASE, Schedule::GlobalVar );
76 }
77 }
78 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
79 SetError(300,NULL,cp);
80 }
81 else if(pRelativeVar->dwKind==VAR_LOCAL){
82 if(pRelativeVar->bOffsetOffset){
83 //movss xmm_reg,dword ptr[rsp+r11+offset]
84 compiler.codeGenerator.PutOld(
85 (char)0xF3,
86 (char)0x42,
87 (char)0x0F,
88 (char)0x10,
89 (char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3),
90 (char)0x1C
91 );
92 compiler.codeGenerator.localVarPertialSchedules.push_back(
93 compiler.codeGenerator.PutOld( (long)pRelativeVar->offset, true )
94 );
95 }
96 else{
97 //movss xmm_reg,dword ptr[rsp+offset]
98 compiler.codeGenerator.localVarPertialSchedules.push_back(
99 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::None, true )
100 );
101 }
102 }
103 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
104 if(pRelativeVar->bOffsetOffset){
105 //add r11,qword ptr[rsp+offset]
106 compiler.codeGenerator.localVarPertialSchedules.push_back(
107 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
108 );
109 }
110 else{
111 //mov r11,qword ptr[rsp+offset]
112 compiler.codeGenerator.localVarPertialSchedules.push_back(
113 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
114 );
115 }
116
117 goto directmem;
118 }
119 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
120directmem:
121 //movss xmm_reg,dword ptr[r11]
122 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_R11, 0, MOD_BASE);
123 }
124}
125
126
127void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg){
128 int varSize;
129
130 varSize=GetTypeSize(type,-1);
131
132 if(pRelativeVar->dwKind==VAR_GLOBAL){
133 if(pRelativeVar->bOffsetOffset){
134 //mov reg, ptr[r11+offset]
135 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::GlobalVar );
136 }
137 else{
138 //mov reg, ptr[offset]
139 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
140 }
141 }
142 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
143 if(pRelativeVar->bOffsetOffset){
144 //add r11,qword ptr[offset]
145 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
146 }
147 else{
148 //mov r11,qword ptr[offset]
149 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
150 }
151
152 goto directmem;
153 }
154 else if(pRelativeVar->dwKind==VAR_LOCAL){
155 if(pRelativeVar->bOffsetOffset){
156 //mov reg, ptr[rsp+r11+offset]
157 compiler.codeGenerator.localVarPertialSchedules.push_back(
158 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET, Schedule::None, true )
159 );
160 }
161 else{
162 //mov reg, ptr[rsp+offset]
163 compiler.codeGenerator.localVarPertialSchedules.push_back(
164 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
165 );
166 }
167 }
168 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
169 if(pRelativeVar->bOffsetOffset){
170 //add r11,qword ptr[rsp+offset]
171 compiler.codeGenerator.localVarPertialSchedules.push_back(
172 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
173 );
174 }
175 else{
176 //mov r11,qword ptr[rsp+offset]
177 compiler.codeGenerator.localVarPertialSchedules.push_back(
178 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
179 );
180 }
181
182 goto directmem;
183 }
184 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
185directmem:
186 //mov reg, ptr[r11]
187 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,0,MOD_BASE);
188 }
189}
Note: See TracBrowser for help on using the repository browser.