• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // 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 
15 #ifndef rr_LLVMRoutine_hpp
16 #define rr_LLVMRoutine_hpp
17 
18 #include "Routine.hpp"
19 
20 #include <cstdint>
21 
22 namespace rr
23 {
24 #if REACTOR_LLVM_VERSION < 7
25 	class LLVMRoutineManager;
26 
27 	class LLVMRoutine : public Routine
28 	{
29 		friend class LLVMRoutineManager;
30 
31 	public:
32 		LLVMRoutine(int bufferSize);
33 		//LLVMRoutine(void *memory, int bufferSize, int offset);
34 
35 		virtual ~LLVMRoutine();
36 
37 		//void setFunctionSize(int functionSize);
38 
39 		//const void *getBuffer();
40 		const void *getEntry();
41 		//int getBufferSize();
42 		//int getFunctionSize();   // Includes constants before the entry point
43 		int getCodeSize();       // Executable code only
44 		//bool isDynamic();
45 
46 	private:
47 		void *buffer;
48 		const void *entry;
49 		int bufferSize;
50 		int functionSize;
51 
52 		//const bool dynamic;   // Generated or precompiled
53 	};
54 #else
55 	class LLVMReactorJIT;
56 
57 	class LLVMRoutine : public Routine
58 	{
59 	public:
60 		LLVMRoutine(void *ent, void (*callback)(LLVMReactorJIT *, uint64_t),
61 		            LLVMReactorJIT *jit, uint64_t key)
62 			: entry(ent), dtor(callback), reactorJIT(jit), moduleKey(key)
63 		{ }
64 
65 		virtual ~LLVMRoutine();
66 
67 		const void *getEntry()
68 		{
69 			return entry;
70 		}
71 
72 	private:
73 		const void *entry;
74 
75 		void (*dtor)(LLVMReactorJIT *, uint64_t);
76 		LLVMReactorJIT *reactorJIT;
77 		uint64_t moduleKey;
78 	};
79 #endif  // REACTOR_LLVM_VERSION < 7
80 }
81 
82 #endif   // rr_LLVMRoutine_hpp
83