ShiftRight performs a bit-shift right by shift bits.
(x, y *Value)
| 292 | |
| 293 | // ShiftRight performs a bit-shift right by shift bits. |
| 294 | func (b *Builder) ShiftRight(x, y *Value) *Value { |
| 295 | assertTypesEqual(x.Type(), y.Type()) |
| 296 | ty := x.Type() |
| 297 | switch { |
| 298 | case IsSignedInteger(ty): |
| 299 | return b.val(ty, b.llvm.CreateAShr(x.llvm, y.llvm, x.Name()+">>"+y.Name())) |
| 300 | case IsUnsignedInteger(ty): |
| 301 | return b.val(ty, b.llvm.CreateLShr(x.llvm, y.llvm, x.Name()+">>"+y.Name())) |
| 302 | default: |
| 303 | panic(fmt.Errorf("Cannot divide values of type %v", ty)) |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | // Select returns (cond ? x : y). x and y must be of the same type. |
| 308 | func (b *Builder) Select(cond, x, y *Value) *Value { |
no test coverage detected