blob: 767487373190670669e60826cdd3e908e422a01b [file] [log] [blame]
Andreas Gampe98430592014-07-27 19:44:50 -07001/*
2 * Copyright (C) 2014 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_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_
18#define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_
19
20#include "quick_entrypoints.h"
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080021#include "quick_entrypoints_enum.h"
Andreas Gampe98430592014-07-27 19:44:50 -070022#include "thread.h"
23
24namespace art {
25
26// Define an enum for the entrypoints. Names are prepended a 'kQuick'.
27enum QuickEntrypointEnum
28{ // NOLINT(whitespace/braces)
29#define ENTRYPOINT_ENUM(name, rettype, ...) kQuick ## name,
30#include "quick_entrypoints_list.h"
31 QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
32#undef QUICK_ENTRYPOINT_LIST
33#undef ENTRYPOINT_ENUM
34};
35
36std::ostream& operator<<(std::ostream& os, const QuickEntrypointEnum& kind);
37
38// Translate a QuickEntrypointEnum value to the corresponding ThreadOffset.
Andreas Gampe542451c2016-07-26 09:02:02 -070039template <PointerSize pointer_size>
Andreas Gampe98430592014-07-27 19:44:50 -070040static ThreadOffset<pointer_size> GetThreadOffset(QuickEntrypointEnum trampoline) {
41 switch (trampoline)
42 { // NOLINT(whitespace/braces)
43 #define ENTRYPOINT_ENUM(name, rettype, ...) case kQuick ## name : \
44 return QUICK_ENTRYPOINT_OFFSET(pointer_size, p ## name);
45 #include "quick_entrypoints_list.h"
46 QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
47 #undef QUICK_ENTRYPOINT_LIST
48 #undef ENTRYPOINT_ENUM
49 };
50 LOG(FATAL) << "Unexpected trampoline " << static_cast<int>(trampoline);
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080051 UNREACHABLE();
Andreas Gampe98430592014-07-27 19:44:50 -070052}
53
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080054// Do a check functions to be able to test whether the right signature is used.
55template <QuickEntrypointEnum entrypoint, typename... Types>
56void CheckEntrypointTypes();
Andreas Gampe98430592014-07-27 19:44:50 -070057
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080058#define ENTRYPOINT_ENUM(name, ...) \
59template <> inline void CheckEntrypointTypes<kQuick ## name, __VA_ARGS__>() {}; // NOLINT [readability/braces] [4]
60#include "quick_entrypoints_list.h"
61 QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
62#undef QUICK_ENTRYPOINT_LIST
63#undef ENTRYPOINT_ENUM
64
Serban Constantinescuda8ffec2016-03-09 12:02:11 +000065bool EntrypointRequiresStackMap(QuickEntrypointEnum trampoline);
66
Andreas Gampe1cc7dba2014-12-17 18:43:01 -080067} // namespace art
Andreas Gampe98430592014-07-27 19:44:50 -070068
69#endif // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_