diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2016-08-06 01:49:59 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2016-08-06 01:49:59 +0000 |
commit | 95a976a3d1842384ed71bcc6e6449de95ec69961 (patch) | |
tree | 6a587cf0f0d680708cf725da9ae0b0bfd5ce01c5 /compiler/utils/jni_macro_assembler.cc | |
parent | 3321f598f8d0b96a7c97e9d01a000c6e59c4562c (diff) | |
parent | 3b165bc53c2f063e3a9c644d0edc7bc30c634884 (diff) |
Merge "ART: Extract macro assembler"
Diffstat (limited to 'compiler/utils/jni_macro_assembler.cc')
-rw-r--r-- | compiler/utils/jni_macro_assembler.cc | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/compiler/utils/jni_macro_assembler.cc b/compiler/utils/jni_macro_assembler.cc new file mode 100644 index 0000000000..6c14888293 --- /dev/null +++ b/compiler/utils/jni_macro_assembler.cc @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2011 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "jni_macro_assembler.h" + +#include <algorithm> +#include <vector> + +#ifdef ART_ENABLE_CODEGEN_arm +#include "arm/assembler_arm32.h" +#include "arm/assembler_thumb2.h" +#endif +#ifdef ART_ENABLE_CODEGEN_arm64 +#include "arm64/assembler_arm64.h" +#endif +#ifdef ART_ENABLE_CODEGEN_mips +#include "mips/assembler_mips.h" +#endif +#ifdef ART_ENABLE_CODEGEN_mips64 +#include "mips64/assembler_mips64.h" +#endif +#ifdef ART_ENABLE_CODEGEN_x86 +#include "x86/assembler_x86.h" +#endif +#ifdef ART_ENABLE_CODEGEN_x86_64 +#include "x86_64/assembler_x86_64.h" +#endif +#include "base/casts.h" +#include "globals.h" +#include "memory_region.h" + +namespace art { + +using MacroAsm32UniquePtr = std::unique_ptr<JNIMacroAssembler<PointerSize::k32>>; + +template <> +MacroAsm32UniquePtr JNIMacroAssembler<PointerSize::k32>::Create( + ArenaAllocator* arena, + InstructionSet instruction_set, + const InstructionSetFeatures* instruction_set_features) { +#ifndef ART_ENABLE_CODEGEN_mips + UNUSED(instruction_set_features); +#endif + + switch (instruction_set) { +#ifdef ART_ENABLE_CODEGEN_arm + case kArm: + return MacroAsm32UniquePtr(new (arena) arm::Arm32Assembler(arena)); + case kThumb2: + return MacroAsm32UniquePtr(new (arena) arm::Thumb2Assembler(arena)); +#endif +#ifdef ART_ENABLE_CODEGEN_mips + case kMips: + return MacroAsm32UniquePtr(new (arena) mips::MipsAssembler( + arena, + instruction_set_features != nullptr + ? instruction_set_features->AsMipsInstructionSetFeatures() + : nullptr)); +#endif +#ifdef ART_ENABLE_CODEGEN_x86 + case kX86: + return MacroAsm32UniquePtr(new (arena) x86::X86Assembler(arena)); +#endif + default: + LOG(FATAL) << "Unknown/unsupported 4B InstructionSet: " << instruction_set; + UNREACHABLE(); + } +} + +using MacroAsm64UniquePtr = std::unique_ptr<JNIMacroAssembler<PointerSize::k64>>; + +template <> +MacroAsm64UniquePtr JNIMacroAssembler<PointerSize::k64>::Create( + ArenaAllocator* arena, + InstructionSet instruction_set, + const InstructionSetFeatures* instruction_set_features ATTRIBUTE_UNUSED) { + switch (instruction_set) { +#ifdef ART_ENABLE_CODEGEN_arm64 + case kArm64: + return MacroAsm64UniquePtr(new (arena) arm64::Arm64Assembler(arena)); +#endif +#ifdef ART_ENABLE_CODEGEN_mips64 + case kMips64: + return MacroAsm64UniquePtr(new (arena) mips64::Mips64Assembler(arena)); +#endif +#ifdef ART_ENABLE_CODEGEN_x86_64 + case kX86_64: + return MacroAsm64UniquePtr(new (arena) x86_64::X86_64Assembler(arena)); +#endif + default: + LOG(FATAL) << "Unknown/unsupported 8B InstructionSet: " << instruction_set; + UNREACHABLE(); + } +} + +} // namespace art |