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

Last change on this file since 241 was 232, checked in by dai_9181, 17 years ago
File size: 5.7 KB
RevLine 
[206]1#include "stdafx.h"
2
[226]3#include <Compiler.h>
4
[3]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]
[232]13 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_R11, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::GlobalVar );
[3]14 }
15 else{
16 //movlpd xmm_reg,qword ptr[offset]
[232]17 compiler.codeGenerator.op_movlpd_RM( xmm_reg, 0, (long)pRelativeVar->offset, MOD_DISP32, Schedule::GlobalVar );
[3]18 }
19 }
[62]20 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
21 SetError(300,NULL,cp);
22 }
[3]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]
[232]38 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar );
[3]39 }
40 }
[40]41 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
[3]42 if(pRelativeVar->bOffsetOffset){
43 //add r11,qword ptr[rsp+offset]
[232]44 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
[3]45 }
46 else{
47 //mov r11,qword ptr[rsp+offset]
[232]48 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
[3]49 }
50
51 goto directmem;
52 }
53 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
54directmem:
55 //movlpd xmm_reg,qword ptr[r11]
[232]56 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_R11, 0, MOD_BASE);
[3]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]
[232]63 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_R11, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::GlobalVar );
[3]64 }
65 else{
66 //movss xmm_reg,dword ptr[offset]
[232]67 compiler.codeGenerator.op_movss_RM( xmm_reg, 0, (long)pRelativeVar->offset, MOD_BASE, Schedule::GlobalVar );
[3]68 }
69 }
[62]70 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
71 SetError(300,NULL,cp);
72 }
[3]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]
[232]88 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar );
[3]89 }
90 }
[40]91 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
[3]92 if(pRelativeVar->bOffsetOffset){
93 //add r11,qword ptr[rsp+offset]
[232]94 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
[3]95 }
96 else{
97 //mov r11,qword ptr[rsp+offset]
[232]98 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
[3]99 }
100
101 goto directmem;
102 }
103 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
104directmem:
105 //movss xmm_reg,dword ptr[r11]
[232]106 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_R11, 0, MOD_BASE);
[3]107 }
108}
109
110
111void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg){
[66]112 int varSize;
[3]113
[66]114 varSize=GetTypeSize(type,-1);
[3]115
116 if(pRelativeVar->dwKind==VAR_GLOBAL){
117 if(pRelativeVar->bOffsetOffset){
118 //mov reg, ptr[r11+offset]
[228]119 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::GlobalVar );
[3]120 }
121 else{
122 //mov reg, ptr[offset]
[228]123 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
[3]124 }
125 }
[62]126 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
127 if(pRelativeVar->bOffsetOffset){
128 //add r11,qword ptr[offset]
[228]129 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
[62]130 }
131 else{
132 //mov r11,qword ptr[offset]
[228]133 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
[62]134 }
135
136 goto directmem;
137 }
[3]138 else if(pRelativeVar->dwKind==VAR_LOCAL){
139 if(pRelativeVar->bOffsetOffset){
140 //mov reg, ptr[rsp+r11+offset]
[228]141 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET, Schedule::LocalVar );
[3]142 }
143 else{
144 //mov reg, ptr[rsp+offset]
[228]145 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
[3]146 }
147 }
[40]148 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
[3]149 if(pRelativeVar->bOffsetOffset){
150 //add r11,qword ptr[rsp+offset]
[228]151 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
[3]152 }
153 else{
154 //mov r11,qword ptr[rsp+offset]
[228]155 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
[3]156 }
157
158 goto directmem;
159 }
160 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
161directmem:
162 //mov reg, ptr[r11]
[226]163 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,0,MOD_BASE);
[3]164 }
165}
Note: See TracBrowser for help on using the repository browser.