From df8ca0427450d9fd64280c18ce3509721491a61b Mon Sep 17 00:00:00 2001 From: Sofia Date: Thu, 2 Apr 2026 17:24:15 +0300 Subject: [PATCH] Remove unneeded LLVM Hello World --- src/main.cpp | 45 --------------------------------------------- 1 file changed, 45 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 751b8b0..80b6a9d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -100,52 +100,7 @@ int main() { std::cout << ir_output << std::endl; - // LLVM Hello World - // llvm_hello_world(); - std::cout << "hello" << std::endl; return 0; -} - -void llvm_hello_world() { - - auto Context = std::make_unique(); - auto Module = std::make_unique("my cool module", *Context); - - auto Builder = std::make_unique>(*Context); - - llvm::FunctionType* FunType = llvm::FunctionType::get(llvm::Type::getInt32Ty(*Context), false); - llvm::Function* Function = llvm::Function::Create( - FunType, llvm::GlobalValue::LinkageTypes::ExternalLinkage, "main", *Module); - - llvm::BasicBlock* BB = llvm::BasicBlock::Create(*Context, "entry", Function, nullptr); - - Builder->SetInsertPoint(BB); - llvm::Value* value = llvm::ConstantInt::get(llvm::Type::getInt32Ty(*Context), 5); - Builder->CreateRet(value); - - llvm::verifyFunction(*Function); - - llvm::InitializeAllTargetInfos(); - llvm::InitializeAllTargets(); - llvm::InitializeAllTargetMCs(); - llvm::InitializeAllAsmParsers(); - llvm::InitializeAllAsmPrinters(); - - auto TargetTriple = llvm::sys::getDefaultTargetTriple(); - std::string Error; - auto Target = llvm::TargetRegistry::lookupTarget(TargetTriple, Error); - - llvm::TargetOptions opt; - auto TargetMachine = Target->createTargetMachine(TargetTriple, "generic", "", opt, llvm::Reloc::PIC_); - Module->setDataLayout(TargetMachine->createDataLayout()); - - std::string out; - llvm::raw_string_ostream dest{ out }; - - Module->print(dest, nullptr); - dest.flush(); - - std::cout << out << std::endl; } \ No newline at end of file