Skip to content

Commit

Permalink
Expose LLVM instruction builder for neg and fneg (#14774)
Browse files Browse the repository at this point in the history
  • Loading branch information
JarnaChao09 authored Aug 7, 2024
1 parent 8f26137 commit ac2ecb0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/llvm/builder.cr
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,13 @@ class LLVM::Builder
end
{% end %}

def not(value, name = "")
# check_value(value)
{% for name in %w(not neg fneg) %}
def {{name.id}}(value, name = "")
# check_value(value)

Value.new LibLLVM.build_not(self, value, name)
end
Value.new LibLLVM.build_{{name.id}}(self, value, name)
end
{% end %}

def unreachable
Value.new LibLLVM.build_unreachable(self)
Expand Down
2 changes: 2 additions & 0 deletions src/llvm/lib_llvm/core.cr
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ lib LibLLVM
fun build_or = LLVMBuildOr(BuilderRef, lhs : ValueRef, rhs : ValueRef, name : Char*) : ValueRef
fun build_xor = LLVMBuildXor(BuilderRef, lhs : ValueRef, rhs : ValueRef, name : Char*) : ValueRef
fun build_not = LLVMBuildNot(BuilderRef, value : ValueRef, name : Char*) : ValueRef
fun build_neg = LLVMBuildNeg(BuilderRef, value : ValueRef, name : Char*) : ValueRef
fun build_fneg = LLVMBuildFNeg(BuilderRef, value : ValueRef, name : Char*) : ValueRef

fun build_malloc = LLVMBuildMalloc(BuilderRef, ty : TypeRef, name : Char*) : ValueRef
fun build_array_malloc = LLVMBuildArrayMalloc(BuilderRef, ty : TypeRef, val : ValueRef, name : Char*) : ValueRef
Expand Down

0 comments on commit ac2ecb0

Please sign in to comment.