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 | ** |
Mark Salyzyn | 66ce3e0 | 2016-09-28 10:07:20 -0700 | [diff] [blame] | 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 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 8 | ** |
Mark Salyzyn | 66ce3e0 | 2016-09-28 10:07:20 -0700 | [diff] [blame] | 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 10 | ** |
Mark Salyzyn | 66ce3e0 | 2016-09-28 10:07:20 -0700 | [diff] [blame] | 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 |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 15 | ** limitations under the License. |
| 16 | */ |
Mark Salyzyn | cfd5b08 | 2016-10-17 14:28:00 -0700 | [diff] [blame] | 17 | #define LOG_TAG "pixelflinger-code" |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 18 | |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 19 | #include <errno.h> |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 20 | #include <stdint.h> |
Mark Salyzyn | 66ce3e0 | 2016-09-28 10:07:20 -0700 | [diff] [blame] | 21 | #include <stdlib.h> |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 22 | #include <sys/types.h> |
| 23 | |
Mark Salyzyn | 66ce3e0 | 2016-09-28 10:07:20 -0700 | [diff] [blame] | 24 | #include <android/log.h> |
| 25 | |
Mathias Agopian | 9857d99 | 2013-04-01 15:17:55 -0700 | [diff] [blame] | 26 | #include "ARMAssemblerInterface.h" |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | |
| 30 | // ---------------------------------------------------------------------------- |
| 31 | |
| 32 | ARMAssemblerInterface::~ARMAssemblerInterface() |
| 33 | { |
| 34 | } |
| 35 | |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 36 | // -------------------------------------------------------------------- |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 37 | |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 38 | // The following two functions are static and used for initializers |
| 39 | // in the original ARM code. The above versions (without __), are now |
| 40 | // virtual, and can be overridden in the MIPS code. But since these are |
| 41 | // needed at initialization time, they must be static. Not thrilled with |
| 42 | // this implementation, but it works... |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 43 | |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 44 | 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] | 45 | { |
| 46 | LOG_ALWAYS_FATAL_IF(abs(immed12) >= 0x800, |
| 47 | "LDR(B)/STR(B)/PLD immediate too big (%08x)", |
| 48 | immed12); |
| 49 | return (1<<24) | (((uint32_t(immed12)>>31)^1)<<23) | |
| 50 | ((W&1)<<21) | (abs(immed12)&0x7FF); |
| 51 | } |
| 52 | |
Paul Lind | 2bc2b79 | 2012-02-01 10:54:19 -0800 | [diff] [blame] | 53 | 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] | 54 | { |
| 55 | uint32_t offset = abs(immed8); |
| 56 | |
| 57 | LOG_ALWAYS_FATAL_IF(abs(immed8) >= 0x100, |
| 58 | "LDRH/LDRSB/LDRSH/STRH immediate too big (%08x)", |
| 59 | immed8); |
| 60 | |
| 61 | return (1<<24) | (1<<22) | (((uint32_t(immed8)>>31)^1)<<23) | |
| 62 | ((W&1)<<21) | (((offset&0xF0)<<4)|(offset&0xF)); |
| 63 | } |
| 64 | |
Ashok Bhat | bfc6dc4 | 2013-02-21 10:27:40 +0000 | [diff] [blame] | 65 | // The following four functions are required for address manipulation |
| 66 | // These are virtual functions, which can be overridden by architectures |
| 67 | // 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] | 68 | |
Ashok Bhat | bfc6dc4 | 2013-02-21 10:27:40 +0000 | [diff] [blame] | 69 | void ARMAssemblerInterface::ADDR_LDR(int cc, int Rd, |
| 70 | int Rn, uint32_t offset) |
| 71 | { |
| 72 | LDR(cc, Rd, Rn, offset); |
| 73 | } |
| 74 | void ARMAssemblerInterface::ADDR_STR(int cc, int Rd, |
| 75 | int Rn, uint32_t offset) |
| 76 | { |
| 77 | STR(cc, Rd, Rn, offset); |
| 78 | } |
| 79 | void ARMAssemblerInterface::ADDR_ADD(int cc, int s, |
| 80 | int Rd, int Rn, uint32_t Op2) |
| 81 | { |
| 82 | dataProcessing(opADD, cc, s, Rd, Rn, Op2); |
| 83 | } |
| 84 | void ARMAssemblerInterface::ADDR_SUB(int cc, int s, |
| 85 | int Rd, int Rn, uint32_t Op2) |
| 86 | { |
| 87 | dataProcessing(opSUB, cc, s, Rd, Rn, Op2); |
| 88 | } |
The Android Open Source Project | dd7bc33 | 2009-03-03 19:32:55 -0800 | [diff] [blame] | 89 | }; // namespace android |
| 90 | |