The Android Open Source Project | 4f6e8d7 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 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 <utils/Vector.h> |
| 25 | #include <utils/KeyedVector.h> |
| 26 | |
| 27 | #include "tinyutils/smartpointer.h" |
| 28 | #include "codeflinger/ARMAssemblerInterface.h" |
| 29 | #include "codeflinger/CodeCache.h" |
| 30 | |
| 31 | namespace android { |
| 32 | |
| 33 | // ---------------------------------------------------------------------------- |
| 34 | |
| 35 | class ARMAssembler : public ARMAssemblerInterface |
| 36 | { |
| 37 | public: |
| 38 | ARMAssembler(const sp<Assembly>& assembly); |
| 39 | virtual ~ARMAssembler(); |
| 40 | |
| 41 | uint32_t* base() const; |
| 42 | uint32_t* pc() const; |
| 43 | |
| 44 | |
| 45 | void disassemble(const char* name); |
| 46 | |
| 47 | // ------------------------------------------------------------------------ |
| 48 | // ARMAssemblerInterface... |
| 49 | // ------------------------------------------------------------------------ |
| 50 | |
| 51 | virtual void reset(); |
| 52 | |
| 53 | virtual int generate(const char* name); |
| 54 | |
| 55 | virtual void prolog(); |
| 56 | virtual void epilog(uint32_t touched); |
| 57 | virtual void comment(const char* string); |
| 58 | |
| 59 | virtual void dataProcessing(int opcode, int cc, int s, |
| 60 | int Rd, int Rn, |
| 61 | uint32_t Op2); |
| 62 | virtual void MLA(int cc, int s, |
| 63 | int Rd, int Rm, int Rs, int Rn); |
| 64 | virtual void MUL(int cc, int s, |
| 65 | int Rd, int Rm, int Rs); |
| 66 | virtual void UMULL(int cc, int s, |
| 67 | int RdLo, int RdHi, int Rm, int Rs); |
| 68 | virtual void UMUAL(int cc, int s, |
| 69 | int RdLo, int RdHi, int Rm, int Rs); |
| 70 | virtual void SMULL(int cc, int s, |
| 71 | int RdLo, int RdHi, int Rm, int Rs); |
| 72 | virtual void SMUAL(int cc, int s, |
| 73 | int RdLo, int RdHi, int Rm, int Rs); |
| 74 | |
| 75 | virtual void B(int cc, uint32_t* pc); |
| 76 | virtual void BL(int cc, uint32_t* pc); |
| 77 | virtual void BX(int cc, int Rn); |
| 78 | virtual void label(const char* theLabel); |
| 79 | virtual void B(int cc, const char* label); |
| 80 | virtual void BL(int cc, const char* label); |
| 81 | |
| 82 | virtual uint32_t* pcForLabel(const char* label); |
| 83 | |
| 84 | virtual void LDR (int cc, int Rd, |
| 85 | int Rn, uint32_t offset = immed12_pre(0)); |
| 86 | virtual void LDRB(int cc, int Rd, |
| 87 | int Rn, uint32_t offset = immed12_pre(0)); |
| 88 | virtual void STR (int cc, int Rd, |
| 89 | int Rn, uint32_t offset = immed12_pre(0)); |
| 90 | virtual void STRB(int cc, int Rd, |
| 91 | int Rn, uint32_t offset = immed12_pre(0)); |
| 92 | virtual void LDRH (int cc, int Rd, |
| 93 | int Rn, uint32_t offset = immed8_pre(0)); |
| 94 | virtual void LDRSB(int cc, int Rd, |
| 95 | int Rn, uint32_t offset = immed8_pre(0)); |
| 96 | virtual void LDRSH(int cc, int Rd, |
| 97 | int Rn, uint32_t offset = immed8_pre(0)); |
| 98 | virtual void STRH (int cc, int Rd, |
| 99 | int Rn, uint32_t offset = immed8_pre(0)); |
| 100 | virtual void LDM(int cc, int dir, |
| 101 | int Rn, int W, uint32_t reg_list); |
| 102 | virtual void STM(int cc, int dir, |
| 103 | int Rn, int W, uint32_t reg_list); |
| 104 | |
| 105 | virtual void SWP(int cc, int Rn, int Rd, int Rm); |
| 106 | virtual void SWPB(int cc, int Rn, int Rd, int Rm); |
| 107 | virtual void SWI(int cc, uint32_t comment); |
| 108 | |
| 109 | virtual void PLD(int Rn, uint32_t offset); |
| 110 | virtual void CLZ(int cc, int Rd, int Rm); |
| 111 | virtual void QADD(int cc, int Rd, int Rm, int Rn); |
| 112 | virtual void QDADD(int cc, int Rd, int Rm, int Rn); |
| 113 | virtual void QSUB(int cc, int Rd, int Rm, int Rn); |
| 114 | virtual void QDSUB(int cc, int Rd, int Rm, int Rn); |
| 115 | virtual void SMUL(int cc, int xy, |
| 116 | int Rd, int Rm, int Rs); |
| 117 | virtual void SMULW(int cc, int y, |
| 118 | int Rd, int Rm, int Rs); |
| 119 | virtual void SMLA(int cc, int xy, |
| 120 | int Rd, int Rm, int Rs, int Rn); |
| 121 | virtual void SMLAL(int cc, int xy, |
| 122 | int RdHi, int RdLo, int Rs, int Rm); |
| 123 | virtual void SMLAW(int cc, int y, |
| 124 | int Rd, int Rm, int Rs, int Rn); |
| 125 | |
| 126 | private: |
| 127 | ARMAssembler(const ARMAssembler& rhs); |
| 128 | ARMAssembler& operator = (const ARMAssembler& rhs); |
| 129 | |
| 130 | sp<Assembly> mAssembly; |
| 131 | uint32_t* mBase; |
| 132 | uint32_t* mPC; |
| 133 | uint32_t* mPrologPC; |
| 134 | int64_t mDuration; |
| 135 | #if defined(WITH_LIB_HARDWARE) |
| 136 | bool mQemuTracing; |
| 137 | #endif |
| 138 | |
| 139 | struct branch_target_t { |
| 140 | inline branch_target_t() : label(0), pc(0) { } |
| 141 | inline branch_target_t(const char* l, uint32_t* p) |
| 142 | : label(l), pc(p) { } |
| 143 | const char* label; |
| 144 | uint32_t* pc; |
| 145 | }; |
| 146 | |
| 147 | Vector<branch_target_t> mBranchTargets; |
| 148 | KeyedVector< const char*, uint32_t* > mLabels; |
| 149 | KeyedVector< uint32_t*, const char* > mLabelsInverseMapping; |
| 150 | KeyedVector< uint32_t*, const char* > mComments; |
| 151 | }; |
| 152 | |
| 153 | }; // namespace android |
| 154 | |
| 155 | #endif //ANDROID_ARMASSEMBLER_H |