🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #51005

Help! Alternatives in machine description

#51005
From: Phil Endecott
Date: Fri, 09 Jul 1993 12:28
54 lines
2583 bytes
I'm investigating what happens when the Sparc is restricted to using 2-address
arithmetic instructions, i.e. add r1,r2,r3 is not allowed but add r1,r1,r2 is. 
I've been doing this by modifying the sparc.md file.  For example, for the add
instruction, the previous code was:

(define_insn "addsi3"
  [(set (match_operand:SI 0 "register_operand" "=r")
	(plus:SI (match_operand:SI 1 "arith_operand" "%r")
		 (match_operand:SI 2 "arith_operand" "rI")))]
  ""
  "add %1,%2,%0")

I changed this to:

(define_insn "addsi3"
  [(set (match_operand:SI 0 "register_operand" "=r")
	(plus:SI (match_operand:SI 1 "arith_operand" "0")
		 (match_operand:SI 2 "arith_operand" "rI")))]
  ""
  "add %1,%2,%0")

i.e. I changed the constraint on the second operand so that it must be the same
as the first, by changing "%r" to "0".  This works.

I now want to be able to select either 2-address mode or 3-address mode as a
command line switch.  I've done this by adding some TARGET_SWITCH things to
sparc.h so that -m2ad on the command line defines TARGET_2AD inside the compiler.
I then try and test TARGET_2AD in the define_insn condition:

(define_insn "addsi3"
  [(set (match_operand:SI 0 "register_operand" "=r")
	(plus:SI (match_operand:SI 1 "arith_operand" "%r")
		 (match_operand:SI 2 "arith_operand" "rI")))]
  "!TARGET_2AD"
  "add %1,%2,%0")

(define_insn "addsi3"
  [(set (match_operand:SI 0 "register_operand" "=r")
	(plus:SI (match_operand:SI 1 "arith_operand" "0")
		 (match_operand:SI 2 "arith_operand" "rI")))]
  "TARGET_2AD"
  "add %1,%2,%0")

But this won't work because I can't have two definitions of addsi3.

I tried it again, removing the name addsi3 from both define_insns, and although
it then compiles, it uses addx and addc rather than add!

Does anyone know how I can make this work?  I've looked at the if_then_else
expression and multiple constraints and I don't think that they solve the
problem.  Please Help!


--Phil.
Technical Details
Message-ID: <1993Jul9.132833@cs.man.ac.uk>
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!news.dfn.de!xlink.net!howland.reston.ans.net!noc.near.net!uunet!pipex!uknet!mucs!endecotp

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,6fae168c6e021b00,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-07-10 07:51:27 PST
Path: arc1-ca.pugleaf.net!gmd.de!Germany.EU.net!news.dfn.de!xlink.net!howland.reston.ans.net!noc.near.net!uunet!pipex!uknet!mucs!endecotp
From: endecotp@cs.man.ac.uk (Phil Endecott)
Newsgroups: gnu.gcc.help
Subject: Help!  Alternatives in machine description
Message-ID: <1993Jul9.132833@cs.man.ac.uk>
Date: 9 Jul 93 12:28:33 GMT
Sender: news@cs.man.ac.uk
Organization: Dept Computer Science, University of Manchester, U.K.
Lines: 54