1984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe/*
2984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe * Copyright (C) 2014 The Android Open Source Project
3984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe *
4984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe * Licensed under the Apache License, Version 2.0 (the "License");
5984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe * you may not use this file except in compliance with the License.
6984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe * You may obtain a copy of the License at
7984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe *
8984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe *      http://www.apache.org/licenses/LICENSE-2.0
9984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe *
10984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe * Unless required by applicable law or agreed to in writing, software
11984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe * distributed under the License is distributed on an "AS IS" BASIS,
12984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe * See the License for the specific language governing permissions and
14984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe * limitations under the License.
15984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe */
16984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe
17984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#ifndef ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_
18984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#define ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_
19984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe
20984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#include "quick_entrypoints.h"
21984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#include "thread.h"
22984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe
23984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampenamespace art {
24984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe
25984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe// Define an enum for the entrypoints. Names are prepended a 'kQuick'.
26984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampeenum QuickEntrypointEnum
27984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe{  // NOLINT(whitespace/braces)
28984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#define ENTRYPOINT_ENUM(name, rettype, ...) kQuick ## name,
29984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#include "quick_entrypoints_list.h"
30984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe  QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
31984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#undef QUICK_ENTRYPOINT_LIST
32984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#undef ENTRYPOINT_ENUM
33984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe};
34984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe
35984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampestd::ostream& operator<<(std::ostream& os, const QuickEntrypointEnum& kind);
36984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe
37984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe// Translate a QuickEntrypointEnum value to the corresponding ThreadOffset.
38984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampetemplate <size_t pointer_size>
39984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampestatic ThreadOffset<pointer_size> GetThreadOffset(QuickEntrypointEnum trampoline) {
40984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe  switch (trampoline)
41984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe  {  // NOLINT(whitespace/braces)
42984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe  #define ENTRYPOINT_ENUM(name, rettype, ...) case kQuick ## name : \
43984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe      return QUICK_ENTRYPOINT_OFFSET(pointer_size, p ## name);
44984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe  #include "quick_entrypoints_list.h"
45984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe    QUICK_ENTRYPOINT_LIST(ENTRYPOINT_ENUM)
46984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe  #undef QUICK_ENTRYPOINT_LIST
47984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe  #undef ENTRYPOINT_ENUM
48984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe  };
49984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe  LOG(FATAL) << "Unexpected trampoline " << static_cast<int>(trampoline);
50984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe  return ThreadOffset<pointer_size>(-1);
51984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe}
52984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe
53984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe}  // namespace art
54984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe
55984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe
56984305917bf57b3f8d92965e4715a0370cc5bcfbAndreas Gampe#endif  // ART_RUNTIME_ENTRYPOINTS_QUICK_QUICK_ENTRYPOINTS_ENUM_H_
57