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

Method cmp

core/codegen/arithmetic.go:74–93  ·  view source on GitHub ↗
(x *Value, op string, y *Value, ucmp, scmp llvm.IntPredicate, fcmp llvm.FloatPredicate)

Source from the content-addressed store, hash-verified

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())
76 ty := x.Type()
77 if vec, isVec := ty.(Vector); isVec {
78 ty = vec.Element
79 }
80 var v *Value
81 switch {
82 case IsSignedInteger(ty):
83 v = b.val(b.m.Types.Bool, b.llvm.CreateICmp(scmp, x.llvm, y.llvm, ""))
84 case IsUnsignedInteger(ty), IsPointer(ty), IsBool(ty):
85 v = b.val(b.m.Types.Bool, b.llvm.CreateICmp(ucmp, x.llvm, y.llvm, ""))
86 case IsFloat(ty):
87 v = b.val(b.m.Types.Bool, b.llvm.CreateFCmp(fcmp, x.llvm, y.llvm, ""))
88 default:
89 panic(fmt.Errorf("Cannot compare %v types with %v", ty.TypeName(), op))
90 }
91 v.SetName(x.Name() + op + y.Name())
92 return v
93}
94
95// Equal returns x == y. The types of the two values must be equal.
96func (b *Builder) Equal(x, y *Value) *Value {

Callers 6

EqualMethod · 0.95
NotEqualMethod · 0.95
GreaterThanMethod · 0.95
LessThanMethod · 0.95
GreaterOrEqualToMethod · 0.95
LessOrEqualToMethod · 0.95

Calls 11

valMethod · 0.95
SetNameMethod · 0.95
assertTypesEqualFunction · 0.85
IsSignedIntegerFunction · 0.85
IsUnsignedIntegerFunction · 0.85
IsPointerFunction · 0.85
IsBoolFunction · 0.85
IsFloatFunction · 0.85
TypeMethod · 0.65
TypeNameMethod · 0.65
NameMethod · 0.65

Tested by

no test coverage detected