1 /* 2 * Copyright (C) 2015 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 #ifndef ART_COMPILER_OPTIMIZING_INTRINSICS_ARM64_H_ 18 #define ART_COMPILER_OPTIMIZING_INTRINSICS_ARM64_H_ 19 20 #include "base/macros.h" 21 #include "intrinsics.h" 22 #include "intrinsics_list.h" 23 24 namespace vixl { 25 namespace aarch64 { 26 27 class MacroAssembler; 28 29 } // namespace aarch64 30 } // namespace vixl 31 32 namespace art HIDDEN { 33 34 class ArenaAllocator; 35 class HInvokeStaticOrDirect; 36 class HInvokeVirtual; 37 38 namespace arm64 { 39 40 class CodeGeneratorARM64; 41 42 class IntrinsicLocationsBuilderARM64 final : public IntrinsicVisitor { 43 public: IntrinsicLocationsBuilderARM64(ArenaAllocator * allocator,CodeGeneratorARM64 * codegen)44 explicit IntrinsicLocationsBuilderARM64(ArenaAllocator* allocator, CodeGeneratorARM64* codegen) 45 : allocator_(allocator), codegen_(codegen) {} 46 47 // Define visitor methods. 48 49 #define OPTIMIZING_INTRINSICS(Name, IsStatic, NeedsEnvironmentOrCache, SideEffects, Exceptions, ...) \ 50 void Visit ## Name(HInvoke* invoke) override; 51 ART_INTRINSICS_WITH_HINVOKE_LIST(OPTIMIZING_INTRINSICS) 52 #undef OPTIMIZING_INTRINSICS 53 54 // Check whether an invoke is an intrinsic, and if so, create a location summary. Returns whether 55 // a corresponding LocationSummary with the intrinsified_ flag set was generated and attached to 56 // the invoke. 57 bool TryDispatch(HInvoke* invoke); 58 59 private: 60 ArenaAllocator* const allocator_; 61 CodeGeneratorARM64* const codegen_; 62 63 DISALLOW_COPY_AND_ASSIGN(IntrinsicLocationsBuilderARM64); 64 }; 65 66 class IntrinsicCodeGeneratorARM64 final : public IntrinsicVisitor { 67 public: IntrinsicCodeGeneratorARM64(CodeGeneratorARM64 * codegen)68 explicit IntrinsicCodeGeneratorARM64(CodeGeneratorARM64* codegen) : codegen_(codegen) {} 69 70 // Define visitor methods. 71 72 #define OPTIMIZING_INTRINSICS(Name, IsStatic, NeedsEnvironmentOrCache, SideEffects, Exceptions, ...) \ 73 void Visit ## Name(HInvoke* invoke) override; 74 ART_INTRINSICS_WITH_HINVOKE_LIST(OPTIMIZING_INTRINSICS) 75 #undef OPTIMIZING_INTRINSICS 76 77 private: 78 vixl::aarch64::MacroAssembler* GetVIXLAssembler(); 79 80 ArenaAllocator* GetAllocator(); 81 82 void HandleValueOf(HInvoke* invoke, 83 const IntrinsicVisitor::ValueOfInfo& info, 84 DataType::Type type); 85 86 CodeGeneratorARM64* const codegen_; 87 88 DISALLOW_COPY_AND_ASSIGN(IntrinsicCodeGeneratorARM64); 89 }; 90 91 } // namespace arm64 92 } // namespace art 93 94 #endif // ART_COMPILER_OPTIMIZING_INTRINSICS_ARM64_H_ 95