| 2297 | }); |
| 2298 | let program = pass_fail_ir( |
| 2299 | "shl", |
| 2300 | entry, |
| 2301 | IrValue::Register(IrRegister::Named("ok".into())), |
| 2302 | ); |
| 2303 | let (_, outcome, _) = run_ir(&program); |
| 2304 | assert!( |
| 2305 | matches!(outcome, RunOutcome::Halted(0)), |
| 2306 | "sll: 1 << 10 == 1024, got {outcome:?}" |
| 2307 | ); |
| 2308 | } |
| 2309 | |
| 2310 | /// IR-level unary negation: IrUnaryOp::Neg applied to 7 yields -7. |
| 2311 | #[test] |
| 2312 | fn ir_unary_neg_ir() { |
| 2313 | let i32_ty = IrType::Integer(IntWidth::I32); |
| 2314 | let mut entry = IrBlock::new("entry"); |
| 2315 | entry.push_instruction(IrInstruction::Unary { |
| 2316 | dest: IrRegister::Named("neg_val".into()), |
| 2317 | op: IrUnaryOp::Neg, |
| 2318 | ty: i32_ty.clone(), |
| 2319 | value: IrValue::Integer(7), |