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

Last change on this file since 303 was 254, checked in by dai_9181, 17 years ago
File size: 6.4 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]
[242]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 );
[254]34 compiler.codeGenerator.localVarPertialSchedules.push_back(
35 compiler.codeGenerator.PutOld( (long)pRelativeVar->offset, true )
[242]36 );
[3]37 }
38 else{
39 //movlpd xmm_reg,qword ptr[rsp+offset]
[254]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 );
[3]43 }
44 }
[40]45 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
[3]46 if(pRelativeVar->bOffsetOffset){
47 //add r11,qword ptr[rsp+offset]
[254]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 );
[3]51 }
52 else{
53 //mov r11,qword ptr[rsp+offset]
[254]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 );
[3]57 }
58
59 goto directmem;
60 }
61 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
62directmem:
63 //movlpd xmm_reg,qword ptr[r11]
[232]64 compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_R11, 0, MOD_BASE);
[3]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]
[232]71 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_R11, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::GlobalVar );
[3]72 }
73 else{
74 //movss xmm_reg,dword ptr[offset]
[232]75 compiler.codeGenerator.op_movss_RM( xmm_reg, 0, (long)pRelativeVar->offset, MOD_BASE, Schedule::GlobalVar );
[3]76 }
77 }
[62]78 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
79 SetError(300,NULL,cp);
80 }
[3]81 else if(pRelativeVar->dwKind==VAR_LOCAL){
82 if(pRelativeVar->bOffsetOffset){
83 //movss xmm_reg,dword ptr[rsp+r11+offset]
[242]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 );
[254]92 compiler.codeGenerator.localVarPertialSchedules.push_back(
93 compiler.codeGenerator.PutOld( (long)pRelativeVar->offset, true )
[242]94 );
[3]95 }
96 else{
97 //movss xmm_reg,dword ptr[rsp+offset]
[254]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 );
[3]101 }
102 }
[40]103 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
[3]104 if(pRelativeVar->bOffsetOffset){
105 //add r11,qword ptr[rsp+offset]
[254]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 );
[3]109 }
110 else{
111 //mov r11,qword ptr[rsp+offset]
[254]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 );
[3]115 }
116
117 goto directmem;
118 }
119 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
120directmem:
121 //movss xmm_reg,dword ptr[r11]
[232]122 compiler.codeGenerator.op_movss_RM( xmm_reg, REG_R11, 0, MOD_BASE);
[3]123 }
124}
125
126
127void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg){
[66]128 int varSize;
[3]129
[66]130 varSize=GetTypeSize(type,-1);
[3]131
132 if(pRelativeVar->dwKind==VAR_GLOBAL){
133 if(pRelativeVar->bOffsetOffset){
134 //mov reg, ptr[r11+offset]
[228]135 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::GlobalVar );
[3]136 }
137 else{
138 //mov reg, ptr[offset]
[228]139 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
[3]140 }
141 }
[62]142 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
143 if(pRelativeVar->bOffsetOffset){
144 //add r11,qword ptr[offset]
[228]145 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
[62]146 }
147 else{
148 //mov r11,qword ptr[offset]
[228]149 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
[62]150 }
151
152 goto directmem;
153 }
[3]154 else if(pRelativeVar->dwKind==VAR_LOCAL){
155 if(pRelativeVar->bOffsetOffset){
156 //mov reg, ptr[rsp+r11+offset]
[254]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 );
[3]160 }
161 else{
162 //mov reg, ptr[rsp+offset]
[254]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 );
[3]166 }
167 }
[40]168 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
[3]169 if(pRelativeVar->bOffsetOffset){
170 //add r11,qword ptr[rsp+offset]
[254]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 );
[3]174 }
175 else{
176 //mov r11,qword ptr[rsp+offset]
[254]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 );
[3]180 }
181
182 goto directmem;
183 }
184 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
185directmem:
186 //mov reg, ptr[r11]
[226]187 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,0,MOD_BASE);
[3]188 }
189}
Note: See TracBrowser for help on using the repository browser.