Negate returns -x. The type of x must be a signed integer or float.
(x *Value)
| 59 | |
| 60 | // Negate returns -x. The type of x must be a signed integer or float. |
| 61 | func (b *Builder) Negate(x *Value) *Value { |
| 62 | ty := Scalar(x.Type()) |
| 63 | name := "-" + x.Name() |
| 64 | switch { |
| 65 | case IsSignedInteger(ty): |
| 66 | return b.val(ty, b.llvm.CreateNeg(x.llvm, name)) |
| 67 | case IsFloat(ty): |
| 68 | return b.val(ty, b.llvm.CreateFNeg(x.llvm, name)) |
| 69 | default: |
| 70 | panic(fmt.Errorf("Cannot divide values of type %v", ty)) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | func (b *Builder) cmp(x *Value, op string, y *Value, ucmp, scmp llvm.IntPredicate, fcmp llvm.FloatPredicate) *Value { |
| 75 | assertTypesEqual(x.Type(), y.Type()) |