🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #52418

Help needed on md file

#52418
From: Michael Gersten
Date: Thu, 17 Sep 1992 18:04
162 lines
5323 bytes
I need some help with a md file.

My problem is with the named patterns; I am having problems writting them for one of  
the addressing modes of the machine.

Specifically, the machine has an addressing mode where (mem (plus (reg) (reg))) is a  
legal rtx for one operand, but the other operand must be R2 when this is done. The  
named insn's are used when the compiler needs to do something, and I cannot figure out  
how to say that R2 will be destroyed in this case.

Here's what I have so far. If some could tell me if I'm doing something really wrong, I'd  
appriciate it; this code looks nothing like the 68K stuff.

; machine description for 1750

; The following exists and is used:
; a - reg 1-15
; b - reg 12-15
; t - reg 2
; r - any reg
; g - anything
; m - any legal memory address
; i - constant immediate values (may not be known til assembly time)
; n - constant immediate values known at compile time
; I - constant in +- 32767
; J - constant in +- 127
; K - constant in 1- 16
; L - constant in -16 - 1
; F - const_double, immediate
; p - used with 'address_operand', refers to the effective address itself,
;	not the effective operand normally used. Only used in load_address
;	or push_address type of instructions. May not be used.

; Things to consider:
; 'm' is entirely false; it is never accepted in an assembler instruction.
;	If any pattern claims to take 'm' (as some instructions can),
;	then it must be followed by C-code to determine what the actual
;	assembler instruction to use it. See 68000 'addsi' pattern for
;	an example.
;
; We do not (yet) have any letters defined for
;	(mem (mem (plus (reg) (const))))-- IX
;	(mem (plus (reg) (const) ))	-- DX
;	(mem (plus (reg) (reg) ))	-- BX
;	(plus (reg) (const))		-- IMX
;
;	Specific names for these would only be needed in named pattern gen;
;	this may be a gain to add in the future
;
;	Nor is it clear how 'i' (immediate value) differs from mode D
;	(immidiate address) at this level in the compiler. Note that there
;	is nothing up there that corresponds to mode 'D'.
;	
;
; Machine modes:
;
; QI: defined, not used (will be 8 bit, eventually, maybe, possibly?)
; HI: 16 bit
; SI: 32 bit
; The move instruction

; First, lets try it with just templates, nothing special
;

#if 0
; Order: Isp, Isn, B, Bx, Im, Imx, D, Dx, I, Ix,
(define_insn "movhi"
	[ (set (match_operand:SI 0 "general_operand" "=r,r,t,t,r,r,r,r,r,r")
		(match_operand:SI 1 "general_operand" "K,L,b,x,i,x,x,x,x,x")
	""
	"@
	LISP	%0,%1
	LISN	%0,%1
	LB	%1,DISPLACEMENT (never mentioned)
	LBX	more problems
	LIM	%0,%1
	LIM	%0,%1,second register
)])
; That was a compelete failure. Too many cases of a third argument not
; addressable.
#endif

; Idea: Named pattern mentions a few easy, common cases
; Other patterns name other cases.
;
; IMPORTANT: BX mode must be listed first (nameless); the
; stuff here cannot handle reg+reg as r2 isn't free for the other end.

; The % in %b means communitive.
(define_insn "movehi_bx_load"
	[ (set (reg:HI 2)
		(plus (match_operand:HI 0 "general_operand" "%b")
			(match_operand:HI 1 "general_operand" "a"))
	)]
	""
"	LBX	%0,%1"
)

(define_insn "movehi_bx_store"
	[ (set (plus (match_operand:HI 0 "general_operand" "%b")
			(match_operand:HI 1 "general_operand" "a"))
		(reg:HI 2)
	)]
	""
"	STBX	%0,%1"
)

(define_insn "movehi"
	[ (set (match_operand:HI 0 "general_operand" "=r,m")
		(match_operand:HI 1 "general_operand" "g,r")
	)]
	""
	"*
	{
	rtx regop, genop;
	char *op=\"L\";	/* Switch to \"ST\" if reg is not destination */
	char *results=alloca(200);
	char *s;
	mode_types mode;
	extern char *mode_string[];

	*results = 0;
	/* Debugging */
	printf (\"Named movehi; operand 0 is \");
	debug_rtx(operands[0]);
	printf (\"Named movehi; operand 1 is \");
	debug_rtx(operands[1]);

	/* First, is the destination a register? */
	if (get_code(operands[0]) == REG)
	{
		regop = operands[0];
		genop = operands[1];
	} else {
		regop = operands[1];
		genop = operands[0];
		op = \"ST\";
	};
	sprintf(results, op);

	/* Determine mode of general op, and print it */
	mode = what_mode(genop);
	if (mode == BX_mode)
		fatal (\"we got a BX with no R2 usable\");
	strcat(results, mode_string[mode]);
	strcat(results, \"\t\");

	/* Assumption: No b/bx mode. Write out the register */
	strcat(results, \"R%d,\", REGNO(regop));

	/* Finally, write the final operand */
	strcat(results, write_operand(genop, mode));

	s = malloc(strlen(results) + 1);
	strcpy(s, results);
	return s;
	}"
)
--
		Michael Gersten		michael@stb.info.com
HELLO! I'm a signature virus! Join in the fun and copy me into yours!
ex:.-1,. w $HOME/.signature
Technical Details
Message-ID: <m0mVQDP-0005OXC@stb.info.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!stb.INfo.COM!michael

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,dcf07e7e8ceea567,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-09-17 05:58:50 PST
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!linac!pacific.mps.ohio-state.edu!cis.ohio-state.edu!stb.INfo.COM!michael
From: michael@stb.INfo.COM (Michael Gersten)
Subject: Help needed on md file
Message-ID: <m0mVQDP-0005OXC@stb.info.com>
Sender: daemon@cis.ohio-state.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 17 Sep 1992 18:04:00 GMT
Lines: 162