• 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_LLVMRoutineManager_hpp
16 #define rr_LLVMRoutineManager_hpp
17 
18 #if REACTOR_LLVM_VERSION < 7
19 
20 #include "llvm/ExecutionEngine/JITMemoryManager.h"
21 #include "llvm/GlobalValue.h"
22 
23 namespace rr
24 {
25 	class LLVMRoutine;
26 
27 	class LLVMRoutineManager : public llvm::JITMemoryManager
28 	{
29 	public:
30 		LLVMRoutineManager();
31 
32 		virtual ~LLVMRoutineManager();
33 
34 		virtual void AllocateGOT();
35 
36 		virtual uint8_t *allocateStub(const llvm::GlobalValue *function, unsigned stubSize, unsigned alignment);
37 		virtual uint8_t *startFunctionBody(const llvm::Function *function, uintptr_t &actualSize);
38 		virtual void endFunctionBody(const llvm::Function *function, uint8_t *functionStart, uint8_t *functionEnd);
39 		virtual uint8_t *startExceptionTable(const llvm::Function *function, uintptr_t &ActualSize);
40 		virtual void endExceptionTable(const llvm::Function *function, uint8_t *tableStart, uint8_t *tableEnd, uint8_t *frameRegister);
41 		virtual uint8_t *getGOTBase() const;
42 		virtual uint8_t *allocateSpace(intptr_t Size, unsigned Alignment);
43 		virtual uint8_t *allocateGlobal(uintptr_t Size, unsigned int Alignment);
44 		virtual void deallocateFunctionBody(void *Body);
45 		virtual void deallocateExceptionTable(void *ET);
46 		virtual void setMemoryWritable();
47 		virtual void setMemoryExecutable();
48 		virtual void setPoisonMemory(bool poison);
49 
50 		LLVMRoutine *acquireRoutine(void *entry);
51 
52 	private:
53 		LLVMRoutine *routine;
54 
55 		static volatile int averageInstructionSize;
56 	};
57 }
58 
59 #endif  // REACTOR_LLVM_VERSION < 7
60 
61 #endif   // rr_LLVMRoutineManager_hpp
62