2009-03-04 11:32:55 +08:00
|
|
|
/* libs/pixelflinger/codeflinger/ARMAssembler.h
|
|
|
|
**
|
|
|
|
** Copyright 2006, The Android Open Source Project
|
|
|
|
**
|
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
|
|
|
**
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
**
|
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
|
|
|
** limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef ANDROID_ARMASSEMBLER_H
|
|
|
|
#define ANDROID_ARMASSEMBLER_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
2009-06-02 06:27:46 +08:00
|
|
|
#include "tinyutils/smartpointer.h"
|
2015-08-28 19:59:48 +08:00
|
|
|
#include "utils/Vector.h"
|
|
|
|
#include "utils/KeyedVector.h"
|
2009-03-04 11:32:55 +08:00
|
|
|
|
2013-04-02 06:17:55 +08:00
|
|
|
#include "ARMAssemblerInterface.h"
|
|
|
|
#include "CodeCache.h"
|
2009-03-04 11:32:55 +08:00
|
|
|
|
|
|
|
namespace android {
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class ARMAssembler : public ARMAssemblerInterface
|
|
|
|
{
|
|
|
|
public:
|
2016-07-13 04:50:44 +08:00
|
|
|
explicit ARMAssembler(const sp<Assembly>& assembly);
|
2009-03-04 11:32:55 +08:00
|
|
|
virtual ~ARMAssembler();
|
|
|
|
|
|
|
|
uint32_t* base() const;
|
|
|
|
uint32_t* pc() const;
|
|
|
|
|
|
|
|
|
|
|
|
void disassemble(const char* name);
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
// ARMAssemblerInterface...
|
|
|
|
// ------------------------------------------------------------------------
|
|
|
|
|
|
|
|
virtual void reset();
|
|
|
|
|
|
|
|
virtual int generate(const char* name);
|
2012-02-02 02:54:19 +08:00
|
|
|
virtual int getCodegenArch();
|
2009-03-04 11:32:55 +08:00
|
|
|
|
|
|
|
virtual void prolog();
|
|
|
|
virtual void epilog(uint32_t touched);
|
|
|
|
virtual void comment(const char* string);
|
|
|
|
|
2012-02-02 02:54:19 +08:00
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// shifters and addressing modes
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// shifters...
|
|
|
|
virtual bool isValidImmediate(uint32_t immed);
|
|
|
|
virtual int buildImmediate(uint32_t i, uint32_t& rot, uint32_t& imm);
|
|
|
|
|
|
|
|
virtual uint32_t imm(uint32_t immediate);
|
|
|
|
virtual uint32_t reg_imm(int Rm, int type, uint32_t shift);
|
|
|
|
virtual uint32_t reg_rrx(int Rm);
|
|
|
|
virtual uint32_t reg_reg(int Rm, int type, int Rs);
|
|
|
|
|
|
|
|
// addressing modes...
|
|
|
|
// LDR(B)/STR(B)/PLD
|
|
|
|
// (immediate and Rm can be negative, which indicates U=0)
|
|
|
|
virtual uint32_t immed12_pre(int32_t immed12, int W=0);
|
|
|
|
virtual uint32_t immed12_post(int32_t immed12);
|
|
|
|
virtual uint32_t reg_scale_pre(int Rm, int type=0, uint32_t shift=0, int W=0);
|
|
|
|
virtual uint32_t reg_scale_post(int Rm, int type=0, uint32_t shift=0);
|
|
|
|
|
|
|
|
// LDRH/LDRSB/LDRSH/STRH
|
|
|
|
// (immediate and Rm can be negative, which indicates U=0)
|
|
|
|
virtual uint32_t immed8_pre(int32_t immed8, int W=0);
|
|
|
|
virtual uint32_t immed8_post(int32_t immed8);
|
|
|
|
virtual uint32_t reg_pre(int Rm, int W=0);
|
|
|
|
virtual uint32_t reg_post(int Rm);
|
|
|
|
|
|
|
|
|
2009-03-04 11:32:55 +08:00
|
|
|
virtual void dataProcessing(int opcode, int cc, int s,
|
|
|
|
int Rd, int Rn,
|
|
|
|
uint32_t Op2);
|
|
|
|
virtual void MLA(int cc, int s,
|
|
|
|
int Rd, int Rm, int Rs, int Rn);
|
|
|
|
virtual void MUL(int cc, int s,
|
|
|
|
int Rd, int Rm, int Rs);
|
|
|
|
virtual void UMULL(int cc, int s,
|
|
|
|
int RdLo, int RdHi, int Rm, int Rs);
|
|
|
|
virtual void UMUAL(int cc, int s,
|
|
|
|
int RdLo, int RdHi, int Rm, int Rs);
|
|
|
|
virtual void SMULL(int cc, int s,
|
|
|
|
int RdLo, int RdHi, int Rm, int Rs);
|
|
|
|
virtual void SMUAL(int cc, int s,
|
|
|
|
int RdLo, int RdHi, int Rm, int Rs);
|
|
|
|
|
|
|
|
virtual void B(int cc, uint32_t* pc);
|
|
|
|
virtual void BL(int cc, uint32_t* pc);
|
|
|
|
virtual void BX(int cc, int Rn);
|
|
|
|
virtual void label(const char* theLabel);
|
|
|
|
virtual void B(int cc, const char* label);
|
|
|
|
virtual void BL(int cc, const char* label);
|
|
|
|
|
|
|
|
virtual uint32_t* pcForLabel(const char* label);
|
|
|
|
|
|
|
|
virtual void LDR (int cc, int Rd,
|
2012-02-02 02:54:19 +08:00
|
|
|
int Rn, uint32_t offset = __immed12_pre(0));
|
2009-03-04 11:32:55 +08:00
|
|
|
virtual void LDRB(int cc, int Rd,
|
2012-02-02 02:54:19 +08:00
|
|
|
int Rn, uint32_t offset = __immed12_pre(0));
|
2009-03-04 11:32:55 +08:00
|
|
|
virtual void STR (int cc, int Rd,
|
2012-02-02 02:54:19 +08:00
|
|
|
int Rn, uint32_t offset = __immed12_pre(0));
|
2009-03-04 11:32:55 +08:00
|
|
|
virtual void STRB(int cc, int Rd,
|
2012-02-02 02:54:19 +08:00
|
|
|
int Rn, uint32_t offset = __immed12_pre(0));
|
2009-03-04 11:32:55 +08:00
|
|
|
virtual void LDRH (int cc, int Rd,
|
2012-02-02 02:54:19 +08:00
|
|
|
int Rn, uint32_t offset = __immed8_pre(0));
|
2009-03-04 11:32:55 +08:00
|
|
|
virtual void LDRSB(int cc, int Rd,
|
2012-02-02 02:54:19 +08:00
|
|
|
int Rn, uint32_t offset = __immed8_pre(0));
|
2009-03-04 11:32:55 +08:00
|
|
|
virtual void LDRSH(int cc, int Rd,
|
2012-02-02 02:54:19 +08:00
|
|
|
int Rn, uint32_t offset = __immed8_pre(0));
|
2009-03-04 11:32:55 +08:00
|
|
|
virtual void STRH (int cc, int Rd,
|
2012-02-02 02:54:19 +08:00
|
|
|
int Rn, uint32_t offset = __immed8_pre(0));
|
|
|
|
|
|
|
|
|
2009-03-04 11:32:55 +08:00
|
|
|
virtual void LDM(int cc, int dir,
|
|
|
|
int Rn, int W, uint32_t reg_list);
|
|
|
|
virtual void STM(int cc, int dir,
|
|
|
|
int Rn, int W, uint32_t reg_list);
|
|
|
|
|
|
|
|
virtual void SWP(int cc, int Rn, int Rd, int Rm);
|
|
|
|
virtual void SWPB(int cc, int Rn, int Rd, int Rm);
|
|
|
|
virtual void SWI(int cc, uint32_t comment);
|
|
|
|
|
|
|
|
virtual void PLD(int Rn, uint32_t offset);
|
|
|
|
virtual void CLZ(int cc, int Rd, int Rm);
|
|
|
|
virtual void QADD(int cc, int Rd, int Rm, int Rn);
|
|
|
|
virtual void QDADD(int cc, int Rd, int Rm, int Rn);
|
|
|
|
virtual void QSUB(int cc, int Rd, int Rm, int Rn);
|
|
|
|
virtual void QDSUB(int cc, int Rd, int Rm, int Rn);
|
|
|
|
virtual void SMUL(int cc, int xy,
|
|
|
|
int Rd, int Rm, int Rs);
|
|
|
|
virtual void SMULW(int cc, int y,
|
|
|
|
int Rd, int Rm, int Rs);
|
|
|
|
virtual void SMLA(int cc, int xy,
|
|
|
|
int Rd, int Rm, int Rs, int Rn);
|
|
|
|
virtual void SMLAL(int cc, int xy,
|
|
|
|
int RdHi, int RdLo, int Rs, int Rm);
|
|
|
|
virtual void SMLAW(int cc, int y,
|
|
|
|
int Rd, int Rm, int Rs, int Rn);
|
Adds UXTB16 support to Pixelflinger
* Add support for UXTB16 to the disassembler
* Add encoding of the UXTB16 instruction to the Pixelflinger JIT.
Introducing the UXTB16 instruction allows removal of some masking code, and is
beneficial from a pipeline point of view - lots of UXTB16 followed by MUL
sequences.
Also, further rescheduling and use of SMULWB brings extra performance
improvements.
* Use UXTB16 in bilinear filtered texturing
Uses UXTB16 to extract channels for SIMD operations, rather than creating and
ANDing with masks. Saves a register and is faster on A8, as UXTB16 result can
feed into first stage of multiply, unlike AND.
Also, used SMULWB rather than SMULBB, which allows removal of MOVs used to
rescale results.
Code has been scheduled for A8 pipeline, specifically aiming to allow
multiplies to issue in pipeline 0, for efficient dual issue operation.
Testing on SpriteMethodTest (http://code.google.com/p/apps-for-android/) gives
8% improvement (12.7 vs. 13.7 fps.)
SMULBB to SMULWB trick could be used in <v6 code path, but this hasn't been
implemented.
2009-12-07 21:59:59 +08:00
|
|
|
virtual void UXTB16(int cc, int Rd, int Rm, int rotate);
|
Adds support for UBFX to JIT and Disassembler
This introduces UBFX instruction generation abilities to the Pixelflinger JIT,
and also modifies the component extraction function to generate the
instruction.
The extract function contains defines to prevent generation of UBFX on pre-v7
cores. The JIT itself retains the ability to produce the instruction even on
v5/6.
This patch only generates UBFX when MOV, AND or BIC can't be used. Based on
the TRM, this appears to be faster on A9 than using UBFX in all cases.
On startup, Pixelflinger JITs three chunks of code. UBFX improves these as
follows:
00000077:03515104_00000000_00000000
(Blends a single colour into an RGB565 buffer.)
Before: 27 inst/pixel, After: 24 inst/pixel, Improvement: 12.5%
00000077:03545404_00000A01_00000000
(Blends RGBA8888 texture into an RGB565 buffer using alpha.)
Before: 30 inst/pixel, After: 27 inst/pixel, Improvement: 11.1%
00000077:03545404_00000A04_00000000
(Blends RGB565 texture into an RGB565 buffer using alpha.)
Before: 29 inst/pixel, After: 27 inst/pixel, Improvement: 7.4%
2009-12-05 00:44:58 +08:00
|
|
|
virtual void UBFX(int cc, int Rd, int Rn, int lsb, int width);
|
2009-03-04 11:32:55 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
ARMAssembler(const ARMAssembler& rhs);
|
|
|
|
ARMAssembler& operator = (const ARMAssembler& rhs);
|
|
|
|
|
|
|
|
sp<Assembly> mAssembly;
|
|
|
|
uint32_t* mBase;
|
|
|
|
uint32_t* mPC;
|
|
|
|
uint32_t* mPrologPC;
|
|
|
|
int64_t mDuration;
|
|
|
|
|
|
|
|
struct branch_target_t {
|
|
|
|
inline branch_target_t() : label(0), pc(0) { }
|
|
|
|
inline branch_target_t(const char* l, uint32_t* p)
|
|
|
|
: label(l), pc(p) { }
|
|
|
|
const char* label;
|
|
|
|
uint32_t* pc;
|
|
|
|
};
|
|
|
|
|
|
|
|
Vector<branch_target_t> mBranchTargets;
|
|
|
|
KeyedVector< const char*, uint32_t* > mLabels;
|
|
|
|
KeyedVector< uint32_t*, const char* > mLabelsInverseMapping;
|
|
|
|
KeyedVector< uint32_t*, const char* > mComments;
|
|
|
|
};
|
|
|
|
|
|
|
|
}; // namespace android
|
|
|
|
|
|
|
|
#endif //ANDROID_ARMASSEMBLER_H
|