Andreas Gampe | 097f34c | 2017-08-23 08:57:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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_DEX2OAT_DEX2OAT_OPTIONS_H_ |
| 18 | #define ART_DEX2OAT_DEX2OAT_OPTIONS_H_ |
| 19 | |
| 20 | #include <cstdio> |
| 21 | #include <string> |
| 22 | #include <vector> |
| 23 | |
David Sehr | c431b9d | 2018-03-02 12:01:51 -0800 | [diff] [blame] | 24 | #include "arch/instruction_set.h" |
Andreas Gampe | 097f34c | 2017-08-23 08:57:51 -0700 | [diff] [blame] | 25 | #include "base/variant_map.h" |
Andreas Gampe | 097f34c | 2017-08-23 08:57:51 -0700 | [diff] [blame] | 26 | #include "cmdline_types.h" // TODO: don't need to include this file here |
| 27 | #include "compiler.h" |
David Sehr | 9e734c7 | 2018-01-04 17:56:19 -0800 | [diff] [blame] | 28 | #include "dex/compact_dex_level.h" |
Andreas Gampe | 097f34c | 2017-08-23 08:57:51 -0700 | [diff] [blame] | 29 | #include "driver/compiler_options_map.h" |
| 30 | #include "image.h" |
Andreas Gampe | 1554417 | 2018-06-25 15:09:06 -0700 | [diff] [blame] | 31 | #include "linker/oat_writer.h" |
Andreas Gampe | 097f34c | 2017-08-23 08:57:51 -0700 | [diff] [blame] | 32 | |
| 33 | namespace art { |
| 34 | |
| 35 | template <typename TVariantMap, |
| 36 | template <typename TKeyValue> class TVariantMapKey> |
| 37 | struct CmdlineParser; |
| 38 | |
| 39 | // Define a key that is usable with a Dex2oatArgumentMap. |
| 40 | // This key will *not* work with other subtypes of VariantMap. |
| 41 | template <typename TValue> |
| 42 | struct Dex2oatArgumentMapKey : VariantMapKey<TValue> { |
| 43 | Dex2oatArgumentMapKey() {} |
| 44 | explicit Dex2oatArgumentMapKey(TValue default_value) |
| 45 | : VariantMapKey<TValue>(std::move(default_value)) {} |
| 46 | // Don't ODR-use constexpr default values, which means that Struct::Fields |
| 47 | // that are declared 'static constexpr T Name = Value' don't need to have a matching definition. |
| 48 | }; |
| 49 | |
| 50 | // Defines a type-safe heterogeneous key->value map. |
| 51 | // Use the VariantMap interface to look up or to store a Dex2oatArgumentMapKey,Value pair. |
| 52 | // |
| 53 | // Example: |
| 54 | // auto map = Dex2oatArgumentMap(); |
| 55 | // map.Set(Dex2oatArgumentMap::ZipFd, -1); |
| 56 | // int *target_utilization = map.Get(Dex2oatArgumentMap::ZipFd); |
| 57 | // |
| 58 | struct Dex2oatArgumentMap : CompilerOptionsMap<Dex2oatArgumentMap, Dex2oatArgumentMapKey> { |
| 59 | // This 'using' line is necessary to inherit the variadic constructor. |
| 60 | using CompilerOptionsMap<Dex2oatArgumentMap, Dex2oatArgumentMapKey>::CompilerOptionsMap; |
| 61 | |
| 62 | static std::unique_ptr<Dex2oatArgumentMap> Parse(int argc, |
| 63 | const char** argv, |
| 64 | std::string* error_msg); |
| 65 | |
| 66 | // Make the next many usages of Key slightly shorter to type. |
| 67 | template <typename TValue> |
| 68 | using Key = Dex2oatArgumentMapKey<TValue>; |
| 69 | |
| 70 | // List of key declarations, shorthand for 'static const Key<T> Name' |
| 71 | #define DEX2OAT_OPTIONS_KEY(Type, Name, ...) static const Key<Type> (Name); |
| 72 | #include "dex2oat_options.def" |
| 73 | }; |
| 74 | |
Alex Light | 0d47a82 | 2020-08-25 09:16:34 -0700 | [diff] [blame] | 75 | CmdlineParser<Dex2oatArgumentMap, Dex2oatArgumentMap::Key> CreateDex2oatArgumentParser(); |
| 76 | |
Andreas Gampe | 097f34c | 2017-08-23 08:57:51 -0700 | [diff] [blame] | 77 | extern template struct CompilerOptionsMap<Dex2oatArgumentMap, Dex2oatArgumentMapKey>; |
| 78 | |
| 79 | } // namespace art |
| 80 | |
| 81 | #endif // ART_DEX2OAT_DEX2OAT_OPTIONS_H_ |