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

Method Div

core/codegen/arithmetic.go:211–225  ·  view source on GitHub ↗

Div returns x / y. The types of the two values must be equal.

(x, y *Value)

Source from the content-addressed store, hash-verified

209
210// Div returns x / y. The types of the two values must be equal.
211func (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.
228func (b *Builder) Rem(x, y *Value) *Value {

Callers 5

DivSMethod · 0.95
doCastMethod · 0.80
buildMapMethod · 0.80
doBinaryOpMethod · 0.80
observedMethod · 0.80

Calls 8

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

Tested by

no test coverage detected