AArch64 Support BFXIL in backend
authorIan Bolton <ian.bolton@arm.com>
Tue, 2 Jul 2013 10:57:30 +0000 (10:57 +0000)
committerIan Bolton <ibolton@gcc.gnu.org>
Tue, 2 Jul 2013 10:57:30 +0000 (10:57 +0000)
From-SVN: r200595

gcc/ChangeLog
gcc/config/aarch64/aarch64.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/bfxil_1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/bfxil_2.c [new file with mode: 0644]

index 727b579e9240ed5439fa1cf9de7fa2793769435b..5f41e369e1fe9884da120afd4d63b932153c1aba 100644 (file)
@@ -1,3 +1,7 @@
+2013-07-02  Ian Bolton  <ian.bolton@arm.com>
+
+       * config/aarch64/aarch64.md (*extr_insv_reg<mode>): New pattern.
+
 2013-07-02  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
        * config/arm/arm.md (arm_andsi3_insn): Add alternatives for 16-bit
index e88e5be894e92d378583ed300ffb1a09d0367738..d06a202e9210a2e2f9d7db3d38e7f6dd9cdea31c 100644 (file)
    (set_attr "mode" "<MODE>")]
 )
 
+(define_insn "*extr_insv_lower_reg<mode>"
+  [(set (zero_extract:GPI (match_operand:GPI 0 "register_operand" "+r")
+                         (match_operand 1 "const_int_operand" "n")
+                         (const_int 0))
+       (zero_extract:GPI (match_operand:GPI 2 "register_operand" "+r")
+                         (match_dup 1)
+                         (match_operand 3 "const_int_operand" "n")))]
+  "!(UINTVAL (operands[1]) == 0
+     || (UINTVAL (operands[3]) + UINTVAL (operands[1])
+        > GET_MODE_BITSIZE (<MODE>mode)))"
+  "bfxil\\t%<w>0, %<w>2, %3, %1"
+  [(set_attr "v8type" "bfm")
+   (set_attr "mode" "<MODE>")]
+)
+
 (define_insn "*<optab><ALLX:mode>_shft_<GPI:mode>"
   [(set (match_operand:GPI 0 "register_operand" "=r")
        (ashift:GPI (ANY_EXTEND:GPI
index 3bf1f96be7ef1a00c5cf1080dd29702b8ba80acc..7357b3c386c87cc4929cf8ad1c341745ad20602d 100644 (file)
@@ -1,3 +1,8 @@
+2013-07-02  Ian Bolton  <ian.bolton@arm.com>
+
+       * gcc.target/aarch64/bfxil_1.c: New test.
+       * gcc.target/aarch64/bfxil_2.c: Likewise.
+
 2013-07-01  Balaji V. Iyer  <balaji.v.iyer@intel.com>
 
        PR c/57766
diff --git a/gcc/testsuite/gcc.target/aarch64/bfxil_1.c b/gcc/testsuite/gcc.target/aarch64/bfxil_1.c
new file mode 100644 (file)
index 0000000..b168347
--- /dev/null
@@ -0,0 +1,40 @@
+/* { dg-do run { target aarch64*-*-* } } */
+/* { dg-options "-O2 --save-temps -fno-inline" } */
+/* { dg-require-effective-target aarch64_little_endian } */
+
+extern void abort (void);
+
+typedef struct bitfield
+{
+  unsigned short eight1: 8;
+  unsigned short four: 4;
+  unsigned short eight2: 8;
+  unsigned short seven: 7;
+  unsigned int sixteen: 16;
+} bitfield;
+
+bitfield
+bfxil (bitfield a)
+{
+  /* { dg-final { scan-assembler "bfxil\tx\[0-9\]+, x\[0-9\]+, 16, 8" } } */
+  a.eight1 = a.eight2;
+  return a;
+}
+
+int
+main (void)
+{
+  static bitfield a;
+  bitfield b;
+
+  a.eight1 = 9;
+  a.eight2 = 57;
+  b = bfxil (a);
+
+  if (b.eight1 != a.eight2)
+    abort ();
+
+  return 0;
+}
+
+/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/bfxil_2.c b/gcc/testsuite/gcc.target/aarch64/bfxil_2.c
new file mode 100644 (file)
index 0000000..4e4d610
--- /dev/null
@@ -0,0 +1,42 @@
+/* { dg-do run { target aarch64*-*-* } } */
+/* { dg-options "-O2 --save-temps -fno-inline" } */
+/* { dg-require-effective-target aarch64_big_endian } */
+
+extern void abort (void);
+
+typedef struct bitfield
+{
+  unsigned short eight1: 8;
+  unsigned short four: 4;
+  unsigned short eight2: 8;
+  unsigned short seven: 7;
+  unsigned int sixteen: 16;
+  unsigned short eight3: 8;
+  unsigned short eight4: 8;
+} bitfield;
+
+bitfield
+bfxil (bitfield a)
+{
+  /* { dg-final { scan-assembler "bfxil\tx\[0-9\]+, x\[0-9\]+, 40, 8" } } */
+  a.eight4 = a.eight2;
+  return a;
+}
+
+int
+main (void)
+{
+  static bitfield a;
+  bitfield b;
+
+  a.eight4 = 9;
+  a.eight2 = 57;
+  b = bfxil (a);
+
+  if (b.eight4 != a.eight2)
+    abort ();
+
+  return 0;
+}
+
+/* { dg-final { cleanup-saved-temps } } */