blob: f467d4ffd3305203ee1e7ed787c9540c19c0b0f0 [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);
buzbee31a4a6f2012-02-28 15:36:15 -080051LIR* loadConstant(CompilationUnit* cUnit, int reg, int immVal);
buzbee82488f52012-03-02 08:20:26 -080052void opRegCopyWide(CompilationUnit* cUnit, int destLo, int destHi,
53 int srcLo, int srcHi);
54LIR* opRegCopy(CompilationUnit* cUnit, int rDest, int rSrc);
buzbee31a4a6f2012-02-28 15:36:15 -080055void freeRegLocTemps(CompilationUnit* cUnit, RegLocation rlKeep,
56 RegLocation rlFree);
57
58
59/*
60 * Return most flexible allowed register class based on size.
61 * Bug: 2813841
62 * Must use a core register for data types narrower than word (due
63 * to possible unaligned load/store.
64 */
65inline RegisterClass oatRegClassBySize(OpSize size)
66{
67 return (size == kUnsignedHalf ||
68 size == kSignedHalf ||
69 size == kUnsignedByte ||
70 size == kSignedByte ) ? kCoreReg : kAnyReg;
71}
72
73/*
74 * Construct an s4 from two consecutive half-words of switch data.
75 * This needs to check endianness because the DEX optimizer only swaps
76 * half-words in instruction stream.
77 *
78 * "switchData" must be 32-bit aligned.
79 */
80#if __BYTE_ORDER == __LITTLE_ENDIAN
81inline s4 s4FromSwitchData(const void* switchData) {
82 return *(s4*) switchData;
83}
84#else
85inline s4 s4FromSwitchData(const void* switchData) {
86 u2* data = switchData;
87 return data[0] | (((s4) data[1]) << 16);
88}
89#endif
buzbee67bf8852011-08-17 17:51:35 -070090
91#endif
92
buzbee31a4a6f2012-02-28 15:36:15 -080093extern void oatSetupResourceMasks(LIR* lir);
buzbee67bf8852011-08-17 17:51:35 -070094
buzbee31a4a6f2012-02-28 15:36:15 -080095extern LIR* oatRegCopyNoInsert(CompilationUnit* cUnit, int rDest,
buzbee67bf8852011-08-17 17:51:35 -070096 int rSrc);
Elliott Hughes11d1b0c2012-01-23 16:57:47 -080097
98} // namespace art