Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!udel!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!+ From: William.Lott@cs.cmu.edu Newsgroups: comp.arch Subject: Re: SPARC tagged data Message-ID: Date: 30 Apr 91 14:35:19 GMT References: <9104291542.AA11213@flora.techfak.uni-bielefeld.de> Organization: Carnegie Mellon, Pittsburgh, PA Lines: 43 In-Reply-To: <9104291542.AA11213@flora.techfak.uni-bielefeld.de> horst@techfak.uni-bielefeld.de writes: > Does anyone know what TAGGED DATA instructions are useful for and how to > use them? Tagged data is assumed to be 30 bits wide followed by trwo bits > set to zero. The SPARC allows add and subtract instructions on tagged > data. > > HH > [Most likely it's for immediate integers in a Lisp-like system that uses > tagged pointers, but I hope someone who actually knows will tell us. -John] > -- > Send compilers articles to compilers@iecc.cambridge.ma.us or > {ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request. The tagged-add and subtract instructions are just like the regular add and subtract instructions except that they check to make sure the two low bits of both operands are zeros and that the add doesn't overflow. One flavor sets the overflow flag if these conditions are not met, and the other flavor causes an exception. In CMU Common Lisp, we represent fixnums as 30 bits of data followed by two zero bits. (We had actually decided on this representation long before any of use knew anything about the SPARC.) We have found several ways to utilize these instructions. The most obvious use is when the arguments to an add are declared to be fixnums. Then we just use the taddcctv instruction which whill trap if either are is not a fixnum. We have the exception handler set up to distinguish between the case when the two fixnums form a bignum when added and the case when one of the operands wasn't really a fixnum. The non-trapping version can be used to check to see if something is a fixnum. Just add it to zero. If the overflow flag is set afterwards, it wasn't a fixnum. Basically, the only time these instructions are going to be useful is if you are representing some kind of signed integer with the two low bits zero. You can use them to check for this case in parallel with and add or a subtract. But unless your language tags run-time values, they aren't much use. -William Lott CMU Common Lisp Group