blob: 86cb221752918387f01fbbfa6275cc513d8dbd23 [file] [log] [blame]
Nicolas Capensdaa5d912016-09-28 16:56:36 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
Nicolas Capens48461502018-08-06 14:20:45 -040015#ifndef rr_LLVMRoutine_hpp
16#define rr_LLVMRoutine_hpp
Nicolas Capensdaa5d912016-09-28 16:56:36 -040017
18#include "Routine.hpp"
19
Logan Chien0eedc8c2018-08-21 09:34:28 +080020#include <cstdint>
Ben Clayton1c82c7b2019-04-30 12:49:27 +010021#include <stddef.h>
22#include <vector>
Logan Chien0eedc8c2018-08-21 09:34:28 +080023
Nicolas Capens48461502018-08-06 14:20:45 -040024namespace rr
Nicolas Capensdaa5d912016-09-28 16:56:36 -040025{
Logan Chien0eedc8c2018-08-21 09:34:28 +080026 class LLVMReactorJIT;
27
28 class LLVMRoutine : public Routine
29 {
30 public:
Ben Clayton1c82c7b2019-04-30 12:49:27 +010031 LLVMRoutine(void **entries, size_t entry_count,
32 void (*callback)(LLVMReactorJIT *, uint64_t),
Logan Chienb5ce5092018-09-27 18:45:58 +080033 LLVMReactorJIT *jit, uint64_t key)
Ben Clayton1c82c7b2019-04-30 12:49:27 +010034 : entries(entries, entries+entry_count),
35 dtor(callback), reactorJIT(jit), moduleKey(key)
Logan Chien0eedc8c2018-08-21 09:34:28 +080036 { }
37
38 virtual ~LLVMRoutine();
39
Ben Clayton1c82c7b2019-04-30 12:49:27 +010040 const void *getEntry(int index)
Logan Chien0eedc8c2018-08-21 09:34:28 +080041 {
Ben Clayton1c82c7b2019-04-30 12:49:27 +010042 return entries[index];
Logan Chien0eedc8c2018-08-21 09:34:28 +080043 }
44
45 private:
Ben Clayton1c82c7b2019-04-30 12:49:27 +010046 const std::vector<const void *> entries;
Logan Chien0eedc8c2018-08-21 09:34:28 +080047
48 void (*dtor)(LLVMReactorJIT *, uint64_t);
49 LLVMReactorJIT *reactorJIT;
50 uint64_t moduleKey;
51 };
Nicolas Capensdaa5d912016-09-28 16:56:36 -040052}
53
Nicolas Capens48461502018-08-06 14:20:45 -040054#endif // rr_LLVMRoutine_hpp