buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 1 | /* |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 2 | * Copyright (C) 2012 The Android Open Source Project |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 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 | |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 27 | namespace art { |
| 28 | |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 29 | #if defined(_CODEGEN_C) |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 30 | LIR *opRegImm(CompilationUnit* cUnit, OpKind op, int rDestSrc1, int value); |
| 31 | LIR *opRegReg(CompilationUnit* cUnit, OpKind op, int rDestSrc1, int rSrc2); |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 32 | LIR* opCmpImmBranch(CompilationUnit* cUnit, ConditionCode cond, int reg, |
| 33 | int checkValue, LIR* target); |
buzbee | c5159d5 | 2012-03-03 11:48:39 -0800 | [diff] [blame] | 34 | bool genNegLong(CompilationUnit* cUnit, MIR* mir, RegLocation rlDest, |
| 35 | RegLocation rlSrc); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 36 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 37 | /* Forward declaraton the portable versions due to circular dependency */ |
| 38 | bool genArithOpFloatPortable(CompilationUnit* cUnit, MIR* mir, |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 39 | RegLocation rlDest, RegLocation rlSrc1, |
| 40 | RegLocation rlSrc2); |
| 41 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 42 | bool genArithOpDoublePortable(CompilationUnit* cUnit, MIR* mir, |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 43 | RegLocation rlDest, RegLocation rlSrc1, |
| 44 | RegLocation rlSrc2); |
| 45 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 46 | bool genConversionPortable(CompilationUnit* cUnit, MIR* mir); |
| 47 | |
| 48 | ArmConditionCode oatArmConditionEncoding(ConditionCode code); |
| 49 | |
| 50 | int loadHelper(CompilationUnit* cUnit, int offset); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 51 | LIR* loadConstant(CompilationUnit* cUnit, int reg, int immVal); |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 52 | void opRegCopyWide(CompilationUnit* cUnit, int destLo, int destHi, |
| 53 | int srcLo, int srcHi); |
| 54 | LIR* opRegCopy(CompilationUnit* cUnit, int rDest, int rSrc); |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 55 | void 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 | */ |
| 65 | inline 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 |
| 81 | inline s4 s4FromSwitchData(const void* switchData) { |
| 82 | return *(s4*) switchData; |
| 83 | } |
| 84 | #else |
| 85 | inline s4 s4FromSwitchData(const void* switchData) { |
| 86 | u2* data = switchData; |
| 87 | return data[0] | (((s4) data[1]) << 16); |
| 88 | } |
| 89 | #endif |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 90 | |
| 91 | #endif |
| 92 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 93 | extern void oatSetupResourceMasks(LIR* lir); |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 94 | |
buzbee | 31a4a6f | 2012-02-28 15:36:15 -0800 | [diff] [blame] | 95 | extern LIR* oatRegCopyNoInsert(CompilationUnit* cUnit, int rDest, |
buzbee | 67bf885 | 2011-08-17 17:51:35 -0700 | [diff] [blame] | 96 | int rSrc); |
Elliott Hughes | 11d1b0c | 2012-01-23 16:57:47 -0800 | [diff] [blame] | 97 | |
| 98 | } // namespace art |