Commit b1a05787 authored by Naveen N. Rao's avatar Naveen N. Rao Committed by Michael Ellerman

powerpc/bpf/jit: Optimize 64-bit Immediate loads

Similar to the LI32() optimization, if the value can be represented
in 32-bits, use LI32(). Also handle loading a few specific forms of
immediate values in an optimum manner.
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Signed-off-by: default avatarNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent aaf2f7e0
...@@ -244,20 +244,25 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh); ...@@ -244,20 +244,25 @@ DECLARE_LOAD_FUNC(sk_load_byte_msh);
} } while(0) } } while(0)
#define PPC_LI64(d, i) do { \ #define PPC_LI64(d, i) do { \
if (!((uintptr_t)(i) & 0xffffffff00000000ULL)) \ if ((long)(i) >= -2147483648 && \
(long)(i) < 2147483648) \
PPC_LI32(d, i); \ PPC_LI32(d, i); \
else { \
if (!((uintptr_t)(i) & 0xffff800000000000ULL)) \
PPC_LI(d, ((uintptr_t)(i) >> 32) & 0xffff); \
else { \ else { \
PPC_LIS(d, ((uintptr_t)(i) >> 48)); \ PPC_LIS(d, ((uintptr_t)(i) >> 48)); \
if ((uintptr_t)(i) & 0x0000ffff00000000ULL) \ if ((uintptr_t)(i) & 0x0000ffff00000000ULL) \
PPC_ORI(d, d, \ PPC_ORI(d, d, \
((uintptr_t)(i) >> 32) & 0xffff); \ ((uintptr_t)(i) >> 32) & 0xffff); \
} \
PPC_SLDI(d, d, 32); \ PPC_SLDI(d, d, 32); \
if ((uintptr_t)(i) & 0x00000000ffff0000ULL) \ if ((uintptr_t)(i) & 0x00000000ffff0000ULL) \
PPC_ORIS(d, d, \ PPC_ORIS(d, d, \
((uintptr_t)(i) >> 16) & 0xffff); \ ((uintptr_t)(i) >> 16) & 0xffff); \
if ((uintptr_t)(i) & 0x000000000000ffffULL) \ if ((uintptr_t)(i) & 0x000000000000ffffULL) \
PPC_ORI(d, d, (uintptr_t)(i) & 0xffff); \ PPC_ORI(d, d, (uintptr_t)(i) & 0xffff); \
} } while (0); } } while (0)
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
#define PPC_FUNC_ADDR(d,i) do { PPC_LI64(d, i); } while(0) #define PPC_FUNC_ADDR(d,i) do { PPC_LI64(d, i); } while(0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment