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

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