llvm/llvm/lib/ExecutionEngine/ExecutionEngine.cpp

//===-- ExecutionEngine.cpp - Common Implementation shared by EEs ---------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines the common interface used by the various execution engine
// subclasses.
//
// FIXME: This file needs to be updated to support scalable vectors
//
//===----------------------------------------------------------------------===//

#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/JITEventListener.h"
#include "llvm/ExecutionEngine/ObjectCache.h"
#include "llvm/ExecutionEngine/RTDyldMemoryManager.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Operator.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/ObjectFile.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/TargetParser/Host.h"
#include <cmath>
#include <cstring>
#include <mutex>
usingnamespacellvm;

#define DEBUG_TYPE

STATISTIC(NumInitBytes, "Number of bytes of global vars initialized");
STATISTIC(NumGlobals  , "Number of global vars initialized");

ExecutionEngine *(*ExecutionEngine::MCJITCtor)(
    std::unique_ptr<Module> M, std::string *ErrorStr,
    std::shared_ptr<MCJITMemoryManager> MemMgr,
    std::shared_ptr<LegacyJITSymbolResolver> Resolver,
    std::unique_ptr<TargetMachine> TM) =;

ExecutionEngine *(*ExecutionEngine::InterpCtor)(std::unique_ptr<Module> M,
                                                std::string *ErrorStr) =;

void JITEventListener::anchor() {}

void ObjectCache::anchor() {}

void ExecutionEngine::Init(std::unique_ptr<Module> M) {}

ExecutionEngine::ExecutionEngine(std::unique_ptr<Module> M)
    :{}

ExecutionEngine::ExecutionEngine(DataLayout DL, std::unique_ptr<Module> M)
    :{}

ExecutionEngine::~ExecutionEngine() {}

namespace {
/// Helper class which uses a value handler to automatically deletes the
/// memory block when the GlobalVariable is destroyed.
class GVMemoryBlock final : public CallbackVH {};
}  // anonymous namespace

char *ExecutionEngine::getMemoryForGV(const GlobalVariable *GV) {}

void ExecutionEngine::addObjectFile(std::unique_ptr<object::ObjectFile> O) {}

void
ExecutionEngine::addObjectFile(object::OwningBinary<object::ObjectFile> O) {}

void ExecutionEngine::addArchive(object::OwningBinary<object::Archive> A) {}

bool ExecutionEngine::removeModule(Module *M) {}

Function *ExecutionEngine::FindFunctionNamed(StringRef FnName) {}

GlobalVariable *ExecutionEngine::FindGlobalVariableNamed(StringRef Name, bool AllowInternal) {}

uint64_t ExecutionEngineState::RemoveMapping(StringRef Name) {}

std::string ExecutionEngine::getMangledName(const GlobalValue *GV) {}

void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {}

void ExecutionEngine::addGlobalMapping(StringRef Name, uint64_t Addr) {}

void ExecutionEngine::clearAllGlobalMappings() {}

void ExecutionEngine::clearGlobalMappingsFromModule(Module *M) {}

uint64_t ExecutionEngine::updateGlobalMapping(const GlobalValue *GV,
                                              void *Addr) {}

uint64_t ExecutionEngine::updateGlobalMapping(StringRef Name, uint64_t Addr) {}

uint64_t ExecutionEngine::getAddressToGlobalIfAvailable(StringRef S) {}


void *ExecutionEngine::getPointerToGlobalIfAvailable(StringRef S) {}

void *ExecutionEngine::getPointerToGlobalIfAvailable(const GlobalValue *GV) {}

const GlobalValue *ExecutionEngine::getGlobalValueAtAddress(void *Addr) {}

namespace {
class ArgvArray {};
}  // anonymous namespace
void *ArgvArray::reset(LLVMContext &C, ExecutionEngine *EE,
                       const std::vector<std::string> &InputArgv) {}

void ExecutionEngine::runStaticConstructorsDestructors(Module &module,
                                                       bool isDtors) {}

void ExecutionEngine::runStaticConstructorsDestructors(bool isDtors) {}

#ifndef NDEBUG
/// isTargetNullPtr - Return whether the target pointer stored at Loc is null.
static bool isTargetNullPtr(ExecutionEngine *EE, void *Loc) {
  unsigned PtrSize = EE->getDataLayout().getPointerSize();
  for (unsigned i = 0; i < PtrSize; ++i)
    if (*(i + (uint8_t*)Loc))
      return false;
  return true;
}
#endif

int ExecutionEngine::runFunctionAsMain(Function *Fn,
                                       const std::vector<std::string> &argv,
                                       const char * const * envp) {}

EngineBuilder::EngineBuilder() :{}

EngineBuilder::EngineBuilder(std::unique_ptr<Module> M)
    :{}

EngineBuilder::~EngineBuilder() = default;

EngineBuilder &EngineBuilder::setMCJITMemoryManager(
                                   std::unique_ptr<RTDyldMemoryManager> mcjmm) {}

EngineBuilder&
EngineBuilder::setMemoryManager(std::unique_ptr<MCJITMemoryManager> MM) {}

EngineBuilder &
EngineBuilder::setSymbolResolver(std::unique_ptr<LegacyJITSymbolResolver> SR) {}

ExecutionEngine *EngineBuilder::create(TargetMachine *TM) {}

void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) {}

/// Converts a Constant* into a GenericValue, including handling of
/// ConstantExpr values.
GenericValue ExecutionEngine::getConstantValue(const Constant *C) {}

void ExecutionEngine::StoreValueToMemory(const GenericValue &Val,
                                         GenericValue *Ptr, Type *Ty) {}

/// FIXME: document
///
void ExecutionEngine::LoadValueFromMemory(GenericValue &Result,
                                          GenericValue *Ptr,
                                          Type *Ty) {}

void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {}

/// EmitGlobals - Emit all of the global variables to memory, storing their
/// addresses into GlobalAddress.  This must make sure to copy the contents of
/// their initializers into the memory.
void ExecutionEngine::emitGlobals() {}

// EmitGlobalVariable - This method emits the specified global variable to the
// address specified in GlobalAddresses, or allocates new memory if it's not
// already in the map.
void ExecutionEngine::emitGlobalVariable(const GlobalVariable *GV) {}