Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 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 | #include "jni_macro_assembler.h" |
| 18 | |
| 19 | #include <algorithm> |
| 20 | #include <vector> |
| 21 | |
| 22 | #ifdef ART_ENABLE_CODEGEN_arm |
Artem Serov | 6287c23 | 2016-11-29 13:31:33 +0000 | [diff] [blame] | 23 | #include "arm/jni_macro_assembler_arm_vixl.h" |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 24 | #endif |
| 25 | #ifdef ART_ENABLE_CODEGEN_arm64 |
Andreas Gampe | dcf3014 | 2016-08-08 16:06:34 -0700 | [diff] [blame] | 26 | #include "arm64/jni_macro_assembler_arm64.h" |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 27 | #endif |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 28 | #ifdef ART_ENABLE_CODEGEN_x86 |
Andreas Gampe | 9954e3b | 2016-08-05 20:34:39 -0700 | [diff] [blame] | 29 | #include "x86/jni_macro_assembler_x86.h" |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 30 | #endif |
| 31 | #ifdef ART_ENABLE_CODEGEN_x86_64 |
Andreas Gampe | 1ace16b | 2016-08-05 09:01:50 -0700 | [diff] [blame] | 32 | #include "x86_64/jni_macro_assembler_x86_64.h" |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 33 | #endif |
| 34 | #include "base/casts.h" |
David Sehr | 1979c64 | 2018-04-26 14:41:18 -0700 | [diff] [blame] | 35 | #include "base/globals.h" |
David Sehr | 1ce2b3b | 2018-04-05 11:02:03 -0700 | [diff] [blame] | 36 | #include "base/memory_region.h" |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 37 | |
| 38 | namespace art { |
| 39 | |
| 40 | using MacroAsm32UniquePtr = std::unique_ptr<JNIMacroAssembler<PointerSize::k32>>; |
| 41 | |
| 42 | template <> |
| 43 | MacroAsm32UniquePtr JNIMacroAssembler<PointerSize::k32>::Create( |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 44 | ArenaAllocator* allocator, |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 45 | InstructionSet instruction_set, |
| 46 | const InstructionSetFeatures* instruction_set_features) { |
Vladimir Marko | 2c8123c | 2020-02-12 10:52:22 +0000 | [diff] [blame] | 47 | // TODO: Remove the parameter from API (not needed after Mips target was removed). |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 48 | UNUSED(instruction_set_features); |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 49 | |
| 50 | switch (instruction_set) { |
| 51 | #ifdef ART_ENABLE_CODEGEN_arm |
Vladimir Marko | 33bff25 | 2017-11-01 14:35:42 +0000 | [diff] [blame] | 52 | case InstructionSet::kArm: |
| 53 | case InstructionSet::kThumb2: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 54 | return MacroAsm32UniquePtr(new (allocator) arm::ArmVIXLJNIMacroAssembler(allocator)); |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 55 | #endif |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 56 | #ifdef ART_ENABLE_CODEGEN_x86 |
Vladimir Marko | 33bff25 | 2017-11-01 14:35:42 +0000 | [diff] [blame] | 57 | case InstructionSet::kX86: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 58 | return MacroAsm32UniquePtr(new (allocator) x86::X86JNIMacroAssembler(allocator)); |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 59 | #endif |
| 60 | default: |
| 61 | LOG(FATAL) << "Unknown/unsupported 4B InstructionSet: " << instruction_set; |
| 62 | UNREACHABLE(); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | using MacroAsm64UniquePtr = std::unique_ptr<JNIMacroAssembler<PointerSize::k64>>; |
| 67 | |
| 68 | template <> |
| 69 | MacroAsm64UniquePtr JNIMacroAssembler<PointerSize::k64>::Create( |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 70 | ArenaAllocator* allocator, |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 71 | InstructionSet instruction_set, |
Goran Jakovljevic | 27af937 | 2017-03-15 15:31:34 +0100 | [diff] [blame] | 72 | const InstructionSetFeatures* instruction_set_features) { |
Vladimir Marko | 2c8123c | 2020-02-12 10:52:22 +0000 | [diff] [blame] | 73 | // TODO: Remove the parameter from API (not needed after Mips64 target was removed). |
Goran Jakovljevic | 27af937 | 2017-03-15 15:31:34 +0100 | [diff] [blame] | 74 | UNUSED(instruction_set_features); |
Goran Jakovljevic | 27af937 | 2017-03-15 15:31:34 +0100 | [diff] [blame] | 75 | |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 76 | switch (instruction_set) { |
| 77 | #ifdef ART_ENABLE_CODEGEN_arm64 |
Vladimir Marko | 33bff25 | 2017-11-01 14:35:42 +0000 | [diff] [blame] | 78 | case InstructionSet::kArm64: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 79 | return MacroAsm64UniquePtr(new (allocator) arm64::Arm64JNIMacroAssembler(allocator)); |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 80 | #endif |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 81 | #ifdef ART_ENABLE_CODEGEN_x86_64 |
Vladimir Marko | 33bff25 | 2017-11-01 14:35:42 +0000 | [diff] [blame] | 82 | case InstructionSet::kX86_64: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 83 | return MacroAsm64UniquePtr(new (allocator) x86_64::X86_64JNIMacroAssembler(allocator)); |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 84 | #endif |
| 85 | default: |
Vladimir Marko | e764d2e | 2017-10-05 14:35:55 +0100 | [diff] [blame] | 86 | UNUSED(allocator); |
Andreas Gampe | 3b165bc | 2016-08-01 22:07:04 -0700 | [diff] [blame] | 87 | LOG(FATAL) << "Unknown/unsupported 8B InstructionSet: " << instruction_set; |
| 88 | UNREACHABLE(); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | } // namespace art |