blob: 3b866ce9ba666ca22270897795b25d26238479c0 [file] [log] [blame]
buzbee67bf8852011-08-17 17:51:35 -07001/*
buzbee5de34942012-03-01 14:51:57 -08002 * Copyright (C) 2012 The Android Open Source Project
buzbee67bf8852011-08-17 17:51:35 -07003 *
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
Elliott Hughes11d1b0c2012-01-23 16:57:47 -080027namespace art {
28
buzbee67bf8852011-08-17 17:51:35 -070029#if defined(_CODEGEN_C)
buzbee31a4a6f2012-02-28 15:36:15 -080030LIR *opRegImm(CompilationUnit* cUnit, OpKind op, int rDestSrc1, int value);
31LIR *opRegReg(CompilationUnit* cUnit, OpKind op, int rDestSrc1, int rSrc2);
buzbee82488f52012-03-02 08:20:26 -080032LIR* opCmpImmBranch(CompilationUnit* cUnit, ConditionCode cond, int reg,
33 int checkValue, LIR* target);
buzbeec5159d52012-03-03 11:48:39 -080034bool genNegLong(CompilationUnit* cUnit, MIR* mir, RegLocation rlDest,
35 RegLocation rlSrc);
buzbee67bf8852011-08-17 17:51:35 -070036
buzbee31a4a6f2012-02-28 15:36:15 -080037/* Forward declaraton the portable versions due to circular dependency */
38bool genArithOpFloatPortable(CompilationUnit* cUnit, MIR* mir,
buzbee67bf8852011-08-17 17:51:35 -070039 RegLocation rlDest, RegLocation rlSrc1,
40 RegLocation rlSrc2);
41
buzbee31a4a6f2012-02-28 15:36:15 -080042bool genArithOpDoublePortable(CompilationUnit* cUnit, MIR* mir,
buzbee67bf8852011-08-17 17:51:35 -070043 RegLocation rlDest, RegLocation rlSrc1,
44 RegLocation rlSrc2);
45
buzbee31a4a6f2012-02-28 15:36:15 -080046bool genConversionPortable(CompilationUnit* cUnit, MIR* mir);
47
48ArmConditionCode oatArmConditionEncoding(ConditionCode code);
49
50int loadHelper(CompilationUnit* cUnit, int offset);
51LIR* callRuntimeHelper(CompilationUnit* cUnit, int reg);
52RegLocation getRetLoc(CompilationUnit* cUnit);
53LIR* loadConstant(CompilationUnit* cUnit, int reg, int immVal);
buzbee82488f52012-03-02 08:20:26 -080054void opRegCopyWide(CompilationUnit* cUnit, int destLo, int destHi,
55 int srcLo, int srcHi);
56LIR* opRegCopy(CompilationUnit* cUnit, int rDest, int rSrc);
buzbee31a4a6f2012-02-28 15:36:15 -080057void freeRegLocTemps(CompilationUnit* cUnit, RegLocation rlKeep,
58 RegLocation rlFree);
59
60
61/*
62 * Return most flexible allowed register class based on size.
63 * Bug: 2813841
64 * Must use a core register for data types narrower than word (due
65 * to possible unaligned load/store.
66 */
67inline RegisterClass oatRegClassBySize(OpSize size)
68{
69 return (size == kUnsignedHalf ||
70 size == kSignedHalf ||
71 size == kUnsignedByte ||
72 size == kSignedByte ) ? kCoreReg : kAnyReg;
73}
74
75/*
76 * Construct an s4 from two consecutive half-words of switch data.
77 * This needs to check endianness because the DEX optimizer only swaps
78 * half-words in instruction stream.
79 *
80 * "switchData" must be 32-bit aligned.
81 */
82#if __BYTE_ORDER == __LITTLE_ENDIAN
83inline s4 s4FromSwitchData(const void* switchData) {
84 return *(s4*) switchData;
85}
86#else
87inline s4 s4FromSwitchData(const void* switchData) {
88 u2* data = switchData;
89 return data[0] | (((s4) data[1]) << 16);
90}
91#endif
buzbee67bf8852011-08-17 17:51:35 -070092
93#endif
94
buzbee31a4a6f2012-02-28 15:36:15 -080095extern void oatSetupResourceMasks(LIR* lir);
buzbee67bf8852011-08-17 17:51:35 -070096
buzbee31a4a6f2012-02-28 15:36:15 -080097extern LIR* oatRegCopyNoInsert(CompilationUnit* cUnit, int rDest,
buzbee67bf8852011-08-17 17:51:35 -070098 int rSrc);
Elliott Hughes11d1b0c2012-01-23 16:57:47 -080099
100} // namespace art