def test_load_from(self): a = PPCBuilder() p = lltype.malloc(rffi.CArray(rffi.LONG), 1, flavor="raw") addr = rffi.cast(lltype.Signed, p) p[0] = rffi.cast(rffi.LONG, 200) a.load_from_addr(r3, addr) a.blr() f = a.get_assembler_function() assert f() == 200 p[0] = rffi.cast(rffi.LONG, 300) assert f() == 300 lltype.free(p, flavor="raw")
def test_load_from(self): a = PPCBuilder() p = lltype.malloc(rffi.CArray(rffi.LONG), 1, flavor="raw") addr = rffi.cast(lltype.Signed, p) p[0] = rffi.cast(rffi.LONG, 200) a.load_from_addr(r3, SCRATCH2, addr) a.blr() f = a.get_assembler_function() assert f() == 200 p[0] = rffi.cast(rffi.LONG, 300) assert f() == 300 lltype.free(p, flavor="raw")
def test_call_function(self): functype = lltype.Ptr(lltype.FuncType([lltype.Signed], lltype.Signed)) call_addr = rffi.cast(lltype.Signed, llhelper(functype, func)) a = PPCBuilder() # NOW EXPLICITLY: # # - Load the address of the function to call into a register x # - Move the content of this register x into CTR # - Set the LR manually (or with bctrl) # - Do jump a.li(3, 50) if IS_PPC_32: a.load_imm(r10, call_addr) elif IS_BIG_ENDIAN: # load the 3-words descriptor a.load_from_addr(r10, call_addr) a.load_from_addr(r2, call_addr + WORD) a.load_from_addr(r11, call_addr + 2 * WORD) else: # no descriptor on little-endian, but the ABI says r12 must # contain the function pointer a.load_imm(r10, call_addr) a.mr(12, 10) a.mtctr(10) a.bctr() a.blr() f = a.get_assembler_function() assert f() == 65
def test_call_function(self): functype = lltype.Ptr(lltype.FuncType([lltype.Signed], lltype.Signed)) call_addr = rffi.cast(lltype.Signed, llhelper(functype, func)) a = PPCBuilder() # NOW EXPLICITLY: # # - Load the address of the function to call into a register x # - Move the content of this register x into CTR # - Set the LR manually (or with bctrl) # - Do jump a.li(3, 50) if IS_PPC_32: a.load_imm(r10, call_addr) elif IS_BIG_ENDIAN: # load the 3-words descriptor a.load_from_addr(r10, SCRATCH2, call_addr) a.load_from_addr(r2, SCRATCH2, call_addr + WORD) a.load_from_addr(r11, SCRATCH2, call_addr + 2 * WORD) else: # no descriptor on little-endian, but the ABI says r12 must # contain the function pointer a.load_imm(r10, call_addr) a.mr(12, 10) a.mtctr(10) a.bctr() a.blr() f = a.get_assembler_function() assert f() == 65