mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
bitshifts for the dev backend
This commit is contained in:
parent
081c61ead6
commit
843f5b15e5
5 changed files with 389 additions and 9 deletions
|
@ -553,6 +553,27 @@ trait Backend<'a> {
|
|||
internal_error!("bitwise xor on a non-integer")
|
||||
}
|
||||
}
|
||||
LowLevel::NumShiftLeftBy => {
|
||||
if let Layout::Builtin(Builtin::Int(int_width)) = self.interner().get(*ret_layout) {
|
||||
self.build_int_shift_left(sym, &args[0], &args[1], int_width)
|
||||
} else {
|
||||
internal_error!("shift left on a non-integer")
|
||||
}
|
||||
}
|
||||
LowLevel::NumShiftRightBy => {
|
||||
if let Layout::Builtin(Builtin::Int(int_width)) = self.interner().get(*ret_layout) {
|
||||
self.build_int_shift_right(sym, &args[0], &args[1], int_width)
|
||||
} else {
|
||||
internal_error!("shift right on a non-integer")
|
||||
}
|
||||
}
|
||||
LowLevel::NumShiftRightZfBy => {
|
||||
if let Layout::Builtin(Builtin::Int(int_width)) = self.interner().get(*ret_layout) {
|
||||
self.build_int_shift_right_zero_fill(sym, &args[0], &args[1], int_width)
|
||||
} else {
|
||||
internal_error!("shift right zero-fill on a non-integer")
|
||||
}
|
||||
}
|
||||
LowLevel::Eq => {
|
||||
debug_assert_eq!(2, args.len(), "Eq: expected to have exactly two argument");
|
||||
debug_assert_eq!(
|
||||
|
@ -888,6 +909,33 @@ trait Backend<'a> {
|
|||
int_width: IntWidth,
|
||||
);
|
||||
|
||||
/// stores the `Num.shiftLeftBy src1 src2` into dst.
|
||||
fn build_int_shift_left(
|
||||
&mut self,
|
||||
dst: &Symbol,
|
||||
src1: &Symbol,
|
||||
src2: &Symbol,
|
||||
int_width: IntWidth,
|
||||
);
|
||||
|
||||
/// stores the `Num.shiftRightBy src1 src2` into dst.
|
||||
fn build_int_shift_right(
|
||||
&mut self,
|
||||
dst: &Symbol,
|
||||
src1: &Symbol,
|
||||
src2: &Symbol,
|
||||
int_width: IntWidth,
|
||||
);
|
||||
|
||||
/// stores the `Num.shiftRightZfBy src1 src2` into dst.
|
||||
fn build_int_shift_right_zero_fill(
|
||||
&mut self,
|
||||
dst: &Symbol,
|
||||
src1: &Symbol,
|
||||
src2: &Symbol,
|
||||
int_width: IntWidth,
|
||||
);
|
||||
|
||||
/// build_eq stores the result of `src1 == src2` into dst.
|
||||
fn build_eq(&mut self, dst: &Symbol, src1: &Symbol, src2: &Symbol, arg_layout: &InLayout<'a>);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue