blob: 22f615722846de50719e4edd1fa18cf0c508f10f [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);
buzbee408ad162012-06-06 16:45:18 -070034bool genNegLong(CompilationUnit* cUnit, RegLocation rlDest,
buzbeec5159d52012-03-03 11:48:39 -080035 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 */
buzbee408ad162012-06-06 16:45:18 -070038bool genArithOpFloatPortable(CompilationUnit* cUnit, Instruction::Code opcode,
Bill Buzbeea114add2012-05-03 15:00:40 -070039 RegLocation rlDest, RegLocation rlSrc1,
40 RegLocation rlSrc2);
buzbee67bf8852011-08-17 17:51:35 -070041
buzbee408ad162012-06-06 16:45:18 -070042bool genArithOpDoublePortable(CompilationUnit* cUnit, Instruction::Code opcode,
Bill Buzbeea114add2012-05-03 15:00:40 -070043 RegLocation rlDest, RegLocation rlSrc1,
44 RegLocation rlSrc2);
buzbee67bf8852011-08-17 17:51:35 -070045
buzbee408ad162012-06-06 16:45:18 -070046bool genConversionPortable(CompilationUnit* cUnit, Instruction::Code opcode,
47 RegLocation rlDest, RegLocation rlSrc);
buzbee31a4a6f2012-02-28 15:36:15 -080048
49ArmConditionCode oatArmConditionEncoding(ConditionCode code);
50
51int loadHelper(CompilationUnit* cUnit, int offset);
buzbee31a4a6f2012-02-28 15:36:15 -080052LIR* loadConstant(CompilationUnit* cUnit, int reg, int immVal);
buzbee82488f52012-03-02 08:20:26 -080053void opRegCopyWide(CompilationUnit* cUnit, int destLo, int destHi,
54 int srcLo, int srcHi);
55LIR* opRegCopy(CompilationUnit* cUnit, int rDest, int rSrc);
buzbee31a4a6f2012-02-28 15:36:15 -080056void freeRegLocTemps(CompilationUnit* cUnit, RegLocation rlKeep,
57 RegLocation rlFree);
58
59
60/*
61 * Return most flexible allowed register class based on size.
62 * Bug: 2813841
63 * Must use a core register for data types narrower than word (due
64 * to possible unaligned load/store.
65 */
66inline RegisterClass oatRegClassBySize(OpSize size)
67{
Bill Buzbeea114add2012-05-03 15:00:40 -070068 return (size == kUnsignedHalf ||
69 size == kSignedHalf ||
70 size == kUnsignedByte ||
71 size == kSignedByte ) ? kCoreReg : kAnyReg;
buzbee31a4a6f2012-02-28 15:36:15 -080072}
73
74/*
75 * Construct an s4 from two consecutive half-words of switch data.
76 * This needs to check endianness because the DEX optimizer only swaps
77 * half-words in instruction stream.
78 *
79 * "switchData" must be 32-bit aligned.
80 */
81#if __BYTE_ORDER == __LITTLE_ENDIAN
82inline s4 s4FromSwitchData(const void* switchData) {
Bill Buzbeea114add2012-05-03 15:00:40 -070083 return *(s4*) switchData;
buzbee31a4a6f2012-02-28 15:36:15 -080084}
85#else
86inline s4 s4FromSwitchData(const void* switchData) {
Bill Buzbeea114add2012-05-03 15:00:40 -070087 u2* data = switchData;
88 return data[0] | (((s4) data[1]) << 16);
buzbee31a4a6f2012-02-28 15:36:15 -080089}
90#endif
buzbee67bf8852011-08-17 17:51:35 -070091
92#endif
93
buzbee31a4a6f2012-02-28 15:36:15 -080094extern void oatSetupResourceMasks(LIR* lir);
buzbee67bf8852011-08-17 17:51:35 -070095
Bill Buzbeea114add2012-05-03 15:00:40 -070096extern LIR* oatRegCopyNoInsert(CompilationUnit* cUnit, int rDest, int rSrc);
Elliott Hughes11d1b0c2012-01-23 16:57:47 -080097
98} // namespace art