Skip to contentSkip to conversation

ARM back-end: Fix register numbering for div/divu and add TCG not

PATCH In review Laurent Desnogues 3 participants 5 messages Jul 24, 2009 – Sep 25, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM back-end: Fix register numbering for div/divu and add TCG not

Hello,

this patch:

- fixes argument numbers for div2 and divu2
- implements TCG not.

Laurent

tcg/arm/tcg-target.c +7 -2
index 7ef2b89..53877cf 100644
@@ -1427,6 +1427,10 @@ static inline void tcg_out_op(TCGContext *s, int opc,
     case INDEX_op_neg_i32:
         tcg_out_dat_imm(s, COND_AL, ARITH_RSB, args[0], args[1], 0);
         break;
+    case INDEX_op_not_i32:
+        tcg_out_dat_reg(s, COND_AL,
+                        ARITH_MVN, args[0], 0, args[1], SHIFT_IMM_LSL(0));
+        break;
     case INDEX_op_mul_i32:
         tcg_out_mul32(s, COND_AL, args[0], args[1], args[2]);
         break;
@@ -1555,12 +1559,13 @@ static const TCGTargetOpDef arm_op_defs[] = {
     { INDEX_op_sub_i32, { "r", "r", "rI" } },
     { INDEX_op_mul_i32, { "r", "r", "r" } },
     { INDEX_op_mulu2_i32, { "r", "r", "r", "r" } },
-    { INDEX_op_div2_i32, { "r", "r", "r", "1", "2" } },
-    { INDEX_op_divu2_i32, { "r", "r", "r", "1", "2" } },
+    { INDEX_op_div2_i32, { "r", "r", "r", "0", "1" } },
+    { INDEX_op_divu2_i32, { "r", "r", "r", "0", "1" } },
     { INDEX_op_and_i32, { "r", "r", "rI" } },
     { INDEX_op_or_i32, { "r", "r", "rI" } },
     { INDEX_op_xor_i32, { "r", "r", "rI" } },
     { INDEX_op_neg_i32, { "r", "r" } },
+    { INDEX_op_not_i32, { "r", "r" } },
 
     { INDEX_op_shl_i32, { "r", "r", "ri" } },
     { INDEX_op_shr_i32, { "r", "r", "ri" } },
tcg/arm/tcg-target.h +1 -0
index 7ff2928..71e1ec5 100644
@@ -33,6 +33,7 @@
 #define TCG_TARGET_HAS_ext16s_i32
 #define TCG_TARGET_HAS_neg_i32
 #undef TCG_TARGET_HAS_neg_i64
+#define TCG_TARGET_HAS_not_i32
 #undef TCG_TARGET_STACK_GROWSUP
 
 enum {
#2 lore raw

A quick comment about the div part after a discussion with malc. The ARM back-end doesn't support div TCG ops, I just fixed a failure when compiling with TCG debug enabled. The proper fix is perhaps to simply remove the two lines.

Laurent

#4 lore raw
Quoted 9 lines · andrzej zaborowski

2009/7/24 Laurent Desnogues <[email protected]>:

Quoted 5 lines

Hello,

this patch:

 - fixes argument numbers for div2 and divu2

But "0" is not defined in target_parse_constraint?  Does div2 not work as is now?

Given Gary Thomas latest question, I guess it's time to resurrect that discussion :-)

Constraints defined as numbers are handled internally by TCG in tcg_add_target_add_op_defs. My understanding is that they mean that an input and an output arg are aliased. I don't think it's what the constraint for div2 and divu2 is trying to express.

Also the div helper looks broken: it potentially restores less registers than what it saved, and uses ldrt.

My proposed fix was completely wrong, but I have no time to make a correct one.

Laurent