blob: b85279485f7b65eb55a13bea6e185067eded1ba6 [file] [log] [blame]
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -07001/* libs/pixelflinger/codeflinger/ARMAssemblerProxy.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
19#ifndef ANDROID_ARMASSEMBLER_PROXY_H
20#define ANDROID_ARMASSEMBLER_PROXY_H
21
22#include <stdint.h>
23#include <sys/types.h>
24
Mathias Agopian9857d992013-04-01 15:17:55 -070025#include "ARMAssemblerInterface.h"
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -070026
27namespace android {
28
29// ----------------------------------------------------------------------------
30
31class ARMAssemblerProxy : public ARMAssemblerInterface
32{
33public:
34 // ARMAssemblerProxy take ownership of the target
35
36 ARMAssemblerProxy();
37 ARMAssemblerProxy(ARMAssemblerInterface* target);
38 virtual ~ARMAssemblerProxy();
39
40 void setTarget(ARMAssemblerInterface* target);
41
42 virtual void reset();
43 virtual int generate(const char* name);
44 virtual void disassemble(const char* name);
Paul Lind2bc2b792012-02-01 10:54:19 -080045 virtual int getCodegenArch();
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -070046
47 virtual void prolog();
48 virtual void epilog(uint32_t touched);
49 virtual void comment(const char* string);
50
Paul Lind2bc2b792012-02-01 10:54:19 -080051 // -----------------------------------------------------------------------
52 // shifters and addressing modes
53 // -----------------------------------------------------------------------
54
55 virtual bool isValidImmediate(uint32_t immed);
56 virtual int buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm);
57
58 virtual uint32_t imm(uint32_t immediate);
59 virtual uint32_t reg_imm(int Rm, int type, uint32_t shift);
60 virtual uint32_t reg_rrx(int Rm);
61 virtual uint32_t reg_reg(int Rm, int type, int Rs);
62
63 // addressing modes...
64 // LDR(B)/STR(B)/PLD
65 // (immediate and Rm can be negative, which indicates U=0)
66 virtual uint32_t immed12_pre(int32_t immed12, int W=0);
67 virtual uint32_t immed12_post(int32_t immed12);
68 virtual uint32_t reg_scale_pre(int Rm, int type=0, uint32_t shift=0, int W=0);
69 virtual uint32_t reg_scale_post(int Rm, int type=0, uint32_t shift=0);
70
71 // LDRH/LDRSB/LDRSH/STRH
72 // (immediate and Rm can be negative, which indicates U=0)
73 virtual uint32_t immed8_pre(int32_t immed8, int W=0);
74 virtual uint32_t immed8_post(int32_t immed8);
75 virtual uint32_t reg_pre(int Rm, int W=0);
76 virtual uint32_t reg_post(int Rm);
77
78
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -070079 virtual void dataProcessing(int opcode, int cc, int s,
80 int Rd, int Rn,
81 uint32_t Op2);
82 virtual void MLA(int cc, int s,
83 int Rd, int Rm, int Rs, int Rn);
84 virtual void MUL(int cc, int s,
85 int Rd, int Rm, int Rs);
86 virtual void UMULL(int cc, int s,
87 int RdLo, int RdHi, int Rm, int Rs);
88 virtual void UMUAL(int cc, int s,
89 int RdLo, int RdHi, int Rm, int Rs);
90 virtual void SMULL(int cc, int s,
91 int RdLo, int RdHi, int Rm, int Rs);
92 virtual void SMUAL(int cc, int s,
93 int RdLo, int RdHi, int Rm, int Rs);
94
95 virtual void B(int cc, uint32_t* pc);
96 virtual void BL(int cc, uint32_t* pc);
97 virtual void BX(int cc, int Rn);
98 virtual void label(const char* theLabel);
99 virtual void B(int cc, const char* label);
100 virtual void BL(int cc, const char* label);
101
102 uint32_t* pcForLabel(const char* label);
103
104 virtual void LDR (int cc, int Rd,
Paul Lind2bc2b792012-02-01 10:54:19 -0800105 int Rn, uint32_t offset = __immed12_pre(0));
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -0700106 virtual void LDRB(int cc, int Rd,
Paul Lind2bc2b792012-02-01 10:54:19 -0800107 int Rn, uint32_t offset = __immed12_pre(0));
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -0700108 virtual void STR (int cc, int Rd,
Paul Lind2bc2b792012-02-01 10:54:19 -0800109 int Rn, uint32_t offset = __immed12_pre(0));
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -0700110 virtual void STRB(int cc, int Rd,
Paul Lind2bc2b792012-02-01 10:54:19 -0800111 int Rn, uint32_t offset = __immed12_pre(0));
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -0700112 virtual void LDRH (int cc, int Rd,
Paul Lind2bc2b792012-02-01 10:54:19 -0800113 int Rn, uint32_t offset = __immed8_pre(0));
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -0700114 virtual void LDRSB(int cc, int Rd,
Paul Lind2bc2b792012-02-01 10:54:19 -0800115 int Rn, uint32_t offset = __immed8_pre(0));
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -0700116 virtual void LDRSH(int cc, int Rd,
Paul Lind2bc2b792012-02-01 10:54:19 -0800117 int Rn, uint32_t offset = __immed8_pre(0));
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -0700118 virtual void STRH (int cc, int Rd,
Paul Lind2bc2b792012-02-01 10:54:19 -0800119 int Rn, uint32_t offset = __immed8_pre(0));
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -0700120 virtual void LDM(int cc, int dir,
121 int Rn, int W, uint32_t reg_list);
122 virtual void STM(int cc, int dir,
123 int Rn, int W, uint32_t reg_list);
124
125 virtual void SWP(int cc, int Rn, int Rd, int Rm);
126 virtual void SWPB(int cc, int Rn, int Rd, int Rm);
127 virtual void SWI(int cc, uint32_t comment);
128
129 virtual void PLD(int Rn, uint32_t offset);
130 virtual void CLZ(int cc, int Rd, int Rm);
131 virtual void QADD(int cc, int Rd, int Rm, int Rn);
132 virtual void QDADD(int cc, int Rd, int Rm, int Rn);
133 virtual void QSUB(int cc, int Rd, int Rm, int Rn);
134 virtual void QDSUB(int cc, int Rd, int Rm, int Rn);
135 virtual void SMUL(int cc, int xy,
136 int Rd, int Rm, int Rs);
137 virtual void SMULW(int cc, int y,
138 int Rd, int Rm, int Rs);
139 virtual void SMLA(int cc, int xy,
140 int Rd, int Rm, int Rs, int Rn);
141 virtual void SMLAL(int cc, int xy,
142 int RdHi, int RdLo, int Rs, int Rm);
143 virtual void SMLAW(int cc, int y,
144 int Rd, int Rm, int Rs, int Rn);
145
Martyn Capewell96dbb4f2009-12-07 13:59:59 +0000146 virtual void UXTB16(int cc, int Rd, int Rm, int rotate);
Martyn Capewell4dc1fa82009-12-04 16:44:58 +0000147 virtual void UBFX(int cc, int Rd, int Rn, int lsb, int width);
Martyn Capewell96dbb4f2009-12-07 13:59:59 +0000148
Ashok Bhatbfc6dc42013-02-21 10:27:40 +0000149 virtual void ADDR_LDR(int cc, int Rd,
150 int Rn, uint32_t offset = __immed12_pre(0));
151 virtual void ADDR_STR (int cc, int Rd,
152 int Rn, uint32_t offset = __immed12_pre(0));
153 virtual void ADDR_ADD(int cc, int s, int Rd,
154 int Rn, uint32_t Op2);
155 virtual void ADDR_SUB(int cc, int s, int Rd,
156 int Rn, uint32_t Op2);
157
The Android Open Source Project4f6e8d72008-10-21 07:00:00 -0700158private:
159 ARMAssemblerInterface* mTarget;
160};
161
162}; // namespace android
163
164#endif //ANDROID_ARMASSEMBLER_PROXY_H