[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [LIBGCC/LIBGCOV PATCH 2/2] Makefile.uk: Enable macros through -D compile flag
Hi Alice, Again, this patch does 2 things: it adds the defines and also popcountdi2.c. Please see my other comments inline. On 5/21/20 10:18 PM, Alice Suiu wrote: > Add -D compile flag to generate specific functions for libgcov. > > Signed-off-by: Alice Suiu <alicesuiu17@xxxxxxxxx> > --- > Makefile.uk | 8 +- > libgcov/include/popcountdi2.c | 39 ++++++++++ > libgcov/include/popcountdi2.h | 137 ++++++++++++++++++++++++++++++++++ > 3 files changed, 183 insertions(+), 1 deletion(-) > create mode 100644 libgcov/include/popcountdi2.c > create mode 100644 libgcov/include/popcountdi2.h > > diff --git a/Makefile.uk b/Makefile.uk > index fe56ad8..fb68c95 100644 > --- a/Makefile.uk > +++ b/Makefile.uk > @@ -131,9 +131,15 @@ LIBGCOV_CINCLUDES-y = -I$(LIBGCC_BASE)/libgcov/include \ > -I$(LIBGCC_BASE)/libgcov/include/config > > LIBGCOV_CFLAGS-y += -O2 -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector \ > - -DHAVE_CC_TLS > + -DHAVE_CC_TLS -DL_gcov_merge_add -DL_gcov_merge_single > -DL_gcov_merge_ior -DL_gcov_merge_time_profile -DL_gcov_merge_icall_topn \ > + -DL_gcov_interval_profiler -DL_gcov_interval_profiler_atomic > -DL_gcov_pow2_profiler -DL_gcov_pow2_profiler_atomic \ > + -DL_gcov_one_value_profiler -DL_gcov_one_value_profiler_atomic > -DL_gcov_average_profiler -DL_gcov_average_profiler_atomic \ > + -DL_gcov_ior_profiler -DL_gcov_ior_profiler_atomic > -DL_gcov_indirect_call_profiler_v2 -DL_gcov_time_profiler > -DL_gcov_indirect_call_topn_profiler \ > + -DL_gcov_dump -DL_gcov_flush -DL_gcov_fork -DL_gcov_execl > -DL_gcov_execlp -DL_gcov_execle -DL_gcov_execv -DL_gcov_execvp > -DL_gcov_execve \ > + -DL_gcov_reset -DL_gcov \ Why do you add these here instead of the first patch? > > LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-merge.c > LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-profiler.c > LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-interface.c > LIBGCOV_SRCS-y += $(LIBGCOV_EXTRACTED)/libgcov-driver.c > +LIBGCOV_SRCS-y += $(LIBGCOV_BASE)/libgcov/include/popcountdi2.c This is a bit weird, why do you add add a source file in the include directory? Another thing, I don't think we need this at all. We already use a `popcountdi2.c` source file from our compiler-rt library port. Did you try using that one instead (i.e. using the compiler-rt library along with libgcc)? > diff --git a/libgcov/include/popcountdi2.c b/libgcov/include/popcountdi2.c > new file mode 100644 > index 0000000..1009c01 > --- /dev/null > +++ b/libgcov/include/popcountdi2.c > @@ -0,0 +1,39 @@ > +#include "popcountdi2.h" > + > +const UQItype __popcount_tab[256] = > +{ > + 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5, > + 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, > + 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, > + 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, > + 1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6, > + 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, > + 2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7, > + 3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8 > +}; > + > +int __popcountdi2 (UDWtype x) > +{ > + /* Force table lookup on targets like AVR and RL78 which only > + pretend they have LIBGCC2_UNITS_PER_WORD 4, but actually > + have 1, and other small word targets. */ > +#if __SIZEOF_INT__ > 2 && defined (POPCOUNTCST) && __CHAR_BIT__ == 8 > + const DWunion uu = {.ll = x}; > + UWtype x1 = uu.s.low, x2 = uu.s.high; > + x1 = x1 - ((x1 >> 1) & POPCOUNTCST (0x55)); > + x2 = x2 - ((x2 >> 1) & POPCOUNTCST (0x55)); > + x1 = (x1 & POPCOUNTCST (0x33)) + ((x1 >> 2) & POPCOUNTCST (0x33)); > + x2 = (x2 & POPCOUNTCST (0x33)) + ((x2 >> 2) & POPCOUNTCST (0x33)); > + x1 = (x1 + (x1 >> 4)) & POPCOUNTCST (0x0F); > + x2 = (x2 + (x2 >> 4)) & POPCOUNTCST (0x0F); > + x1 += x2; > + return (x1 * POPCOUNTCST (0x01)) >> (W_TYPE_SIZE - __CHAR_BIT__); > +#else > + int i, ret = 0; > + > + for (i = 0; i < 2*W_TYPE_SIZE; i += 8) > + ret += __popcount_tab[(x >> i) & 0xff]; > + > + return ret; > +#endif > +} > diff --git a/libgcov/include/popcountdi2.h b/libgcov/include/popcountdi2.h > new file mode 100644 > index 0000000..becf8fc > --- /dev/null > +++ b/libgcov/include/popcountdi2.h > @@ -0,0 +1,137 @@ > +typedef char SINT8; > +typedef unsigned char UINT8; > +typedef unsigned UINT32; > +typedef signed SINT32; > + > +#if __GNUC__ || defined LINUX || defined SUNOS > +typedef unsigned long long UINT64; > +typedef signed long long SINT64; > +#else > +typedef unsigned __int64 UINT64; > +typedef signed __int64 SINT64; > +#endif > + > +#define USItype UINT32; > +#define SItype SINT32; > +#define UDItype UINT64; > +#define DItype SINT64; > + > +typedef int QItype __attribute__ ((mode (QI))); > +typedef unsigned int UQItype __attribute__ ((mode (QI))); > +typedef int HItype __attribute__ ((mode (HI))); > +typedef unsigned int UHItype __attribute__ ((mode (HI))); > +#if MIN_UNITS_PER_WORD > 1 > +/* These typedefs are usually forbidden on dsp's with UNITS_PER_WORD 1. */ > +typedef int SItype __attribute__ ((mode (SI))); > +typedef unsigned int USItype __attribute__ ((mode (SI))); > +#if __SIZEOF_LONG_LONG__ > 4 > +/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 2. */ > +typedef int DItype __attribute__ ((mode (DI))); > +typedef unsigned int UDItype __attribute__ ((mode (DI))); > +#if MIN_UNITS_PER_WORD > 4 > +/* These typedefs are usually forbidden on archs with UNITS_PER_WORD 4. */ > +typedef int TItype __attribute__ ((mode (TI))); > +typedef unsigned int UTItype __attribute__ ((mode (TI))); > +#endif > +#endif > +#endif > + > +#if LIBGCC2_HAS_HF_MODE > +typedef float HFtype __attribute__ ((mode (HF))); > +typedef _Complex float HCtype __attribute__ ((mode (HC))); > +#endif > +#if LIBGCC2_HAS_SF_MODE > +typedef float SFtype __attribute__ ((mode (SF))); > +typedef _Complex float SCtype __attribute__ ((mode (SC))); > +#endif > +#if LIBGCC2_HAS_DF_MODE > +typedef float DFtype __attribute__ ((mode (DF))); > +typedef _Complex float DCtype __attribute__ ((mode (DC))); > +#endif > +#if LIBGCC2_HAS_XF_MODE > +typedef float XFtype __attribute__ ((mode (XF))); > +typedef _Complex float XCtype __attribute__ ((mode (XC))); > +#endif > +#if LIBGCC2_HAS_TF_MODE > +typedef float TFtype __attribute__ ((mode (TF))); > +typedef _Complex float TCtype __attribute__ ((mode (TC))); > +#endif > + > + > +#if LIBGCC2_UNITS_PER_WORD == 8 > +#define W_TYPE_SIZE (8 * __CHAR_BIT__) > +#define Wtype DItype > +#define UWtype UDItype > +#define HWtype DItype > +#define UHWtype UDItype > +#define DWtype TItype > +#define UDWtype UTItype > +#ifdef LIBGCC2_GNU_PREFIX > +#define __NW(a,b) __gnu_ ## a ## di ## b > +#define __NDW(a,b) __gnu_ ## a ## ti ## b > +#else > +#define __NW(a,b) __ ## a ## di ## b > +#define __NDW(a,b) __ ## a ## ti ## b > +#endif > +#define COMPAT_SIMODE_TRAPPING_ARITHMETIC > +#elif LIBGCC2_UNITS_PER_WORD == 4 > +#define W_TYPE_SIZE (4 * __CHAR_BIT__) > +#define Wtype SItype > +#define UWtype USItype > +#define HWtype SItype > +#define UHWtype USItype > +#define DWtype DItype > +#define UDWtype UDItype > +#ifdef LIBGCC2_GNU_PREFIX > +#define __NW(a,b) __gnu_ ## a ## si ## b > +#define __NDW(a,b) __gnu_ ## a ## di ## b > +#else > +#define __NW(a,b) __ ## a ## si ## b > +#define __NDW(a,b) __ ## a ## di ## b > +#endif > +#elif LIBGCC2_UNITS_PER_WORD == 2 > +#define W_TYPE_SIZE (2 * __CHAR_BIT__) > +#define Wtype HItype > +#define UWtype UHItype > +#define HWtype HItype > +#define UHWtype UHItype > +#define DWtype SItype > +#define UDWtype USItype > +#ifdef LIBGCC2_GNU_PREFIX > +#define __NW(a,b) __gnu_ ## a ## hi ## b > +#define __NDW(a,b) __gnu_ ## a ## si ## b > +#else > +#define __NW(a,b) __ ## a ## hi ## b > +#define __NDW(a,b) __ ## a ## si ## b > +#endif > +#else > +#define W_TYPE_SIZE __CHAR_BIT__ > +#define Wtype QItype > +#define UWtype UQItype > +#define HWtype QItype > +#define UHWtype UQItype > +#define DWtype HItype > +#define UDWtype UHItype > +#ifdef LIBGCC2_GNU_PREFIX > +#define __NW(a,b) __gnu_ ## a ## qi ## b > +#define __NDW(a,b) __gnu_ ## a ## hi ## b > +#else > +#define __NW(a,b) __ ## a ## qi ## b > +#define __NDW(a,b) __ ## a ## hi ## b > +#endif > +#endif > + > +/* DWstructs are pairs of Wtype values in the order determined by > + __BYTE_ORDER__. */ > + > +#if __BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__ > + struct DWstruct {Wtype high, low;}; > +#else > + struct DWstruct {Wtype low, high;}; > +#endif > + > +typedef union > +{ > + struct DWstruct s; > + DWtype ll; > +} DWunion; > \ No newline at end of file >
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |