1 | #include "stdafx.h"
|
---|
2 |
|
---|
3 | #include <Compiler.h>
|
---|
4 |
|
---|
5 | #include "../BasicCompiler_Common/common.h"
|
---|
6 | #include "Opcode.h"
|
---|
7 |
|
---|
8 |
|
---|
9 | void 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 | SetError(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.PutOld(
|
---|
35 | (long)pRelativeVar->offset,
|
---|
36 | Schedule::LocalVar
|
---|
37 | );
|
---|
38 | }
|
---|
39 | else{
|
---|
40 | //movlpd xmm_reg,qword ptr[rsp+offset]
|
---|
41 | compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar );
|
---|
42 | }
|
---|
43 | }
|
---|
44 | else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
|
---|
45 | if(pRelativeVar->bOffsetOffset){
|
---|
46 | //add r11,qword ptr[rsp+offset]
|
---|
47 | compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
|
---|
48 | }
|
---|
49 | else{
|
---|
50 | //mov r11,qword ptr[rsp+offset]
|
---|
51 | compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
|
---|
52 | }
|
---|
53 |
|
---|
54 | goto directmem;
|
---|
55 | }
|
---|
56 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
57 | directmem:
|
---|
58 | //movlpd xmm_reg,qword ptr[r11]
|
---|
59 | compiler.codeGenerator.op_movlpd_RM( xmm_reg, REG_R11, 0, MOD_BASE);
|
---|
60 | }
|
---|
61 | }
|
---|
62 | void 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]
|
---|
66 | compiler.codeGenerator.op_movss_RM( xmm_reg, REG_R11, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::GlobalVar );
|
---|
67 | }
|
---|
68 | else{
|
---|
69 | //movss xmm_reg,dword ptr[offset]
|
---|
70 | compiler.codeGenerator.op_movss_RM( xmm_reg, 0, (long)pRelativeVar->offset, MOD_BASE, Schedule::GlobalVar );
|
---|
71 | }
|
---|
72 | }
|
---|
73 | else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
|
---|
74 | SetError(300,NULL,cp);
|
---|
75 | }
|
---|
76 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
77 | if(pRelativeVar->bOffsetOffset){
|
---|
78 | //movss xmm_reg,dword ptr[rsp+r11+offset]
|
---|
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 | );
|
---|
91 | }
|
---|
92 | else{
|
---|
93 | //movss xmm_reg,dword ptr[rsp+offset]
|
---|
94 | compiler.codeGenerator.op_movss_RM( xmm_reg, REG_RSP, (long)pRelativeVar->offset, MOD_BASE_DISP32, Schedule::LocalVar );
|
---|
95 | }
|
---|
96 | }
|
---|
97 | else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
|
---|
98 | if(pRelativeVar->bOffsetOffset){
|
---|
99 | //add r11,qword ptr[rsp+offset]
|
---|
100 | compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
|
---|
101 | }
|
---|
102 | else{
|
---|
103 | //mov r11,qword ptr[rsp+offset]
|
---|
104 | compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
|
---|
105 | }
|
---|
106 |
|
---|
107 | goto directmem;
|
---|
108 | }
|
---|
109 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
110 | directmem:
|
---|
111 | //movss xmm_reg,dword ptr[r11]
|
---|
112 | compiler.codeGenerator.op_movss_RM( xmm_reg, REG_R11, 0, MOD_BASE);
|
---|
113 | }
|
---|
114 | }
|
---|
115 |
|
---|
116 |
|
---|
117 | void SetReg_WholeVariable(int type,RELATIVE_VAR *pRelativeVar,int reg){
|
---|
118 | int varSize;
|
---|
119 |
|
---|
120 | varSize=GetTypeSize(type,-1);
|
---|
121 |
|
---|
122 | if(pRelativeVar->dwKind==VAR_GLOBAL){
|
---|
123 | if(pRelativeVar->bOffsetOffset){
|
---|
124 | //mov reg, ptr[r11+offset]
|
---|
125 | compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::GlobalVar );
|
---|
126 | }
|
---|
127 | else{
|
---|
128 | //mov reg, ptr[offset]
|
---|
129 | compiler.codeGenerator.op_mov_RM(varSize,reg,0,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
|
---|
130 | }
|
---|
131 | }
|
---|
132 | else if( pRelativeVar->dwKind == VAR_REFGLOBAL ){
|
---|
133 | if(pRelativeVar->bOffsetOffset){
|
---|
134 | //add r11,qword ptr[offset]
|
---|
135 | compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
|
---|
136 | }
|
---|
137 | else{
|
---|
138 | //mov r11,qword ptr[offset]
|
---|
139 | compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_NON,(int)pRelativeVar->offset,MOD_DISP32, Schedule::GlobalVar );
|
---|
140 | }
|
---|
141 |
|
---|
142 | goto directmem;
|
---|
143 | }
|
---|
144 | else if(pRelativeVar->dwKind==VAR_LOCAL){
|
---|
145 | if(pRelativeVar->bOffsetOffset){
|
---|
146 | //mov reg, ptr[rsp+r11+offset]
|
---|
147 | compiler.codeGenerator.op_mov_RM_ex(varSize,reg,REG_RSP,REG_R11,(int)pRelativeVar->offset,USE_OFFSET, Schedule::LocalVar );
|
---|
148 | }
|
---|
149 | else{
|
---|
150 | //mov reg, ptr[rsp+offset]
|
---|
151 | compiler.codeGenerator.op_mov_RM(varSize,reg,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
|
---|
152 | }
|
---|
153 | }
|
---|
154 | else if( pRelativeVar->dwKind == VAR_REFLOCAL ){
|
---|
155 | if(pRelativeVar->bOffsetOffset){
|
---|
156 | //add r11,qword ptr[rsp+offset]
|
---|
157 | compiler.codeGenerator.op_add_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
|
---|
158 | }
|
---|
159 | else{
|
---|
160 | //mov r11,qword ptr[rsp+offset]
|
---|
161 | compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_R11,REG_RSP,(int)pRelativeVar->offset,MOD_BASE_DISP32, Schedule::LocalVar );
|
---|
162 | }
|
---|
163 |
|
---|
164 | goto directmem;
|
---|
165 | }
|
---|
166 | else if(pRelativeVar->dwKind==VAR_DIRECTMEM){
|
---|
167 | directmem:
|
---|
168 | //mov reg, ptr[r11]
|
---|
169 | compiler.codeGenerator.op_mov_RM(varSize,reg,REG_R11,0,MOD_BASE);
|
---|
170 | }
|
---|
171 | }
|
---|