🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #46638

Alpha inline assembly

#46638
From: Linus Torvalds
Date: Sat, 29 Oct 1994 21:04
42 lines
2458 bytes
Hi, I have a gcc problem which I haven't been able to solve myself.. 

This is a inline-assembly problem on the alpha: specifically, I'd like
to force some of the operands into specific registers.  On the alpha,
all registers are obviously created equal, so right now gcc seems to
allow just the general "r" constraint, but many of the cases where I'd
like to use inline assembly really would want a specific reg.. 

I took a look at the gcc sources (I'm at 2.5.8 right now), and the only
simple way I can see how to do this is to create a register class for
each register I'd want to use (potentially all of them), and preferably
(at least according to the comments) then create register classes out of
all the possible unions of these as well.  Sadly, that makes the number
of register classes go up to 2^64, which isn't exactly practical (even
just doing 31 integer registers as their own classes looks rather ugly). 

Anyway, what I want to do is mainly call PAL-code from within inline
assembly, and this will want arguments in specific regs.  What I can do
right now is something like this:

	__asm__ __volatile__(
		"bis %1,%1,$0\n\t"
		"call_pal xxx\n\t"
		"bis $0,$0,%0"
		:"=r" (result)
		:"r" (input)
		:"$0");

(the above may not be exact, but you get the idea: essentially moving
the argument there by force), but it would obviously be much nicer (as
well as resulting in better code) if I instead could say

	__asm__ __volatile__(
		"call_pal xxx"
		:"=r0" (result)
		:"0" (input));

and have gcc notice that "r0" specifies the register completely.  This
feature would probably be useful for similar things on most other RISC
processors as well. 

		Linus
Technical Details
Message-ID: <38udce$gjs@kruuna.Helsinki.FI>
Path: arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!scsing.switch.ch!swidir.switch.ch!univ-lyon1.fr!jussieu.fr!math.ohio-state.edu!howland.reston.ans.net!pipex!sunic!news.funet.fi!news.csc.fi!news.helsinki.fi!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,df3a982579f34ee2,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1994-10-29 14:04:14 PST
Path: arc1-ca.pugleaf.net!nntp.gmd.de!xlink.net!scsing.switch.ch!swidir.switch.ch!univ-lyon1.fr!jussieu.fr!math.ohio-state.edu!howland.reston.ans.net!pipex!sunic!news.funet.fi!news.csc.fi!news.helsinki.fi!not-for-mail
From: torvalds@cc.Helsinki.FI (Linus Torvalds)
Newsgroups: gnu.gcc.help
Subject: Alpha inline assembly
Date: 29 Oct 1994 23:04:14 +0200
Organization: University of Helsinki
Lines: 42
Message-ID: <38udce$gjs@kruuna.Helsinki.FI>
NNTP-Posting-Host: kruuna.helsinki.fi
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit