public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Unconditional trap
@ 2020-09-12 20:17 William Tambe
  2020-09-12 20:26 ` Marc Glisse
  2020-09-13 14:11 ` Segher Boessenkool
  0 siblings, 2 replies; 5+ messages in thread
From: William Tambe @ 2020-09-12 20:17 UTC (permalink / raw)
  To: gcc-help

I am currently using following for trap instruction:

(define_insn "trap"
  [(trap_if (const_int 1) (const_int 0))]
  ""
  "brk")

However it causes the compiler to generate a trap when address 0 is
used; in the example below, I have a function that prints characters
through the UART using address 0; but the resulting assembly generates
a function that traps instead.

#define UART_ADDR 0
void uart_print (char *s) {
        while (*s) {
                *(volatile char *)UART_ADDR = *s;
                ++s;
        }
}

How can one implement unconditional trap ?

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-13 14:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-12 20:17 Unconditional trap William Tambe
2020-09-12 20:26 ` Marc Glisse
2020-09-12 21:04   ` William Tambe
2020-09-12 21:24     ` Marc Glisse
2020-09-13 14:11 ` Segher Boessenkool

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).