microblaze.md: Add trap insn and attribute
authorDavid Holsgrove <david.holsgrove@xilinx.com>
Thu, 23 Jan 2014 14:37:44 +0000 (14:37 +0000)
committerMichael Eager <eager@gcc.gnu.org>
Thu, 23 Jan 2014 14:37:44 +0000 (14:37 +0000)
2014-01-23  David Holsgrove <david.holsgrove@xilinx.com>

* config/microblaze/microblaze.md: Add trap insn and attribute

From-SVN: r206967

gcc/ChangeLog
gcc/config/microblaze/microblaze.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c [new file with mode: 0644]

index c67c6ff10c65a3f28ec38e8b77a54e5a4092145a..f52752d86a4dbe3e22a80d9c66dea5be97fdb793 100644 (file)
@@ -1,3 +1,7 @@
+2014-01-23  David Holsgrove <david.holsgrove@xilinx.com>
+
+       * config/microblaze/microblaze.md: Add trap insn and attribute
+
 2014-01-23  Dodji Seketeli  <dodji@redhat.com>
 
        PR preprocessor/58580
index 46a7eddd96d83a6b2da8ba475451fc0946948e34..367f2539fc935d9cf8036ffbdfbc5c18a457b288 100644 (file)
@@ -74,7 +74,7 @@
 ;; bshift      Shift operations
 
 (define_attr "type"
-  "unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt"
+  "unknown,branch,jump,call,load,store,move,arith,darith,imul,idiv,icmp,multi,nop,no_delay_arith,no_delay_load,no_delay_store,no_delay_imul,no_delay_move,bshift,fadd,frsub,fmul,fdiv,fcmp,fsl,fsqrt,fcvt,trap"
   (const_string "unknown"))
 
 ;; Main data type used by the insn
   (set_attr "mode"     "none")
   (set_attr "length"   "4")])
 
+;; Trap instruction pattern for __builtin_trap. Same as the glibc ABORT_INSTRUCTION
+(define_insn "trap"
+  [(trap_if (const_int 1) (const_int 0))]
+  ""
+  "brki\tr0,-1"
+ [(set_attr "type" "trap")]
+)
+
 ;; The insn to set GOT. The hardcoded number "8" accounts for $pc difference
 ;; between "mfs" and "addik" instructions.
 (define_insn "set_got"
index 2180cb81980df8c360749d5b1f332fa9f6b449de..5b33fbbf8d71616c6dfdad4f3f55611c6952f618 100644 (file)
@@ -1,3 +1,7 @@
+2014-01-23  David Holsgrove <david.holsgrove@xilinx.com>
+
+       * gcc.target/microblaze/others/builtin-trap.c: New test,
+
 2014-01-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/58809
diff --git a/gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c b/gcc/testsuite/gcc.target/microblaze/others/builtin-trap.c
new file mode 100644 (file)
index 0000000..fdcde1f
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+void trap ()
+{
+  __builtin_trap ();
+}
+
+/* { dg-final { scan-assembler "brki\tr0,-1" } } */
\ No newline at end of file