hoshi-lang dev
Yet another programming language
Loading...
Searching...
No Matches
llvmCodegenContext.hpp
Go to the documentation of this file.
1//
2// Created by XIaokang00010 on 2024/10/9.
3//
4
5#ifndef HOSHI_LANG_LLVMCODEGENCONTEXT_HPP
6#define HOSHI_LANG_LLVMCODEGENCONTEXT_HPP
7
8#include <llvm/IR/BasicBlock.h>
9#include <llvm/IR/DIBuilder.h>
10#include <llvm/IR/DerivedTypes.h>
11#include <llvm/IR/Function.h>
12#include <llvm/IR/GlobalVariable.h>
13#include <llvm/IR/IRBuilder.h>
14#include <llvm/IR/LLVMContext.h>
15#include <llvm/IR/Module.h>
16#include <llvm/IR/Type.h>
17#include <llvm/IR/Value.h>
18#include <llvm/IR/Verifier.h>
19
20#include "compiler/ir/IR.h"
23#include "share/def.hpp"
24
25#include <map>
26#include <memory>
27#include <vector>
28
29#ifdef LLVM_CODEGEN_DEBUG
30#define TIMER(X, Y) { auto start = std::chrono::high_resolution_clock::now(); Y; auto end = std::chrono::high_resolution_clock::now(); std::lock_guard<std::mutex> lock(yoi::consoleMutex); std::cout << X << " took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << " ms" << std::endl; }
31#else
32#define TIMER(X, Y) Y
33#endif
34
35namespace yoi {
36
38 public:
39 LLVMCodegen(std::shared_ptr<compilerContext> compilerCtx, const std::shared_ptr<IRModule> & yoiModule);
40
42
43 void dumpIR(const yoi::wstr& modulePath, const std::string& filename);
44
45 private:
48
50 std::map<yoi::indexT, std::vector<indexT>> G; // graph
51 std::map<yoi::indexT, std::vector<indexT>> reverseG; // record the predecessors of each block
52
53 ControlFlowAnalysis(const std::vector<std::shared_ptr<IRCodeBlock>> &blocks);
54 };
55
60 struct StackValue {
61 llvm::Value *llvmValue;
62 std::shared_ptr<IRValueType> yoiType;
64 };
65
67 std::map<yoi::indexT, yoi::vec<StackValue>> valueStackStateIn;
68 std::map<yoi::indexT, yoi::vec<StackValue>> valueStackStateOut;
69 std::map<yoi::indexT, yoi::vec<llvm::PHINode *>> phiNodes;
76 llvm::IRBuilder<> *builder;
77 std::shared_ptr<IRModule> yoiModule;
78
79 ValueStackWithPhi(const ControlFlowAnalysis &cfa, llvm::IRBuilder<> *builder, const std::shared_ptr<IRModule> &yoiModule);
80
82 yoi::indexT fromState,
83 llvm::BasicBlock *currentBlock,
84 llvm::BasicBlock *fromBlock);
85
86 void enterNode(yoi::indexT currentState, llvm::BasicBlock *currentBlock);
87
88 void finalizeNode();
89
90 void push_back(const StackValue &value);
91
93
94 void pop_back();
95
96 void clear();
97
99
100 yoi::indexT size() const;
101
102 bool empty() const;
103 };
104
106 public:
107 std::unique_ptr<llvm::LLVMContext> TheContext;
109 std::unique_ptr<llvm::Module> TheModule;
110 std::unique_ptr<llvm::IRBuilder<>> Builder;
111 std::unique_ptr<llvm::DIBuilder> DBuilder;
112 std::map<yoi::wstr, llvm::Function *> runtimeFunctions;
113 std::map<yoi::wstr, llvm::DICompileUnit *> compileUnits;
114 std::map<yoi::wstr, llvm::DIType *> basicDITypeMap;
115
116 // Singleton None object
117 llvm::GlobalVariable *noneObjectSingleton = nullptr;
118 llvm::GlobalVariable *RTTITable = nullptr;
119 llvm::StructType *RTTIEntryType = nullptr;
120
121 // Codegen state
123 llvm::Function *currentFunction = nullptr;
124 llvm::Value *currentGeneratorContextValue = nullptr;
125 struct {
126 llvm::BasicBlock *resumeBB{};
127 llvm::BasicBlock *cleanupBB{};
128 llvm::BasicBlock *suspendBB{};
130 std::shared_ptr<yoi::IRFunctionDefinition> currentFunctionDef;
131 std::map<yoi::indexT, llvm::AllocaInst *> namedValues; // Maps local var index to AllocaInst
132 std::map<yoi::indexT, llvm::BasicBlock *> basicBlockMap; // [from_block, to_block] => target basic block
133 std::map<yoi::indexT, bool> basicBlockVisited;
134
135 // Mappings from yoi IR to LLVM IR
136 std::map<yoi::indexT, llvm::GlobalVariable *> globalValues; // Maps global var index to GlobalVariable
137 std::map<yoi::wstr, llvm::Function *> functionMap; // Maps yoi function names to LLVM functions
138 std::map<std::tuple<yoi::IRValueType::valueType, yoi::indexT, yoi::indexT>,
139 llvm::StructType *>
140 structTypeMap; // Maps (type_enum, module_id, type_idx) to LLVM struct type
141 std::map<std::tuple<yoi::IRValueType::valueType, yoi::indexT, yoi::indexT>,
142 llvm::Type *>
143 foreignTypeMap; // Maps (type_enum, module_id, type_idx) to LLVM type
144 std::map<std::tuple<yoi::IRValueType::valueType, yoi::indexT, yoi::indexT, yoi::indexT>,
145 llvm::StructType *>
146 arrayTypeMap; // Maps (type_enum, module_id, type_idx, size) to LLVM array type
147 std::map<std::tuple<yoi::IRValueType::valueType, yoi::indexT, yoi::indexT, yoi::indexT>,
148 llvm::DIType *>
149 arrayDataRegionDITypeMap; // Maps (type_enum, module_id, type_idx, size) to LLVM array data region type
150 std::map<std::tuple<yoi::IRValueType::valueType, yoi::indexT, yoi::indexT>,
151 llvm::DIType *>
152 structTypeDIMap; // Maps (type_enum, module_id, type_idx) to LLVM DI type
153 std::map<std::tuple<yoi::IRValueType::valueType, yoi::indexT, yoi::indexT, yoi::indexT>,
154 llvm::DIType *>
155 arrayTypeDIMap; // Maps (type_enum, module_id, type_idx, size) to LLVM DI type
156 std::map<yoi::indexT, llvm::DIType *> dataStructDataRegionTypeDIMap;
157 std::map<std::tuple<yoi::IRValueType::valueType, yoi::indexT, yoi::indexT, yoi::indexT>,
159 typeIDMap; // Maps (type_enum, module_id, type_idx, size) to type ID (if no array, size = 0)
160 yoi::vec<std::tuple<std::shared_ptr<IRValueType>, llvm::StructType *, llvm::Type *>>
161 arrayToGenerateImplementations; // Array types to generate GC functions for
162 std::map<yoi::indexT, llvm::StructType *> dataStructDataRegionMap;
163
165
167
168 LLVMModuleContext(const std::shared_ptr<IRModule> &yoiModule,
169 yoi::indexT hash,
170 const yoi::wstr &absolute_path);
171 };
172
173 // Yoi language context
174 std::shared_ptr<compilerContext> compilerCtx;
175 std::shared_ptr<IRModule> yoiModule;
176 mutable std::mutex contextMutex;
177
178 std::map<yoi::wstr, std::unique_ptr<LLVMModuleContext>> llvmModuleContext;
179
181
182 void generate(LLVMModuleContext &llvmModCtx);
183
184 llvm::Module *getModule(LLVMModuleContext &llvmModCtx);
185
186 // Helper methods
189
192
193 void generateDeclarations(LLVMModuleContext &llvmModCtx);
200
211 void generateMainFunction(LLVMModuleContext &llvmModCtx);
212
213 void generateWrapperForForeignCallablesIfNotExists(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type);
214
216 void generateFunction(LLVMModuleContext &llvmModCtx, IRFunctionDefinition &funcDef);
218 void generateCodeBlock(LLVMModuleContext &llvmModCtx, IRCodeBlock &block, yoi::indexT fromBlock, yoi::indexT toBlock, llvm::BasicBlock *actualFromBlock = nullptr);
219 void generateInstruction(LLVMModuleContext &llvmModCtx, const IR &instr, yoi::indexT fromBlock, yoi::indexT toBlock);
220 void generateDescription(LLVMModuleContext &llvmModCtx);
224 llvm::Value *createGeneratorContext(LLVMModuleContext &llvmModCtx, llvm::Value *coro_handle);
225 void storeYieldValue(LLVMModuleContext &llvmModCtx, llvm::Value *value, const std::shared_ptr<IRValueType> &yoiType);
226 void storeMember(LLVMModuleContext &llvmModCtx, const StackValue &storeValue, const StackValue &structVal, yoi::indexT memberIndex);
227
228 llvm::Value *createStructObject(LLVMModuleContext &llvmModCtx, yoi::indexT moduleIndex, yoi::indexT structIndex);
229
230 llvm::Function *getLLVMCoroIntrinsic(LLVMModuleContext &llvmModCtx, llvm::Intrinsic::ID Id, llvm::ArrayRef<llvm::Type *> Types = {});
231
232 llvm::Value *loadIfDataStructObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type, llvm::Value *value);
233
234 std::shared_ptr<IRValueType> normalizeForeignType(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type);
235 llvm::Type *yoiTypeToLLVMType(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type, bool enforceForeignType = false);
236 llvm::Type *getArrayLLVMType(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type, bool enforceForeignType = false);
237 llvm::Type *getDynamicArrayLLVMType(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type, bool enforceForeignType = false);
238 void generateArrayGCFunctionDeclarations(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type, llvm::StructType *structType, llvm::Type *baseType);
239 llvm::FunctionType *getFunctionType(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRFunctionDefinition> &funcDef);
240 llvm::Constant *getGlobalInitializer(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type);
241
242 // Helpers for specific instructions & object model
243 void handleBinaryOp(LLVMModuleContext &llvmModCtx, llvm::Instruction::BinaryOps op, bool isFloat, yoi::indexT fromBlock, yoi::indexT toBlock);
244 void handleComparison(LLVMModuleContext &llvmModCtx, llvm::CmpInst::Predicate pred, bool isFloat, yoi::indexT fromBlock, yoi::indexT toBlock);
245 llvm::Value *createBasicObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &yoiType, llvm::Value *rawValue);
246 llvm::Value *unboxValue(LLVMModuleContext &llvmModCtx, llvm::Value *objectPtr, const std::shared_ptr<IRValueType> &yoiType);
247 llvm::Value *
248 loadArrayElement(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type, llvm::Value *arrayPtr, llvm::Value *index);
249 llvm::Function *getGcFunction(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &yoiType, bool isIncrease);
250 void callGcFunction(LLVMModuleContext &llvmModCtx, llvm::Value *objectPtr, const std::shared_ptr<IRValueType> &yoiType, bool isIncrease, bool forceForPermanent = false, bool forceForBorrow = false);
251 llvm::Value *
252 handleForeignTypeConv(LLVMModuleContext &llvmModCtx, llvm::Value *val, yoi::indexT foreignTypeIndex, yoi::indexT isArray, bool convertToForeign = false);
253 llvm::Value *handleForeignTypeConv(LLVMModuleContext &llvmModCtx, llvm::Value *val,
254 const std::shared_ptr<IRValueType> &foreignType,
255 bool convertToForeign = false);
256 llvm::Value *createArrayObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type,
257 const yoi::vec<StackValue> &elements);
258 llvm::DIType *getDIType(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type);
259 llvm::Value *createDynamicArrayObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type,
260 const yoi::vec<StackValue> &elements,
261 llvm::Value *size);
262 void storeArrayElement(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type,
263 const std::shared_ptr<IRValueType> &valueToStoreType,
264 llvm::Value *arrayPtr,
265 llvm::Value *index,
266 llvm::Value *value);
267 void generateArrayGCFunctionImplementations(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type,
268 llvm::StructType *structType,
269 llvm::Type *baseType);
270
271 std::pair<std::shared_ptr<IRValueType>, llvm::Value *> ensureObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type,
272 llvm::Value *val);
273
274 void generateIfTargetNotNull(LLVMModuleContext &llvmModCtx, llvm::Value *objectPtr,
275 const std::shared_ptr<IRValueType> &yoiType,
276 const std::function<void()> &func, bool enforced = false);
277
278 StackValue actualizeInterfaceObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr<IRValueType> &type,
279 llvm::Value *objectPtr,
280 yoi::indexT implIndex);
281
283
284 llvm::Value * unwrapInterfaceObject(LLVMModuleContext &llvmModCtx, const StackValue &objectVal);
285
287
288 void handleIntrinsicCall(LLVMModuleContext &llvmModCtx, const IR &instr);
289
291
292 void generateTargetObjectCode(LLVMModuleContext &llvmModCtx, const yoi::wstr &pathToOutput);
293 };
294
295} // namespace yoi
296
297#endif // HOSHI_LANG_LLVMCODEGENCONTEXT_HPP
Definition IR.h:264
std::map< std::tuple< yoi::IRValueType::valueType, yoi::indexT, yoi::indexT, yoi::indexT >, yoi::indexT > typeIDMap
std::map< yoi::indexT, llvm::AllocaInst * > namedValues
std::map< std::tuple< yoi::IRValueType::valueType, yoi::indexT, yoi::indexT >, llvm::Type * > foreignTypeMap
std::shared_ptr< yoi::IRFunctionDefinition > currentFunctionDef
std::map< yoi::wstr, llvm::DIType * > basicDITypeMap
yoi::vec< std::tuple< std::shared_ptr< IRValueType >, llvm::StructType *, llvm::Type * > > arrayToGenerateImplementations
std::map< yoi::indexT, llvm::DIType * > dataStructDataRegionTypeDIMap
std::map< yoi::wstr, llvm::Function * > functionMap
std::map< std::tuple< yoi::IRValueType::valueType, yoi::indexT, yoi::indexT, yoi::indexT >, llvm::DIType * > arrayDataRegionDITypeMap
std::map< std::tuple< yoi::IRValueType::valueType, yoi::indexT, yoi::indexT >, llvm::DIType * > structTypeDIMap
std::unique_ptr< llvm::LLVMContext > TheContext
std::map< yoi::wstr, llvm::DICompileUnit * > compileUnits
std::map< yoi::indexT, llvm::BasicBlock * > basicBlockMap
std::map< yoi::indexT, llvm::GlobalVariable * > globalValues
std::unique_ptr< llvm::IRBuilder<> > Builder
std::map< std::tuple< yoi::IRValueType::valueType, yoi::indexT, yoi::indexT >, llvm::StructType * > structTypeMap
std::unique_ptr< llvm::Module > TheModule
std::map< yoi::indexT, bool > basicBlockVisited
std::unique_ptr< llvm::DIBuilder > DBuilder
struct yoi::LLVMCodegen::LLVMModuleContext::@0 currentGeneratorContextBasicBlocks
std::map< std::tuple< yoi::IRValueType::valueType, yoi::indexT, yoi::indexT, yoi::indexT >, llvm::DIType * > arrayTypeDIMap
std::map< yoi::indexT, llvm::StructType * > dataStructDataRegionMap
std::map< yoi::wstr, llvm::Function * > runtimeFunctions
std::map< std::tuple< yoi::IRValueType::valueType, yoi::indexT, yoi::indexT, yoi::indexT >, llvm::StructType * > arrayTypeMap
void generateInstruction(LLVMModuleContext &llvmModCtx, const IR &instr, yoi::indexT fromBlock, yoi::indexT toBlock)
llvm::Function * getGcFunction(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &yoiType, bool isIncrease)
void generateRuntimeFunctionImplementations(LLVMModuleContext &llvmModCtx)
llvm::Value * createBasicObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &yoiType, llvm::Value *rawValue)
StackValue promiseInterfaceObjectIfInterface(LLVMModuleContext &llvmModCtx, const StackValue &objectVal)
void generateInterfaceObjectGCFunctionImplementations(LLVMModuleContext &llvmModCtx)
yoi::vec< yoi::wstr > generate()
void generateImplementations(LLVMModuleContext &llvmModCtx)
void generateExportFunctionDecls(LLVMModuleContext &llvmModCtx)
CodegenTaskDispatcher codegenTaskDispatcher
void generateImportFunctionDeclarations(LLVMModuleContext &llvmModCtx)
llvm::Value * createGeneratorContext(LLVMModuleContext &llvmModCtx, llvm::Value *coro_handle)
StackValue wrapInterfaceObjectIfRegressed(LLVMModuleContext &llvmModCtx, const StackValue &objectVal)
llvm::Value * loadIfDataStructObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, llvm::Value *value)
llvm::Value * createDynamicArrayObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, const yoi::vec< StackValue > &elements, llvm::Value *size)
void generateGlobalDeclarations(LLVMModuleContext &llvmModCtx)
void generateDeclarations(LLVMModuleContext &llvmModCtx)
void handleBinaryOp(LLVMModuleContext &llvmModCtx, llvm::Instruction::BinaryOps op, bool isFloat, yoi::indexT fromBlock, yoi::indexT toBlock)
void generateMainFunction(LLVMModuleContext &llvmModCtx)
void generateCodeBlock(LLVMModuleContext &llvmModCtx, IRCodeBlock &block, yoi::indexT fromBlock, yoi::indexT toBlock, llvm::BasicBlock *actualFromBlock=nullptr)
llvm::Value * createArrayObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, const yoi::vec< StackValue > &elements)
llvm::Value * loadArrayElement(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, llvm::Value *arrayPtr, llvm::Value *index)
void callGcFunction(LLVMModuleContext &llvmModCtx, llvm::Value *objectPtr, const std::shared_ptr< IRValueType > &yoiType, bool isIncrease, bool forceForPermanent=false, bool forceForBorrow=false)
void generateStructDeclarations(LLVMModuleContext &llvmModCtx)
void storeArrayElement(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, const std::shared_ptr< IRValueType > &valueToStoreType, llvm::Value *arrayPtr, llvm::Value *index, llvm::Value *value)
llvm::Module * getModule(LLVMModuleContext &llvmModCtx)
std::pair< std::shared_ptr< IRValueType >, llvm::Value * > ensureObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, llvm::Value *val)
void generateForeignStructTypes(LLVMModuleContext &llvmModCtx)
void generateBasicTypeDeclarations(LLVMModuleContext &llvmModCtx)
llvm::Value * handleForeignTypeConv(LLVMModuleContext &llvmModCtx, llvm::Value *val, yoi::indexT foreignTypeIndex, yoi::indexT isArray, bool convertToForeign=false)
void generateWrapperForForeignCallablesIfNotExists(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type)
void generateDataStructDeclarations(LLVMModuleContext &llvmModCtx)
void generateFunctionDeclarations(LLVMModuleContext &llvmModCtx)
void declareRuntimeFunctions(LLVMModuleContext &llvmModCtx)
void generateStructGCFunctionImplementations(LLVMModuleContext &llvmModCtx)
void dumpIR(const yoi::wstr &modulePath, const std::string &filename)
void generateDataStructShallowDeclarations(LLVMModuleContext &llvmModCtx)
void generateDescription(LLVMModuleContext &llvmModCtx)
llvm::Type * getArrayLLVMType(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, bool enforceForeignType=false)
void generateArrayGCFunctionDeclarations(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, llvm::StructType *structType, llvm::Type *baseType)
void generateRTTIImplmentation(LLVMModuleContext &llvmModCtx)
void generateArrayGCFunctionImplementations(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, llvm::StructType *structType, llvm::Type *baseType)
llvm::Value * createStructObject(LLVMModuleContext &llvmModCtx, yoi::indexT moduleIndex, yoi::indexT structIndex)
std::map< yoi::wstr, std::unique_ptr< LLVMModuleContext > > llvmModuleContext
StackValue actualizeInterfaceObject(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, llvm::Value *objectPtr, yoi::indexT implIndex)
llvm::Type * yoiTypeToLLVMType(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, bool enforceForeignType=false)
void generateFunctionImplementations(LLVMModuleContext &llvmModCtx)
void generateGeneratorContextInitialization(LLVMModuleContext &llvmModCtx)
llvm::Constant * getGlobalInitializer(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type)
void generateIfTargetNotNull(LLVMModuleContext &llvmModCtx, llvm::Value *objectPtr, const std::shared_ptr< IRValueType > &yoiType, const std::function< void()> &func, bool enforced=false)
llvm::Value * unwrapInterfaceObject(LLVMModuleContext &llvmModCtx, const StackValue &objectVal)
void generateFunctionExitCleanup(LLVMModuleContext &llvmModCtx)
void storeYieldValue(LLVMModuleContext &llvmModCtx, llvm::Value *value, const std::shared_ptr< IRValueType > &yoiType)
void handleComparison(LLVMModuleContext &llvmModCtx, llvm::CmpInst::Predicate pred, bool isFloat, yoi::indexT fromBlock, yoi::indexT toBlock)
void storeMember(LLVMModuleContext &llvmModCtx, const StackValue &storeValue, const StackValue &structVal, yoi::indexT memberIndex)
void generateInterfaceObjectGCFunctionDeclarations(LLVMModuleContext &llvmModCtx)
void generateBasicTypeImplementations(LLVMModuleContext &llvmModCtx)
std::shared_ptr< IRValueType > normalizeForeignType(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type)
void generateTargetObjectCode(LLVMModuleContext &llvmModCtx, const yoi::wstr &pathToOutput)
llvm::DIType * getDIType(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type)
void handleIntrinsicCall(LLVMModuleContext &llvmModCtx, const IR &instr)
void generateStructGCFunctionDeclarations(LLVMModuleContext &llvmModCtx)
llvm::Value * unboxValue(LLVMModuleContext &llvmModCtx, llvm::Value *objectPtr, const std::shared_ptr< IRValueType > &yoiType)
void generateImportFunctionImplementations(LLVMModuleContext &llvmModCtx)
std::shared_ptr< compilerContext > compilerCtx
LLVMModuleContext & getLLVMModuleContext(const yoi::wstr &absolutePath)
std::shared_ptr< IRModule > yoiModule
CodegenObjectCache codegenObjectCache
void generateRTTIDeclaration(LLVMModuleContext &llvmModCtx)
llvm::Function * getLLVMCoroIntrinsic(LLVMModuleContext &llvmModCtx, llvm::Intrinsic::ID Id, llvm::ArrayRef< llvm::Type * > Types={})
llvm::FunctionType * getFunctionType(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRFunctionDefinition > &funcDef)
llvm::Type * getDynamicArrayLLVMType(LLVMModuleContext &llvmModCtx, const std::shared_ptr< IRValueType > &type, bool enforceForeignType=false)
void generateGlobalInitializers(LLVMModuleContext &llvmModCtx)
void generateFunction(LLVMModuleContext &llvmModCtx, IRFunctionDefinition &funcDef)
void generateStructShallowDeclarations(LLVMModuleContext &llvmModCtx)
std::vector< t > vec
Definition def.hpp:53
std::wstring wstr
Definition def.hpp:48
uint64_t indexT
Definition def.hpp:51
std::map< yoi::indexT, std::vector< indexT > > reverseG
std::map< yoi::indexT, std::vector< indexT > > G
Stack Value struct exposed to original code base for compatibility.
std::shared_ptr< IRValueType > yoiType
StackValue & operator[](yoi::indexT index)
std::map< yoi::indexT, yoi::vec< StackValue > > valueStackStateIn
std::map< yoi::indexT, yoi::vec< StackValue > > valueStackStateOut
enum yoi::LLVMCodegen::ValueStackWithPhi::StackState stackState
void push_back(const StackValue &value)
void enterNode(yoi::indexT currentState, yoi::indexT fromState, llvm::BasicBlock *currentBlock, llvm::BasicBlock *fromBlock)
std::shared_ptr< IRModule > yoiModule
std::map< yoi::indexT, yoi::vec< llvm::PHINode * > > phiNodes