Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 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_X86_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_INTRINSICS_X86_H_ |
| 19 | |
Vladimír Marko | 434d968 | 2022-11-04 14:04:17 +0000 | [diff] [blame] | 20 | #include "base/macros.h" |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 21 | #include "intrinsics.h" |
| 22 | |
Vladimír Marko | 434d968 | 2022-11-04 14:04:17 +0000 | [diff] [blame] | 23 | namespace art HIDDEN { |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 24 | |
| 25 | class ArenaAllocator; |
| 26 | class HInvokeStaticOrDirect; |
| 27 | class HInvokeVirtual; |
| 28 | |
| 29 | namespace x86 { |
| 30 | |
| 31 | class CodeGeneratorX86; |
| 32 | class X86Assembler; |
| 33 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 34 | class IntrinsicLocationsBuilderX86 final : public IntrinsicVisitor { |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 35 | public: |
Mark Mendell | fb8d279 | 2015-03-31 22:16:59 -0400 | [diff] [blame] | 36 | explicit IntrinsicLocationsBuilderX86(CodeGeneratorX86* codegen); |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 37 | |
| 38 | // Define visitor methods. |
| 39 | |
Nicolas Geoffray | 762869d | 2016-07-15 15:28:35 +0100 | [diff] [blame] | 40 | #define OPTIMIZING_INTRINSICS(Name, IsStatic, NeedsEnvironmentOrCache, SideEffects, Exceptions, ...) \ |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 41 | void Visit ## Name(HInvoke* invoke) override; |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 42 | #include "intrinsics_list.h" |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 43 | INTRINSICS_LIST(OPTIMIZING_INTRINSICS) |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 44 | #undef INTRINSICS_LIST |
| 45 | #undef OPTIMIZING_INTRINSICS |
| 46 | |
| 47 | // Check whether an invoke is an intrinsic, and if so, create a location summary. Returns whether |
| 48 | // a corresponding LocationSummary with the intrinsified_ flag set was generated and attached to |
| 49 | // the invoke. |
| 50 | bool TryDispatch(HInvoke* invoke); |
| 51 | |
| 52 | private: |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 53 | ArenaAllocator* const allocator_; |
| 54 | CodeGeneratorX86* const codegen_; |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 55 | |
| 56 | DISALLOW_COPY_AND_ASSIGN(IntrinsicLocationsBuilderX86); |
| 57 | }; |
| 58 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 59 | class IntrinsicCodeGeneratorX86 final : public IntrinsicVisitor { |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 60 | public: |
| 61 | explicit IntrinsicCodeGeneratorX86(CodeGeneratorX86* codegen) : codegen_(codegen) {} |
| 62 | |
| 63 | // Define visitor methods. |
| 64 | |
Nicolas Geoffray | 762869d | 2016-07-15 15:28:35 +0100 | [diff] [blame] | 65 | #define OPTIMIZING_INTRINSICS(Name, IsStatic, NeedsEnvironmentOrCache, SideEffects, Exceptions, ...) \ |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 66 | void Visit ## Name(HInvoke* invoke) override; |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 67 | #include "intrinsics_list.h" |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 68 | INTRINSICS_LIST(OPTIMIZING_INTRINSICS) |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 69 | #undef INTRINSICS_LIST |
| 70 | #undef OPTIMIZING_INTRINSICS |
| 71 | |
| 72 | private: |
| 73 | X86Assembler* GetAssembler(); |
| 74 | |
| 75 | ArenaAllocator* GetAllocator(); |
| 76 | |
Vladimir Marko | 69d310e | 2017-10-09 14:12:23 +0100 | [diff] [blame] | 77 | CodeGeneratorX86* const codegen_; |
Mark Mendell | 09ed1a3 | 2015-03-25 08:30:06 -0400 | [diff] [blame] | 78 | |
| 79 | DISALLOW_COPY_AND_ASSIGN(IntrinsicCodeGeneratorX86); |
| 80 | }; |
| 81 | |
| 82 | } // namespace x86 |
| 83 | } // namespace art |
| 84 | |
| 85 | #endif // ART_COMPILER_OPTIMIZING_INTRINSICS_X86_H_ |