blob: 6ddc5ac21096bd0962343cecd4fc561f0ec09a84 [file] [log] [blame]
buzbeee3acd072012-02-25 17:03:10 -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)
buzbeec5159d52012-03-03 11:48:39 -080030bool 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);
buzbee5de34942012-03-01 14:51:57 -080036LIR *opRegImm(CompilationUnit* cUnit, OpKind op, int rDestSrc1, int value);
37LIR *opRegReg(CompilationUnit* cUnit, OpKind op, int rDestSrc1, int rSrc2);
buzbee82488f52012-03-02 08:20:26 -080038LIR* 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);
buzbeee3acd072012-02-25 17:03:10 -080042
buzbee5de34942012-03-01 14:51:57 -080043/* Forward declaraton the portable versions due to circular dependency */
44bool genArithOpFloatPortable(CompilationUnit* cUnit, MIR* mir,
buzbeee3acd072012-02-25 17:03:10 -080045 RegLocation rlDest, RegLocation rlSrc1,
46 RegLocation rlSrc2);
47
buzbee5de34942012-03-01 14:51:57 -080048bool genArithOpDoublePortable(CompilationUnit* cUnit, MIR* mir,
buzbeee3acd072012-02-25 17:03:10 -080049 RegLocation rlDest, RegLocation rlSrc1,
50 RegLocation rlSrc2);
51
buzbee5de34942012-03-01 14:51:57 -080052bool genConversionPortable(CompilationUnit* cUnit, MIR* mir);
53
buzbee5de34942012-03-01 14:51:57 -080054int loadHelper(CompilationUnit* cUnit, int offset);
buzbee5de34942012-03-01 14:51:57 -080055LIR* loadConstant(CompilationUnit* cUnit, int reg, int immVal);
buzbee82488f52012-03-02 08:20:26 -080056void opRegCopyWide(CompilationUnit* cUnit, int destLo, int destHi,
57 int srcLo, int srcHi);
58LIR* opRegCopy(CompilationUnit* cUnit, int rDest, int rSrc);
buzbee5de34942012-03-01 14:51:57 -080059void freeRegLocTemps(CompilationUnit* cUnit, RegLocation rlKeep,
60 RegLocation rlFree);
61
62
63/*
64 * Return most flexible allowed register class based on size.
65 * Bug: 2813841
66 * Must use a core register for data types narrower than word (due
67 * to possible unaligned load/store.
68 */
69inline RegisterClass oatRegClassBySize(OpSize size)
70{
Bill Buzbeea114add2012-05-03 15:00:40 -070071 return (size == kUnsignedHalf ||
72 size == kSignedHalf ||
73 size == kUnsignedByte ||
74 size == kSignedByte ) ? kCoreReg : kAnyReg;
buzbee5de34942012-03-01 14:51:57 -080075}
76
77/*
78 * Construct an s4 from two consecutive half-words of switch data.
79 * This needs to check endianness because the DEX optimizer only swaps
80 * half-words in instruction stream.
81 *
82 * "switchData" must be 32-bit aligned.
83 */
84#if __BYTE_ORDER == __LITTLE_ENDIAN
85inline s4 s4FromSwitchData(const void* switchData) {
Bill Buzbeea114add2012-05-03 15:00:40 -070086 return *(s4*) switchData;
buzbee5de34942012-03-01 14:51:57 -080087}
88#else
89inline s4 s4FromSwitchData(const void* switchData) {
Bill Buzbeea114add2012-05-03 15:00:40 -070090 u2* data = switchData;
91 return data[0] | (((s4) data[1]) << 16);
buzbee5de34942012-03-01 14:51:57 -080092}
93#endif
buzbeee3acd072012-02-25 17:03:10 -080094
95#endif
96
buzbee5de34942012-03-01 14:51:57 -080097extern void oatSetupResourceMasks(LIR* lir);
buzbeee3acd072012-02-25 17:03:10 -080098
Bill Buzbeea114add2012-05-03 15:00:40 -070099extern LIR* oatRegCopyNoInsert(CompilationUnit* cUnit, int rDest, int rSrc);
buzbeee3acd072012-02-25 17:03:10 -0800100
101} // namespace art