• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* libs/pixelflinger/codeflinger/ARMAssembler.h
2 **
3 ** Copyright 2006, The Android Open Source Project
4 **
5 ** Licensed under the Apache License, Version 2.0 (the "License");
6 ** you may not use this file except in compliance with the License.
7 ** You may obtain a copy of the License at
8 **
9 **     http://www.apache.org/licenses/LICENSE-2.0
10 **
11 ** Unless required by applicable law or agreed to in writing, software
12 ** distributed under the License is distributed on an "AS IS" BASIS,
13 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 ** See the License for the specific language governing permissions and
15 ** limitations under the License.
16 */
17 
18 #ifndef ANDROID_ARMASSEMBLER_H
19 #define ANDROID_ARMASSEMBLER_H
20 
21 #include <stdint.h>
22 #include <sys/types.h>
23 
24 #include "tinyutils/Vector.h"
25 #include "tinyutils/KeyedVector.h"
26 #include "tinyutils/smartpointer.h"
27 
28 #include "tinyutils/smartpointer.h"
29 #include "codeflinger/ARMAssemblerInterface.h"
30 #include "codeflinger/CodeCache.h"
31 
32 namespace android {
33 
34 // ----------------------------------------------------------------------------
35 
36 class ARMAssembler : public ARMAssemblerInterface
37 {
38 public:
39                 ARMAssembler(const sp<Assembly>& assembly);
40     virtual     ~ARMAssembler();
41 
42     uint32_t*   base() const;
43     uint32_t*   pc() const;
44 
45 
46     void        disassemble(const char* name);
47 
48     // ------------------------------------------------------------------------
49     // ARMAssemblerInterface...
50     // ------------------------------------------------------------------------
51 
52     virtual void    reset();
53 
54     virtual int     generate(const char* name);
55 
56     virtual void    prolog();
57     virtual void    epilog(uint32_t touched);
58     virtual void    comment(const char* string);
59 
60     virtual void    dataProcessing(int opcode, int cc, int s,
61                                 int Rd, int Rn,
62                                 uint32_t Op2);
63     virtual void MLA(int cc, int s,
64                 int Rd, int Rm, int Rs, int Rn);
65     virtual void MUL(int cc, int s,
66                 int Rd, int Rm, int Rs);
67     virtual void UMULL(int cc, int s,
68                 int RdLo, int RdHi, int Rm, int Rs);
69     virtual void UMUAL(int cc, int s,
70                 int RdLo, int RdHi, int Rm, int Rs);
71     virtual void SMULL(int cc, int s,
72                 int RdLo, int RdHi, int Rm, int Rs);
73     virtual void SMUAL(int cc, int s,
74                 int RdLo, int RdHi, int Rm, int Rs);
75 
76     virtual void B(int cc, uint32_t* pc);
77     virtual void BL(int cc, uint32_t* pc);
78     virtual void BX(int cc, int Rn);
79     virtual void label(const char* theLabel);
80     virtual void B(int cc, const char* label);
81     virtual void BL(int cc, const char* label);
82 
83     virtual uint32_t* pcForLabel(const char* label);
84 
85     virtual void LDR (int cc, int Rd,
86                 int Rn, uint32_t offset = immed12_pre(0));
87     virtual void LDRB(int cc, int Rd,
88                 int Rn, uint32_t offset = immed12_pre(0));
89     virtual void STR (int cc, int Rd,
90                 int Rn, uint32_t offset = immed12_pre(0));
91     virtual void STRB(int cc, int Rd,
92                 int Rn, uint32_t offset = immed12_pre(0));
93     virtual void LDRH (int cc, int Rd,
94                 int Rn, uint32_t offset = immed8_pre(0));
95     virtual void LDRSB(int cc, int Rd,
96                 int Rn, uint32_t offset = immed8_pre(0));
97     virtual void LDRSH(int cc, int Rd,
98                 int Rn, uint32_t offset = immed8_pre(0));
99     virtual void STRH (int cc, int Rd,
100                 int Rn, uint32_t offset = immed8_pre(0));
101     virtual void LDM(int cc, int dir,
102                 int Rn, int W, uint32_t reg_list);
103     virtual void STM(int cc, int dir,
104                 int Rn, int W, uint32_t reg_list);
105 
106     virtual void SWP(int cc, int Rn, int Rd, int Rm);
107     virtual void SWPB(int cc, int Rn, int Rd, int Rm);
108     virtual void SWI(int cc, uint32_t comment);
109 
110     virtual void PLD(int Rn, uint32_t offset);
111     virtual void CLZ(int cc, int Rd, int Rm);
112     virtual void QADD(int cc, int Rd, int Rm, int Rn);
113     virtual void QDADD(int cc, int Rd, int Rm, int Rn);
114     virtual void QSUB(int cc, int Rd, int Rm, int Rn);
115     virtual void QDSUB(int cc, int Rd, int Rm, int Rn);
116     virtual void SMUL(int cc, int xy,
117                 int Rd, int Rm, int Rs);
118     virtual void SMULW(int cc, int y,
119                 int Rd, int Rm, int Rs);
120     virtual void SMLA(int cc, int xy,
121                 int Rd, int Rm, int Rs, int Rn);
122     virtual void SMLAL(int cc, int xy,
123                 int RdHi, int RdLo, int Rs, int Rm);
124     virtual void SMLAW(int cc, int y,
125                 int Rd, int Rm, int Rs, int Rn);
126     virtual void UXTB16(int cc, int Rd, int Rm, int rotate);
127 
128 private:
129                 ARMAssembler(const ARMAssembler& rhs);
130                 ARMAssembler& operator = (const ARMAssembler& rhs);
131 
132     sp<Assembly>    mAssembly;
133     uint32_t*       mBase;
134     uint32_t*       mPC;
135     uint32_t*       mPrologPC;
136     int64_t         mDuration;
137 #if defined(WITH_LIB_HARDWARE)
138     bool            mQemuTracing;
139 #endif
140 
141     struct branch_target_t {
branch_target_tbranch_target_t142         inline branch_target_t() : label(0), pc(0) { }
branch_target_tbranch_target_t143         inline branch_target_t(const char* l, uint32_t* p)
144             : label(l), pc(p) { }
145         const char* label;
146         uint32_t*   pc;
147     };
148 
149     Vector<branch_target_t>                 mBranchTargets;
150     KeyedVector< const char*, uint32_t* >   mLabels;
151     KeyedVector< uint32_t*, const char* >   mLabelsInverseMapping;
152     KeyedVector< uint32_t*, const char* >   mComments;
153 };
154 
155 }; // namespace android
156 
157 #endif //ANDROID_ARMASSEMBLER_H
158