@Test
	public void testSimpleRefsAndDelaySlots() throws AddressFormatException {
		//verify that the test program contains the instructions for the test
		Address calldsAddr = defaultSpace.getAddress(CALLDS_FUNC3_10002a);
		Instruction callds = program.getListing().getInstructionAt(calldsAddr);
		assertNotNull(callds);
		assertEquals("callds 0x" + func3Addr.toString(), callds.toString());

		Address callAddr = defaultSpace.getAddress(CALL_FUNC1_10002c);
		Instruction call = program.getListing().getInstructionAt(callAddr);
		assertNotNull(call);
		assertEquals("_call 0x" + func1Addr.toString(), call.toString());

		//grab pcode for both instructions before any overrides applied
		PcodeOp[] calldsUnmodified = callds.getPcode(false);
		assertTrue(calldsUnmodified.length == 4);
		assertTrue(calldsUnmodified[0].getOpcode() == PcodeOp.COPY);  //from inst in delay slot
		assertTrue(calldsUnmodified[1].getOpcode() == PcodeOp.CALL);  //from inst in delay slot
		assertTrue(calldsUnmodified[1].getInput(0).getOffset() == func1Addr.getOffset());
		assertTrue(calldsUnmodified[2].getOpcode() == PcodeOp.COPY);  //save ret address to lr
		assertTrue(calldsUnmodified[3].getInput(0).getOffset() == func3Addr.getOffset());
		assertTrue(calldsUnmodified[3].getOpcode() == PcodeOp.CALL);  //call to func3
		PcodeOp[] callUnmodified = call.getPcode(false);
		assertTrue(callUnmodified.length == 2);
		assertTrue(equalPcodeOps(callUnmodified[0], calldsUnmodified[0]));  //save ret address to lr
		assertTrue(equalPcodeOps(callUnmodified[1], calldsUnmodified[1]));  //call to func1

		//verify that pcode is the same whether or not you request overrides for the instruction
		//in the delay slot
		assertTrue(equalPcodeOpArrays(call.getPcode(false), call.getPcode(true)));

		//this is the same corner case discussed in testFlowOverridesAndDelaySlots
		//it demonstrates that a simple ref override on an instruction with a delay slot
		//can apply to the pcode generated by the delayslot directive
		PcodeOp[] cornerCase = callds.getPcode(true);
		assertFalse(equalPcodeOpArrays(callds.getPcode(false), cornerCase));
		assertTrue(cornerCase[0].getOpcode() == PcodeOp.COPY);  //from inst in delay slot
		assertTrue(cornerCase[1].getOpcode() == PcodeOp.CALL);  //from inst in delay slot, overridden
		assertTrue(cornerCase[1].getInput(0).getOffset() == func3Addr.getOffset());
		assertTrue(cornerCase[2].getOpcode() == PcodeOp.COPY);  //save ret address to lr
		assertTrue(cornerCase[3].getOpcode() == PcodeOp.CALL);  //call to func3
		assertTrue(cornerCase[3].getInput(0).getOffset() == func3Addr.getOffset());

		//apply a simple ref on the call in the delay slot
		int id = program.startTransaction("test");
		Reference simpleCallRef = refManager.addMemoryReference(callAddr, func1Addr,
			RefType.UNCONDITIONAL_CALL, SourceType.USER_DEFINED, 0);
		//default reference is primary; set simpleCallRef to primary to unseat it
		refManager.setPrimary(simpleCallRef, true);
		program.endTransaction(id, true);

		//verify the pcode generated for the call instruction without overrides
		assertTrue(equalPcodeOpArrays(call.getPcode(false), callUnmodified));

		//verify the pcode generated for the call instruction with overrides
		PcodeOp[] callModifiedSimpleRef = call.getPcode(true);
		assertTrue(callModifiedSimpleRef.length == 2);
		assertTrue(equalPcodeOps(callModifiedSimpleRef[0], callUnmodified[0]));
		assertTrue(callModifiedSimpleRef[1].getOpcode() == PcodeOp.CALL);
		assertTrue(callModifiedSimpleRef[1].getInput(0).getOffset() == func1Addr.getOffset());

		//verify that nothing changes when generating the pcode for callds
		assertTrue(equalPcodeOpArrays(callds.getPcode(false), calldsUnmodified));
		assertTrue(equalPcodeOpArrays(callds.getPcode(true), cornerCase));

		//apply a non-primary CALL_OVERRIDE_UNCONDITIONAL ref
		id = program.startTransaction("test");
		Reference callOverrideRef = refManager.addMemoryReference(callAddr, func2Addr,
			RefType.CALL_OVERRIDE_UNCONDITIONAL, SourceType.USER_DEFINED, 0);
		program.endTransaction(id, true);

		//verify no effect (since simpleCallRef has precedence)
		assertTrue(equalPcodeOpArrays(call.getPcode(false), callUnmodified));
		assertTrue(equalPcodeOpArrays(call.getPcode(true), callModifiedSimpleRef));
		assertTrue(equalPcodeOpArrays(callds.getPcode(false), calldsUnmodified));
		assertTrue(equalPcodeOpArrays(callds.getPcode(true), cornerCase));

		//make callOverrideRef primary
		id = program.startTransaction("test");
		refManager.setPrimary(callOverrideRef, true);
		program.endTransaction(id, true);

		//verify no effect on pcode for call when overrides not requested
		assertTrue(equalPcodeOpArrays(call.getPcode(false), callUnmodified));

		//verify that the call target is changed to func2addr when overrides are requested
		PcodeOp[] callModifiedoverrideRef = call.getPcode(true);
		assertTrue(equalPcodeOps(callModifiedoverrideRef[0], callUnmodified[0]));
		assertTrue(callModifiedoverrideRef[1].getOpcode() == PcodeOp.CALL);
		assertTrue(callModifiedoverrideRef[1].getInput(0).getOffset() == func2Addr.getOffset());

		//verify no effect on the pcode for callds
		assertTrue(equalPcodeOpArrays(callds.getPcode(false), calldsUnmodified));
		assertTrue(equalPcodeOpArrays(callds.getPcode(true), cornerCase));
	}
note: for callds, the delayslot directive occurs before the call
so a call in the delay slot wil end up being the first call of the callds instruction
@throws AddressFormatException if {@code AddressSpace.getAddress throws it}
Ghidra/Test/IntegrationTest/src/test.slow/java/ghidra/program/model/pcode/PcodeEmitContextTest.java