dotnet / LLVMSharp

LLVM bindings for .NET Standard written in C# using ClangSharp
MIT License
844 stars 97 forks source link

Add HelloWorld sample of LLVM14 #201

Closed CWKSC closed 1 year ago

CWKSC commented 2 years ago

HelloWorld sample of LLVM14

I'm not sure if the running JIT compiler part is correct (RunMain()).

This sample will output:

[Output of LLVM IR]:

; ModuleID = 'Hello World'
source_filename = "Hello World"

@0 = private unnamed_addr constant [13 x i8] c"Hello World!\00", align 1

declare i32 @puts(i8* %0)

define i32 @main() {
entry:
  %0 = call i32 @puts(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @0, i32 0, i32 0))
  ret i32 0
}

[Output of JIT Compiler]:

Hello World!
dnfadmin commented 2 years ago

CLA assistant check
All CLA requirements met.