OSDN Git Service

* config/cris/cris.h (TARGET_HAS_LZ, CLZ_DEFINED_VALUE_AT_ZERO):
authorhp <hp@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Sep 2007 00:47:30 +0000 (00:47 +0000)
committerhp <hp@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 3 Sep 2007 00:47:30 +0000 (00:47 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@128034 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/cris/arit.c
gcc/config/cris/cris.h
gcc/config/cris/cris.md
gcc/config/cris/cris.opt
gcc/longlong.h

index a5d6a08..df1be60 100644 (file)
@@ -1,3 +1,14 @@
+2007-09-03  Jesper Nilsson  <jesper.nilsson@axis.com>
+           Hans-Peter Nilsson  <hp@axis.com>
+
+       * 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  <laurynas.biveinis@gmail.com>
 
        * ggc-page.c (ggc_pch_read): Call validate_free_objects.
index e094ea7..6e73a74 100644 (file)
@@ -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
 
 
index 2cb8448..b7b4bba 100644 (file)
@@ -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
index f9b0e92..974e1d6 100644 (file)
        (subreg:BW (match_dup 3) 0))]
   ""
   "operands[2] = gen_reg_rtx (SImode); operands[3] = gen_reg_rtx (SImode);")
-\f
+
+(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.
index 9af5f84..9caa489 100644 (file)
@@ -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)
index 0d8e01d..edb9bfd 100644 (file)
@@ -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"                             \