MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / ir_math_shr_signed

Function ir_math_shr_signed

tests/integration/vm_execution.rs:2050–2077  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2048/// Signed right shift (`sra`): -8 >> 2 must equal -2. Built directly in IR.
2049#[test]
2050fn 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]

Callers

nothing calls this directly

Calls 4

pass_fail_irFunction · 0.85
run_irFunction · 0.85
push_instructionMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected