Div returns x / y. The types of the two values must be equal.
(x, y *Value)
| 209 | |
| 210 | // Div returns x / y. The types of the two values must be equal. |
| 211 | func (b *Builder) Div(x, y *Value) *Value { |
| 212 | assertTypesEqual(x.Type(), y.Type()) |
| 213 | ty := Scalar(x.Type()) |
| 214 | name := x.Name() + "/" + y.Name() |
| 215 | switch { |
| 216 | case IsSignedInteger(ty): |
| 217 | return b.val(ty, b.llvm.CreateSDiv(x.llvm, y.llvm, name)) |
| 218 | case IsUnsignedInteger(ty): |
| 219 | return b.val(ty, b.llvm.CreateUDiv(x.llvm, y.llvm, name)) |
| 220 | case IsFloat(ty): |
| 221 | return b.val(ty, b.llvm.CreateFDiv(x.llvm, y.llvm, name)) |
| 222 | default: |
| 223 | panic(fmt.Errorf("Cannot divide values of type %v", ty)) |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | // Rem returns x % y. The types of the two values must be equal. |
| 228 | func (b *Builder) Rem(x, y *Value) *Value { |
no test coverage detected