From c2a3cecc1ab2d3f27dcea40a6f0f353b0306d66a Mon Sep 17 00:00:00 2001 From: ov-4 Date: Thu, 29 Jan 2026 10:20:58 +0000 Subject: Added INPUT, OUTPUT and DECLARE --- include/cps/CodeGen.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 include/cps/CodeGen.h (limited to 'include/cps/CodeGen.h') diff --git a/include/cps/CodeGen.h b/include/cps/CodeGen.h new file mode 100644 index 0000000..2621795 --- /dev/null +++ b/include/cps/CodeGen.h @@ -0,0 +1,32 @@ +#pragma once +#include "cps/AST.h" +#include "llvm/IR/IRBuilder.h" +#include "llvm/IR/LLVMContext.h" +#include "llvm/IR/Module.h" +#include + +namespace cps { + +class CodeGen { + std::unique_ptr TheContext; + std::unique_ptr TheModule; + std::unique_ptr> Builder; + std::map NamedValues; + + llvm::AllocaInst *CreateEntryBlockAlloca(llvm::Function *TheFunction, + const std::string &VarName); + + llvm::FunctionCallee PrintfFunc; + llvm::FunctionCallee ScanfFunc; + llvm::Value *PrintfFormatStr; + llvm::Value *ScanfFormatStr; + + void SetupExternalFunctions(); + +public: + CodeGen(); + void compile(const std::vector> &Statements); + void print(); +}; + +} // namespace cps -- cgit v1.3.1-4-g156e