source: dev/trunk/ab5.0/abdev/compiler_x64/Compile_Calc_PushVar.cpp

Last change on this file was 829, checked in by イグトランス (egtra), 13 years ago

svn:eol-styleとsvn:mime-type(文字コード指定含む)の設定

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/plain; charset=Shift_JIS
File size: 6.3 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 compiler.errorMessenger.Output(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_DISP32, Schedule::GlobalVar );
76 }
77 }
78 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
79 compiler.errorMessenger.Output(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( const Type &type, RELATIVE_VAR *pRelativeVar,int reg)
128{
129 int varSize = type.GetSize();
130
131 if(pRelativeVar->dwKind==VAR_GLOBAL){
132 if(pRelativeVar->bOffsetOffset){
133 //mov reg, ptr[r11+offset]
134 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::GlobalVar );
135 }
136 else{
137 //mov reg, ptr[offset]
138 compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
139 }
140 }
141 else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
142 if(pRelativeVar->bOffsetOffset){
143 //add r11,qword ptr[offset]
144 compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
145 }
146 else{
147 //mov r11,qword ptr[offset]
148 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
149 }
150
151 goto directmem;
152 }
153 else if(pRelativeVar->dwKind==VAR_LOCAL){
154 if(pRelativeVar->bOffsetOffset){
155 //mov reg, ptr[rsp+r11+offset]
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 );
159 }
160 else{
161 //mov reg, ptr[rsp+offset]
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 );
165 }
166 }
167 else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
168 if(pRelativeVar->bOffsetOffset){
169 //add r11,qword ptr[rsp+offset]
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 );
173 }
174 else{
175 //mov r11,qword ptr[rsp+offset]
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 );
179 }
180
181 goto directmem;
182 }
183 else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
184directmem:
185 //mov reg, ptr[r11]
186 compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,0,MOD_BASE);
187 }
188}
Note: See TracBrowser for help on using the repository browser.