Sub returns x - y. The types of the two values must be equal.
(x, y *Value)
| 171 | |
| 172 | // Sub returns x - y. The types of the two values must be equal. |
| 173 | func (b *Builder) Sub(x, y *Value) *Value { |
| 174 | assertTypesEqual(x.Type(), y.Type()) |
| 175 | ty := Scalar(x.Type()) |
| 176 | switch { |
| 177 | case IsInteger(ty): |
| 178 | return b.val(x.Type(), b.llvm.CreateSub(x.llvm, y.llvm, x.Name()+"-"+y.Name())) |
| 179 | case IsFloat(ty): |
| 180 | return b.val(x.Type(), b.llvm.CreateFSub(x.llvm, y.llvm, x.Name()+"-"+y.Name())) |
| 181 | default: |
| 182 | panic(fmt.Errorf("Cannot subtract values of type %v", ty)) |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | // SubS returns x - y. The types of the two values must be equal. |
| 187 | func (b *Builder) SubS(x *Value, y interface{}) *Value { |
no test coverage detected