From e636e5082715d2ff61685725187c2bbc2e9860cc Mon Sep 17 00:00:00 2001 From: Jesper Nilsson Date: Mon, 3 Sep 2007 00:47:30 +0000 Subject: [PATCH] cris.h (TARGET_HAS_LZ, [...]): Defined to describe availability and behavior of CLZ. * config/cris/cris.h (TARGET_HAS_LZ, CLZ_DEFINED_VALUE_AT_ZERO): Defined to describe availability and behavior of CLZ. * config/cris/cris.md (clzsi2): Implement using lz instruction. * config/cris/cris.opt: Tweak comment for "-metrax4". * config/cris/arit.c (LZ): When defined, define as __builtin_clz. * longlong.h [__CRIS__ && __CRIS_arch_version >= 3] (count_leading_zeros): Define. Co-Authored-By: Hans-Peter Nilsson From-SVN: r128034 --- gcc/ChangeLog | 11 +++++++++++ gcc/config/cris/arit.c | 3 +-- gcc/config/cris/cris.h | 3 +++ gcc/config/cris/cris.md | 9 ++++++++- gcc/config/cris/cris.opt | 2 +- gcc/longlong.h | 4 ++++ 6 files changed, 28 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a5d6a08..df1be60 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2007-09-03 Jesper Nilsson + Hans-Peter Nilsson + + * config/cris/cris.h (TARGET_HAS_LZ, CLZ_DEFINED_VALUE_AT_ZERO): + Defined to describe availability and behavior of CLZ. + * config/cris/cris.md (clzsi2): Implement using lz instruction. + * config/cris/cris.opt: Tweak comment for "-metrax4". + * config/cris/arit.c (LZ): When defined, define as __builtin_clz. + * longlong.h [__CRIS__ && __CRIS_arch_version >= 3] + (count_leading_zeros): Define. + 2007-09-01 Laurynas Biveinis * ggc-page.c (ggc_pch_read): Call validate_free_objects. diff --git a/gcc/config/cris/arit.c b/gcc/config/cris/arit.c index e094ea7..6e73a74 100644 --- a/gcc/config/cris/arit.c +++ b/gcc/config/cris/arit.c @@ -48,8 +48,7 @@ Boston, MA 02110-1301, USA. #include "config.h" #if defined (__CRIS_arch_version) && __CRIS_arch_version >= 3 -#define LZ(v) __extension__ \ - ({ int tmp_; __asm__ ("lz %1,%0" : "=r" (tmp_) : "r" (v)); tmp_; }) +#define LZ(v) __builtin_clz (v) #endif diff --git a/gcc/config/cris/cris.h b/gcc/config/cris/cris.h index 2cb8448..b7b4bba 100644 --- a/gcc/config/cris/cris.h +++ b/gcc/config/cris/cris.h @@ -278,6 +278,7 @@ extern int target_flags; #define CRIS_DEFAULT_CPU_VERSION CRIS_CPU_BASE #define TARGET_HAS_MUL_INSNS (cris_cpu_version >= CRIS_CPU_NG) +#define TARGET_HAS_LZ (cris_cpu_version >= CRIS_CPU_ETRAX4) #define CRIS_SUBTARGET_HANDLE_OPTION(x, y, z) @@ -1407,6 +1408,8 @@ enum cris_pic_symbol_type #define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 +#define CLZ_DEFINED_VALUE_AT_ZERO(MODE, VALUE) ((VALUE) = 32, 1) + #define Pmode SImode #define FUNCTION_MODE QImode diff --git a/gcc/config/cris/cris.md b/gcc/config/cris/cris.md index f9b0e92..974e1d6 100644 --- a/gcc/config/cris/cris.md +++ b/gcc/config/cris/cris.md @@ -2663,7 +2663,14 @@ (subreg:BW (match_dup 3) 0))] "" "operands[2] = gen_reg_rtx (SImode); operands[3] = gen_reg_rtx (SImode);") - + +(define_insn "clzsi2" + [(set (match_operand:SI 0 "register_operand" "=r") + (clz:SI (match_operand:SI 1 "register_operand" "r")))] + "TARGET_HAS_LZ" + "lz %1,%0" + [(set_attr "slottable" "yes")]) + ;; Bound-insn. Defined to be the same as an unsigned minimum, which is an ;; operation supported by gcc. Used in casesi, but used now and then in ;; normal code too. diff --git a/gcc/config/cris/cris.opt b/gcc/config/cris/cris.opt index 9af5f84..9caa489 100644 --- a/gcc/config/cris/cris.opt +++ b/gcc/config/cris/cris.opt @@ -45,7 +45,7 @@ Target Report Mask(MUL_BUG) Work around bug in multiplication instruction ; TARGET_ETRAX4_ADD: Instruction-set additions from Etrax 4 and up. -; (Just "lz", which we don't really generate from GCC -- yet). +; (Just "lz".) metrax4 Target Report Mask(ETRAX4_ADD) Compile for ETRAX 4 (CRIS v3) diff --git a/gcc/longlong.h b/gcc/longlong.h index 0d8e01d..edb9bfd 100644 --- a/gcc/longlong.h +++ b/gcc/longlong.h @@ -226,6 +226,10 @@ UDItype __umulsidi3 (USItype, USItype); #define UDIV_TIME 100 #endif /* __arm__ */ +#if defined (__CRIS__) && __CRIS_arch_version >= 3 +#define count_leading_zeros(COUNT, X) ((COUNT) = __builtin_clz (X)) +#endif /* __CRIS__ */ + #if defined (__hppa) && W_TYPE_SIZE == 32 #define add_ssaaaa(sh, sl, ah, al, bh, bl) \ __asm__ ("add %4,%5,%1\n\taddc %2,%3,%0" \ -- 2.7.4