()
| 2048 | /// Signed right shift (`sra`): -8 >> 2 must equal -2. Built directly in IR. |
| 2049 | #[test] |
| 2050 | fn ir_math_shr_signed() { |
| 2051 | let i32_ty = IrType::Integer(IntWidth::I32); |
| 2052 | let mut entry = IrBlock::new("entry"); |
| 2053 | entry.push_instruction(IrInstruction::Math { |
| 2054 | dest: IrRegister::Named("shifted".into()), |
| 2055 | op: IrMathOp::Shr, |
| 2056 | ty: i32_ty.clone(), |
| 2057 | lhs: IrValue::Integer(-8), |
| 2058 | rhs: IrValue::Integer(2), |
| 2059 | }); |
| 2060 | entry.push_instruction(IrInstruction::Cmp { |
| 2061 | dest: IrRegister::Named("ok".into()), |
| 2062 | op: IrCmpOp::Eq, |
| 2063 | ty: i32_ty, |
| 2064 | lhs: IrValue::Register(IrRegister::Named("shifted".into())), |
| 2065 | rhs: IrValue::Integer(-2), |
| 2066 | }); |
| 2067 | let program = pass_fail_ir( |
| 2068 | "shr_signed", |
| 2069 | entry, |
| 2070 | IrValue::Register(IrRegister::Named("ok".into())), |
| 2071 | ); |
| 2072 | let (_, outcome, _) = run_ir(&program); |
| 2073 | assert!( |
| 2074 | matches!(outcome, StepOutcome::Halted(0)), |
| 2075 | "sra: -8 >> 2 == -2, got {outcome:?}" |
| 2076 | ); |
| 2077 | } |
| 2078 | |
| 2079 | /// Left shift (`sll`): 1 << 10 must equal 1024. Built directly in IR. |
| 2080 | #[test] |
nothing calls this directly
no test coverage detected