• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <x86_64/x64_cg.h>
17 #include "x64_cgfunc.h"
18 #include "x64_memlayout.h"
19 #include "x64_isa.h"
20 #include "assembler/operand.h"
21 
22 namespace maplebe {
23 /* null implementation yet */
GenSaveMethodInfoCode(BB & bb)24 void X64CGFunc::GenSaveMethodInfoCode(BB &bb)
25 {
26     CHECK_FATAL(false, "NIY");
27 }
GenerateCleanupCode(BB & bb)28 void X64CGFunc::GenerateCleanupCode(BB &bb)
29 {
30     CHECK_FATAL(false, "NIY");
31 }
NeedCleanup()32 bool X64CGFunc::NeedCleanup()
33 {
34     CHECK_FATAL(false, "NIY");
35     return false;
36 }
GenerateCleanupCodeForExtEpilog(BB & bb)37 void X64CGFunc::GenerateCleanupCodeForExtEpilog(BB &bb)
38 {
39     CHECK_FATAL(false, "NIY");
40 }
FloatParamRegRequired(MIRStructType * structType,uint32 & fpSize)41 uint32 X64CGFunc::FloatParamRegRequired(MIRStructType *structType, uint32 &fpSize)
42 {
43     CHECK_FATAL(false, "NIY");
44     return 0;
45 }
AssignLmbcFormalParams()46 void X64CGFunc::AssignLmbcFormalParams()
47 {
48     CHECK_FATAL(false, "NIY");
49 }
LmbcGenSaveSpForAlloca()50 void X64CGFunc::LmbcGenSaveSpForAlloca()
51 {
52     CHECK_FATAL(false, "NIY");
53 }
MergeReturn()54 void X64CGFunc::MergeReturn()
55 {
56     CHECK_FATAL(false, "NIY");
57 }
HandleRCCall(bool begin,const MIRSymbol * retRef)58 void X64CGFunc::HandleRCCall(bool begin, const MIRSymbol *retRef)
59 {
60     CHECK_FATAL(false, "NIY");
61 }
HandleRetCleanup(NaryStmtNode & retNode)62 void X64CGFunc::HandleRetCleanup(NaryStmtNode &retNode)
63 {
64     CHECK_FATAL(false, "NIY");
65 }
SelectDassign(DassignNode & stmt,Operand & opnd0)66 void X64CGFunc::SelectDassign(DassignNode &stmt, Operand &opnd0)
67 {
68     CHECK_FATAL(false, "NIY");
69 }
SelectDassignoff(DassignoffNode & stmt,Operand & opnd0)70 void X64CGFunc::SelectDassignoff(DassignoffNode &stmt, Operand &opnd0)
71 {
72     CHECK_FATAL(false, "NIY");
73 }
SelectRegassign(RegassignNode & stmt,Operand & opnd0)74 void X64CGFunc::SelectRegassign(RegassignNode &stmt, Operand &opnd0)
75 {
76     CHECK_FATAL(false, "NIY");
77 }
SelectAbort()78 void X64CGFunc::SelectAbort()
79 {
80     CHECK_FATAL(false, "NIY");
81 }
SelectAssertNull(UnaryStmtNode & stmt)82 void X64CGFunc::SelectAssertNull(UnaryStmtNode &stmt)
83 {
84     CHECK_FATAL(false, "NIY");
85 }
SelectAsm(AsmNode & node)86 void X64CGFunc::SelectAsm(AsmNode &node)
87 {
88     CHECK_FATAL(false, "NIY");
89 }
SelectAggDassign(DassignNode & stmt)90 void X64CGFunc::SelectAggDassign(DassignNode &stmt)
91 {
92     CHECK_FATAL(false, "NIY");
93 }
SelectIassign(IassignNode & stmt)94 void X64CGFunc::SelectIassign(IassignNode &stmt)
95 {
96     CHECK_FATAL(false, "NIY");
97 }
SelectIassignoff(IassignoffNode & stmt)98 void X64CGFunc::SelectIassignoff(IassignoffNode &stmt)
99 {
100     CHECK_FATAL(false, "NIY");
101 }
SelectIassignfpoff(IassignFPoffNode & stmt,Operand & opnd)102 void X64CGFunc::SelectIassignfpoff(IassignFPoffNode &stmt, Operand &opnd)
103 {
104     CHECK_FATAL(false, "NIY");
105 }
SelectIassignspoff(PrimType pTy,int32 offset,Operand & opnd)106 void X64CGFunc::SelectIassignspoff(PrimType pTy, int32 offset, Operand &opnd)
107 {
108     CHECK_FATAL(false, "NIY");
109 }
SelectBlkassignoff(BlkassignoffNode & bNode,Operand * src)110 void X64CGFunc::SelectBlkassignoff(BlkassignoffNode &bNode, Operand *src)
111 {
112     CHECK_FATAL(false, "NIY");
113 }
SelectAggIassign(IassignNode & stmt,Operand & lhsAddrOpnd)114 void X64CGFunc::SelectAggIassign(IassignNode &stmt, Operand &lhsAddrOpnd)
115 {
116     CHECK_FATAL(false, "NIY");
117 }
SelectReturnSendOfStructInRegs(BaseNode * x)118 void X64CGFunc::SelectReturnSendOfStructInRegs(BaseNode *x)
119 {
120     CHECK_FATAL(false, "NIY");
121 }
SelectReturn(Operand * opnd)122 void X64CGFunc::SelectReturn(Operand *opnd)
123 {
124     CHECK_FATAL(false, "NIY");
125 }
SelectIgoto(Operand * opnd0)126 void X64CGFunc::SelectIgoto(Operand *opnd0)
127 {
128     CHECK_FATAL(false, "NIY");
129 }
SelectCondGoto(CondGotoNode & stmt,Operand & opnd0,Operand & opnd1)130 void X64CGFunc::SelectCondGoto(CondGotoNode &stmt, Operand &opnd0, Operand &opnd1)
131 {
132     CHECK_FATAL(false, "NIY");
133 }
SelectCondSpecialCase1(CondGotoNode & stmt,BaseNode & opnd0)134 void X64CGFunc::SelectCondSpecialCase1(CondGotoNode &stmt, BaseNode &opnd0)
135 {
136     CHECK_FATAL(false, "NIY");
137 }
SelectCondSpecialCase2(const CondGotoNode & stmt,BaseNode & opnd0)138 void X64CGFunc::SelectCondSpecialCase2(const CondGotoNode &stmt, BaseNode &opnd0)
139 {
140     CHECK_FATAL(false, "NIY");
141 }
SelectGoto(GotoNode & stmt)142 void X64CGFunc::SelectGoto(GotoNode &stmt)
143 {
144     CHECK_FATAL(false, "NIY");
145 }
SelectCall(CallNode & callNode)146 void X64CGFunc::SelectCall(CallNode &callNode)
147 {
148     CHECK_FATAL(false, "NIY");
149 }
SelectIcall(IcallNode & icallNode)150 void X64CGFunc::SelectIcall(IcallNode &icallNode)
151 {
152     CHECK_FATAL(false, "NIY");
153 }
SelectIntrinsicCall(IntrinsiccallNode & intrinsiccallNode)154 void X64CGFunc::SelectIntrinsicCall(IntrinsiccallNode &intrinsiccallNode)
155 {
156     CHECK_FATAL(false, "NIY");
157 }
SelectIntrinsicOpWithOneParam(IntrinsicopNode & intrinopNode,std::string name)158 Operand *X64CGFunc::SelectIntrinsicOpWithOneParam(IntrinsicopNode &intrinopNode, std::string name)
159 {
160     CHECK_FATAL(false, "NIY");
161     return nullptr;
162 }
SelectCclz(IntrinsicopNode & intrinopNode)163 Operand *X64CGFunc::SelectCclz(IntrinsicopNode &intrinopNode)
164 {
165     CHECK_FATAL(false, "NIY");
166     return nullptr;
167 }
SelectCctz(IntrinsicopNode & intrinopNode)168 Operand *X64CGFunc::SelectCctz(IntrinsicopNode &intrinopNode)
169 {
170     CHECK_FATAL(false, "NIY");
171     return nullptr;
172 }
SelectCpopcount(IntrinsicopNode & intrinopNode)173 Operand *X64CGFunc::SelectCpopcount(IntrinsicopNode &intrinopNode)
174 {
175     CHECK_FATAL(false, "NIY");
176     return nullptr;
177 }
SelectCparity(IntrinsicopNode & intrinopNode)178 Operand *X64CGFunc::SelectCparity(IntrinsicopNode &intrinopNode)
179 {
180     CHECK_FATAL(false, "NIY");
181     return nullptr;
182 }
SelectCclrsb(IntrinsicopNode & intrinopNode)183 Operand *X64CGFunc::SelectCclrsb(IntrinsicopNode &intrinopNode)
184 {
185     CHECK_FATAL(false, "NIY");
186     return nullptr;
187 }
SelectCisaligned(IntrinsicopNode & intrinopNode)188 Operand *X64CGFunc::SelectCisaligned(IntrinsicopNode &intrinopNode)
189 {
190     CHECK_FATAL(false, "NIY");
191     return nullptr;
192 }
SelectCalignup(IntrinsicopNode & intrinopNode)193 Operand *X64CGFunc::SelectCalignup(IntrinsicopNode &intrinopNode)
194 {
195     CHECK_FATAL(false, "NIY");
196     return nullptr;
197 }
SelectCaligndown(IntrinsicopNode & intrinopNode)198 Operand *X64CGFunc::SelectCaligndown(IntrinsicopNode &intrinopNode)
199 {
200     CHECK_FATAL(false, "NIY");
201     return nullptr;
202 }
SelectCSyncBoolCmpSwap(IntrinsicopNode & intrinopNode)203 Operand *X64CGFunc::SelectCSyncBoolCmpSwap(IntrinsicopNode &intrinopNode)
204 {
205     CHECK_FATAL(false, "NIY");
206     return nullptr;
207 }
SelectCSyncValCmpSwap(IntrinsicopNode & intrinopNode)208 Operand *X64CGFunc::SelectCSyncValCmpSwap(IntrinsicopNode &intrinopNode)
209 {
210     CHECK_FATAL(false, "NIY");
211     return nullptr;
212 }
SelectCSyncLockTestSet(IntrinsicopNode & intrinopNode,PrimType pty)213 Operand *X64CGFunc::SelectCSyncLockTestSet(IntrinsicopNode &intrinopNode, PrimType pty)
214 {
215     CHECK_FATAL(false, "NIY");
216     return nullptr;
217 }
SelectBswap(IntrinsicopNode & node,Operand & opnd0,const BaseNode & parent)218 Operand *X64CGFunc::SelectBswap(IntrinsicopNode &node, Operand &opnd0, const BaseNode &parent)
219 {
220     CHECK_FATAL(false, "NIY");
221     return nullptr;
222 }
SelectCSyncFetch(IntrinsicopNode & intrinsicopNode,Opcode op,bool fetchBefore)223 Operand *X64CGFunc::SelectCSyncFetch(IntrinsicopNode &intrinsicopNode, Opcode op, bool fetchBefore)
224 {
225     CHECK_FATAL(false, "NIY");
226     return nullptr;
227 }
SelectCSyncSynchronize(IntrinsicopNode & intrinsicopNode)228 Operand *X64CGFunc::SelectCSyncSynchronize(IntrinsicopNode &intrinsicopNode)
229 {
230     CHECK_FATAL(false, "NIY");
231     return nullptr;
232 }
SelectCAtomicLoadN(IntrinsicopNode & intrinsicopNode)233 Operand *X64CGFunc::SelectCAtomicLoadN(IntrinsicopNode &intrinsicopNode)
234 {
235     CHECK_FATAL(false, "NIY");
236     return nullptr;
237 }
SelectCAtomicExchangeN(const IntrinsiccallNode & intrinsicopNode)238 Operand *X64CGFunc::SelectCAtomicExchangeN(const IntrinsiccallNode &intrinsicopNode)
239 {
240     CHECK_FATAL(false, "NIY");
241     return nullptr;
242 }
SelectCReturnAddress(IntrinsicopNode & intrinopNode)243 Operand *X64CGFunc::SelectCReturnAddress(IntrinsicopNode &intrinopNode)
244 {
245     CHECK_FATAL(false, "NIY");
246     return nullptr;
247 }
SelectMembar(StmtNode & membar)248 void X64CGFunc::SelectMembar(StmtNode &membar)
249 {
250     CHECK_FATAL(false, "NIY");
251 }
SelectComment(CommentNode & comment)252 void X64CGFunc::SelectComment(CommentNode &comment)
253 {
254     CHECK_FATAL(false, "NIY");
255 }
HandleCatch()256 void X64CGFunc::HandleCatch()
257 {
258     CHECK_FATAL(false, "NIY");
259 }
SelectDread(const BaseNode & parent,AddrofNode & expr)260 Operand *X64CGFunc::SelectDread(const BaseNode &parent, AddrofNode &expr)
261 {
262     CHECK_FATAL(false, "NIY");
263     return nullptr;
264 }
SelectRegread(RegreadNode & expr)265 RegOperand *X64CGFunc::SelectRegread(RegreadNode &expr)
266 {
267     CHECK_FATAL(false, "NIY");
268     return nullptr;
269 }
SelectAddrof(AddrofNode & expr,const BaseNode & parent,bool isAddrofoff)270 Operand *X64CGFunc::SelectAddrof(AddrofNode &expr, const BaseNode &parent, bool isAddrofoff)
271 {
272     CHECK_FATAL(false, "NIY");
273     return nullptr;
274 }
SelectAddrofoff(AddrofoffNode & expr,const BaseNode & parent)275 Operand *X64CGFunc::SelectAddrofoff(AddrofoffNode &expr, const BaseNode &parent)
276 {
277     CHECK_FATAL(false, "NIY");
278     return nullptr;
279 }
280 
SelectAddrofFunc(AddroffuncNode & expr,const BaseNode & parent)281 Operand &X64CGFunc::SelectAddrofFunc(AddroffuncNode &expr, const BaseNode &parent)
282 {
283     CHECK_FATAL(false, "NIY");
284     Operand *a;
285     return *a;
286 }
SelectAddrofLabel(AddroflabelNode & expr,const BaseNode & parent)287 Operand &X64CGFunc::SelectAddrofLabel(AddroflabelNode &expr, const BaseNode &parent)
288 {
289     CHECK_FATAL(false, "NIY");
290     Operand *a;
291     return *a;
292 }
SelectIread(const BaseNode & parent,IreadNode & expr,int extraOffset,PrimType finalBitFieldDestType)293 Operand *X64CGFunc::SelectIread(const BaseNode &parent, IreadNode &expr, int extraOffset,
294                                 PrimType finalBitFieldDestType)
295 {
296     CHECK_FATAL(false, "NIY");
297     return nullptr;
298 }
SelectIreadoff(const BaseNode & parent,IreadoffNode & ireadoff)299 Operand *X64CGFunc::SelectIreadoff(const BaseNode &parent, IreadoffNode &ireadoff)
300 {
301     CHECK_FATAL(false, "NIY");
302     return nullptr;
303 }
SelectIreadfpoff(const BaseNode & parent,IreadFPoffNode & ireadoff)304 Operand *X64CGFunc::SelectIreadfpoff(const BaseNode &parent, IreadFPoffNode &ireadoff)
305 {
306     CHECK_FATAL(false, "NIY");
307     return nullptr;
308 }
SelectIntConst(const MIRIntConst & intConst,const BaseNode & parent)309 Operand *X64CGFunc::SelectIntConst(const MIRIntConst &intConst, const BaseNode &parent)
310 {
311     CHECK_FATAL(false, "NIY");
312     return nullptr;
313 }
SelectFloatConst(MIRFloatConst & floatConst,const BaseNode & parent)314 Operand *X64CGFunc::SelectFloatConst(MIRFloatConst &floatConst, const BaseNode &parent)
315 {
316     CHECK_FATAL(false, "NIY");
317     return nullptr;
318 }
SelectDoubleConst(MIRDoubleConst & doubleConst,const BaseNode & parent)319 Operand *X64CGFunc::SelectDoubleConst(MIRDoubleConst &doubleConst, const BaseNode &parent)
320 {
321     CHECK_FATAL(false, "NIY");
322     return nullptr;
323 }
SelectStrConst(MIRStrConst & strConst)324 Operand *X64CGFunc::SelectStrConst(MIRStrConst &strConst)
325 {
326     CHECK_FATAL(false, "NIY");
327     return nullptr;
328 }
SelectStr16Const(MIRStr16Const & strConst)329 Operand *X64CGFunc::SelectStr16Const(MIRStr16Const &strConst)
330 {
331     CHECK_FATAL(false, "NIY");
332     return nullptr;
333 }
SelectAdd(Operand & resOpnd,Operand & opnd0,Operand & opnd1,PrimType primType)334 void X64CGFunc::SelectAdd(Operand &resOpnd, Operand &opnd0, Operand &opnd1, PrimType primType)
335 {
336     CHECK_FATAL(false, "NIY");
337 }
SelectAdd(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)338 Operand *X64CGFunc::SelectAdd(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
339 {
340     CHECK_FATAL(false, "NIY");
341     return nullptr;
342 }
SelectMadd(Operand & resOpnd,Operand & opndM0,Operand & opndM1,Operand & opnd1,PrimType primType)343 void X64CGFunc::SelectMadd(Operand &resOpnd, Operand &opndM0, Operand &opndM1, Operand &opnd1, PrimType primType)
344 {
345     CHECK_FATAL(false, "NIY");
346 }
SelectMadd(BinaryNode & node,Operand & opndM0,Operand & opndM1,Operand & opnd1,const BaseNode & parent)347 Operand *X64CGFunc::SelectMadd(BinaryNode &node, Operand &opndM0, Operand &opndM1, Operand &opnd1,
348                                const BaseNode &parent)
349 {
350     CHECK_FATAL(false, "NIY");
351     return nullptr;
352 }
SelectRor(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)353 Operand *X64CGFunc::SelectRor(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
354 {
355     CHECK_FATAL(false, "NIY");
356     return nullptr;
357 }
SelectCGArrayElemAdd(BinaryNode & node,const BaseNode & parent)358 Operand &X64CGFunc::SelectCGArrayElemAdd(BinaryNode &node, const BaseNode &parent)
359 {
360     CHECK_FATAL(false, "NIY");
361     Operand *a;
362     return *a;
363 }
SelectShift(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)364 Operand *X64CGFunc::SelectShift(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
365 {
366     CHECK_FATAL(false, "NIY");
367     return nullptr;
368 }
SelectMpy(Operand & resOpnd,Operand & opnd0,Operand & opnd1,PrimType primType)369 void X64CGFunc::SelectMpy(Operand &resOpnd, Operand &opnd0, Operand &opnd1, PrimType primType)
370 {
371     CHECK_FATAL(false, "NIY");
372 }
SelectMpy(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)373 Operand *X64CGFunc::SelectMpy(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
374 {
375     CHECK_FATAL(false, "NIY");
376     return nullptr;
377 }
SelectRem(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)378 Operand *X64CGFunc::SelectRem(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
379 {
380     CHECK_FATAL(false, "NIY");
381     return nullptr;
382 }
SelectDiv(Operand & resOpnd,Operand & opnd0,Operand & opnd1,PrimType primType)383 void X64CGFunc::SelectDiv(Operand &resOpnd, Operand &opnd0, Operand &opnd1, PrimType primType)
384 {
385     CHECK_FATAL(false, "NIY");
386 }
SelectDiv(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)387 Operand *X64CGFunc::SelectDiv(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
388 {
389     CHECK_FATAL(false, "NIY");
390     return nullptr;
391 }
SelectSub(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)392 Operand *X64CGFunc::SelectSub(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
393 {
394     CHECK_FATAL(false, "NIY");
395     return nullptr;
396 }
SelectSub(Operand & resOpnd,Operand & opnd0,Operand & opnd1,PrimType primType)397 void X64CGFunc::SelectSub(Operand &resOpnd, Operand &opnd0, Operand &opnd1, PrimType primType)
398 {
399     CHECK_FATAL(false, "NIY");
400 }
SelectBand(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)401 Operand *X64CGFunc::SelectBand(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
402 {
403     CHECK_FATAL(false, "NIY");
404     return nullptr;
405 }
SelectBand(Operand & resOpnd,Operand & opnd0,Operand & opnd1,PrimType primType)406 void X64CGFunc::SelectBand(Operand &resOpnd, Operand &opnd0, Operand &opnd1, PrimType primType)
407 {
408     CHECK_FATAL(false, "NIY");
409 }
SelectLand(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)410 Operand *X64CGFunc::SelectLand(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
411 {
412     CHECK_FATAL(false, "NIY");
413     return nullptr;
414 }
SelectLor(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent,bool parentIsBr)415 Operand *X64CGFunc::SelectLor(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent, bool parentIsBr)
416 {
417     CHECK_FATAL(false, "NIY");
418     return nullptr;
419 }
SelectMin(Operand & resOpnd,Operand & opnd0,Operand & opnd1,PrimType primType)420 void X64CGFunc::SelectMin(Operand &resOpnd, Operand &opnd0, Operand &opnd1, PrimType primType)
421 {
422     CHECK_FATAL(false, "NIY");
423 }
SelectMin(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)424 Operand *X64CGFunc::SelectMin(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
425 {
426     CHECK_FATAL(false, "NIY");
427     return nullptr;
428 }
SelectMax(Operand & resOpnd,Operand & opnd0,Operand & opnd1,PrimType primType)429 void X64CGFunc::SelectMax(Operand &resOpnd, Operand &opnd0, Operand &opnd1, PrimType primType)
430 {
431     CHECK_FATAL(false, "NIY");
432 }
SelectMax(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)433 Operand *X64CGFunc::SelectMax(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
434 {
435     CHECK_FATAL(false, "NIY");
436     return nullptr;
437 }
SelectCmpOp(CompareNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)438 Operand *X64CGFunc::SelectCmpOp(CompareNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
439 {
440     CHECK_FATAL(false, "NIY");
441     return nullptr;
442 }
SelectBior(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)443 Operand *X64CGFunc::SelectBior(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
444 {
445     CHECK_FATAL(false, "NIY");
446     return nullptr;
447 }
SelectBior(Operand & resOpnd,Operand & opnd0,Operand & opnd1,PrimType primType)448 void X64CGFunc::SelectBior(Operand &resOpnd, Operand &opnd0, Operand &opnd1, PrimType primType)
449 {
450     CHECK_FATAL(false, "NIY");
451 }
SelectBxor(BinaryNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)452 Operand *X64CGFunc::SelectBxor(BinaryNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
453 {
454     CHECK_FATAL(false, "NIY");
455     return nullptr;
456 }
SelectBxor(Operand & resOpnd,Operand & opnd0,Operand & opnd1,PrimType primType)457 void X64CGFunc::SelectBxor(Operand &resOpnd, Operand &opnd0, Operand &opnd1, PrimType primType)
458 {
459     CHECK_FATAL(false, "NIY");
460 }
SelectAbs(UnaryNode & node,Operand & opnd0)461 Operand *X64CGFunc::SelectAbs(UnaryNode &node, Operand &opnd0)
462 {
463     CHECK_FATAL(false, "NIY");
464     return nullptr;
465 }
SelectBnot(UnaryNode & node,Operand & opnd0,const BaseNode & parent)466 Operand *X64CGFunc::SelectBnot(UnaryNode &node, Operand &opnd0, const BaseNode &parent)
467 {
468     CHECK_FATAL(false, "NIY");
469     return nullptr;
470 }
SelectExtractbits(ExtractbitsNode & node,Operand & opnd0,const BaseNode & parent)471 Operand *X64CGFunc::SelectExtractbits(ExtractbitsNode &node, Operand &opnd0, const BaseNode &parent)
472 {
473     CHECK_FATAL(false, "NIY");
474     return nullptr;
475 }
SelectDepositBits(DepositbitsNode & node,Operand & opnd0,Operand & opnd1,const BaseNode & parent)476 Operand *X64CGFunc::SelectDepositBits(DepositbitsNode &node, Operand &opnd0, Operand &opnd1, const BaseNode &parent)
477 {
478     CHECK_FATAL(false, "NIY");
479     return nullptr;
480 }
SelectRegularBitFieldLoad(ExtractbitsNode & node,const BaseNode & parent)481 Operand *X64CGFunc::SelectRegularBitFieldLoad(ExtractbitsNode &node, const BaseNode &parent)
482 {
483     CHECK_FATAL(false, "NIY");
484     return nullptr;
485 }
SelectLnot(UnaryNode & node,Operand & opnd0,const BaseNode & parent)486 Operand *X64CGFunc::SelectLnot(UnaryNode &node, Operand &opnd0, const BaseNode &parent)
487 {
488     CHECK_FATAL(false, "NIY");
489     return nullptr;
490 }
SelectNeg(UnaryNode & node,Operand & opnd0,const BaseNode & parent)491 Operand *X64CGFunc::SelectNeg(UnaryNode &node, Operand &opnd0, const BaseNode &parent)
492 {
493     CHECK_FATAL(false, "NIY");
494     return nullptr;
495 }
SelectRecip(UnaryNode & node,Operand & opnd0,const BaseNode & parent)496 Operand *X64CGFunc::SelectRecip(UnaryNode &node, Operand &opnd0, const BaseNode &parent)
497 {
498     CHECK_FATAL(false, "NIY");
499     return nullptr;
500 }
SelectSqrt(UnaryNode & node,Operand & opnd0,const BaseNode & parent)501 Operand *X64CGFunc::SelectSqrt(UnaryNode &node, Operand &opnd0, const BaseNode &parent)
502 {
503     CHECK_FATAL(false, "NIY");
504     return nullptr;
505 }
SelectCeil(TypeCvtNode & node,Operand & opnd0,const BaseNode & parent)506 Operand *X64CGFunc::SelectCeil(TypeCvtNode &node, Operand &opnd0, const BaseNode &parent)
507 {
508     CHECK_FATAL(false, "NIY");
509     return nullptr;
510 }
SelectFloor(TypeCvtNode & node,Operand & opnd0,const BaseNode & parent)511 Operand *X64CGFunc::SelectFloor(TypeCvtNode &node, Operand &opnd0, const BaseNode &parent)
512 {
513     CHECK_FATAL(false, "NIY");
514     return nullptr;
515 }
SelectRetype(TypeCvtNode & node,Operand & opnd0)516 Operand *X64CGFunc::SelectRetype(TypeCvtNode &node, Operand &opnd0)
517 {
518     CHECK_FATAL(false, "NIY");
519     return nullptr;
520 }
SelectRound(TypeCvtNode & node,Operand & opnd0,const BaseNode & parent)521 Operand *X64CGFunc::SelectRound(TypeCvtNode &node, Operand &opnd0, const BaseNode &parent)
522 {
523     CHECK_FATAL(false, "NIY");
524     return nullptr;
525 }
SelectCvt(const BaseNode & parent,TypeCvtNode & node,Operand & opnd0)526 Operand *X64CGFunc::SelectCvt(const BaseNode &parent, TypeCvtNode &node, Operand &opnd0)
527 {
528     CHECK_FATAL(false, "NIY");
529     return nullptr;
530 }
SelectTrunc(TypeCvtNode & node,Operand & opnd0,const BaseNode & parent)531 Operand *X64CGFunc::SelectTrunc(TypeCvtNode &node, Operand &opnd0, const BaseNode &parent)
532 {
533     CHECK_FATAL(false, "NIY");
534     return nullptr;
535 }
SelectSelect(TernaryNode & node,Operand & cond,Operand & opnd0,Operand & opnd1,const BaseNode & parent,bool hasCompare)536 Operand *X64CGFunc::SelectSelect(TernaryNode &node, Operand &cond, Operand &opnd0, Operand &opnd1,
537                                  const BaseNode &parent, bool hasCompare)
538 {
539     CHECK_FATAL(false, "NIY");
540     return nullptr;
541 }
SelectMalloc(UnaryNode & call,Operand & opnd0)542 Operand *X64CGFunc::SelectMalloc(UnaryNode &call, Operand &opnd0)
543 {
544     CHECK_FATAL(false, "NIY");
545     return nullptr;
546 }
SelectCopy(Operand & src,PrimType srcType,PrimType dstType)547 RegOperand &X64CGFunc::SelectCopy(Operand &src, PrimType srcType, PrimType dstType)
548 {
549     CHECK_FATAL(false, "NIY");
550     RegOperand *a;
551     return *a;
552 }
SelectAlloca(UnaryNode & call,Operand & opnd0)553 Operand *X64CGFunc::SelectAlloca(UnaryNode &call, Operand &opnd0)
554 {
555     CHECK_FATAL(false, "NIY");
556     return nullptr;
557 }
SelectGCMalloc(GCMallocNode & call)558 Operand *X64CGFunc::SelectGCMalloc(GCMallocNode &call)
559 {
560     CHECK_FATAL(false, "NIY");
561     return nullptr;
562 }
SelectJarrayMalloc(JarrayMallocNode & call,Operand & opnd0)563 Operand *X64CGFunc::SelectJarrayMalloc(JarrayMallocNode &call, Operand &opnd0)
564 {
565     CHECK_FATAL(false, "NIY");
566     return nullptr;
567 }
SelectRangeGoto(RangeGotoNode & rangeGotoNode,Operand & opnd0)568 void X64CGFunc::SelectRangeGoto(RangeGotoNode &rangeGotoNode, Operand &opnd0)
569 {
570     CHECK_FATAL(false, "NIY");
571 }
SelectLazyLoad(Operand & opnd0,PrimType primType)572 Operand *X64CGFunc::SelectLazyLoad(Operand &opnd0, PrimType primType)
573 {
574     CHECK_FATAL(false, "NIY");
575     return nullptr;
576 }
SelectLazyLoadStatic(MIRSymbol & st,int64 offset,PrimType primType)577 Operand *X64CGFunc::SelectLazyLoadStatic(MIRSymbol &st, int64 offset, PrimType primType)
578 {
579     CHECK_FATAL(false, "NIY");
580     return nullptr;
581 }
SelectLoadArrayClassCache(MIRSymbol & st,int64 offset,PrimType primType)582 Operand *X64CGFunc::SelectLoadArrayClassCache(MIRSymbol &st, int64 offset, PrimType primType)
583 {
584     CHECK_FATAL(false, "NIY");
585     return nullptr;
586 }
GenerateYieldpoint(BB & bb)587 void X64CGFunc::GenerateYieldpoint(BB &bb)
588 {
589     CHECK_FATAL(false, "NIY");
590 }
GetOrCreateRflag()591 Operand &X64CGFunc::GetOrCreateRflag()
592 {
593     CHECK_FATAL(false, "NIY");
594     Operand *a;
595     return *a;
596 }
GetRflag() const597 const Operand *X64CGFunc::GetRflag() const
598 {
599     CHECK_FATAL(false, "NIY");
600     return nullptr;
601 }
GetFloatRflag() const602 const Operand *X64CGFunc::GetFloatRflag() const
603 {
604     CHECK_FATAL(false, "NIY");
605     return nullptr;
606 }
GetLabelOperand(LabelIdx labIdx) const607 const LabelOperand *X64CGFunc::GetLabelOperand(LabelIdx labIdx) const
608 {
609     CHECK_FATAL(false, "NIY");
610     return nullptr;
611 }
GetOrCreateLabelOperand(LabelIdx labIdx)612 LabelOperand &X64CGFunc::GetOrCreateLabelOperand(LabelIdx labIdx)
613 {
614     std::string lableName = ".L." + std::to_string(GetUniqueID()) + "__" + std::to_string(labIdx);
615     return GetOpndBuilder()->CreateLabel(lableName.c_str(), labIdx);
616 }
GetOrCreateLabelOperand(BB & bb)617 LabelOperand &X64CGFunc::GetOrCreateLabelOperand(BB &bb)
618 {
619     CHECK_FATAL(false, "NIY");
620     LabelOperand *a;
621     return *a;
622 }
CreateVirtualRegisterOperand(regno_t vRegNO)623 RegOperand &X64CGFunc::CreateVirtualRegisterOperand(regno_t vRegNO)
624 {
625     CHECK_FATAL(false, "NIY");
626     RegOperand *a;
627     return *a;
628 }
GetOrCreateVirtualRegisterOperand(regno_t vRegNO)629 RegOperand &X64CGFunc::GetOrCreateVirtualRegisterOperand(regno_t vRegNO)
630 {
631     CHECK_FATAL(false, "NIY");
632     RegOperand *a;
633     return *a;
634 }
GetOrCreateVirtualRegisterOperand(RegOperand & regOpnd)635 RegOperand &X64CGFunc::GetOrCreateVirtualRegisterOperand(RegOperand &regOpnd)
636 {
637     CHECK_FATAL(false, "NIY");
638     RegOperand *a;
639     return *a;
640 }
GetOrCreateFramePointerRegOperand()641 RegOperand &X64CGFunc::GetOrCreateFramePointerRegOperand()
642 {
643     CHECK_FATAL(false, "NIY");
644     RegOperand *a;
645     return *a;
646 }
GetOrCreateStackBaseRegOperand()647 RegOperand &X64CGFunc::GetOrCreateStackBaseRegOperand()
648 {
649     return GetOpndBuilder()->CreatePReg(x64::RBP, GetPointerSize() * kBitsPerByte, kRegTyInt);
650 }
GetZeroOpnd(uint32 size)651 RegOperand &X64CGFunc::GetZeroOpnd(uint32 size)
652 {
653     CHECK_FATAL(false, "NIY");
654     RegOperand *a;
655     return *a;
656 }
CreateCfiRegOperand(uint32 reg,uint32 size)657 Operand &X64CGFunc::CreateCfiRegOperand(uint32 reg, uint32 size)
658 {
659     CHECK_FATAL(false, "NIY");
660     Operand *a;
661     return *a;
662 }
GetTargetRetOperand(PrimType primType,int32 sReg)663 Operand &X64CGFunc::GetTargetRetOperand(PrimType primType, int32 sReg)
664 {
665     CHECK_FATAL(false, "NIY");
666     Operand *a;
667     return *a;
668 }
CreateImmOperand(PrimType primType,int64 val)669 Operand &X64CGFunc::CreateImmOperand(PrimType primType, int64 val)
670 {
671     CHECK_FATAL(false, "NIY");
672     Operand *a;
673     return *a;
674 }
ReplaceOpndInInsn(RegOperand & regDest,RegOperand & regSrc,Insn & insn,regno_t regno)675 void X64CGFunc::ReplaceOpndInInsn(RegOperand &regDest, RegOperand &regSrc, Insn &insn, regno_t regno)
676 {
677     CHECK_FATAL(false, "NIY");
678 }
CleanupDeadMov(bool dump)679 void X64CGFunc::CleanupDeadMov(bool dump)
680 {
681     CHECK_FATAL(false, "NIY");
682 }
GetRealCallerSaveRegs(const Insn & insn,std::set<regno_t> & realCallerSave)683 void X64CGFunc::GetRealCallerSaveRegs(const Insn &insn, std::set<regno_t> &realCallerSave)
684 {
685     CHECK_FATAL(false, "NIY");
686 }
IsFrameReg(const RegOperand & opnd) const687 bool X64CGFunc::IsFrameReg(const RegOperand &opnd) const
688 {
689     CHECK_FATAL(false, "NIY");
690     return false;
691 }
SelectVectorAddLong(PrimType rTy,Operand * o1,Operand * o2,PrimType oty,bool isLow)692 RegOperand *X64CGFunc::SelectVectorAddLong(PrimType rTy, Operand *o1, Operand *o2, PrimType oty, bool isLow)
693 {
694     CHECK_FATAL(false, "NIY");
695     return nullptr;
696 }
SelectVectorAddWiden(Operand * o1,PrimType oty1,Operand * o2,PrimType oty2,bool isLow)697 RegOperand *X64CGFunc::SelectVectorAddWiden(Operand *o1, PrimType oty1, Operand *o2, PrimType oty2, bool isLow)
698 {
699     CHECK_FATAL(false, "NIY");
700     return nullptr;
701 }
SelectVectorAbs(PrimType rType,Operand * o1)702 RegOperand *X64CGFunc::SelectVectorAbs(PrimType rType, Operand *o1)
703 {
704     CHECK_FATAL(false, "NIY");
705     return nullptr;
706 }
SelectVectorBinOp(PrimType rType,Operand * o1,PrimType oTyp1,Operand * o2,PrimType oTyp2,Opcode opc)707 RegOperand *X64CGFunc::SelectVectorBinOp(PrimType rType, Operand *o1, PrimType oTyp1, Operand *o2, PrimType oTyp2,
708                                          Opcode opc)
709 {
710     CHECK_FATAL(false, "NIY");
711     return nullptr;
712 }
SelectVectorBitwiseOp(PrimType rType,Operand * o1,PrimType oty1,Operand * o2,PrimType oty2,Opcode opc)713 RegOperand *X64CGFunc::SelectVectorBitwiseOp(PrimType rType, Operand *o1, PrimType oty1, Operand *o2, PrimType oty2,
714                                              Opcode opc)
715 {
716     CHECK_FATAL(false, "NIY");
717     return nullptr;
718 }
SelectVectorCompareZero(Operand * o1,PrimType oty1,Operand * o2,Opcode opc)719 RegOperand *X64CGFunc::SelectVectorCompareZero(Operand *o1, PrimType oty1, Operand *o2, Opcode opc)
720 {
721     CHECK_FATAL(false, "NIY");
722     return nullptr;
723 }
SelectVectorCompare(Operand * o1,PrimType oty1,Operand * o2,PrimType oty2,Opcode opc)724 RegOperand *X64CGFunc::SelectVectorCompare(Operand *o1, PrimType oty1, Operand *o2, PrimType oty2, Opcode opc)
725 {
726     CHECK_FATAL(false, "NIY");
727     return nullptr;
728 }
SelectVectorFromScalar(PrimType pType,Operand * opnd,PrimType sType)729 RegOperand *X64CGFunc::SelectVectorFromScalar(PrimType pType, Operand *opnd, PrimType sType)
730 {
731     CHECK_FATAL(false, "NIY");
732     return nullptr;
733 }
SelectVectorDup(PrimType rType,Operand * src,bool getLow)734 RegOperand *X64CGFunc::SelectVectorDup(PrimType rType, Operand *src, bool getLow)
735 {
736     CHECK_FATAL(false, "NIY");
737     return nullptr;
738 }
SelectVectorGetElement(PrimType rType,Operand * src,PrimType sType,int32 lane)739 RegOperand *X64CGFunc::SelectVectorGetElement(PrimType rType, Operand *src, PrimType sType, int32 lane)
740 {
741     CHECK_FATAL(false, "NIY");
742     return nullptr;
743 }
SelectVectorAbsSubL(PrimType rType,Operand * o1,Operand * o2,PrimType oTy,bool isLow)744 RegOperand *X64CGFunc::SelectVectorAbsSubL(PrimType rType, Operand *o1, Operand *o2, PrimType oTy, bool isLow)
745 {
746     CHECK_FATAL(false, "NIY");
747     return nullptr;
748 }
SelectVectorMadd(Operand * o1,PrimType oTyp1,Operand * o2,PrimType oTyp2,Operand * o3,PrimType oTyp3)749 RegOperand *X64CGFunc::SelectVectorMadd(Operand *o1, PrimType oTyp1, Operand *o2, PrimType oTyp2, Operand *o3,
750                                         PrimType oTyp3)
751 {
752     CHECK_FATAL(false, "NIY");
753     return nullptr;
754 }
SelectVectorMerge(PrimType rTyp,Operand * o1,Operand * o2,int32 iNum)755 RegOperand *X64CGFunc::SelectVectorMerge(PrimType rTyp, Operand *o1, Operand *o2, int32 iNum)
756 {
757     CHECK_FATAL(false, "NIY");
758     return nullptr;
759 }
SelectVectorMull(PrimType rType,Operand * o1,PrimType oTyp1,Operand * o2,PrimType oTyp2,bool isLow)760 RegOperand *X64CGFunc::SelectVectorMull(PrimType rType, Operand *o1, PrimType oTyp1, Operand *o2, PrimType oTyp2,
761                                         bool isLow)
762 {
763     CHECK_FATAL(false, "NIY");
764     return nullptr;
765 }
SelectVectorNarrow(PrimType rType,Operand * o1,PrimType otyp)766 RegOperand *X64CGFunc::SelectVectorNarrow(PrimType rType, Operand *o1, PrimType otyp)
767 {
768     CHECK_FATAL(false, "NIY");
769     return nullptr;
770 }
SelectVectorNarrow2(PrimType rType,Operand * o1,PrimType oty1,Operand * o2,PrimType oty2)771 RegOperand *X64CGFunc::SelectVectorNarrow2(PrimType rType, Operand *o1, PrimType oty1, Operand *o2, PrimType oty2)
772 {
773     CHECK_FATAL(false, "NIY");
774     return nullptr;
775 }
SelectVectorNeg(PrimType rType,Operand * o1)776 RegOperand *X64CGFunc::SelectVectorNeg(PrimType rType, Operand *o1)
777 {
778     CHECK_FATAL(false, "NIY");
779     return nullptr;
780 }
SelectVectorNot(PrimType rType,Operand * o1)781 RegOperand *X64CGFunc::SelectVectorNot(PrimType rType, Operand *o1)
782 {
783     CHECK_FATAL(false, "NIY");
784     return nullptr;
785 }
SelectVectorPairwiseAdalp(Operand * src1,PrimType sty1,Operand * src2,PrimType sty2)786 RegOperand *X64CGFunc::SelectVectorPairwiseAdalp(Operand *src1, PrimType sty1, Operand *src2, PrimType sty2)
787 {
788     CHECK_FATAL(false, "NIY");
789     return nullptr;
790 }
SelectVectorPairwiseAdd(PrimType rType,Operand * src,PrimType sType)791 RegOperand *X64CGFunc::SelectVectorPairwiseAdd(PrimType rType, Operand *src, PrimType sType)
792 {
793     CHECK_FATAL(false, "NIY");
794     return nullptr;
795 }
SelectVectorReverse(PrimType rtype,Operand * src,PrimType stype,uint32 size)796 RegOperand *X64CGFunc::SelectVectorReverse(PrimType rtype, Operand *src, PrimType stype, uint32 size)
797 {
798     CHECK_FATAL(false, "NIY");
799     return nullptr;
800 }
SelectVectorSetElement(Operand * eOp,PrimType eTyp,Operand * vOpd,PrimType vTyp,int32 lane)801 RegOperand *X64CGFunc::SelectVectorSetElement(Operand *eOp, PrimType eTyp, Operand *vOpd, PrimType vTyp, int32 lane)
802 {
803     CHECK_FATAL(false, "NIY");
804     return nullptr;
805 }
SelectVectorShift(PrimType rType,Operand * o1,PrimType oty1,Operand * o2,PrimType oty2,Opcode opc)806 RegOperand *X64CGFunc::SelectVectorShift(PrimType rType, Operand *o1, PrimType oty1, Operand *o2, PrimType oty2,
807                                          Opcode opc)
808 {
809     CHECK_FATAL(false, "NIY");
810     return nullptr;
811 }
SelectVectorShiftImm(PrimType rType,Operand * o1,Operand * imm,int32 sVal,Opcode opc)812 RegOperand *X64CGFunc::SelectVectorShiftImm(PrimType rType, Operand *o1, Operand *imm, int32 sVal, Opcode opc)
813 {
814     CHECK_FATAL(false, "NIY");
815     return nullptr;
816 }
SelectVectorShiftRNarrow(PrimType rType,Operand * o1,PrimType oType,Operand * o2,bool isLow)817 RegOperand *X64CGFunc::SelectVectorShiftRNarrow(PrimType rType, Operand *o1, PrimType oType, Operand *o2, bool isLow)
818 {
819     CHECK_FATAL(false, "NIY");
820     return nullptr;
821 }
SelectVectorSubWiden(PrimType resType,Operand * o1,PrimType otyp1,Operand * o2,PrimType otyp2,bool isLow,bool isWide)822 RegOperand *X64CGFunc::SelectVectorSubWiden(PrimType resType, Operand *o1, PrimType otyp1, Operand *o2, PrimType otyp2,
823                                             bool isLow, bool isWide)
824 {
825     CHECK_FATAL(false, "NIY");
826     return nullptr;
827 }
SelectVectorSum(PrimType rtype,Operand * o1,PrimType oType)828 RegOperand *X64CGFunc::SelectVectorSum(PrimType rtype, Operand *o1, PrimType oType)
829 {
830     CHECK_FATAL(false, "NIY");
831     return nullptr;
832 }
SelectVectorTableLookup(PrimType rType,Operand * o1,Operand * o2)833 RegOperand *X64CGFunc::SelectVectorTableLookup(PrimType rType, Operand *o1, Operand *o2)
834 {
835     CHECK_FATAL(false, "NIY");
836     return nullptr;
837 }
SelectVectorWiden(PrimType rType,Operand * o1,PrimType otyp,bool isLow)838 RegOperand *X64CGFunc::SelectVectorWiden(PrimType rType, Operand *o1, PrimType otyp, bool isLow)
839 {
840     CHECK_FATAL(false, "NIY");
841     return nullptr;
842 }
SelectIntrinsicOpWithNParams(IntrinsicopNode & intrinopNode,PrimType retType,const std::string & name)843 Operand *X64CGFunc::SelectIntrinsicOpWithNParams(IntrinsicopNode &intrinopNode, PrimType retType,
844                                                  const std::string &name)
845 {
846     CHECK_FATAL(false, "NIY");
847     return nullptr;
848 }
ProcessLazyBinding()849 void X64CGFunc::ProcessLazyBinding()
850 {
851     CHECK_FATAL(false, "NIY");
852 }
DBGFixCallFrameLocationOffsets()853 void X64CGFunc::DBGFixCallFrameLocationOffsets()
854 {
855     CHECK_FATAL(false, "NIY");
856 }
GetPseudoRegisterSpillMemoryOperand(PregIdx idx)857 MemOperand *X64CGFunc::GetPseudoRegisterSpillMemoryOperand(PregIdx idx)
858 {
859     CHECK_FATAL(false, "NIY");
860     return nullptr;
861 }
GetBaseOffset(const SymbolAlloc & symbolAlloc)862 int32 X64CGFunc::GetBaseOffset(const SymbolAlloc &symbolAlloc)
863 {
864     const auto *symAlloc = static_cast<const X64SymbolAlloc *>(&symbolAlloc);
865     /* Call Frame layout of X64
866      * Refer to layout in x64_memlayout.h.
867      * Do Not change this unless you know what you do
868      * memlayout like this
869      * rbp position
870      * prologue slots --
871      * ArgsReg          |
872      * Locals           | -- FrameSize
873      * Spill            |
874      * ArgsStk        --
875      */
876     constexpr const int32 sizeofFplr = 2 * kX64IntregBytelen;
877     // baseOffset is the offset of this symbol based on the rbp position.
878     int32 baseOffset = symAlloc->GetOffset();
879     MemSegmentKind sgKind = symAlloc->GetMemSegment()->GetMemSegmentKind();
880     auto *memLayout = static_cast<X64MemLayout *>(this->GetMemlayout());
881     if (sgKind == kMsSpillReg) {
882         /* spill = -(Locals + ArgsReg + baseOffset + ReseverdSlot + kSizeOfPtr) */
883         return -(static_cast<int32>(memLayout->GetSizeOfLocals()) +
884             static_cast<int32>(memLayout->SizeOfArgsRegisterPassed()) + baseOffset +
885             GetFunction().GetFrameReseverdSlot() + static_cast<int32>(GetPointerSize()));
886     } else if (sgKind == kMsLocals) {
887         /* Locals = baseOffset - (ReseverdSlot + Locals + ArgsReg) */
888         return baseOffset - (GetFunction().GetFrameReseverdSlot() + static_cast<int32>(memLayout->GetSizeOfLocals()) +
889             static_cast<int32>(memLayout->SizeOfArgsRegisterPassed()));
890     } else if (sgKind == kMsArgsRegPassed) {
891         /* ArgsReg = baseOffset - ReseverdSlot  - ArgsReg */
892         return baseOffset - static_cast<int32_t>(GetFunction().GetFrameReseverdSlot()) -
893             static_cast<int32_t>(memLayout->SizeOfArgsRegisterPassed());
894     } else if (sgKind == kMsArgsStkPassed) {
895         return baseOffset + sizeofFplr;
896     } else {
897         CHECK_FATAL(false, "sgKind check");
898     }
899     return 0;
900 }
901 
GetBaseReg(const maplebe::SymbolAlloc & symAlloc)902 RegOperand *X64CGFunc::GetBaseReg(const maplebe::SymbolAlloc &symAlloc)
903 {
904     MemSegmentKind sgKind = symAlloc.GetMemSegment()->GetMemSegmentKind();
905     DEBUG_ASSERT(((sgKind == kMsArgsRegPassed) || (sgKind == kMsLocals) || (sgKind == kMsRefLocals) ||
906                   (sgKind == kMsArgsToStkPass) || (sgKind == kMsArgsStkPassed)),
907                  "NIY");
908     if (sgKind == kMsLocals || sgKind == kMsArgsRegPassed || sgKind == kMsArgsStkPassed) {
909         return &GetOpndBuilder()->CreatePReg(x64::RBP, GetPointerSize() * kBitsPerByte, kRegTyInt);
910     } else {
911         CHECK_FATAL(false, "NIY sgKind");
912     }
913     return nullptr;
914 }
915 
FreeSpillRegMem(regno_t vrNum)916 void X64CGFunc::FreeSpillRegMem(regno_t vrNum)
917 {
918     MemOperand *memOpnd = nullptr;
919 
920     auto p = spillRegMemOperands.find(vrNum);
921     if (p != spillRegMemOperands.end()) {
922         memOpnd = p->second;
923     }
924 
925     if ((memOpnd == nullptr) && IsVRegNOForPseudoRegister(vrNum)) {
926         auto pSecond = pRegSpillMemOperands.find(GetPseudoRegIdxFromVirtualRegNO(vrNum));
927         if (pSecond != pRegSpillMemOperands.end()) {
928             memOpnd = pSecond->second;
929         }
930     }
931 
932     if (memOpnd == nullptr) {
933         DEBUG_ASSERT(false, "free spillreg have no mem");
934         return;
935     }
936 
937     uint32 size = memOpnd->GetSize();
938     MapleUnorderedMap<uint32, SpillMemOperandSet *>::iterator iter;
939     if ((iter = reuseSpillLocMem.find(size)) != reuseSpillLocMem.end()) {
940         iter->second->Add(*memOpnd);
941     } else {
942         reuseSpillLocMem[size] = memPool->New<SpillMemOperandSet>(*GetFuncScopeAllocator());
943         reuseSpillLocMem[size]->Add(*memOpnd);
944     }
945 }
946 
GetOrCreatSpillMem(regno_t vrNum,uint32 memSize)947 MemOperand *X64CGFunc::GetOrCreatSpillMem(regno_t vrNum, uint32 memSize)
948 {
949     /* NOTES: must used in RA, not used in other place. */
950     if (IsVRegNOForPseudoRegister(vrNum)) {
951         auto p = pRegSpillMemOperands.find(GetPseudoRegIdxFromVirtualRegNO(vrNum));
952         if (p != pRegSpillMemOperands.end()) {
953             return p->second;
954         }
955     }
956 
957     auto p = spillRegMemOperands.find(vrNum);
958     if (p == spillRegMemOperands.end()) {
959         uint32 memBitSize = k64BitSize;
960         auto it = reuseSpillLocMem.find(memBitSize);
961         if (it != reuseSpillLocMem.end()) {
962             MemOperand *memOpnd = it->second->GetOne();
963             if (memOpnd != nullptr) {
964                 spillRegMemOperands.emplace(std::pair<regno_t, MemOperand *>(vrNum, memOpnd));
965                 return memOpnd;
966             }
967         }
968 
969         RegOperand &baseOpnd = GetOrCreateStackBaseRegOperand();
970         int32 offset = GetOrCreatSpillRegLocation(vrNum, memBitSize / kBitsPerByte);
971         MemOperand *memOpnd = &GetOpndBuilder()->CreateMem(baseOpnd, offset, memBitSize);
972         spillRegMemOperands.emplace(std::pair<regno_t, MemOperand *>(vrNum, memOpnd));
973         return memOpnd;
974     } else {
975         return p->second;
976     }
977 }
978 
Visit(maplebe::RegOperand * v)979 void X64OpndDumpVisitor::Visit(maplebe::RegOperand *v)
980 {
981     DumpOpndPrefix();
982     LogInfo::MapleLogger() << "reg ";
983     DumpRegInfo(*v);
984     DumpSize(*v);
985     DumpReferenceInfo(*v);
986     const OpndDesc *regDesc = GetOpndDesc();
987     LogInfo::MapleLogger() << " [";
988     if (regDesc->IsRegDef()) {
989         LogInfo::MapleLogger() << "DEF ";
990     }
991     if (regDesc->IsRegUse()) {
992         LogInfo::MapleLogger() << "USE ";
993     }
994     LogInfo::MapleLogger() << "]";
995     DumpOpndSuffix();
996 }
997 
Visit(CommentOperand * v)998 void X64OpndDumpVisitor::Visit(CommentOperand *v)
999 {
1000     LogInfo::MapleLogger() << ":#" << v->GetComment();
1001 }
1002 
Visit(maplebe::ImmOperand * v)1003 void X64OpndDumpVisitor::Visit(maplebe::ImmOperand *v)
1004 {
1005     DumpOpndPrefix();
1006     LogInfo::MapleLogger() << "imm ";
1007     LogInfo::MapleLogger() << v->GetValue();
1008     DumpSize(*v);
1009     DumpReferenceInfo(*v);
1010     DumpOpndSuffix();
1011 }
1012 
Visit(maplebe::MemOperand * v)1013 void X64OpndDumpVisitor::Visit(maplebe::MemOperand *v)
1014 {
1015     DumpOpndPrefix();
1016     LogInfo::MapleLogger() << "mem ";
1017     if (v->GetBaseRegister() != nullptr) {
1018         DumpRegInfo(*v->GetBaseRegister());
1019         if (v->GetOffsetOperand() != nullptr) {
1020             LogInfo::MapleLogger() << " + " << v->GetOffsetOperand()->GetValue();
1021         }
1022     }
1023     DumpSize(*v);
1024     DumpReferenceInfo(*v);
1025     DumpOpndSuffix();
1026 }
DumpRegInfo(maplebe::RegOperand & v)1027 void X64OpndDumpVisitor::DumpRegInfo(maplebe::RegOperand &v)
1028 {
1029     if (v.GetRegisterNumber() > baseVirtualRegNO) {
1030         LogInfo::MapleLogger() << "V" << v.GetRegisterNumber();
1031     } else {
1032         uint8 regType = -1;
1033         switch (v.GetSize()) {
1034             case k8BitSize:
1035                 /* use lower 8-bits */
1036                 regType = X64CG::kR8LowList;
1037                 break;
1038             case k16BitSize:
1039                 regType = X64CG::kR16List;
1040                 break;
1041             case k32BitSize:
1042                 regType = X64CG::kR32List;
1043                 break;
1044             case k64BitSize:
1045                 regType = X64CG::kR64List;
1046                 break;
1047             default:
1048                 CHECK_FATAL(false, "unkown reg size");
1049                 break;
1050         }
1051         assembler::Reg reg = assembler::kRegArray[regType][v.GetRegisterNumber()];
1052         LogInfo::MapleLogger() << "%" << assembler::kRegStrMap.at(reg);
1053     }
1054 }
1055 
Visit(maplebe::FuncNameOperand * v)1056 void X64OpndDumpVisitor::Visit(maplebe::FuncNameOperand *v)
1057 {
1058     DumpOpndPrefix();
1059     LogInfo::MapleLogger() << "funcname ";
1060     LogInfo::MapleLogger() << v->GetName();
1061     DumpSize(*v);
1062     DumpReferenceInfo(*v);
1063     DumpOpndSuffix();
1064 }
1065 
Visit(maplebe::ListOperand * v)1066 void X64OpndDumpVisitor::Visit(maplebe::ListOperand *v)
1067 {
1068     DumpOpndPrefix();
1069     LogInfo::MapleLogger() << "list ";
1070 
1071     MapleList<RegOperand *> opndList = v->GetOperands();
1072     for (auto it = opndList.begin(); it != opndList.end();) {
1073         (*it)->Dump();
1074         LogInfo::MapleLogger() << (++it == opndList.end() ? "" : " ,");
1075     }
1076     DumpSize(*v);
1077     DumpOpndSuffix();
1078 }
1079 
Visit(maplebe::LabelOperand * v)1080 void X64OpndDumpVisitor::Visit(maplebe::LabelOperand *v)
1081 {
1082     DumpOpndPrefix();
1083     LogInfo::MapleLogger() << "label ";
1084     LogInfo::MapleLogger() << v->GetLabelIndex();
1085     DumpSize(*v);
1086     DumpOpndSuffix();
1087 }
1088 
Visit(PhiOperand * v)1089 void X64OpndDumpVisitor::Visit(PhiOperand *v)
1090 {
1091     CHECK_FATAL(false, "NIY");
1092 }
1093 
Visit(CondOperand * v)1094 void X64OpndDumpVisitor::Visit(CondOperand *v)
1095 {
1096     CHECK_FATAL(false, "do not use this operand, it will be eliminated soon");
1097 }
Visit(StImmOperand * v)1098 void X64OpndDumpVisitor::Visit(StImmOperand *v)
1099 {
1100     CHECK_FATAL(false, "do not use this operand, it will be eliminated soon");
1101 }
Visit(BitShiftOperand * v)1102 void X64OpndDumpVisitor::Visit(BitShiftOperand *v)
1103 {
1104     CHECK_FATAL(false, "do not use this operand, it will be eliminated soon");
1105 }
Visit(ExtendShiftOperand * v)1106 void X64OpndDumpVisitor::Visit(ExtendShiftOperand *v)
1107 {
1108     CHECK_FATAL(false, "do not use this operand, it will be eliminated soon");
1109 }
1110 }  // namespace maplebe
1111