blob: d6d49f8faa807290ee3b4ac87cb934c5c0d4b85e [file] [log] [blame]
Andreas Gampe3b165bc2016-08-01 22:07:04 -07001/*
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 Serov6287c232016-11-29 13:31:33 +000023#include "arm/jni_macro_assembler_arm_vixl.h"
Andreas Gampe3b165bc2016-08-01 22:07:04 -070024#endif
25#ifdef ART_ENABLE_CODEGEN_arm64
Andreas Gampedcf30142016-08-08 16:06:34 -070026#include "arm64/jni_macro_assembler_arm64.h"
Andreas Gampe3b165bc2016-08-01 22:07:04 -070027#endif
Andreas Gampe3b165bc2016-08-01 22:07:04 -070028#ifdef ART_ENABLE_CODEGEN_x86
Andreas Gampe9954e3b2016-08-05 20:34:39 -070029#include "x86/jni_macro_assembler_x86.h"
Andreas Gampe3b165bc2016-08-01 22:07:04 -070030#endif
31#ifdef ART_ENABLE_CODEGEN_x86_64
Andreas Gampe1ace16b2016-08-05 09:01:50 -070032#include "x86_64/jni_macro_assembler_x86_64.h"
Andreas Gampe3b165bc2016-08-01 22:07:04 -070033#endif
34#include "base/casts.h"
David Sehr1979c642018-04-26 14:41:18 -070035#include "base/globals.h"
David Sehr1ce2b3b2018-04-05 11:02:03 -070036#include "base/memory_region.h"
Andreas Gampe3b165bc2016-08-01 22:07:04 -070037
38namespace art {
39
40using MacroAsm32UniquePtr = std::unique_ptr<JNIMacroAssembler<PointerSize::k32>>;
41
42template <>
43MacroAsm32UniquePtr JNIMacroAssembler<PointerSize::k32>::Create(
Vladimir Markoe764d2e2017-10-05 14:35:55 +010044 ArenaAllocator* allocator,
Andreas Gampe3b165bc2016-08-01 22:07:04 -070045 InstructionSet instruction_set,
46 const InstructionSetFeatures* instruction_set_features) {
Vladimir Marko2c8123c2020-02-12 10:52:22 +000047 // TODO: Remove the parameter from API (not needed after Mips target was removed).
Andreas Gampe3b165bc2016-08-01 22:07:04 -070048 UNUSED(instruction_set_features);
Andreas Gampe3b165bc2016-08-01 22:07:04 -070049
50 switch (instruction_set) {
51#ifdef ART_ENABLE_CODEGEN_arm
Vladimir Marko33bff252017-11-01 14:35:42 +000052 case InstructionSet::kArm:
53 case InstructionSet::kThumb2:
Vladimir Markoe764d2e2017-10-05 14:35:55 +010054 return MacroAsm32UniquePtr(new (allocator) arm::ArmVIXLJNIMacroAssembler(allocator));
Andreas Gampe3b165bc2016-08-01 22:07:04 -070055#endif
Andreas Gampe3b165bc2016-08-01 22:07:04 -070056#ifdef ART_ENABLE_CODEGEN_x86
Vladimir Marko33bff252017-11-01 14:35:42 +000057 case InstructionSet::kX86:
Vladimir Markoe764d2e2017-10-05 14:35:55 +010058 return MacroAsm32UniquePtr(new (allocator) x86::X86JNIMacroAssembler(allocator));
Andreas Gampe3b165bc2016-08-01 22:07:04 -070059#endif
60 default:
61 LOG(FATAL) << "Unknown/unsupported 4B InstructionSet: " << instruction_set;
62 UNREACHABLE();
63 }
64}
65
66using MacroAsm64UniquePtr = std::unique_ptr<JNIMacroAssembler<PointerSize::k64>>;
67
68template <>
69MacroAsm64UniquePtr JNIMacroAssembler<PointerSize::k64>::Create(
Vladimir Markoe764d2e2017-10-05 14:35:55 +010070 ArenaAllocator* allocator,
Andreas Gampe3b165bc2016-08-01 22:07:04 -070071 InstructionSet instruction_set,
Goran Jakovljevic27af9372017-03-15 15:31:34 +010072 const InstructionSetFeatures* instruction_set_features) {
Vladimir Marko2c8123c2020-02-12 10:52:22 +000073 // TODO: Remove the parameter from API (not needed after Mips64 target was removed).
Goran Jakovljevic27af9372017-03-15 15:31:34 +010074 UNUSED(instruction_set_features);
Goran Jakovljevic27af9372017-03-15 15:31:34 +010075
Andreas Gampe3b165bc2016-08-01 22:07:04 -070076 switch (instruction_set) {
77#ifdef ART_ENABLE_CODEGEN_arm64
Vladimir Marko33bff252017-11-01 14:35:42 +000078 case InstructionSet::kArm64:
Vladimir Markoe764d2e2017-10-05 14:35:55 +010079 return MacroAsm64UniquePtr(new (allocator) arm64::Arm64JNIMacroAssembler(allocator));
Andreas Gampe3b165bc2016-08-01 22:07:04 -070080#endif
Andreas Gampe3b165bc2016-08-01 22:07:04 -070081#ifdef ART_ENABLE_CODEGEN_x86_64
Vladimir Marko33bff252017-11-01 14:35:42 +000082 case InstructionSet::kX86_64:
Vladimir Markoe764d2e2017-10-05 14:35:55 +010083 return MacroAsm64UniquePtr(new (allocator) x86_64::X86_64JNIMacroAssembler(allocator));
Andreas Gampe3b165bc2016-08-01 22:07:04 -070084#endif
85 default:
Vladimir Markoe764d2e2017-10-05 14:35:55 +010086 UNUSED(allocator);
Andreas Gampe3b165bc2016-08-01 22:07:04 -070087 LOG(FATAL) << "Unknown/unsupported 8B InstructionSet: " << instruction_set;
88 UNREACHABLE();
89 }
90}
91
92} // namespace art