This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: new port: Moxie


Anthony Green wrote:


+(define_insn "mulsi3"
+  [(set (match_operand:SI 0 "register_operand" "=r")
+         (mult:SI
+          (match_operand:SI 1 "register_operand" "0")
+          (match_operand:SI 2 "nonmemory_operand" "r")))]

Some of these you changed to use nonmemory_operand that only actually take registers, and so should use register_operand. It appears to be only the ones in Arithmetic Instructions section that are affected.

+(define_expand "cbranchsi4"
+  [(set (reg:CC CC_REG)
+        (compare:CC
+         (match_operand:SI 1 "general_operand" "")
+         (match_operand:SI 2 "general_operand" "")))
+   (set (pc)
+        (if_then_else (match_operator:CC 0 "comparison_operator"
+                       [(reg:CC CC_REG) (const_int 0)])
+                      (label_ref (match_operand 3 "" ""))
+                      (pc)))]
+  ""
+  "
+  /* Force the compare operands into regsiters.  */
+  if (GET_CODE (operands[1]) != REG)
+    operands[1] = force_reg (SImode, operands[1]);
+  if (GET_CODE (operands[2]) != REG)
+    operands[2] = force_reg (SImode, operands[2]);
+")

Use register_operand for op1 and op2 and you won't need the C code there.

Fixed (and it can handle "jsra 3").

You should look at what it actually does at runtime. The i386 assembler (used to?) accepts this, but what it really implements is "call .+3" rather than "call absolute-memory-3". This is because most call instructions are pc-relative, but the assembler doesn't add a relocation for absolute-memory-3.

Oh, and call_value/call_value_indirect need the same change.

+(define_predicate "moxie_add_operand"
+  (match_code "const_int,reg")
+{
+  if ((GET_CODE (op) == CONST_INT
+       && INTVAL (op) >= -255
+       && INTVAL (op) <= 255)
+      || (REG_P (op)))
+    return 1;
+  else
+    return 0;
+})

This actually returns false for all registers. You want


  if (CONST_INT_P (op))
    return INTVAL (op) >= -255 && INTVAL (op) <= 255;
  return true;

Similarly for moxie_sub_operand.

+(define_constraint "I"
+ "An 8-bit constant (0..255)"
+ (and (match_code "const_int")
+ (match_test "(unsigned int) ival <= 255")))
+
+(define_constraint "N"
+ "An constant -(0..255)"
+ (and (match_code "const_int")
+ (match_test "((unsigned int) ival) >= 0xffffff01 + && ((unsigned int) ival) <= 0xffffffff")))

The casting to unsigned int is wrong. It fails whenever HOST_WIDE_INT is larger than int. Don't try and be clever, just do normal comparisons vs ival; the compiler will optimize.



r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]