diff options
author | Renlin Li <renlin.li@arm.com> | 2013-12-24 15:34:30 +0000 |
---|---|---|
committer | Yufeng Zhang <yufeng@gcc.gnu.org> | 2013-12-24 15:34:30 +0000 |
commit | c75d51aa81c517b616c2984251a4364d45fbd781 (patch) | |
tree | efe8a2b5e3fb7d97580bd038c64633ea31bafe74 /gcc/config | |
parent | 8bebb9532b4724afacf514dfe1f0d127cb7f6f07 (diff) | |
download | gcc-c75d51aa81c517b616c2984251a4364d45fbd781.tar.gz |
arm-protos.h (vfp_const_double_for_bits): Declare.
gcc/
2013-12-24 Renlin Li <Renlin.Li@arm.com>
* config/arm/arm-protos.h (vfp_const_double_for_bits): Declare.
* config/arm/constraints.md (Dp): Define new constraint.
* config/arm/predicates.md (const_double_vcvt_power_of_two): Define
new predicate.
* config/arm/arm.c (arm_print_operand): Add print for new fucntion.
(vfp3_const_double_for_bits): New function.
* config/arm/vfp.md (combine_vcvtf2i): Define new instruction.
gcc/testsuite/
2013-12-24 Renlin Li <Renlin.Li@arm.com>
* gcc.target/arm/fixed_float_conversion.c: New test case.
From-SVN: r206195
Diffstat (limited to 'gcc/config')
-rw-r--r-- | gcc/config/arm/arm-protos.h | 2 | ||||
-rw-r--r-- | gcc/config/arm/arm.c | 26 | ||||
-rw-r--r-- | gcc/config/arm/constraints.md | 10 | ||||
-rw-r--r-- | gcc/config/arm/predicates.md | 9 | ||||
-rw-r--r-- | gcc/config/arm/vfp.md | 14 |
5 files changed, 56 insertions, 5 deletions
diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 558f13418e6..62741cbd161 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -276,6 +276,8 @@ struct tune_params extern const struct tune_params *current_tune; extern int vfp3_const_double_for_fract_bits (rtx); +/* return power of two from operand, otherwise 0. */ +extern int vfp3_const_double_for_bits (rtx); extern void arm_emit_coreregs_64bit_shift (enum rtx_code, rtx, rtx, rtx, rtx, rtx); diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 706846e909f..39d23ccb251 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -21594,7 +21594,11 @@ arm_print_operand (FILE *stream, rtx x, int code) case 'v': gcc_assert (CONST_DOUBLE_P (x)); - fprintf (stream, "#%d", vfp3_const_double_for_fract_bits (x)); + int result; + result = vfp3_const_double_for_fract_bits (x); + if (result == 0) + result = vfp3_const_double_for_bits (x); + fprintf (stream, "#%d", result); return; /* Register specifier for vld1.16/vst1.16. Translate the S register @@ -29707,6 +29711,26 @@ vfp3_const_double_for_fract_bits (rtx operand) } return 0; } + +int +vfp3_const_double_for_bits (rtx operand) +{ + REAL_VALUE_TYPE r0; + + if (!CONST_DOUBLE_P (operand)) + return 0; + + REAL_VALUE_FROM_CONST_DOUBLE (r0, operand); + if (exact_real_truncate (DFmode, &r0)) + { + HOST_WIDE_INT value = real_to_integer (&r0); + value = value & 0xffffffff; + if ((value != 0) && ( (value & (value - 1)) == 0)) + return int_log2 (value); + } + + return 0; +} /* Emit a memory barrier around an atomic sequence according to MODEL. */ diff --git a/gcc/config/arm/constraints.md b/gcc/config/arm/constraints.md index e2a3099e041..59ca4b62440 100644 --- a/gcc/config/arm/constraints.md +++ b/gcc/config/arm/constraints.md @@ -31,7 +31,7 @@ ;; 'H' was previously used for FPA. ;; The following multi-letter normal constraints have been used: -;; in ARM/Thumb-2 state: Da, Db, Dc, Dd, Dn, Dl, DL, Do, Dv, Dy, Di, Dt, Dz +;; in ARM/Thumb-2 state: Da, Db, Dc, Dd, Dn, Dl, DL, Do, Dv, Dy, Di, Dt, Dp, Dz ;; in Thumb-1 state: Pa, Pb, Pc, Pd, Pe ;; in Thumb-2 state: Pj, PJ, Ps, Pt, Pu, Pv, Pw, Px, Py @@ -328,12 +328,18 @@ (and (match_code "const_double") (match_test "TARGET_32BIT && TARGET_VFP_DOUBLE && vfp3_const_double_rtx (op)"))) -(define_constraint "Dt" +(define_constraint "Dt" "@internal In ARM/ Thumb2 a const_double which can be used with a vcvt.f32.s32 with fract bits operation" (and (match_code "const_double") (match_test "TARGET_32BIT && TARGET_VFP && vfp3_const_double_for_fract_bits (op)"))) +(define_constraint "Dp" + "@internal + In ARM/ Thumb2 a const_double which can be used with a vcvt.s32.f32 with bits operation" + (and (match_code "const_double") + (match_test "TARGET_32BIT && TARGET_VFP && vfp3_const_double_for_bits (op)"))) + (define_register_constraint "Ts" "(arm_restrict_it) ? LO_REGS : GENERAL_REGS" "For arm_restrict_it the core registers @code{r0}-@code{r7}. GENERAL_REGS otherwise.") diff --git a/gcc/config/arm/predicates.md b/gcc/config/arm/predicates.md index e151a6b1f88..641228612f5 100644 --- a/gcc/config/arm/predicates.md +++ b/gcc/config/arm/predicates.md @@ -645,8 +645,13 @@ (define_predicate "const_double_vcvt_power_of_two_reciprocal" (and (match_code "const_double") - (match_test "TARGET_32BIT && TARGET_VFP - && vfp3_const_double_for_fract_bits (op)"))) + (match_test "TARGET_32BIT && TARGET_VFP + && vfp3_const_double_for_fract_bits (op)"))) + +(define_predicate "const_double_vcvt_power_of_two" + (and (match_code "const_double") + (match_test "TARGET_32BIT && TARGET_VFP + && vfp3_const_double_for_bits (op)"))) (define_predicate "neon_struct_operand" (and (match_code "mem") diff --git a/gcc/config/arm/vfp.md b/gcc/config/arm/vfp.md index 6d0515a92b1..8d755fc1dfe 100644 --- a/gcc/config/arm/vfp.md +++ b/gcc/config/arm/vfp.md @@ -1253,6 +1253,20 @@ (set_attr "length" "8")] ) +(define_insn "*combine_vcvtf2i" + [(set (match_operand:SI 0 "s_register_operand" "=r") + (fix:SI (fix:SF (mult:SF (match_operand:SF 1 "s_register_operand" "t") + (match_operand 2 + "const_double_vcvt_power_of_two" "Dp")))))] + "TARGET_32BIT && TARGET_HARD_FLOAT && TARGET_VFP3 && !flag_rounding_math" + "vcvt%?.s32.f32\\t%1, %1, %v2\;vmov%?\\t%0, %1" + [(set_attr "predicable" "yes") + (set_attr "predicable_short_it" "no") + (set_attr "ce_count" "2") + (set_attr "type" "f_cvtf2i") + (set_attr "length" "8")] + ) + ;; Store multiple insn used in function prologue. (define_insn "*push_multi_vfp" [(match_parallel 2 "multi_register_push" |