mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Reinstate "Nuke the old JIT."
Approved by Jim Grosbach, Lang Hames, Rafael Espindola. This reinstates commits r215111, 215115, 215116, 215117, 215136. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216982 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -34,7 +34,6 @@ extern "C" {
|
||||
* @{
|
||||
*/
|
||||
|
||||
void LLVMLinkInJIT(void);
|
||||
void LLVMLinkInMCJIT(void);
|
||||
void LLVMLinkInInterpreter(void);
|
||||
|
||||
|
@@ -1,344 +0,0 @@
|
||||
//===-- llvm/CodeGen/JITCodeEmitter.h - Code emission ----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines an abstract interface that is used by the machine code
|
||||
// emission framework to output the code. This allows machine code emission to
|
||||
// be separated from concerns such as resolution of call targets, and where the
|
||||
// machine code will be written (memory or disk, f.e.).
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CODEGEN_JITCODEEMITTER_H
|
||||
#define LLVM_CODEGEN_JITCODEEMITTER_H
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include <string>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class MachineBasicBlock;
|
||||
class MachineConstantPool;
|
||||
class MachineJumpTableInfo;
|
||||
class MachineFunction;
|
||||
class MachineModuleInfo;
|
||||
class MachineRelocation;
|
||||
class Value;
|
||||
class GlobalValue;
|
||||
class Function;
|
||||
|
||||
/// JITCodeEmitter - This class defines two sorts of methods: those for
|
||||
/// emitting the actual bytes of machine code, and those for emitting auxiliary
|
||||
/// structures, such as jump tables, relocations, etc.
|
||||
///
|
||||
/// Emission of machine code is complicated by the fact that we don't (in
|
||||
/// general) know the size of the machine code that we're about to emit before
|
||||
/// we emit it. As such, we preallocate a certain amount of memory, and set the
|
||||
/// BufferBegin/BufferEnd pointers to the start and end of the buffer. As we
|
||||
/// emit machine instructions, we advance the CurBufferPtr to indicate the
|
||||
/// location of the next byte to emit. In the case of a buffer overflow (we
|
||||
/// need to emit more machine code than we have allocated space for), the
|
||||
/// CurBufferPtr will saturate to BufferEnd and ignore stores. Once the entire
|
||||
/// function has been emitted, the overflow condition is checked, and if it has
|
||||
/// occurred, more memory is allocated, and we reemit the code into it.
|
||||
///
|
||||
class JITCodeEmitter : public MachineCodeEmitter {
|
||||
void anchor() override;
|
||||
public:
|
||||
virtual ~JITCodeEmitter() {}
|
||||
|
||||
/// startFunction - This callback is invoked when the specified function is
|
||||
/// about to be code generated. This initializes the BufferBegin/End/Ptr
|
||||
/// fields.
|
||||
///
|
||||
void startFunction(MachineFunction &F) override = 0;
|
||||
|
||||
/// finishFunction - This callback is invoked when the specified function has
|
||||
/// finished code generation. If a buffer overflow has occurred, this method
|
||||
/// returns true (the callee is required to try again), otherwise it returns
|
||||
/// false.
|
||||
///
|
||||
bool finishFunction(MachineFunction &F) override = 0;
|
||||
|
||||
/// allocIndirectGV - Allocates and fills storage for an indirect
|
||||
/// GlobalValue, and returns the address.
|
||||
virtual void *allocIndirectGV(const GlobalValue *GV,
|
||||
const uint8_t *Buffer, size_t Size,
|
||||
unsigned Alignment) = 0;
|
||||
|
||||
/// emitByte - This callback is invoked when a byte needs to be written to the
|
||||
/// output stream.
|
||||
///
|
||||
void emitByte(uint8_t B) {
|
||||
if (CurBufferPtr != BufferEnd)
|
||||
*CurBufferPtr++ = B;
|
||||
}
|
||||
|
||||
/// emitWordLE - This callback is invoked when a 32-bit word needs to be
|
||||
/// written to the output stream in little-endian format.
|
||||
///
|
||||
void emitWordLE(uint32_t W) {
|
||||
if (4 <= BufferEnd-CurBufferPtr) {
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 0);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 8);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 16);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 24);
|
||||
} else {
|
||||
CurBufferPtr = BufferEnd;
|
||||
}
|
||||
}
|
||||
|
||||
/// emitWordBE - This callback is invoked when a 32-bit word needs to be
|
||||
/// written to the output stream in big-endian format.
|
||||
///
|
||||
void emitWordBE(uint32_t W) {
|
||||
if (4 <= BufferEnd-CurBufferPtr) {
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 24);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 16);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 8);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 0);
|
||||
} else {
|
||||
CurBufferPtr = BufferEnd;
|
||||
}
|
||||
}
|
||||
|
||||
/// emitDWordLE - This callback is invoked when a 64-bit word needs to be
|
||||
/// written to the output stream in little-endian format.
|
||||
///
|
||||
void emitDWordLE(uint64_t W) {
|
||||
if (8 <= BufferEnd-CurBufferPtr) {
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 0);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 8);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 16);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 24);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 32);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 40);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 48);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 56);
|
||||
} else {
|
||||
CurBufferPtr = BufferEnd;
|
||||
}
|
||||
}
|
||||
|
||||
/// emitDWordBE - This callback is invoked when a 64-bit word needs to be
|
||||
/// written to the output stream in big-endian format.
|
||||
///
|
||||
void emitDWordBE(uint64_t W) {
|
||||
if (8 <= BufferEnd-CurBufferPtr) {
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 56);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 48);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 40);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 32);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 24);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 16);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 8);
|
||||
*CurBufferPtr++ = (uint8_t)(W >> 0);
|
||||
} else {
|
||||
CurBufferPtr = BufferEnd;
|
||||
}
|
||||
}
|
||||
|
||||
/// emitAlignment - Move the CurBufferPtr pointer up to the specified
|
||||
/// alignment (saturated to BufferEnd of course).
|
||||
void emitAlignment(unsigned Alignment) {
|
||||
if (Alignment == 0) Alignment = 1;
|
||||
uint8_t *NewPtr = (uint8_t*)RoundUpToAlignment((uintptr_t)CurBufferPtr,
|
||||
Alignment);
|
||||
CurBufferPtr = std::min(NewPtr, BufferEnd);
|
||||
}
|
||||
|
||||
/// emitAlignmentWithFill - Similar to emitAlignment, except that the
|
||||
/// extra bytes are filled with the provided byte.
|
||||
void emitAlignmentWithFill(unsigned Alignment, uint8_t Fill) {
|
||||
if (Alignment == 0) Alignment = 1;
|
||||
uint8_t *NewPtr = (uint8_t*)RoundUpToAlignment((uintptr_t)CurBufferPtr,
|
||||
Alignment);
|
||||
// Fail if we don't have room.
|
||||
if (NewPtr > BufferEnd) {
|
||||
CurBufferPtr = BufferEnd;
|
||||
return;
|
||||
}
|
||||
while (CurBufferPtr < NewPtr) {
|
||||
*CurBufferPtr++ = Fill;
|
||||
}
|
||||
}
|
||||
|
||||
/// emitULEB128Bytes - This callback is invoked when a ULEB128 needs to be
|
||||
/// written to the output stream.
|
||||
void emitULEB128Bytes(uint64_t Value, unsigned PadTo = 0) {
|
||||
do {
|
||||
uint8_t Byte = Value & 0x7f;
|
||||
Value >>= 7;
|
||||
if (Value || PadTo != 0) Byte |= 0x80;
|
||||
emitByte(Byte);
|
||||
} while (Value);
|
||||
|
||||
if (PadTo) {
|
||||
do {
|
||||
uint8_t Byte = (PadTo > 1) ? 0x80 : 0x0;
|
||||
emitByte(Byte);
|
||||
} while (--PadTo);
|
||||
}
|
||||
}
|
||||
|
||||
/// emitSLEB128Bytes - This callback is invoked when a SLEB128 needs to be
|
||||
/// written to the output stream.
|
||||
void emitSLEB128Bytes(int64_t Value) {
|
||||
int32_t Sign = Value >> (8 * sizeof(Value) - 1);
|
||||
bool IsMore;
|
||||
|
||||
do {
|
||||
uint8_t Byte = Value & 0x7f;
|
||||
Value >>= 7;
|
||||
IsMore = Value != Sign || ((Byte ^ Sign) & 0x40) != 0;
|
||||
if (IsMore) Byte |= 0x80;
|
||||
emitByte(Byte);
|
||||
} while (IsMore);
|
||||
}
|
||||
|
||||
/// emitString - This callback is invoked when a String needs to be
|
||||
/// written to the output stream.
|
||||
void emitString(const std::string &String) {
|
||||
for (size_t i = 0, N = String.size(); i < N; ++i) {
|
||||
uint8_t C = String[i];
|
||||
emitByte(C);
|
||||
}
|
||||
emitByte(0);
|
||||
}
|
||||
|
||||
/// emitInt32 - Emit a int32 directive.
|
||||
void emitInt32(uint32_t Value) {
|
||||
if (4 <= BufferEnd-CurBufferPtr) {
|
||||
*((uint32_t*)CurBufferPtr) = Value;
|
||||
CurBufferPtr += 4;
|
||||
} else {
|
||||
CurBufferPtr = BufferEnd;
|
||||
}
|
||||
}
|
||||
|
||||
/// emitInt64 - Emit a int64 directive.
|
||||
void emitInt64(uint64_t Value) {
|
||||
if (8 <= BufferEnd-CurBufferPtr) {
|
||||
*((uint64_t*)CurBufferPtr) = Value;
|
||||
CurBufferPtr += 8;
|
||||
} else {
|
||||
CurBufferPtr = BufferEnd;
|
||||
}
|
||||
}
|
||||
|
||||
/// emitInt32At - Emit the Int32 Value in Addr.
|
||||
void emitInt32At(uintptr_t *Addr, uintptr_t Value) {
|
||||
if (Addr >= (uintptr_t*)BufferBegin && Addr < (uintptr_t*)BufferEnd)
|
||||
(*(uint32_t*)Addr) = (uint32_t)Value;
|
||||
}
|
||||
|
||||
/// emitInt64At - Emit the Int64 Value in Addr.
|
||||
void emitInt64At(uintptr_t *Addr, uintptr_t Value) {
|
||||
if (Addr >= (uintptr_t*)BufferBegin && Addr < (uintptr_t*)BufferEnd)
|
||||
(*(uint64_t*)Addr) = (uint64_t)Value;
|
||||
}
|
||||
|
||||
|
||||
/// emitLabel - Emits a label
|
||||
void emitLabel(MCSymbol *Label) override = 0;
|
||||
|
||||
/// allocateSpace - Allocate a block of space in the current output buffer,
|
||||
/// returning null (and setting conditions to indicate buffer overflow) on
|
||||
/// failure. Alignment is the alignment in bytes of the buffer desired.
|
||||
void *allocateSpace(uintptr_t Size, unsigned Alignment) override {
|
||||
emitAlignment(Alignment);
|
||||
void *Result;
|
||||
|
||||
// Check for buffer overflow.
|
||||
if (Size >= (uintptr_t)(BufferEnd-CurBufferPtr)) {
|
||||
CurBufferPtr = BufferEnd;
|
||||
Result = nullptr;
|
||||
} else {
|
||||
// Allocate the space.
|
||||
Result = CurBufferPtr;
|
||||
CurBufferPtr += Size;
|
||||
}
|
||||
|
||||
return Result;
|
||||
}
|
||||
|
||||
/// allocateGlobal - Allocate memory for a global. Unlike allocateSpace,
|
||||
/// this method does not allocate memory in the current output buffer,
|
||||
/// because a global may live longer than the current function.
|
||||
virtual void *allocateGlobal(uintptr_t Size, unsigned Alignment) = 0;
|
||||
|
||||
/// StartMachineBasicBlock - This should be called by the target when a new
|
||||
/// basic block is about to be emitted. This way the MCE knows where the
|
||||
/// start of the block is, and can implement getMachineBasicBlockAddress.
|
||||
void StartMachineBasicBlock(MachineBasicBlock *MBB) override = 0;
|
||||
|
||||
/// getCurrentPCValue - This returns the address that the next emitted byte
|
||||
/// will be output to.
|
||||
///
|
||||
uintptr_t getCurrentPCValue() const override {
|
||||
return (uintptr_t)CurBufferPtr;
|
||||
}
|
||||
|
||||
/// getCurrentPCOffset - Return the offset from the start of the emitted
|
||||
/// buffer that we are currently writing to.
|
||||
uintptr_t getCurrentPCOffset() const override {
|
||||
return CurBufferPtr-BufferBegin;
|
||||
}
|
||||
|
||||
/// earlyResolveAddresses - True if the code emitter can use symbol addresses
|
||||
/// during code emission time. The JIT is capable of doing this because it
|
||||
/// creates jump tables or constant pools in memory on the fly while the
|
||||
/// object code emitters rely on a linker to have real addresses and should
|
||||
/// use relocations instead.
|
||||
bool earlyResolveAddresses() const override { return true; }
|
||||
|
||||
/// addRelocation - Whenever a relocatable address is needed, it should be
|
||||
/// noted with this interface.
|
||||
void addRelocation(const MachineRelocation &MR) override = 0;
|
||||
|
||||
/// FIXME: These should all be handled with relocations!
|
||||
|
||||
/// getConstantPoolEntryAddress - Return the address of the 'Index' entry in
|
||||
/// the constant pool that was last emitted with the emitConstantPool method.
|
||||
///
|
||||
uintptr_t getConstantPoolEntryAddress(unsigned Index) const override = 0;
|
||||
|
||||
/// getJumpTableEntryAddress - Return the address of the jump table with index
|
||||
/// 'Index' in the function that last called initJumpTableInfo.
|
||||
///
|
||||
uintptr_t getJumpTableEntryAddress(unsigned Index) const override = 0;
|
||||
|
||||
/// getMachineBasicBlockAddress - Return the address of the specified
|
||||
/// MachineBasicBlock, only usable after the label for the MBB has been
|
||||
/// emitted.
|
||||
///
|
||||
uintptr_t
|
||||
getMachineBasicBlockAddress(MachineBasicBlock *MBB) const override = 0;
|
||||
|
||||
/// getLabelAddress - Return the address of the specified Label, only usable
|
||||
/// after the Label has been emitted.
|
||||
///
|
||||
uintptr_t getLabelAddress(MCSymbol *Label) const override = 0;
|
||||
|
||||
/// Specifies the MachineModuleInfo object. This is used for exception handling
|
||||
/// purposes.
|
||||
void setModuleInfo(MachineModuleInfo* Info) override = 0;
|
||||
|
||||
/// getLabelLocations - Return the label locations map of the label IDs to
|
||||
/// their address.
|
||||
virtual DenseMap<MCSymbol*, uintptr_t> *getLabelLocations() {
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@@ -139,15 +139,6 @@ protected:
|
||||
/// getMemoryforGV - Allocate memory for a global variable.
|
||||
virtual char *getMemoryForGV(const GlobalVariable *GV);
|
||||
|
||||
// To avoid having libexecutionengine depend on the JIT and interpreter
|
||||
// libraries, the execution engine implementations set these functions to ctor
|
||||
// pointers at startup time if they are linked in.
|
||||
static ExecutionEngine *(*JITCtor)(
|
||||
std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr,
|
||||
JITMemoryManager *JMM,
|
||||
bool GVsWithCode,
|
||||
TargetMachine *TM);
|
||||
static ExecutionEngine *(*MCJITCtor)(
|
||||
std::unique_ptr<Module> M,
|
||||
std::string *ErrorStr,
|
||||
@@ -336,13 +327,6 @@ public:
|
||||
/// getFunctionAddress instead.
|
||||
virtual void *getPointerToFunction(Function *F) = 0;
|
||||
|
||||
/// getPointerToBasicBlock - The different EE's represent basic blocks in
|
||||
/// different ways. Return the representation for a blockaddress of the
|
||||
/// specified block.
|
||||
///
|
||||
/// This function will not be implemented for the MCJIT execution engine.
|
||||
virtual void *getPointerToBasicBlock(BasicBlock *BB) = 0;
|
||||
|
||||
/// getPointerToFunctionOrStub - If the specified function has been
|
||||
/// code-gen'd, return a pointer to the function. If not, compile it, or use
|
||||
/// a stub to implement lazy compilation if available. See
|
||||
@@ -390,18 +374,6 @@ public:
|
||||
|
||||
void InitializeMemory(const Constant *Init, void *Addr);
|
||||
|
||||
/// recompileAndRelinkFunction - This method is used to force a function which
|
||||
/// has already been compiled to be compiled again, possibly after it has been
|
||||
/// modified. Then the entry to the old copy is overwritten with a branch to
|
||||
/// the new copy. If there was no old copy, this acts just like
|
||||
/// VM::getPointerToFunction().
|
||||
virtual void *recompileAndRelinkFunction(Function *F) = 0;
|
||||
|
||||
/// freeMachineCodeForFunction - Release memory in the ExecutionEngine
|
||||
/// corresponding to the machine code emitted to execute this function, useful
|
||||
/// for garbage-collecting generated code.
|
||||
virtual void freeMachineCodeForFunction(Function *F) = 0;
|
||||
|
||||
/// getOrEmitGlobalVariable - Return the address of the specified global
|
||||
/// variable, possibly emitting it to memory if needed. This is used by the
|
||||
/// Emitter.
|
||||
@@ -538,14 +510,12 @@ private:
|
||||
CodeGenOpt::Level OptLevel;
|
||||
RTDyldMemoryManager *MCJMM;
|
||||
JITMemoryManager *JMM;
|
||||
bool AllocateGVsWithCode;
|
||||
TargetOptions Options;
|
||||
Reloc::Model RelocModel;
|
||||
CodeModel::Model CMModel;
|
||||
std::string MArch;
|
||||
std::string MCPU;
|
||||
SmallVector<std::string, 4> MAttrs;
|
||||
bool UseMCJIT;
|
||||
bool VerifyModules;
|
||||
|
||||
/// InitEngine - Does the common initialization of default options.
|
||||
@@ -626,18 +596,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// setAllocateGVsWithCode - Sets whether global values should be allocated
|
||||
/// into the same buffer as code. For most applications this should be set
|
||||
/// to false. Allocating globals with code breaks freeMachineCodeForFunction
|
||||
/// and is probably unsafe and bad for performance. However, we have clients
|
||||
/// who depend on this behavior, so we must support it. This option defaults
|
||||
/// to false so that users of the new API can safely use the new memory
|
||||
/// manager and free machine code.
|
||||
EngineBuilder &setAllocateGVsWithCode(bool a) {
|
||||
AllocateGVsWithCode = a;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// setMArch - Override the architecture set by the Module's triple.
|
||||
EngineBuilder &setMArch(StringRef march) {
|
||||
MArch.assign(march.begin(), march.end());
|
||||
@@ -650,13 +608,6 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// setUseMCJIT - Set whether the MC-JIT implementation should be used
|
||||
/// (experimental).
|
||||
EngineBuilder &setUseMCJIT(bool Value) {
|
||||
UseMCJIT = Value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/// setVerifyModules - Set whether the JIT implementation should verify
|
||||
/// IR modules during compilation.
|
||||
EngineBuilder &setVerifyModules(bool Verify) {
|
||||
|
@@ -1,38 +0,0 @@
|
||||
//===-- JIT.h - Abstract Execution Engine Interface -------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file forces the JIT to link in on certain operating systems.
|
||||
// (Windows).
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_EXECUTIONENGINE_JIT_H
|
||||
#define LLVM_EXECUTIONENGINE_JIT_H
|
||||
|
||||
#include "llvm/ExecutionEngine/ExecutionEngine.h"
|
||||
#include <cstdlib>
|
||||
|
||||
extern "C" void LLVMLinkInJIT();
|
||||
|
||||
namespace {
|
||||
struct ForceJITLinking {
|
||||
ForceJITLinking() {
|
||||
// We must reference JIT in such a way that compilers will not
|
||||
// delete it all as dead code, even with whole program optimization,
|
||||
// yet is effectively a NO-OP. As the compiler isn't smart enough
|
||||
// to know that getenv() never returns -1, this will do the job.
|
||||
if (std::getenv("bar") != (char*) -1)
|
||||
return;
|
||||
|
||||
LLVMLinkInJIT();
|
||||
}
|
||||
} ForceJITLinking;
|
||||
}
|
||||
|
||||
#endif
|
@@ -1,136 +0,0 @@
|
||||
//===- Target/TargetJITInfo.h - Target Information for JIT ------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file exposes an abstract interface used by the Just-In-Time code
|
||||
// generator to perform target-specific activities, such as emitting stubs. If
|
||||
// a TargetMachine supports JIT code generation, it should provide one of these
|
||||
// objects through the getJITInfo() method.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TARGET_TARGETJITINFO_H
|
||||
#define LLVM_TARGET_TARGETJITINFO_H
|
||||
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include <cassert>
|
||||
|
||||
namespace llvm {
|
||||
class Function;
|
||||
class GlobalValue;
|
||||
class JITCodeEmitter;
|
||||
class MachineRelocation;
|
||||
|
||||
/// TargetJITInfo - Target specific information required by the Just-In-Time
|
||||
/// code generator.
|
||||
class TargetJITInfo {
|
||||
virtual void anchor();
|
||||
public:
|
||||
virtual ~TargetJITInfo() {}
|
||||
|
||||
/// replaceMachineCodeForFunction - Make it so that calling the function
|
||||
/// whose machine code is at OLD turns into a call to NEW, perhaps by
|
||||
/// overwriting OLD with a branch to NEW. This is used for self-modifying
|
||||
/// code.
|
||||
///
|
||||
virtual void replaceMachineCodeForFunction(void *Old, void *New) = 0;
|
||||
|
||||
/// emitGlobalValueIndirectSym - Use the specified JITCodeEmitter object
|
||||
/// to emit an indirect symbol which contains the address of the specified
|
||||
/// ptr.
|
||||
virtual void *emitGlobalValueIndirectSym(const GlobalValue* GV, void *ptr,
|
||||
JITCodeEmitter &JCE) {
|
||||
llvm_unreachable("This target doesn't implement "
|
||||
"emitGlobalValueIndirectSym!");
|
||||
}
|
||||
|
||||
/// Records the required size and alignment for a call stub in bytes.
|
||||
struct StubLayout {
|
||||
size_t Size;
|
||||
size_t Alignment;
|
||||
};
|
||||
/// Returns the maximum size and alignment for a call stub on this target.
|
||||
virtual StubLayout getStubLayout() {
|
||||
llvm_unreachable("This target doesn't implement getStubLayout!");
|
||||
}
|
||||
|
||||
/// emitFunctionStub - Use the specified JITCodeEmitter object to emit a
|
||||
/// small native function that simply calls the function at the specified
|
||||
/// address. The JITCodeEmitter must already have storage allocated for the
|
||||
/// stub. Return the address of the resultant function, which may have been
|
||||
/// aligned from the address the JCE was set up to emit at.
|
||||
virtual void *emitFunctionStub(const Function* F, void *Target,
|
||||
JITCodeEmitter &JCE) {
|
||||
llvm_unreachable("This target doesn't implement emitFunctionStub!");
|
||||
}
|
||||
|
||||
/// getPICJumpTableEntry - Returns the value of the jumptable entry for the
|
||||
/// specific basic block.
|
||||
virtual uintptr_t getPICJumpTableEntry(uintptr_t BB, uintptr_t JTBase) {
|
||||
llvm_unreachable("This target doesn't implement getPICJumpTableEntry!");
|
||||
}
|
||||
|
||||
/// LazyResolverFn - This typedef is used to represent the function that
|
||||
/// unresolved call points should invoke. This is a target specific
|
||||
/// function that knows how to walk the stack and find out which stub the
|
||||
/// call is coming from.
|
||||
typedef void (*LazyResolverFn)();
|
||||
|
||||
/// JITCompilerFn - This typedef is used to represent the JIT function that
|
||||
/// lazily compiles the function corresponding to a stub. The JIT keeps
|
||||
/// track of the mapping between stubs and LLVM Functions, the target
|
||||
/// provides the ability to figure out the address of a stub that is called
|
||||
/// by the LazyResolverFn.
|
||||
typedef void* (*JITCompilerFn)(void *);
|
||||
|
||||
/// getLazyResolverFunction - This method is used to initialize the JIT,
|
||||
/// giving the target the function that should be used to compile a
|
||||
/// function, and giving the JIT the target function used to do the lazy
|
||||
/// resolving.
|
||||
virtual LazyResolverFn getLazyResolverFunction(JITCompilerFn) {
|
||||
llvm_unreachable("Not implemented for this target!");
|
||||
}
|
||||
|
||||
/// relocate - Before the JIT can run a block of code that has been emitted,
|
||||
/// it must rewrite the code to contain the actual addresses of any
|
||||
/// referenced global symbols.
|
||||
virtual void relocate(void *Function, MachineRelocation *MR,
|
||||
unsigned NumRelocs, unsigned char* GOTBase) {
|
||||
assert(NumRelocs == 0 && "This target does not have relocations!");
|
||||
}
|
||||
|
||||
/// allocateThreadLocalMemory - Each target has its own way of
|
||||
/// handling thread local variables. This method returns a value only
|
||||
/// meaningful to the target.
|
||||
virtual char* allocateThreadLocalMemory(size_t size) {
|
||||
llvm_unreachable("This target does not implement thread local storage!");
|
||||
}
|
||||
|
||||
/// needsGOT - Allows a target to specify that it would like the
|
||||
/// JIT to manage a GOT for it.
|
||||
bool needsGOT() const { return useGOT; }
|
||||
|
||||
/// hasCustomConstantPool - Allows a target to specify that constant
|
||||
/// pool address resolution is handled by the target.
|
||||
virtual bool hasCustomConstantPool() const { return false; }
|
||||
|
||||
/// hasCustomJumpTables - Allows a target to specify that jumptables
|
||||
/// are emitted by the target.
|
||||
virtual bool hasCustomJumpTables() const { return false; }
|
||||
|
||||
/// allocateSeparateGVMemory - If true, globals should be placed in
|
||||
/// separately allocated heap memory rather than in the same
|
||||
/// code memory allocated by JITCodeEmitter.
|
||||
virtual bool allocateSeparateGVMemory() const { return false; }
|
||||
protected:
|
||||
bool useGOT;
|
||||
};
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
@@ -838,11 +838,6 @@ public:
|
||||
return UseUnderscoreLongJmp;
|
||||
}
|
||||
|
||||
/// Return whether the target can generate code for jump tables.
|
||||
bool supportJumpTables() const {
|
||||
return SupportJumpTables;
|
||||
}
|
||||
|
||||
/// Return integer threshold on number of blocks to use jump tables rather
|
||||
/// than if sequence.
|
||||
int getMinimumJumpTableEntries() const {
|
||||
@@ -1031,11 +1026,6 @@ protected:
|
||||
UseUnderscoreLongJmp = Val;
|
||||
}
|
||||
|
||||
/// Indicate whether the target can generate code for jump tables.
|
||||
void setSupportJumpTables(bool Val) {
|
||||
SupportJumpTables = Val;
|
||||
}
|
||||
|
||||
/// Indicate the number of blocks to generate jump tables rather than if
|
||||
/// sequence.
|
||||
void setMinimumJumpTableEntries(int Val) {
|
||||
@@ -1549,10 +1539,6 @@ private:
|
||||
/// Defaults to false.
|
||||
bool UseUnderscoreLongJmp;
|
||||
|
||||
/// Whether the target can generate code for jumptables. If it's not true,
|
||||
/// then each jumptable must be lowered into if-then-else's.
|
||||
bool SupportJumpTables;
|
||||
|
||||
/// Number of blocks threshold to use jump tables.
|
||||
int MinimumJumpTableEntries;
|
||||
|
||||
|
@@ -24,7 +24,6 @@
|
||||
namespace llvm {
|
||||
|
||||
class InstrItineraryData;
|
||||
class JITCodeEmitter;
|
||||
class GlobalValue;
|
||||
class Mangler;
|
||||
class MCAsmInfo;
|
||||
@@ -36,7 +35,6 @@ class DataLayout;
|
||||
class TargetLibraryInfo;
|
||||
class TargetFrameLowering;
|
||||
class TargetIntrinsicInfo;
|
||||
class TargetJITInfo;
|
||||
class TargetLowering;
|
||||
class TargetPassConfig;
|
||||
class TargetRegisterInfo;
|
||||
@@ -101,10 +99,6 @@ public:
|
||||
virtual const TargetSubtargetInfo *getSubtargetImpl() const {
|
||||
return nullptr;
|
||||
}
|
||||
TargetSubtargetInfo *getSubtargetImpl() {
|
||||
const TargetMachine *TM = this;
|
||||
return const_cast<TargetSubtargetInfo *>(TM->getSubtargetImpl());
|
||||
}
|
||||
|
||||
/// getSubtarget - This method returns a pointer to the specified type of
|
||||
/// TargetSubtargetInfo. In debug builds, it verifies that the object being
|
||||
@@ -201,18 +195,6 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
||||
/// get machine code emitted. This uses a JITCodeEmitter object to handle
|
||||
/// actually outputting the machine code and resolving things like the address
|
||||
/// of functions. This method returns true if machine code emission is
|
||||
/// not supported.
|
||||
///
|
||||
virtual bool addPassesToEmitMachineCode(PassManagerBase &,
|
||||
JITCodeEmitter &,
|
||||
bool /*DisableVerify*/ = true) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/// addPassesToEmitMC - Add passes to the specified pass manager to get
|
||||
/// machine code emitted with the MCJIT. This method returns true if machine
|
||||
/// code is not supported. It fills the MCContext Ctx pointer which can be
|
||||
@@ -259,15 +241,6 @@ public:
|
||||
AnalysisID StartAfter = nullptr,
|
||||
AnalysisID StopAfter = nullptr) override;
|
||||
|
||||
/// addPassesToEmitMachineCode - Add passes to the specified pass manager to
|
||||
/// get machine code emitted. This uses a JITCodeEmitter object to handle
|
||||
/// actually outputting the machine code and resolving things like the address
|
||||
/// of functions. This method returns true if machine code emission is
|
||||
/// not supported.
|
||||
///
|
||||
bool addPassesToEmitMachineCode(PassManagerBase &PM, JITCodeEmitter &MCE,
|
||||
bool DisableVerify = true) override;
|
||||
|
||||
/// addPassesToEmitMC - Add passes to the specified pass manager to get
|
||||
/// machine code emitted with the MCJIT. This method returns true if machine
|
||||
/// code is not supported. It fills the MCContext Ctx pointer which can be
|
||||
@@ -275,14 +248,6 @@ public:
|
||||
///
|
||||
bool addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx,
|
||||
raw_ostream &OS, bool DisableVerify = true) override;
|
||||
|
||||
/// addCodeEmitter - This pass should be overridden by the target to add a
|
||||
/// code emitter, if supported. If this is not supported, 'true' should be
|
||||
/// returned.
|
||||
virtual bool addCodeEmitter(PassManagerBase &,
|
||||
JITCodeEmitter &) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
@@ -26,7 +26,6 @@ class SDep;
|
||||
class SUnit;
|
||||
class TargetFrameLowering;
|
||||
class TargetInstrInfo;
|
||||
class TargetJITInfo;
|
||||
class TargetLowering;
|
||||
class TargetRegisterClass;
|
||||
class TargetRegisterInfo;
|
||||
@@ -79,11 +78,6 @@ public:
|
||||
///
|
||||
virtual const TargetRegisterInfo *getRegisterInfo() const { return nullptr; }
|
||||
|
||||
/// getJITInfo - If this target supports a JIT, return information for it,
|
||||
/// otherwise return null.
|
||||
///
|
||||
virtual TargetJITInfo *getJITInfo() { return nullptr; }
|
||||
|
||||
/// getInstrItineraryData - Returns instruction itinerary data for the target
|
||||
/// or specific subtarget.
|
||||
///
|
||||
|
Reference in New Issue
Block a user