• 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 #ifndef MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_EMITTER_H
17 #define MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_EMITTER_H
18 
19 #include "asm_emit.h"
20 
21 namespace maplebe {
22 using namespace maple;
23 
24 class AArch64AsmEmitter : public AsmEmitter {
25 public:
AArch64AsmEmitter(CG & cg,const std::string & asmFileName)26     AArch64AsmEmitter(CG &cg, const std::string &asmFileName) : AsmEmitter(cg, asmFileName) {}
27     ~AArch64AsmEmitter() = default;
28 
29     void EmitRefToMethodDesc(FuncEmitInfo &funcEmitInfo, Emitter &emitter) override;
30     void EmitRefToMethodInfo(FuncEmitInfo &funcEmitInfo, Emitter &emitter) override;
31     void EmitMethodDesc(FuncEmitInfo &funcEmitInfo, Emitter &emitter) override;
32     void EmitFastLSDA(FuncEmitInfo &funcEmitInfo) override;
33     void EmitFullLSDA(FuncEmitInfo &funcEmitInfo) override;
34     void EmitBBHeaderLabel(FuncEmitInfo &funcEmitInfo, const std::string &name, LabelIdx labIdx) override;
35     void EmitJavaInsnAddr(FuncEmitInfo &funcEmitInfo) override;
36     void RecordRegInfo(FuncEmitInfo &funcEmitInfo) const;
37     void Run(FuncEmitInfo &funcEmitInfo) override;
38 
39 private:
40     /* cfi & dbg need target info ? */
41     void EmitAArch64CfiInsn(Emitter &emitter, const Insn &insn) const;
42     void EmitAArch64DbgInsn(Emitter &emitter, const Insn &insn) const;
43 
44     void EmitAArch64Insn(Emitter &emitter, Insn &insn) const;
45     void EmitClinit(Emitter &emitter, const Insn &insn) const;
46     void EmitAdrpLdr(Emitter &emitter, const Insn &insn) const;
47     void EmitCounter(Emitter &emitter, const Insn &insn) const;
48     void EmitInlineAsm(Emitter &emitter, const Insn &insn) const;
49     void EmitClinitTail(Emitter &emitter, const Insn &insn) const;
50     void EmitLazyLoad(Emitter &emitter, const Insn &insn) const;
51     void EmitAdrpLabel(Emitter &emitter, const Insn &insn) const;
52     void EmitLazyLoadStatic(Emitter &emitter, const Insn &insn) const;
53     void EmitArrayClassCacheLoad(Emitter &emitter, const Insn &insn) const;
54     void EmitGetAndAddInt(Emitter &emitter, const Insn &insn) const;
55     void EmitGetAndSetInt(Emitter &emitter, const Insn &insn) const;
56     void EmitCompareAndSwapInt(Emitter &emitter, const Insn &insn) const;
57     void EmitStringIndexOf(Emitter &emitter, const Insn &insn) const;
58     void EmitLazyBindingRoutine(Emitter &emitter, const Insn &insn) const;
59     void EmitCheckThrowPendingException(Emitter &emitter, Insn &insn) const;
60     void EmitCTlsDescRel(Emitter &emitter, const Insn &insn) const;
61     void EmitCTlsDescCall(Emitter &emitter, const Insn &insn) const;
62     void EmitSyncLockTestSet(Emitter &emitter, const Insn &insn) const;
63 
64     void PrepareVectorOperand(RegOperand *regOpnd, uint32 &compositeOpnds, Insn &insn) const;
65     bool CheckInsnRefField(const Insn &insn, size_t opndIndex) const;
66 };
67 } /* namespace maplebe */
68 
69 #endif /* MAPLEBE_INCLUDE_CG_AARCH64_AARCH64_EMITTER_H */
70