<commit_before>//===- ExecutionEngine.h - Abstract Execution Engine Interface --*- C++ -*-===//
// 
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
// 
//===----------------------------------------------------------------------===//
//
// This file defines the abstract interface that implements execution support
// for LLVM.
//
//===----------------------------------------------------------------------===//

#ifndef EXECUTION_ENGINE_H
#define EXECUTION_ENGINE_H

#include <vector>
#include <map>
#include <cassert>
#include <string>

namespace llvm {

union GenericValue;
class Constant;
class Function;
class GlobalVariable;
class GlobalValue;
class Module;
class ModuleProvider;
class TargetData;
class Type;
class IntrinsicLowering;

class ExecutionEngine {
  Module &CurMod;
  const TargetData *TD;

  /// GlobalAddressMap - A mapping between LLVM global values and their
  /// actualized version...
  std::map<const GlobalValue*, void *> GlobalAddressMap;

  /// GlobalAddressReverseMap - This is the reverse mapping of GlobalAddressMap,
  /// used to convert raw addresses into the LLVM global value that is emitted
  /// at the address.  This map is not computed unless getGlobalValueAtAddress
  /// is called at some point.
  std::map<void *, const GlobalValue*> GlobalAddressReverseMap;
protected:
  ModuleProvider *MP;

  void setTargetData(const TargetData &td) {
    TD = &td;
  }

public:
  ExecutionEngine(ModuleProvider *P);
  ExecutionEngine(Module *M);
  virtual ~ExecutionEngine();
  
  Module &getModule() const { return CurMod; }
  const TargetData &getTargetData() const { return *TD; }

  /// create - This is the factory method for creating an execution engine which
  /// is appropriate for the current machine.  If specified, the
  /// IntrinsicLowering implementation should be allocated on the heap.
  static ExecutionEngine *create(ModuleProvider *MP, bool ForceInterpreter,
                                 IntrinsicLowering *IL = 0);

  /// runFunction - Execute the specified function with the specified arguments,
  /// and return the result.
  ///
  virtual GenericValue runFunction(Function *F,
                                const std::vector<GenericValue> &ArgValues) = 0;

  /// runFunctionAsMain - This is a helper function which wraps runFunction to
  /// handle the common task of starting up main with the specified argc, argv,
  /// and envp parameters.
  int runFunctionAsMain(Function *Fn, const std::vector<std::string> &argv,
                        const char * const * envp);


  void addGlobalMapping(const GlobalValue *GV, void *Addr) {
    void *&CurVal = GlobalAddressMap[GV];
    assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!");
    CurVal = Addr;

    // If we are using the reverse mapping, add it too
    if (!GlobalAddressReverseMap.empty()) {
      const GlobalValue *&V = GlobalAddressReverseMap[Addr];
      assert((V == 0 || GV == 0) && "GlobalMapping already established!");
      V = GV;
    }
  }
<commit_msg>Implement a missing function called by JIT/Emitter.cpp but never defined.<commit_after>//===- ExecutionEngine.h - Abstract Execution Engine Interface --*- C++ -*-===//
// 
//                     The LLVM Compiler Infrastructure
//
// This file was developed by the LLVM research group and is distributed under
// the University of Illinois Open Source License. See LICENSE.TXT for details.
// 
//===----------------------------------------------------------------------===//
//
// This file defines the abstract interface that implements execution support
// for LLVM.
//
//===----------------------------------------------------------------------===//

#ifndef EXECUTION_ENGINE_H
#define EXECUTION_ENGINE_H

#include <vector>
#include <map>
#include <cassert>
#include <string>

namespace llvm {

union GenericValue;
class Constant;
class Function;
class GlobalVariable;
class GlobalValue;
class Module;
class ModuleProvider;
class TargetData;
class Type;
class IntrinsicLowering;

class ExecutionEngine {
  Module &CurMod;
  const TargetData *TD;

  /// GlobalAddressMap - A mapping between LLVM global values and their
  /// actualized version...
  std::map<const GlobalValue*, void *> GlobalAddressMap;

  /// GlobalAddressReverseMap - This is the reverse mapping of GlobalAddressMap,
  /// used to convert raw addresses into the LLVM global value that is emitted
  /// at the address.  This map is not computed unless getGlobalValueAtAddress
  /// is called at some point.
  std::map<void *, const GlobalValue*> GlobalAddressReverseMap;
protected:
  ModuleProvider *MP;

  void setTargetData(const TargetData &td) {
    TD = &td;
  }

public:
  ExecutionEngine(ModuleProvider *P);
  ExecutionEngine(Module *M);
  virtual ~ExecutionEngine();
  
  Module &getModule() const { return CurMod; }
  const TargetData &getTargetData() const { return *TD; }

  /// create - This is the factory method for creating an execution engine which
  /// is appropriate for the current machine.  If specified, the
  /// IntrinsicLowering implementation should be allocated on the heap.
  static ExecutionEngine *create(ModuleProvider *MP, bool ForceInterpreter,
                                 IntrinsicLowering *IL = 0);

  /// runFunction - Execute the specified function with the specified arguments,
  /// and return the result.
  ///
  virtual GenericValue runFunction(Function *F,
                                const std::vector<GenericValue> &ArgValues) = 0;

  /// runFunctionAsMain - This is a helper function which wraps runFunction to
  /// handle the common task of starting up main with the specified argc, argv,
  /// and envp parameters.
  int runFunctionAsMain(Function *Fn, const std::vector<std::string> &argv,
                        const char * const * envp);


  void addGlobalMapping(const GlobalValue *GV, void *Addr) {
    void *&CurVal = GlobalAddressMap[GV];
    assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!");
    CurVal = Addr;

    // If we are using the reverse mapping, add it too
    if (!GlobalAddressReverseMap.empty()) {
      const GlobalValue *&V = GlobalAddressReverseMap[Addr];
      assert((V == 0 || GV == 0) && "GlobalMapping already established!");
      V = GV;
    }
  }

  /// FIXME: I have no idea if this is right, I just implemented it to get
  /// the build to compile because it is called by JIT/Emitter.cpp.
  void updateGlobalMapping(const GlobalValue *GV, void*Addr) {
    GlobalAddressMap[GV] = Addr;
    GlobalAddressReverseMap[Addr] = GV;
  }

{'fraction_non_alphanumeric': 0.14087242306543174, 'fraction_numerical': 0.00179265013444876, 'mean_word_length': 2.713255684969495, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4930871', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1721, 'n_words': 659}