MCPcopy Create free account
hub / github.com/google/gapid / Negate

Method Negate

core/codegen/arithmetic.go:61–72  ·  view source on GitHub ↗

Negate returns -x. The type of x must be a signed integer or float.

(x *Value)

Source from the content-addressed store, hash-verified

59
60// Negate returns -x. The type of x must be a signed integer or float.
61func (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
74func (b *Builder) cmp(x *Value, op string, y *Value, ucmp, scmp llvm.IntPredicate, fcmp llvm.FloatPredicate) *Value {
75 assertTypesEqual(x.Type(), y.Type())

Callers 2

encodeValueMethod · 0.80
buildEncodeTypeFuncsMethod · 0.80

Calls 6

valMethod · 0.95
ScalarFunction · 0.85
IsSignedIntegerFunction · 0.85
IsFloatFunction · 0.85
TypeMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected