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

Last change on this file since 338 was 321, checked in by dai_9181, 17 years ago

64bitコンパイラでSingle型変数をパラメータ引渡ししようとしたときに強制終了してしまうバグを修正。

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]
[321]75 compiler.codeGenerator.op_movss_RM( xmm_reg, 0, (long)pRelativeVar->offset, MOD_DISP32, 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
[308]127void SetReg_WholeVariable( const Type &type, RELATIVE_VAR *pRelativeVar,int reg)
128{
129 int varSize = type.GetSize();
[3]130
131 if(pRelativeVar->dwKind==VAR_GLOBAL){
132 if(pRelativeVar->bOffsetOffset){
133 //mov reg, ptr[r11+offset]
[228]134 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::GlobalVar );
[3]135 }
136 else{
137 //mov reg, ptr[offset]
[228]138 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
[3]139 }
140 }
[62]141 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
142 if(pRelativeVar->bOffsetOffset){
143 //add r11,qword ptr[offset]
[228]144 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
[62]145 }
146 else{
147 //mov r11,qword ptr[offset]
[228]148 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
[62]149 }
150
151 goto directmem;
152 }
[3]153 else if(pRelativeVar->dwKind==VAR_LOCAL){
154 if(pRelativeVar->bOffsetOffset){
155 //mov reg, ptr[rsp+r11+offset]
[254]156 compiler.codeGenerator.localVarPertialSchedules.push_back(
157 compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET, Schedule::None, true )
158 );
[3]159 }
160 else{
161 //mov reg, ptr[rsp+offset]
[254]162 compiler.codeGenerator.localVarPertialSchedules.push_back(
163 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
164 );
[3]165 }
166 }
[40]167 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
[3]168 if(pRelativeVar->bOffsetOffset){
169 //add r11,qword ptr[rsp+offset]
[254]170 compiler.codeGenerator.localVarPertialSchedules.push_back(
171 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
172 );
[3]173 }
174 else{
175 //mov r11,qword ptr[rsp+offset]
[254]176 compiler.codeGenerator.localVarPertialSchedules.push_back(
177 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::None, true )
178 );
[3]179 }
180
181 goto directmem;
182 }
183 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
184directmem:
185 //mov reg, ptr[r11]
[226]186 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,0,MOD_BASE);
[3]187 }
188}
Note: See TracBrowser for help on using the repository browser.