On Wed, Jun 27, 2007 at 11:26:41AM +1000, Hasjim Williams wrote:
> G'day all,
>
> As I wrote previously on gcc-patches (
> http://gcc.gnu.org/ml/gcc-patches/2007-06/msg00244.html ), I'm working
> on code to get the MaverickCrunch Floating-Point Co-processor supported
> on ARM. I mentioned previously that you can't use the same opcodes for
> testing GE on the MaverickCrunch, as you use on ARM. See the below
> table for NZCV values from MaverickCrunch.
>
> MaverickCrunch - (cfcmp*):
> N Z C V
> A == B 0 1 0 0
> A < B 1 0 0 0
> A > B 1 0 0 1
> unord 0 0 0 0
>
> ARM/FPA/VFP - (cmp*):
> N Z C V
> A == B 0 1 1 0
> A < B 1 0 0 0
> A > B 0 0 1 0
> unord 0 0 1 1
The key to getting this right is to use a special comparison mode for
MaverickCrunch comparisons. You have to look at arm_gen_compare_reg(), which
calls arm_select_cc_mode() to do all the work. I think there's probably a
mess in there: CCFPmode is used for some non-MaverickCrunch floating point
compares as well as some MaverickCrunch ones. You'll have to sort that out.
The safe way would be to define a new mode, say CCMAVmode, and use that.
Just wondering (since I'm no ARM expert):
(define_insn "*cirrus_cmpdi"
[(set (reg:CC CC_REGNUM)
(compare:CC (match_operand:DI 0 "cirrus_fp_register" "v")
(match_operand:DI 1 "cirrus_fp_register" "v")))]
"TARGET_ARM && TARGET_HARD_FLOAT && TARGET_MAVERICK"
"cfcmp64%?\\tr15, %V0, %V1"
[(set_attr "type" "mav_farith")
(set_attr "cirrus" "compare")]
)
Does this insn also set the flags according to the MaverickCrunch NZCV table
above? If so, it needs to use a MaverickCrunch CCmode too, in which case,
with the CANONICALIZE_COMPARISON macro, you can change
(set (reg:CCMAV CC_REGNUM)
(compare:CCMAV (match_operand:DI ...)
(const_int x))))
(... (ge (reg:CCMAV CC_REGNUM) ...))
into
(set (reg:CCMAV CC_REGNUM)
(compare:CCMAV (match_operand:DI ...)
(const_int x-1))))
(... (gt (reg:CCMAV CC_REGNUM) ...))
which is better if I understand correctly.
Once you know that all MaverickCrunch comparisons (and only those) have
(reg:CCMAV CC_REGNUM) in them, then it is easy to write all the
corresponding comparison and branch instructions.
--
Rask Ingemann Lambertsen