The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 1 | /* libs/pixelflinger/codeflinger/ARMAssemblerInterface.cpp |
| 2 | ** |
| 3 | ** Copyright 2006, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | |
| 19 | #include <errno.h> |
| 20 | #include <stdlib.h> |
| 21 | #include <stdint.h> |
| 22 | #include <sys/types.h> |
| 23 | |
| 24 | #include <cutils/log.h> |
Mathias Agopian | 9857d99 | 2013-04-01 15:17:55 -0700 | [diff] [blame] | 25 | #include "ARMAssemblerInterface.h" |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | // ---------------------------------------------------------------------------- |
| 30 | |
| 31 | ARMAssemblerInterface::~ARMAssemblerInterface() |
| 32 | { |
| 33 | } |
| 34 | |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 35 | // -------------------------------------------------------------------- |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 36 | |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 37 | // The following two functions are static and used for initializers |
| 38 | // in the original ARM code. The above versions (without __), are now |
| 39 | // virtual, and can be overridden in the MIPS code. But since these are |
| 40 | // needed at initialization time, they must be static. Not thrilled with |
| 41 | // this implementation, but it works... |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 42 | |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 43 | uint32_t ARMAssemblerInterface::__immed12_pre(int32_t immed12, int W) |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 44 | { |
| 45 | LOG_ALWAYS_FATAL_IF(abs(immed12) >= 0x800, |
| 46 | "LDR(B)/STR(B)/PLD immediate too big (%08x)", |
| 47 | immed12); |
| 48 | return (1<<24) | (((uint32_t(immed12)>>31)^1)<<23) | |
| 49 | ((W&1)<<21) | (abs(immed12)&0x7FF); |
| 50 | } |
| 51 | |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 52 | uint32_t ARMAssemblerInterface::__immed8_pre(int32_t immed8, int W) |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 53 | { |
| 54 | uint32_t offset = abs(immed8); |
| 55 | |
| 56 | LOG_ALWAYS_FATAL_IF(abs(immed8) >= 0x100, |
| 57 | "LDRH/LDRSB/LDRSH/STRH immediate too big (%08x)", |
| 58 | immed8); |
| 59 | |
| 60 | return (1<<24) | (1<<22) | (((uint32_t(immed8)>>31)^1)<<23) | |
| 61 | ((W&1)<<21) | (((offset&0xF0)<<4)|(offset&0xF)); |
| 62 | } |
| 63 | |
Ashok Bhat | bfc6dc4 | 2013-02-21 10:27:40 +0000 | [diff] [blame] | 64 | // The following four functions are required for address manipulation |
| 65 | // These are virtual functions, which can be overridden by architectures |
| 66 | // that need special handling of address values (e.g. 64-bit arch) |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 67 | |
Ashok Bhat | bfc6dc4 | 2013-02-21 10:27:40 +0000 | [diff] [blame] | 68 | void ARMAssemblerInterface::ADDR_LDR(int cc, int Rd, |
| 69 | int Rn, uint32_t offset) |
| 70 | { |
| 71 | LDR(cc, Rd, Rn, offset); |
| 72 | } |
| 73 | void ARMAssemblerInterface::ADDR_STR(int cc, int Rd, |
| 74 | int Rn, uint32_t offset) |
| 75 | { |
| 76 | STR(cc, Rd, Rn, offset); |
| 77 | } |
| 78 | void ARMAssemblerInterface::ADDR_ADD(int cc, int s, |
| 79 | int Rd, int Rn, uint32_t Op2) |
| 80 | { |
| 81 | dataProcessing(opADD, cc, s, Rd, Rn, Op2); |
| 82 | } |
| 83 | void ARMAssemblerInterface::ADDR_SUB(int cc, int s, |
| 84 | int Rd, int Rn, uint32_t Op2) |
| 85 | { |
| 86 | dataProcessing(opSUB, cc, s, Rd, Rn, Op2); |
| 87 | } |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 88 | }; // namespace android |
| 89 | |