From: ciemo@bananapc.csd.sgi.com (Dave Ciemiewicz)
Newsgroups: comp.sys.sgi
Subject: Re: 3.10 compiler set, and r4000 code.
Keywords: compiler, R4000
Date: 5 Jan 93 22:15:16 GMT
Organization: Silicon Graphics, Customer Support Division

In article <1993Jan5.205248.17542@bnlux1.bnl.gov>, adler@bnlku2.phy.bnl.gov (Steve Adler) writes:
|> I just installed the 3.10 compiler set on my Indigo R4k. I also have
|> the fortran compiler installed on my Indigo. Will the compilers
|> automatically know to generate the r4k instruction set, or do I have to
|> use some bizar qualifier on the f77 command line. I noticed in the man
|> pages for f77 that there is the -mips1 and -mips2 qualifiers|>  where
|> the -mips1 is the default. Does this mean that the -mips1 qualifier
|> generates r3000 code and the -mips2 generates the r4000 code? Any one
|> out there in Interland know?
|>
|> Steve Adler.

No, R4000 (MIPS-II archictecture) specific code is not generated automagically.
In fact, for portability reasons, you don't want that to happen because systems
based on the R2000/R3000 (MIPS-I architecture) don't implement all of the
instructions of the MIPS-II architecture thus they are not binary compatible
with MIPS-II architecture code.  MIPS-I code is portable acrossed all three
processors (R2/3/4000).  The following information may help you understand
the issues further:

------------------------------------------------------------------------------
NAME
	MIPS R4000 and -mips2 compiler option

AUTHOR
	Dave Ciemiewicz, SGI Customer Services Engineering

DATE
	November 21, 1992


ABSTRACT
	This paper is a short discussion of the R4000 specific compiler
	issues including the benefits of using the -mips2 option.


DESCRIPTION
	The SGI 3.10 compilers provide a -mips2 option for accessing
	the MIPSII instruction set extensions of the R4000.  This provides
	The -mips2 used when compiling with C, C++, Fortran, or Pascal,
	will instruct the code generation phase to generate the R4000
	specific instructions.  When linking, -mips2 instructs the linker
	ld(1) to use mips2 specific versions of libraries from the directory
	/usr/lib/mips2.


 	Benefits of using -mips2
	------------------------
	Code which performs a significant amount of double precision
	arithmetic may benefit from using the -mips2 option.  The primary
	reason for this is that the R4000 instruction set provides both
	double word load and store instructions which can load or save
	a double precision number in a single double word memory reference
	instead of requiring two one-word memory references as is necessary
	on the R2000/R3000.

	In addition, the R4000 implements intrinsic instructions for
	truncating, rounding, ceiling, and flooring when converting floating
	point numbers to integers.  On the R2000/R3000, these instructions
	where implemented as assembler macros which were expanded into a
	set of approximately 11 instructions.  Code which does of significant
	amount of floating point to integer conversions should benefit from
	the -mips2 option.

	The 3.10 Fortran compiler using the -mips2 option also makes use of
	the R4000 sqrt instruction which would be implemented as sqrt routine
	in the math libraries for the R2000/R3000.

	The 3.10 compilers also supply a special set of libraries compiled
	using the -mips2 option.  As part of the basic development environment,
	you get:

		/usr/lib/mips2/libfastm.a	/* fast sqrt algorithm */
		/usr/lib/mips2/libm.a		/* Math library */
		/usr/lib/mips2/libm43.a		/* 4.3 BSD math algorithms */

	Note: at this time, these sqrt() function in these math libraries do
	not use the R4000 intrinsic sqrt instruction though they may at some
	future time. 

	For the 3.10 Fortran compiler, you get -mips2 versions of:

		/usr/lib/mips2/libF77.a
		/usr/lib/mips2/libI77.a
		/usr/lib/mips2/libU77.a
		/usr/lib/mips2/libisam.a

	The shared library versions of the above Fortran libraries have not
	been compiled using the -mips2 option on R4000 platforms.


	Disadvantages of using -mips2
	-----------------------------
	Code compiled and/or linked using the -mips2 option will not run
	on R2000/R3000 based machines.  Code compiled without the -mips2
	option will run all machines - R2000/R3000/R4000 -- within the
	contraints of operating system compatibility.  If broad machine
	base compatibility is an issue, SGI recommends using the -mips2
	flag only when significant benefit is acheived on an R4000 when
	compared to running the same program compiled without -mips2 on
	the same R4000 machine.


	R4000 features not provide by -mips2
	------------------------------------
	The following features of the R4000 are not currently accessible
	using the -mips2 option and are part of the MIPSIII instruction
	extensions.  These features are not currently supported as some
	of them require operating system support which is not yet available.
	Thes features will be supported in the next major release of the
	IRIX operating system.

	The R4000 has the capability of performing long or double word (64-bit)
	integer arithmetic.  This is not available with -mips2.

	The R4000 MIPSIII architecture supports 64-bit addresses and pointers.
	This is not available with -mips2.

	The R4000 supports two floating point register (FPR) modes: 16 64-bit
	floating point register mode and 32 64-bit floating point register
	mode.  The 16 64-bit mode is compatible with the R2010/R3010 which
	only support 16 64-bit floating point registers.  The 32 register
	mode is not supported by IRIX at this time and so is not available
	via the -mips2 option.


REFERENCES
	"VR4000 Microprocessor User's Manual"
	NEC Electronics Inc.
	Corporate Headquarters
	401 Ellis Street
	P.O. Box 7241
	Mountain View, CA 94039-7241
	For literature, call: 1-800-632-3531

	"MIPS RISC Architecture"
	Gerry Kane and Joe Heinrich
	Prentice Hall

-- 

    __   * __   _  __  ___			
   /  \ / / /  / \/  \/   \ 	He was a man like any other man, however, not
  /    /  \/  /  /\  /    /	quite like any other man.
  \___/\__/\_/  /_/ / \__/	
	           *		
Newsgroups: comp.sys.sgi