Skip to content
Browse files

Add missing nsw/nuw instructions (ruby-llvm/ruby-llvm#10).

  • Loading branch information...
1 parent 969a044 commit 1a61cf7e2adfd99f39dfa369fe9e9cb49ab6f2a0 @whitequark whitequark committed Jan 21, 2013
Showing with 73 additions and 1 deletion.
  1. +73 −1 lib/llvm/core/builder.rb
View
74 lib/llvm/core/builder.rb
@@ -157,6 +157,7 @@ def unreachable
Instruction.from_ptr(C.build_unreachable(self))
end
+ # Integer addition.
# @param [LLVM::Value] lhs Integer or vector of integers
# @param [LLVM::Value] rhs Integer or vector of integers
# @param [String] name Name of the result in LLVM IR
@@ -166,7 +167,7 @@ def add(lhs, rhs, name = "")
Instruction.from_ptr(C.build_add(self, lhs, rhs, name))
end
- # No signed wrap addition.
+ # "No signed wrap" integer addition.
# @param [LLVM::Value] lhs Integer or vector of integers
# @param [LLVM::Value] rhs Integer or vector of integers
# @param [String] name Name of the result in LLVM IR
@@ -176,6 +177,16 @@ def nsw_add(lhs, rhs, name = "")
Instruction.from_ptr(C.build_nsw_add(self, lhs, rhs, name))
end
+ # "No unsigned wrap" integer addition.
+ # @param [LLVM::Value] lhs Integer or vector of integers
+ # @param [LLVM::Value] rhs Integer or vector of integers
+ # @param [String] name Name of the result in LLVM IR
+ # @return [LLVM::Instruction] The integer sum of the two operands
+ # @LLVMinst add
+ def nuw_add(lhs, rhs, name = "")
+ Instruction.from_ptr(C.build_nuw_add(self, lhs, rhs, name))
+ end
+
# @param [LLVM::Value] lhs Floating point or vector of floating points
# @param [LLVM::Value] rhs Floating point or vector of floating points
# @param [String] name Name of the result in LLVM IR
@@ -185,6 +196,7 @@ def fadd(lhs, rhs, name = "")
Instruction.from_ptr(C.build_f_add(self, lhs, rhs, name))
end
+ # Integer subtraction.
# @param [LLVM::Value] lhs Integer or vector of integers
# @param [LLVM::Value] rhs Integer or vector of integers
# @param [String] name Name of the result in LLVM IR
@@ -194,6 +206,26 @@ def sub(lhs, rhs, name = "")
Instruction.from_ptr(C.build_sub(self, lhs, rhs, name))
end
+ # No signed wrap integer subtraction.
+ # @param [LLVM::Value] lhs Integer or vector of integers
+ # @param [LLVM::Value] rhs Integer or vector of integers
+ # @param [String] name Name of the result in LLVM IR
+ # @return [LLVM::Instruction] The integer difference of the two operands
+ # @LLVMinst sub
+ def nsw_sub(lhs, rhs, name = "")
+ Instruction.from_ptr(C.build_nsw_sub(self, lhs, rhs, name))
+ end
+
+ # No unsigned wrap integer subtraction.
+ # @param [LLVM::Value] lhs Integer or vector of integers
+ # @param [LLVM::Value] rhs Integer or vector of integers
+ # @param [String] name Name of the result in LLVM IR
+ # @return [LLVM::Instruction] The integer difference of the two operands
+ # @LLVMinst sub
+ def nuw_sub(lhs, rhs, name = "")
+ Instruction.from_ptr(C.build_nuw_sub(self, lhs, rhs, name))
+ end
+
# @param [LLVM::Value] lhs Floating point or vector of floating points
# @param [LLVM::Value] rhs Floating point or vector of floating points
# @param [String] name Name of the result in LLVM IR
@@ -204,6 +236,7 @@ def fsub(lhs, rhs, name = "")
Instruction.from_ptr(C.build_f_sub(self, lhs, rhs, name))
end
+ # Integer multiplication.
# @param [LLVM::Value] lhs Integer or vector of integers
# @param [LLVM::Value] rhs Integer or vector of integers
# @param [String] name Name of the result in LLVM IR
@@ -213,6 +246,27 @@ def mul(lhs, rhs, name = "")
Instruction.from_ptr(C.build_mul(self, lhs, rhs, name))
end
+ # "No signed wrap" integer multiplication.
+ # @param [LLVM::Value] lhs Integer or vector of integers
+ # @param [LLVM::Value] rhs Integer or vector of integers
+ # @param [String] name Name of the result in LLVM IR
+ # @return [LLVM::Instruction] The integer product of the two operands
+ # @LLVMinst mul
+ def nsw_mul(lhs, rhs, name = "")
+ Instruction.from_ptr(C.build_nsw_mul(self, lhs, rhs, name))
+ end
+
+ # "No unsigned wrap" integer multiplication.
+ # @param [LLVM::Value] lhs Integer or vector of integers
+ # @param [LLVM::Value] rhs Integer or vector of integers
+ # @param [String] name Name of the result in LLVM IR
+ # @return [LLVM::Instruction] The integer product of the two operands
+ # @LLVMinst mul
+ def nuw_mul(lhs, rhs, name = "")
+ Instruction.from_ptr(C.build_nuw_mul(self, lhs, rhs, name))
+ end
+
+ # Floating point multiplication
# @param [LLVM::Value] lhs Floating point or vector of floating points
# @param [LLVM::Value] rhs Floating point or vector of floating points
# @param [String] name Name of the result in LLVM IR
@@ -358,6 +412,24 @@ def neg(arg, name = "")
Instruction.from_ptr(C.build_neg(self, arg, name))
end
+ # "No signed wrap" integer negation.
+ # @param [LLVM::Value] arg Integer or vector of integers
+ # @param [String] name Name of the result in LLVM IR
+ # @return [LLVM::Instruction] The negated operand
+ # @LLVMinst sub
+ def nsw_neg(arg, name = "")
+ Instruction.from_ptr(C.build_nsw_neg(self, arg, name))
+ end
+
+ # "No unsigned wrap" integer negation.
+ # @param [LLVM::Value] arg Integer or vector of integers
+ # @param [String] name Name of the result in LLVM IR
+ # @return [LLVM::Instruction] The negated operand
+ # @LLVMinst sub
+ def nuw_neg(arg, name = "")
+ Instruction.from_ptr(C.build_nuw_neg(self, arg, name))
+ end
+
# Boolean negation.
# @param [LLVM::Value] arg Integer or vector of integers
# @param [String] name The name of the result in LLVM IR

0 comments on commit 1a61cf7

Please sign in to comment.
Something went wrong with that request. Please try again.