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

Method Rem

core/codegen/arithmetic.go:228–242  ·  view source on GitHub ↗

Rem returns x % y. The types of the two values must be equal.

(x, y *Value)

Source from the content-addressed store, hash-verified

226
227// Rem returns x % y. The types of the two values must be equal.
228func (b *Builder) Rem(x, y *Value) *Value {
229 assertTypesEqual(x.Type(), y.Type())
230 ty := Scalar(x.Type())
231 name := x.Name() + "%" + y.Name()
232 switch {
233 case IsSignedInteger(ty):
234 return b.val(ty, b.llvm.CreateSRem(x.llvm, y.llvm, name))
235 case IsUnsignedInteger(ty):
236 return b.val(ty, b.llvm.CreateURem(x.llvm, y.llvm, name))
237 case IsFloat(ty):
238 return b.val(ty, b.llvm.CreateFRem(x.llvm, y.llvm, name))
239 default:
240 panic(fmt.Errorf("Cannot divide values of type %v", ty))
241 }
242}
243
244// DivS returns x / y. The types of the two values must be equal.
245func (b *Builder) DivS(x *Value, y interface{}) *Value {

Callers

nothing calls this directly

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