public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: William Tambe <tambewilliam@gmail.com>
To: gcc-help@gcc.gnu.org
Subject: Unconditional trap
Date: Sat, 12 Sep 2020 15:17:03 -0500	[thread overview]
Message-ID: <CAF8i9mMheO7_RpnuY=h+zMe1DTun90J=VuBjdnNdc0ozRSs2qA@mail.gmail.com> (raw)

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 ?

             reply	other threads:[~2020-09-12 20:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-12 20:17 William Tambe [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAF8i9mMheO7_RpnuY=h+zMe1DTun90J=VuBjdnNdc0ozRSs2qA@mail.gmail.com' \
    --to=tambewilliam@gmail.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).