blob: 2fb2df21b44e7ae1013481c1c1a82eac38ba4cda [file] [log] [blame]
buzbeee88dfbf2012-03-05 11:19:57 -08001/*
2 * Copyright (C) 2012 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 * This file contains register alloction support and is intended to be
19 * included by:
20 *
21 * Codegen-$(TARGET_ARCH_VARIANT).c
22 *
23 */
24
25#include "../../CompilerIR.h"
26
27namespace art {
28
29#if defined(_CODEGEN_C)
30bool genAddLong(CompilationUnit* cUnit, MIR* mir, RegLocation rlDest,
31 RegLocation rlSrc1, RegLocation rlSrc2);
32bool genSubLong(CompilationUnit* cUnit, MIR* mir, RegLocation rlDest,
33 RegLocation rlSrc1, RegLocation rlSrc2);
34bool genNegLong(CompilationUnit* cUnit, MIR* mir, RegLocation rlDest,
35 RegLocation rlSrc);
36LIR *opRegImm(CompilationUnit* cUnit, OpKind op, int rDestSrc1, int value);
37LIR *opRegReg(CompilationUnit* cUnit, OpKind op, int rDestSrc1, int rSrc2);
38LIR* opCmpBranch(CompilationUnit* cUnit, ConditionCode cond, int src1,
39 int src2, LIR* target);
40LIR* opCmpImmBranch(CompilationUnit* cUnit, ConditionCode cond, int reg,
41 int checkValue, LIR* target);
42
Ian Rogers96ab4202012-03-05 19:51:02 -080043/* Forward declaration of the portable versions due to circular dependency */
buzbeee88dfbf2012-03-05 11:19:57 -080044bool genArithOpFloatPortable(CompilationUnit* cUnit, MIR* mir,
45 RegLocation rlDest, RegLocation rlSrc1,
46 RegLocation rlSrc2);
47
48bool genArithOpDoublePortable(CompilationUnit* cUnit, MIR* mir,
49 RegLocation rlDest, RegLocation rlSrc1,
50 RegLocation rlSrc2);
51
52bool genConversionPortable(CompilationUnit* cUnit, MIR* mir);
53
54int loadHelper(CompilationUnit* cUnit, int offset);
55LIR* callRuntimeHelper(CompilationUnit* cUnit, int reg);
56RegLocation getRetLoc(CompilationUnit* cUnit);
57LIR* loadConstant(CompilationUnit* cUnit, int reg, int immVal);
58void opRegCopyWide(CompilationUnit* cUnit, int destLo, int destHi,
59 int srcLo, int srcHi);
60LIR* opRegCopy(CompilationUnit* cUnit, int rDest, int rSrc);
61void freeRegLocTemps(CompilationUnit* cUnit, RegLocation rlKeep,
62 RegLocation rlFree);
63
64
65/*
66 * Return most flexible allowed register class based on size.
67 * Bug: 2813841
68 * Must use a core register for data types narrower than word (due
69 * to possible unaligned load/store.
70 */
71inline RegisterClass oatRegClassBySize(OpSize size)
72{
73 return (size == kUnsignedHalf ||
74 size == kSignedHalf ||
75 size == kUnsignedByte ||
76 size == kSignedByte ) ? kCoreReg : kAnyReg;
77}
78
79/*
80 * Construct an s4 from two consecutive half-words of switch data.
81 * This needs to check endianness because the DEX optimizer only swaps
82 * half-words in instruction stream.
83 *
84 * "switchData" must be 32-bit aligned.
85 */
86#if __BYTE_ORDER == __LITTLE_ENDIAN
87inline s4 s4FromSwitchData(const void* switchData) {
88 return *(s4*) switchData;
89}
90#else
91inline s4 s4FromSwitchData(const void* switchData) {
92 u2* data = switchData;
93 return data[0] | (((s4) data[1]) << 16);
94}
95#endif
96
97#endif
98
99extern void oatSetupResourceMasks(LIR* lir);
100
101extern LIR* oatRegCopyNoInsert(CompilationUnit* cUnit, int rDest,
102 int rSrc);
103
104} // namespace art