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
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 make_function_returning_stack_pointer(self): mc = PPCBuilder() mc.mr(r.r3.value, r.r1.value) mc.blr() return rffi.cast(lltype.Signed, mc.get_assembler_function())