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

Last change on this file since 240 was 232, checked in by dai_9181, 17 years ago
File size: 5.7 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 OpBuffer[obp++]=(char)0x66;
27 OpBuffer[obp++]=(char)0x42;
28 OpBuffer[obp++]=(char)0x0F;
29 OpBuffer[obp++]=(char)0x12;
30 OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3);
31 OpBuffer[obp++]=(char)0x1C;
32 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
33 AddLocalVarAddrSchedule();
34 obp+=sizeof(long);
35 }
36 else{
37 //movlpd xmm_reg,qword ptr[rsp+offset]
38 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar );
39 }
40 }
41 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
42 if(pRelativeVar->bOffsetOffset){
43 //add r11,qword ptr[rsp+offset]
44 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
45 }
46 else{
47 //mov r11,qword ptr[rsp+offset]
48 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
49 }
50
51 goto directmem;
52 }
53 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
54directmem:
55 //movlpd xmm_reg,qword ptr[r11]
56 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_R11, 0, MOD_BASE);
57 }
58}
59void SetXmmReg_SingleVariable(RELATIVE_VAR *pRelativeVar,int xmm_reg){
60 if(pRelativeVar->dwKind==VAR_GLOBAL){
61 if(pRelativeVar->bOffsetOffset){
62 //movss xmm_reg,dword ptr[r11+offset]
63 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_R11, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::GlobalVar );
64 }
65 else{
66 //movss xmm_reg,dword ptr[offset]
67 compiler.codeGenerator.op_movss_RM( xmm_reg, 0, (long)pRelativeVar->offset, MOD_BASE, Schedule::GlobalVar );
68 }
69 }
70 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
71 SetError(300,NULL,cp);
72 }
73 else if(pRelativeVar->dwKind==VAR_LOCAL){
74 if(pRelativeVar->bOffsetOffset){
75 //movss xmm_reg,dword ptr[rsp+r11+offset]
76 OpBuffer[obp++]=(char)0xF3;
77 OpBuffer[obp++]=(char)0x42;
78 OpBuffer[obp++]=(char)0x0F;
79 OpBuffer[obp++]=(char)0x10;
80 OpBuffer[obp++]=(char)(0x84 | REGISTER_OPERAND(xmm_reg)<<3);
81 OpBuffer[obp++]=(char)0x1C;
82 *((long *)(OpBuffer+obp))=(int)pRelativeVar->offset;
83 AddLocalVarAddrSchedule();
84 obp+=sizeof(long);
85 }
86 else{
87 //movss xmm_reg,dword ptr[rsp+offset]
88 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar );
89 }
90 }
91 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
92 if(pRelativeVar->bOffsetOffset){
93 //add r11,qword ptr[rsp+offset]
94 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
95 }
96 else{
97 //mov r11,qword ptr[rsp+offset]
98 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
99 }
100
101 goto directmem;
102 }
103 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
104directmem:
105 //movss xmm_reg,dword ptr[r11]
106 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_R11, 0, MOD_BASE);
107 }
108}
109
110
111void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg){
112 int varSize;
113
114 varSize=GetTypeSize(type,-1);
115
116 if(pRelativeVar->dwKind==VAR_GLOBAL){
117 if(pRelativeVar->bOffsetOffset){
118 //mov reg, ptr[r11+offset]
119 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::GlobalVar );
120 }
121 else{
122 //mov reg, ptr[offset]
123 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
124 }
125 }
126 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
127 if(pRelativeVar->bOffsetOffset){
128 //add r11,qword ptr[offset]
129 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
130 }
131 else{
132 //mov r11,qword ptr[offset]
133 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
134 }
135
136 goto directmem;
137 }
138 else if(pRelativeVar->dwKind==VAR_LOCAL){
139 if(pRelativeVar->bOffsetOffset){
140 //mov reg, ptr[rsp+r11+offset]
141 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET, Schedule::LocalVar );
142 }
143 else{
144 //mov reg, ptr[rsp+offset]
145 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
146 }
147 }
148 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
149 if(pRelativeVar->bOffsetOffset){
150 //add r11,qword ptr[rsp+offset]
151 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
152 }
153 else{
154 //mov r11,qword ptr[rsp+offset]
155 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
156 }
157
158 goto directmem;
159 }
160 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
161directmem:
162 //mov reg, ptr[r11]
163 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,0,MOD_BASE);
164 }
165}
Note: See TracBrowser for help on using the repository browser.