diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b6097ca5def..b8b7ac35c33 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,18 @@ +2002-01-30 Andrew Haley + + * config/stormy16/stormy16.md (pushqi): New. + (popqi): New. + (pushhi): New. + (pophi): New. + (movhi): Remove stack operands. + (movqi): Likewise. + * config/stormy16/stormy16.h (PREDICATE_CODES): Add + nonimmediate_nonstack_operand. + * config/stormy16/stormy16.c (nonimmediate_nonstack_operand): + New. + * config/stormy16/stormy16-protos.h (nonimmediate_nonstack_operand) + New. + 2002-01-31 Jason Merrill * Makefile.in (c-parse.c): Handle .output file. diff --git a/gcc/config/stormy16/stormy16-protos.h b/gcc/config/stormy16/stormy16-protos.h index 47c1e3e2b54..76d0bc0dcfe 100644 --- a/gcc/config/stormy16/stormy16-protos.h +++ b/gcc/config/stormy16/stormy16-protos.h @@ -73,6 +73,7 @@ extern int inequality_operator PARAMS ((rtx, enum machine_mode)); extern void xstormy16_split_cbranch PARAMS ((enum machine_mode, rtx, rtx, rtx, rtx)); extern int short_memory_operand PARAMS ((rtx, enum machine_mode)); +extern int nonimmediate_nonstack_operand PARAMS ((rtx, enum machine_mode)); extern enum reg_class xstormy16_secondary_reload_class PARAMS ((enum reg_class, enum machine_mode, rtx)); extern int xstormy16_carry_plus_operand PARAMS ((rtx, enum machine_mode)); diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index fd8c978f901..0a886aceea4 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -622,6 +622,17 @@ short_memory_operand (x, mode) return (GET_CODE (XEXP (x, 0)) != PLUS); } +int +nonimmediate_nonstack_operand (op, mode) + rtx op; + enum machine_mode mode; +{ + /* 'Q' is for pushes, 'R' for pops. */ + return (nonimmediate_operand (op, mode) + && ! xstormy16_extra_constraint_p (op, 'Q') + && ! xstormy16_extra_constraint_p (op, 'R')); +} + /* Splitter for the 'move' patterns, for modes not directly implemeted by hardware. Emit insns to copy a value of mode MODE from SRC to DEST. diff --git a/gcc/config/stormy16/stormy16.h b/gcc/config/stormy16/stormy16.h index c3539d22de1..b4ceb3efe3f 100644 --- a/gcc/config/stormy16/stormy16.h +++ b/gcc/config/stormy16/stormy16.h @@ -3894,8 +3894,8 @@ do { \ {"shift_operator", {ASHIFT, ASHIFTRT, LSHIFTRT }}, \ {"equality_operator", {EQ, NE }}, \ {"inequality_operator", {GE, GT, LE, LT, GEU, GTU, LEU, LTU }}, \ - {"xstormy16_ineqsi_operator", {LT, GE, LTU, GEU }}, - + {"xstormy16_ineqsi_operator", {LT, GE, LTU, GEU }}, \ + {"nonimmediate_nonstack_operand", {REG, MEM}}, /* An alias for a machine mode name. This is the machine mode that elements of a jump-table should have. */ #define CASE_VECTOR_MODE SImode diff --git a/gcc/config/stormy16/stormy16.md b/gcc/config/stormy16/stormy16.md index 4435379d780..3dcaa6859fd 100644 --- a/gcc/config/stormy16/stormy16.md +++ b/gcc/config/stormy16/stormy16.md @@ -72,21 +72,46 @@ ;; :: Moves ;; :: ;; :::::::::::::::::::: +;; push/pop qi and hi are here as separate insns rather than part of +;; the movqi/hi patterns because we need to ensure that reload isn't +;; passed anything it can't cope with. Without these patterns, we +;; might end up with + +;; (set (mem (post_inc (sp))) mem (post_inc (reg))) + +;; If, in this example, reg needs reloading, reload will read reg from +;; the stack , adjust sp, and store reg back at what is now the wrong +;; offset. By using separate patterns for push and pop we ensure that +;; insns like this one are never generated. + +(define_insn "pushqi" + [(set (mem:QI (post_inc (reg:HI 15))) + (match_operand:QI 0 "register_operand" "r"))] + "" + "push %0" + [(set_attr "psw_operand" "nop") + (set_attr "length" "2")]) + +(define_insn "popqi" + [(set (match_operand:QI 0 "register_operand" "=r") + (mem:QI (pre_dec (reg:HI 15))))] + "" + "pop %0" + [(set_attr "psw_operand" "nop") + (set_attr "length" "2")]) (define_expand "movqi" - [(set (match_operand:QI 0 "nonimmediate_operand" "") + [(set (match_operand:QI 0 "nonimmediate_nonstack_operand" "") (match_operand:QI 1 "general_operand" ""))] "" "{ xstormy16_expand_move (QImode, operands[0], operands[1]); DONE; }") (define_insn "*movqi_internal" - [(set (match_operand:QI 0 "nonimmediate_operand" "=r,Q,r,m,e,e,T,r,S") - (match_operand:QI 1 "general_operand" "r,r,R,e,m,i,i,i,i"))] + [(set (match_operand:QI 0 "nonimmediate_nonstack_operand" "=r,m,e,e,T,r,S") + (match_operand:QI 1 "general_operand" "r,e,m,i,i,i,i"))] "" "@ mov %0,%1 - push %1 - pop %0 mov.b %0,%1 mov.b %0,%1 mov %0,%1 @@ -95,8 +120,6 @@ mov.b %0,%1" [(set_attr_alternative "length" [(const_int 2) - (const_int 2) - (const_int 2) (if_then_else (match_operand:QI 0 "short_memory_operand" "") (const_int 2) (const_int 4)) @@ -107,22 +130,36 @@ (const_int 2) (const_int 4) (const_int 4)]) - (set_attr "psw_operand" "0,nop,nop,0,0,0,nop,0,nop")]) + (set_attr "psw_operand" "0,0,0,0,nop,0,nop")]) + +(define_insn "pushhi" + [(set (mem:HI (post_inc (reg:HI 15))) + (match_operand:HI 0 "register_operand" "r"))] + "" + "push %0" + [(set_attr "psw_operand" "nop") + (set_attr "length" "2")]) + +(define_insn "pophi" + [(set (match_operand:HI 0 "register_operand" "=r") + (mem:HI (pre_dec (reg:HI 15))))] + "" + "pop %0" + [(set_attr "psw_operand" "nop") + (set_attr "length" "2")]) (define_expand "movhi" - [(set (match_operand:HI 0 "nonimmediate_operand" "") + [(set (match_operand:HI 0 "nonimmediate_nonstack_operand" "") (match_operand:HI 1 "general_operand" ""))] "" "{ xstormy16_expand_move (HImode, operands[0], operands[1]); DONE; }") (define_insn "*movhi_internal" - [(set (match_operand:HI 0 "nonimmediate_operand" "=r,Q,r,m,e,e,T,r,S") - (match_operand:HI 1 "general_operand" "r,r,R,e,m,L,L,i,i"))] + [(set (match_operand:HI 0 "nonimmediate_nonstack_operand" "=r,m,e,e,T,r,S") + (match_operand:HI 1 "general_operand" "r,e,m,L,L,i,i"))] "" "@ mov %0,%1 - push %1 - pop %0 mov.w %0,%1 mov.w %0,%1 mov.w %0,%1 @@ -131,8 +168,6 @@ mov.w %0,%1" [(set_attr_alternative "length" [(const_int 2) - (const_int 2) - (const_int 2) (if_then_else (match_operand:QI 0 "short_memory_operand" "") (const_int 2) (const_int 4)) @@ -143,7 +178,7 @@ (const_int 2) (const_int 4) (const_int 4)]) - (set_attr "psw_operand" "0,nop,nop,0,0,0,nop,0,nop")]) + (set_attr "psw_operand" "0,0,0,0,nop,0,nop")]) (define_expand "movsi" [(set (match_operand:SI 0 "nonimmediate_operand" "")