xo-umbrella2/xo-jit/include/xo/jit/LlvmContext.hpp
Roland Conybeare 757dfed99c Add 'xo-jit/' from commit '855887df71'
git-subtree-dir: xo-jit
git-subtree-mainline: 35555df976
git-subtree-split: 855887df71
2025-05-11 01:54:47 -05:00

45 lines
1.2 KiB
C++

/** @file LlvmContext.hpp
*
* Author: Roland Conybeare
**/
#pragma once
#include "xo/refcnt/Refcounted.hpp"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
# include "llvm/IR/LLVMContext.h"
#pragma GCC diagnostic pop
//#include <cstdint>
namespace xo {
namespace jit {
/** @class LlvmContext
* @brief Keepalive for a llvm::LLVMContext instance.
*
* For example IrPipeline holds an rp<LlvmContext>
* to help ensure validity of embedded llvm::LLVMContext reference
**/
class LlvmContext : public ref::Refcount {
public:
static rp<LlvmContext> make();
llvm::LLVMContext & llvm_cx_ref() { return *llvm_cx_; }
std::unique_ptr<llvm::LLVMContext> & llvm_cx() { return llvm_cx_; }
private:
LlvmContext();
private:
/** Llvm context. Ties together fragments of code generation
* for AST subtrees that go into the same module.
**/
std::unique_ptr<llvm::LLVMContext> llvm_cx_;
}; /*LlvmContext*/
} /*namespace jit*/
} /*namespace xo*/
/** end LlvmContext.hpp **/