buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 27 | namespace art { |
| 28 | |
| 29 | #if defined(_CODEGEN_C) |
buzbee | 408ad16 | 2012-06-06 16:45:18 -0700 | [diff] [blame^] | 30 | bool genAddLong(CompilationUnit* cUnit, RegLocation rlDest, |
buzbee | c5159d5 | 2012-03-03 11:48:39 -0800 | [diff] [blame] | 31 | RegLocation rlSrc1, RegLocation rlSrc2); |
buzbee | 408ad16 | 2012-06-06 16:45:18 -0700 | [diff] [blame^] | 32 | bool genSubLong(CompilationUnit* cUnit, RegLocation rlDest, |
buzbee | c5159d5 | 2012-03-03 11:48:39 -0800 | [diff] [blame] | 33 | RegLocation rlSrc1, RegLocation rlSrc2); |
buzbee | 408ad16 | 2012-06-06 16:45:18 -0700 | [diff] [blame^] | 34 | bool genNegLong(CompilationUnit* cUnit, RegLocation rlDest, |
buzbee | c5159d5 | 2012-03-03 11:48:39 -0800 | [diff] [blame] | 35 | RegLocation rlSrc); |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 36 | LIR *opRegImm(CompilationUnit* cUnit, OpKind op, int rDestSrc1, int value); |
| 37 | LIR *opRegReg(CompilationUnit* cUnit, OpKind op, int rDestSrc1, int rSrc2); |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 38 | LIR* opCmpBranch(CompilationUnit* cUnit, ConditionCode cond, int src1, |
| 39 | int src2, LIR* target); |
| 40 | LIR* opCmpImmBranch(CompilationUnit* cUnit, ConditionCode cond, int reg, |
| 41 | int checkValue, LIR* target); |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 42 | |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 43 | /* Forward declaraton the portable versions due to circular dependency */ |
buzbee | 408ad16 | 2012-06-06 16:45:18 -0700 | [diff] [blame^] | 44 | bool genArithOpFloatPortable(CompilationUnit* cUnit, Instruction::Code opcode, |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 45 | RegLocation rlDest, RegLocation rlSrc1, |
| 46 | RegLocation rlSrc2); |
| 47 | |
buzbee | 408ad16 | 2012-06-06 16:45:18 -0700 | [diff] [blame^] | 48 | bool genArithOpDoublePortable(CompilationUnit* cUnit, Instruction::Code opcode, |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 49 | RegLocation rlDest, RegLocation rlSrc1, |
| 50 | RegLocation rlSrc2); |
| 51 | |
buzbee | 408ad16 | 2012-06-06 16:45:18 -0700 | [diff] [blame^] | 52 | bool genConversionPortable(CompilationUnit* cUnit, Instruction::Code opcode, |
| 53 | RegLocation rlDest, RegLocation rlSrc); |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 54 | |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 55 | int loadHelper(CompilationUnit* cUnit, int offset); |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 56 | LIR* loadConstant(CompilationUnit* cUnit, int reg, int immVal); |
buzbee | 82488f5 | 2012-03-02 08:20:26 -0800 | [diff] [blame] | 57 | void opRegCopyWide(CompilationUnit* cUnit, int destLo, int destHi, |
| 58 | int srcLo, int srcHi); |
| 59 | LIR* opRegCopy(CompilationUnit* cUnit, int rDest, int rSrc); |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 60 | void freeRegLocTemps(CompilationUnit* cUnit, RegLocation rlKeep, |
| 61 | RegLocation rlFree); |
| 62 | |
| 63 | |
| 64 | /* |
| 65 | * Return most flexible allowed register class based on size. |
| 66 | * Bug: 2813841 |
| 67 | * Must use a core register for data types narrower than word (due |
| 68 | * to possible unaligned load/store. |
| 69 | */ |
| 70 | inline RegisterClass oatRegClassBySize(OpSize size) |
| 71 | { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 72 | return (size == kUnsignedHalf || |
| 73 | size == kSignedHalf || |
| 74 | size == kUnsignedByte || |
| 75 | size == kSignedByte ) ? kCoreReg : kAnyReg; |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | /* |
| 79 | * Construct an s4 from two consecutive half-words of switch data. |
| 80 | * This needs to check endianness because the DEX optimizer only swaps |
| 81 | * half-words in instruction stream. |
| 82 | * |
| 83 | * "switchData" must be 32-bit aligned. |
| 84 | */ |
| 85 | #if __BYTE_ORDER == __LITTLE_ENDIAN |
| 86 | inline s4 s4FromSwitchData(const void* switchData) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 87 | return *(s4*) switchData; |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 88 | } |
| 89 | #else |
| 90 | inline s4 s4FromSwitchData(const void* switchData) { |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 91 | u2* data = switchData; |
| 92 | return data[0] | (((s4) data[1]) << 16); |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 93 | } |
| 94 | #endif |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 95 | |
| 96 | #endif |
| 97 | |
buzbee | 5de3494 | 2012-03-01 14:51:57 -0800 | [diff] [blame] | 98 | extern void oatSetupResourceMasks(LIR* lir); |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 99 | |
Bill Buzbee | a114add | 2012-05-03 15:00:40 -0700 | [diff] [blame] | 100 | extern LIR* oatRegCopyNoInsert(CompilationUnit* cUnit, int rDest, int rSrc); |
buzbee | e3acd07 | 2012-02-25 17:03:10 -0800 | [diff] [blame] | 101 | |
| 102 | } // namespace art |