blob: e4a18408a89f98bb5066c7a6a8fbaf80e8135cd7 [file] [log] [blame]
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -07001/*
2 * Copyright (C) 2012 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#include "target_registry.h"
18
19#include "logging.h"
20
21namespace {
22
23// The following arrays contain the real registry data store by Register*()
24// methods in TargetRegistry. Should keep sync with enum InstructionSet.
25art::greenland::TargetRegistry::TargetCodeGenMachineCtorTy
26RegisteredTargetCodeGenMachineCtor[] = {
27 NULL, /* kNone */
28 NULL, /* kArm */
29 NULL, /* kThumb2 */
30 NULL, /* kX86 */
31 NULL, /* kMips */
32};
33
34art::greenland::TargetRegistry::CreateInvokeStubFn
35RegisteredInvokeStubCompiler[] = {
36 NULL, /* kNone */
37 NULL, /* kArm */
38 NULL, /* kThumb2 */
39 NULL, /* kX86 */
40 NULL, /* kMips */
41};
42
43} // anonymous namespace
44
45namespace art {
46namespace greenland {
47
48void TargetRegistry::RegisterTargetCodeGenMachine(InstructionSet insn_set,
49 TargetCodeGenMachineCtorTy ctor) {
50 CHECK(static_cast<unsigned>(insn_set) <
51 (sizeof(RegisteredTargetCodeGenMachineCtor) / sizeof(RegisteredTargetCodeGenMachineCtor[0])));
52 RegisteredTargetCodeGenMachineCtor[static_cast<unsigned>(insn_set)] = ctor;
53 return;
54}
55
56TargetRegistry::TargetCodeGenMachineCtorTy
57TargetRegistry::GetTargetCodeGenMachineCtor(InstructionSet insn_set) {
58 CHECK(static_cast<unsigned>(insn_set) <
59 (sizeof(RegisteredTargetCodeGenMachineCtor) / sizeof(RegisteredTargetCodeGenMachineCtor[0])));
60 return RegisteredTargetCodeGenMachineCtor[static_cast<unsigned>(insn_set)];
61}
62
63void
64TargetRegistry::RegisterInvokeStubCompiler(InstructionSet insn_set,
65 CreateInvokeStubFn compiler_fn) {
66 CHECK(static_cast<unsigned>(insn_set) <
67 (sizeof(RegisteredInvokeStubCompiler) / sizeof(RegisteredInvokeStubCompiler[0])));
68 RegisteredInvokeStubCompiler[static_cast<unsigned>(insn_set)] = compiler_fn;
69 return;
70}
71
72TargetRegistry::CreateInvokeStubFn
73TargetRegistry::GetInvokeStubCompiler(InstructionSet insn_set) {
74 CHECK(static_cast<unsigned>(insn_set) <
75 (sizeof(RegisteredInvokeStubCompiler) / sizeof(RegisteredInvokeStubCompiler[0])));
76 return RegisteredInvokeStubCompiler[static_cast<unsigned>(insn_set)];
77}
78
79} // namespace greenland
80} // namespace art