From: "Edgar E. Iglesias" <edgar.iglesias@axis.com>
To: Thiemo Seufer <ths@networkno.de>
Cc: "J. Mayer" <l_indien@magic.fr>,
qemu-devel@nongnu.org, hys545@dreamwiz.com
Subject: Re: [Qemu-devel] qemu-2007-10-24 build error
Date: Wed, 24 Oct 2007 18:03:18 +0200 [thread overview]
Message-ID: <20071024160318.GA28359@edgar.underground.se.axis.com> (raw)
In-Reply-To: <20071024153349.GB6666@networkno.de>
On Wed, Oct 24, 2007 at 04:33:49PM +0100, Thiemo Seufer wrote:
> Edgar E. Iglesias wrote:
> > On Wed, Oct 24, 2007 at 12:33:24PM +0200, J. Mayer wrote:
> > > On Wed, 2007-10-24 at 09:36 +0900, Hwang YunSong(?????????) wrote:
> > > >
> > > > gcc32 -g -o qemu-system-cris vl.o osdep.o readline.o monitor.o pci.o
> > > > console.o loader.o isa_mmio.o cutils.o block.o block-raw.o block-cow.o
> > > > block-qcow.o aes.o block-vmdk.o block-cloop.o block-dmg.o
> > > > block-bochs.o block-vpc.o block-vvfat.o block-qcow2.o
> > > > block-parallels.o irq.o i2c.o smbus.o scsi-disk.o cdrom.o lsi53c895a.o
> > > > usb.o usb-hub.o usb-linux.o usb-hid.o usb-ohci.o usb-msd.o usb-wacom.o
> > > > eeprom93xx.o eepro100.o ne2000.o pcnet.o rtl8139.o etraxfs.o ptimer.o
> > > > etraxfs_timer.o etraxfs_ser.o gdbstub.o sdl.o x_keymap.o vnc.o d3des.o
> > > > slirp/cksum.o slirp/if.o slirp/ip_icmp.o slirp/ip_input.o
> > > > slirp/ip_output.o slirp/slirp.o slirp/mbuf.o slirp/misc.o slirp/sbuf.o
> > > > slirp/socket.o slirp/tcp_input.o slirp/tcp_output.o slirp/tcp_subr.o
> > > > slirp/tcp_timer.o slirp/udp.o slirp/bootp.o slirp/debug.o slirp/tftp.o
> > > > libqemu.a -lm -lz -lgnutls -L/usr/lib -lSDL -lpthread -lrt -lutil
> > > > libqemu.a(helper.o): In function `do_interrupt':
> > > > /usr/src/Haansoft/BUILD/qemu/target-cris/helper.c:137: undefined
> > > > reference to `__builtin_clz'
> > > > libqemu.a(translate-op.o): In function `dyngen_code':
> > > > /home/hys545/qemu/cris-softmmu/op.h:1566: undefined reference to
> > > > `__builtin_clz'
> > > > libqemu.a(op.o): In function `op_lz_T0_T1':
> > > > /usr/src/Haansoft/BUILD/qemu/target-cris/op.c:1009: undefined
> > > > reference to `__builtin_clz'
> > > > collect2: ld returned 1 exit status
> > >
> > > It does not seem to be a good idea, imho, to use gcc builtins directly
> > > from micro-ops. But your compiler should implement __builtin_clz. As far
> >
> > Hi,
> >
> > I submitted a patch that at compile-time fallbacks to clz code without builtins. Do you see any additional issues with using the builtins?
> >
> > I think the speed-up with GCC ports implementing fast builtin variants of operations like clz would be significant enough to justify their use but if there is disagreement I'll send in a new patch removing the builtin_clz alltogether.
>
> If the builtin ends up calling into libgcc (this can happen depending
> on the host / host compiler), then the dynamic code generation breaks.
>
> It is safer not to force the compiler to use builtins.
Right, if calls are made things could break. Thanks for clarifying that.
Here's a new patch to remove the builtin altogether. When building the system simulator for CRIS I found another one which will cause build problems with older GCC's so I replaced that one aswell.
Best regards
--
Edgar E. Iglesias
Axis Communications AB
diff --git a/target-cris/helper.c b/target-cris/helper.c
index 3db3bea..43fcdd1 100644
--- a/target-cris/helper.c
+++ b/target-cris/helper.c
@@ -87,6 +87,32 @@ static void cris_shift_ccs(CPUState *env)
env->pregs[SR_CCS] = ccs;
}
+static int cris_clz(uint32_t x)
+{
+ int n;
+ /* Binary search for leading zeros. */
+
+ n = 1;
+ if ((x >> 16) == 0) {
+ n = n + 16;
+ x = x << 16;
+ }
+ if ((x >> 24) == 0) {
+ n = n + 8;
+ x = x << 8;
+ }
+ if ((x >> 28) == 0) {
+ n = n + 4;
+ x = x << 4;
+ }
+ if ((x >> 30) == 0) {
+ n = n + 2;
+ x = x << 2;
+ }
+ n = n - (x >> 31);
+ return n;
+}
+
void do_interrupt(CPUState *env)
{
uint32_t ebp, isr;
@@ -135,7 +161,7 @@ void do_interrupt(CPUState *env)
}
irqnum = 31 -
- __builtin_clz(env->pending_interrupts);
+ cris_clz(env->pending_interrupts);
irqnum += 0x30;
ebp = env->pregs[SR_EBP];
isr = ldl_code(ebp + irqnum * 4);
diff --git a/target-cris/op.c b/target-cris/op.c
index 3ce9888..12188b4 100644
--- a/target-cris/op.c
+++ b/target-cris/op.c
@@ -1006,7 +1006,28 @@ void OPPROTO op_lz_T0_T1 (void)
if (T1 == 0)
T0 = 32;
else
- T0 = __builtin_clz(T1);
+ {
+ /* Binary search for leading zeros. */
+
+ T0 = 1;
+ if ((T1 >> 16) == 0) {
+ T0 = T0 + 16;
+ T1 = T1 << 16;
+ }
+ if ((T1 >> 24) == 0) {
+ T0 = T0 + 8;
+ T1 = T1 << 8;
+ }
+ if ((T1 >> 28) == 0) {
+ T0 = T0 + 4;
+ T1 = T1 << 4;
+ }
+ if ((T1 >> 30) == 0) {
+ T0 = T0 + 2;
+ T1 = T1 << 2;
+ }
+ T0 = T0 - (T1 >> 31);
+ }
RETURN();
}
prev parent reply other threads:[~2007-10-24 16:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-24 0:36 [Qemu-devel] qemu-2007-10-24 build error Hwang YunSong(황윤성)
2007-10-24 10:20 ` Edgar E. Iglesias
2007-10-24 10:33 ` J. Mayer
2007-10-24 12:36 ` Edgar E. Iglesias
2007-10-24 15:33 ` Thiemo Seufer
2007-10-24 16:03 ` Edgar E. Iglesias [this message]
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=20071024160318.GA28359@edgar.underground.se.axis.com \
--to=edgar.iglesias@axis.com \
--cc=hys545@dreamwiz.com \
--cc=l_indien@magic.fr \
--cc=qemu-devel@nongnu.org \
--cc=ths@networkno.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.