1/* 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
25#include "codeflinger/ARMAssemblerInterface.h"
26
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);
45    virtual int     getCodegenArch();
46
47    virtual void    prolog();
48    virtual void    epilog(uint32_t touched);
49    virtual void    comment(const char* string);
50
51    // -----------------------------------------------------------------------
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
79    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,
105                int Rn, uint32_t offset = __immed12_pre(0));
106    virtual void LDRB(int cc, int Rd,
107                int Rn, uint32_t offset = __immed12_pre(0));
108    virtual void STR (int cc, int Rd,
109                int Rn, uint32_t offset = __immed12_pre(0));
110    virtual void STRB(int cc, int Rd,
111                int Rn, uint32_t offset = __immed12_pre(0));
112    virtual void LDRH (int cc, int Rd,
113                int Rn, uint32_t offset = __immed8_pre(0));
114    virtual void LDRSB(int cc, int Rd,
115                int Rn, uint32_t offset = __immed8_pre(0));
116    virtual void LDRSH(int cc, int Rd,
117                int Rn, uint32_t offset = __immed8_pre(0));
118    virtual void STRH (int cc, int Rd,
119                int Rn, uint32_t offset = __immed8_pre(0));
120    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
146    virtual void UXTB16(int cc, int Rd, int Rm, int rotate);
147    virtual void UBFX(int cc, int Rd, int Rn, int lsb, int width);
148
149private:
150    ARMAssemblerInterface*  mTarget;
151};
152
153}; // namespace android
154
155#endif //ANDROID_ARMASSEMBLER_PROXY_H
156