Skip to content

Commit

Permalink
Merge pull request #4 from xushiwei/q
Browse files Browse the repository at this point in the history
Builder.Finalize; CreateBinOp/ICmp/FCmp
  • Loading branch information
xushiwei authored Apr 17, 2024
2 parents 1020ca7 + 65389de commit 4fb15c5
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions z_finalize.go → z_llvmext.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,24 @@ func (m Module) Finalize() {
Module{m}.Dispose()
})
}

func (b Builder) Finalize() {
runtime.SetFinalizer(b.C, func(b C.LLVMBuilderRef) {
Builder{b}.Dispose()
})
}

func CreateBinOp(b Builder, op Opcode, lhs, rhs Value) (v Value) {
v.C = C.LLVMBuildBinOp(b.C, C.LLVMOpcode(op), lhs.C, rhs.C, nil)
return
}

func CreateICmp(b Builder, op IntPredicate, lhs, rhs Value) (v Value) {
v.C = C.LLVMBuildICmp(b.C, C.LLVMIntPredicate(op), lhs.C, rhs.C, nil)
return
}

func CreateFCmp(b Builder, op FloatPredicate, lhs, rhs Value) (v Value) {
v.C = C.LLVMBuildFCmp(b.C, C.LLVMRealPredicate(op), lhs.C, rhs.C, nil)
return
}

0 comments on commit 4fb15c5

Please sign in to comment.