1 /* libs/pixelflinger/codeflinger/ARMAssemblerProxy.cpp
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 #include <stdint.h>
20 #include <sys/types.h>
21 
22 #include "ARMAssemblerProxy.h"
23 
24 namespace android {
25 
26 // ----------------------------------------------------------------------------
27 
ARMAssemblerProxy()28 ARMAssemblerProxy::ARMAssemblerProxy()
29     : mTarget(0)
30 {
31 }
32 
ARMAssemblerProxy(ARMAssemblerInterface * target)33 ARMAssemblerProxy::ARMAssemblerProxy(ARMAssemblerInterface* target)
34     : mTarget(target)
35 {
36 }
37 
~ARMAssemblerProxy()38 ARMAssemblerProxy::~ARMAssemblerProxy()
39 {
40     delete mTarget;
41 }
42 
setTarget(ARMAssemblerInterface * target)43 void ARMAssemblerProxy::setTarget(ARMAssemblerInterface* target)
44 {
45     delete mTarget;
46     mTarget = target;
47 }
48 
reset()49 void ARMAssemblerProxy::reset() {
50     mTarget->reset();
51 }
generate(const char * name)52 int ARMAssemblerProxy::generate(const char* name) {
53     return mTarget->generate(name);
54 }
disassemble(const char * name)55 void ARMAssemblerProxy::disassemble(const char* name) {
56     return mTarget->disassemble(name);
57 }
getCodegenArch()58 int ARMAssemblerProxy::getCodegenArch()
59 {
60     return mTarget->getCodegenArch();
61 }
prolog()62 void ARMAssemblerProxy::prolog() {
63     mTarget->prolog();
64 }
epilog(uint32_t touched)65 void ARMAssemblerProxy::epilog(uint32_t touched) {
66     mTarget->epilog(touched);
67 }
comment(const char * string)68 void ARMAssemblerProxy::comment(const char* string) {
69     mTarget->comment(string);
70 }
71 
72 
73 
74 // addressing modes
75 
isValidImmediate(uint32_t immed)76 bool ARMAssemblerProxy::isValidImmediate(uint32_t immed)
77 {
78     return mTarget->isValidImmediate(immed);
79 }
80 
buildImmediate(uint32_t i,uint32_t & rot,uint32_t & imm)81 int ARMAssemblerProxy::buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm)
82 {
83     return mTarget->buildImmediate(i, rot, imm);
84 }
85 
86 
87 
imm(uint32_t immediate)88 uint32_t ARMAssemblerProxy::imm(uint32_t immediate)
89 {
90     return mTarget->imm(immediate);
91 }
92 
reg_imm(int Rm,int type,uint32_t shift)93 uint32_t ARMAssemblerProxy::reg_imm(int Rm, int type, uint32_t shift)
94 {
95     return mTarget->reg_imm(Rm, type, shift);
96 }
97 
reg_rrx(int Rm)98 uint32_t ARMAssemblerProxy::reg_rrx(int Rm)
99 {
100     return mTarget->reg_rrx(Rm);
101 }
102 
reg_reg(int Rm,int type,int Rs)103 uint32_t ARMAssemblerProxy::reg_reg(int Rm, int type, int Rs)
104 {
105     return mTarget->reg_reg(Rm, type, Rs);
106 }
107 
108 
109 // addressing modes...
110 // LDR(B)/STR(B)/PLD
111 // (immediate and Rm can be negative, which indicates U=0)
immed12_pre(int32_t immed12,int W)112 uint32_t ARMAssemblerProxy::immed12_pre(int32_t immed12, int W)
113 {
114     return mTarget->immed12_pre(immed12, W);
115 }
116 
immed12_post(int32_t immed12)117 uint32_t ARMAssemblerProxy::immed12_post(int32_t immed12)
118 {
119     return mTarget->immed12_post(immed12);
120 }
121 
reg_scale_pre(int Rm,int type,uint32_t shift,int W)122 uint32_t ARMAssemblerProxy::reg_scale_pre(int Rm, int type, uint32_t shift, int W)
123 {
124     return mTarget->reg_scale_pre(Rm, type, shift, W);
125 }
126 
reg_scale_post(int Rm,int type,uint32_t shift)127 uint32_t ARMAssemblerProxy::reg_scale_post(int Rm, int type, uint32_t shift)
128 {
129     return mTarget->reg_scale_post(Rm, type, shift);
130 }
131 
132 
133 // LDRH/LDRSB/LDRSH/STRH
134 // (immediate and Rm can be negative, which indicates U=0)
immed8_pre(int32_t immed8,int W)135 uint32_t ARMAssemblerProxy::immed8_pre(int32_t immed8, int W)
136 {
137     return mTarget->immed8_pre(immed8, W);
138 }
139 
immed8_post(int32_t immed8)140 uint32_t ARMAssemblerProxy::immed8_post(int32_t immed8)
141 {
142     return mTarget->immed8_post(immed8);
143 }
144 
reg_pre(int Rm,int W)145 uint32_t ARMAssemblerProxy::reg_pre(int Rm, int W)
146 {
147     return mTarget->reg_pre(Rm, W);
148 }
149 
reg_post(int Rm)150 uint32_t ARMAssemblerProxy::reg_post(int Rm)
151 {
152     return mTarget->reg_post(Rm);
153 }
154 
155 
156 //------------------------------------------------------------------------
157 
158 
159 
dataProcessing(int opcode,int cc,int s,int Rd,int Rn,uint32_t Op2)160 void ARMAssemblerProxy::dataProcessing( int opcode, int cc, int s,
161                                         int Rd, int Rn, uint32_t Op2)
162 {
163     mTarget->dataProcessing(opcode, cc, s, Rd, Rn, Op2);
164 }
165 
MLA(int cc,int s,int Rd,int Rm,int Rs,int Rn)166 void ARMAssemblerProxy::MLA(int cc, int s, int Rd, int Rm, int Rs, int Rn) {
167     mTarget->MLA(cc, s, Rd, Rm, Rs, Rn);
168 }
MUL(int cc,int s,int Rd,int Rm,int Rs)169 void ARMAssemblerProxy::MUL(int cc, int s, int Rd, int Rm, int Rs) {
170     mTarget->MUL(cc, s, Rd, Rm, Rs);
171 }
UMULL(int cc,int s,int RdLo,int RdHi,int Rm,int Rs)172 void ARMAssemblerProxy::UMULL(int cc, int s,
173             int RdLo, int RdHi, int Rm, int Rs) {
174     mTarget->UMULL(cc, s, RdLo, RdHi, Rm, Rs);
175 }
UMUAL(int cc,int s,int RdLo,int RdHi,int Rm,int Rs)176 void ARMAssemblerProxy::UMUAL(int cc, int s,
177             int RdLo, int RdHi, int Rm, int Rs) {
178     mTarget->UMUAL(cc, s, RdLo, RdHi, Rm, Rs);
179 }
SMULL(int cc,int s,int RdLo,int RdHi,int Rm,int Rs)180 void ARMAssemblerProxy::SMULL(int cc, int s,
181             int RdLo, int RdHi, int Rm, int Rs) {
182     mTarget->SMULL(cc, s, RdLo, RdHi, Rm, Rs);
183 }
SMUAL(int cc,int s,int RdLo,int RdHi,int Rm,int Rs)184 void ARMAssemblerProxy::SMUAL(int cc, int s,
185             int RdLo, int RdHi, int Rm, int Rs) {
186     mTarget->SMUAL(cc, s, RdLo, RdHi, Rm, Rs);
187 }
188 
B(int cc,uint32_t * pc)189 void ARMAssemblerProxy::B(int cc, uint32_t* pc) {
190     mTarget->B(cc, pc);
191 }
BL(int cc,uint32_t * pc)192 void ARMAssemblerProxy::BL(int cc, uint32_t* pc) {
193     mTarget->BL(cc, pc);
194 }
BX(int cc,int Rn)195 void ARMAssemblerProxy::BX(int cc, int Rn) {
196     mTarget->BX(cc, Rn);
197 }
label(const char * theLabel)198 void ARMAssemblerProxy::label(const char* theLabel) {
199     mTarget->label(theLabel);
200 }
B(int cc,const char * label)201 void ARMAssemblerProxy::B(int cc, const char* label) {
202     mTarget->B(cc, label);
203 }
BL(int cc,const char * label)204 void ARMAssemblerProxy::BL(int cc, const char* label) {
205     mTarget->BL(cc, label);
206 }
207 
pcForLabel(const char * label)208 uint32_t* ARMAssemblerProxy::pcForLabel(const char* label) {
209     return mTarget->pcForLabel(label);
210 }
211 
LDR(int cc,int Rd,int Rn,uint32_t offset)212 void ARMAssemblerProxy::LDR(int cc, int Rd, int Rn, uint32_t offset) {
213     mTarget->LDR(cc, Rd, Rn, offset);
214 }
LDRB(int cc,int Rd,int Rn,uint32_t offset)215 void ARMAssemblerProxy::LDRB(int cc, int Rd, int Rn, uint32_t offset) {
216     mTarget->LDRB(cc, Rd, Rn, offset);
217 }
STR(int cc,int Rd,int Rn,uint32_t offset)218 void ARMAssemblerProxy::STR(int cc, int Rd, int Rn, uint32_t offset) {
219     mTarget->STR(cc, Rd, Rn, offset);
220 }
STRB(int cc,int Rd,int Rn,uint32_t offset)221 void ARMAssemblerProxy::STRB(int cc, int Rd, int Rn, uint32_t offset) {
222     mTarget->STRB(cc, Rd, Rn, offset);
223 }
LDRH(int cc,int Rd,int Rn,uint32_t offset)224 void ARMAssemblerProxy::LDRH(int cc, int Rd, int Rn, uint32_t offset) {
225     mTarget->LDRH(cc, Rd, Rn, offset);
226 }
LDRSB(int cc,int Rd,int Rn,uint32_t offset)227 void ARMAssemblerProxy::LDRSB(int cc, int Rd, int Rn, uint32_t offset) {
228     mTarget->LDRSB(cc, Rd, Rn, offset);
229 }
LDRSH(int cc,int Rd,int Rn,uint32_t offset)230 void ARMAssemblerProxy::LDRSH(int cc, int Rd, int Rn, uint32_t offset) {
231     mTarget->LDRSH(cc, Rd, Rn, offset);
232 }
STRH(int cc,int Rd,int Rn,uint32_t offset)233 void ARMAssemblerProxy::STRH(int cc, int Rd, int Rn, uint32_t offset) {
234     mTarget->STRH(cc, Rd, Rn, offset);
235 }
LDM(int cc,int dir,int Rn,int W,uint32_t reg_list)236 void ARMAssemblerProxy::LDM(int cc, int dir, int Rn, int W, uint32_t reg_list) {
237     mTarget->LDM(cc, dir, Rn, W, reg_list);
238 }
STM(int cc,int dir,int Rn,int W,uint32_t reg_list)239 void ARMAssemblerProxy::STM(int cc, int dir, int Rn, int W, uint32_t reg_list) {
240     mTarget->STM(cc, dir, Rn, W, reg_list);
241 }
242 
SWP(int cc,int Rn,int Rd,int Rm)243 void ARMAssemblerProxy::SWP(int cc, int Rn, int Rd, int Rm) {
244     mTarget->SWP(cc, Rn, Rd, Rm);
245 }
SWPB(int cc,int Rn,int Rd,int Rm)246 void ARMAssemblerProxy::SWPB(int cc, int Rn, int Rd, int Rm) {
247     mTarget->SWPB(cc, Rn, Rd, Rm);
248 }
SWI(int cc,uint32_t comment)249 void ARMAssemblerProxy::SWI(int cc, uint32_t comment) {
250     mTarget->SWI(cc, comment);
251 }
252 
253 
PLD(int Rn,uint32_t offset)254 void ARMAssemblerProxy::PLD(int Rn, uint32_t offset) {
255     mTarget->PLD(Rn, offset);
256 }
CLZ(int cc,int Rd,int Rm)257 void ARMAssemblerProxy::CLZ(int cc, int Rd, int Rm) {
258     mTarget->CLZ(cc, Rd, Rm);
259 }
QADD(int cc,int Rd,int Rm,int Rn)260 void ARMAssemblerProxy::QADD(int cc, int Rd, int Rm, int Rn) {
261     mTarget->QADD(cc, Rd, Rm, Rn);
262 }
QDADD(int cc,int Rd,int Rm,int Rn)263 void ARMAssemblerProxy::QDADD(int cc, int Rd, int Rm, int Rn) {
264     mTarget->QDADD(cc, Rd, Rm, Rn);
265 }
QSUB(int cc,int Rd,int Rm,int Rn)266 void ARMAssemblerProxy::QSUB(int cc, int Rd, int Rm, int Rn) {
267     mTarget->QSUB(cc, Rd, Rm, Rn);
268 }
QDSUB(int cc,int Rd,int Rm,int Rn)269 void ARMAssemblerProxy::QDSUB(int cc, int Rd, int Rm, int Rn) {
270     mTarget->QDSUB(cc, Rd, Rm, Rn);
271 }
SMUL(int cc,int xy,int Rd,int Rm,int Rs)272 void ARMAssemblerProxy::SMUL(int cc, int xy, int Rd, int Rm, int Rs) {
273     mTarget->SMUL(cc, xy, Rd, Rm, Rs);
274 }
SMULW(int cc,int y,int Rd,int Rm,int Rs)275 void ARMAssemblerProxy::SMULW(int cc, int y, int Rd, int Rm, int Rs) {
276     mTarget->SMULW(cc, y, Rd, Rm, Rs);
277 }
SMLA(int cc,int xy,int Rd,int Rm,int Rs,int Rn)278 void ARMAssemblerProxy::SMLA(int cc, int xy, int Rd, int Rm, int Rs, int Rn) {
279     mTarget->SMLA(cc, xy, Rd, Rm, Rs, Rn);
280 }
SMLAL(int cc,int xy,int RdHi,int RdLo,int Rs,int Rm)281 void ARMAssemblerProxy::SMLAL(  int cc, int xy,
282                                 int RdHi, int RdLo, int Rs, int Rm) {
283     mTarget->SMLAL(cc, xy, RdHi, RdLo, Rs, Rm);
284 }
SMLAW(int cc,int y,int Rd,int Rm,int Rs,int Rn)285 void ARMAssemblerProxy::SMLAW(int cc, int y, int Rd, int Rm, int Rs, int Rn) {
286     mTarget->SMLAW(cc, y, Rd, Rm, Rs, Rn);
287 }
288 
UXTB16(int cc,int Rd,int Rm,int rotate)289 void ARMAssemblerProxy::UXTB16(int cc, int Rd, int Rm, int rotate) {
290     mTarget->UXTB16(cc, Rd, Rm, rotate);
291 }
292 
UBFX(int cc,int Rd,int Rn,int lsb,int width)293 void ARMAssemblerProxy::UBFX(int cc, int Rd, int Rn, int lsb, int width) {
294     mTarget->UBFX(cc, Rd, Rn, lsb, width);
295 }
296 
ADDR_LDR(int cc,int Rd,int Rn,uint32_t offset)297 void ARMAssemblerProxy::ADDR_LDR(int cc, int Rd, int Rn, uint32_t offset) {
298      mTarget->ADDR_LDR(cc, Rd, Rn, offset);
299 }
ADDR_STR(int cc,int Rd,int Rn,uint32_t offset)300 void ARMAssemblerProxy::ADDR_STR(int cc, int Rd, int Rn, uint32_t offset) {
301      mTarget->ADDR_STR(cc, Rd, Rn, offset);
302 }
ADDR_ADD(int cc,int s,int Rd,int Rn,uint32_t Op2)303 void ARMAssemblerProxy::ADDR_ADD(int cc, int s, int Rd, int Rn, uint32_t Op2){
304      mTarget->ADDR_ADD(cc, s, Rd, Rn, Op2);
305 }
ADDR_SUB(int cc,int s,int Rd,int Rn,uint32_t Op2)306 void ARMAssemblerProxy::ADDR_SUB(int cc, int s, int Rd, int Rn, uint32_t Op2){
307      mTarget->ADDR_SUB(cc, s, Rd, Rn, Op2);
308 }
309 
310 }; // namespace android
311 
312