genemit.c (96263) | genemit.c (117395) |
---|---|
1/* Generate code from machine description to emit insns as rtl. 2 Copyright (C) 1987, 1988, 1991, 1994, 1995, 1997, 1998, 1999, 2000, 2001 3 Free Software Foundation, Inc. 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify it under 8the terms of the GNU General Public License as published by the Free --- 45 unchanged lines hidden (view full) --- 54 int code_number; /* Counts only insns. */ 55 struct clobber_ent *next; 56}; 57 58static void max_operand_1 PARAMS ((rtx)); 59static int max_operand_vec PARAMS ((rtx, int)); 60static void print_code PARAMS ((RTX_CODE)); 61static void gen_exp PARAMS ((rtx, enum rtx_code, char *)); | 1/* Generate code from machine description to emit insns as rtl. 2 Copyright (C) 1987, 1988, 1991, 1994, 1995, 1997, 1998, 1999, 2000, 2001 3 Free Software Foundation, Inc. 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify it under 8the terms of the GNU General Public License as published by the Free --- 45 unchanged lines hidden (view full) --- 54 int code_number; /* Counts only insns. */ 55 struct clobber_ent *next; 56}; 57 58static void max_operand_1 PARAMS ((rtx)); 59static int max_operand_vec PARAMS ((rtx, int)); 60static void print_code PARAMS ((RTX_CODE)); 61static void gen_exp PARAMS ((rtx, enum rtx_code, char *)); |
62static void gen_insn PARAMS ((rtx)); | 62static void gen_insn PARAMS ((rtx, int)); |
63static void gen_expand PARAMS ((rtx)); 64static void gen_split PARAMS ((rtx)); 65static void output_add_clobbers PARAMS ((void)); 66static void output_added_clobbers_hard_reg_p PARAMS ((void)); 67static void gen_rtx_scratch PARAMS ((rtx, enum rtx_code)); 68static void output_peephole2_scratches PARAMS ((rtx)); 69 70 --- 170 unchanged lines hidden (view full) --- 241 printf ("const1_rtx"); 242 else if (INTVAL (x) == -1) 243 printf ("constm1_rtx"); 244 else if (INTVAL (x) == STORE_FLAG_VALUE) 245 printf ("const_true_rtx"); 246 else 247 { 248 printf ("GEN_INT ("); | 63static void gen_expand PARAMS ((rtx)); 64static void gen_split PARAMS ((rtx)); 65static void output_add_clobbers PARAMS ((void)); 66static void output_added_clobbers_hard_reg_p PARAMS ((void)); 67static void gen_rtx_scratch PARAMS ((rtx, enum rtx_code)); 68static void output_peephole2_scratches PARAMS ((rtx)); 69 70 --- 170 unchanged lines hidden (view full) --- 241 printf ("const1_rtx"); 242 else if (INTVAL (x) == -1) 243 printf ("constm1_rtx"); 244 else if (INTVAL (x) == STORE_FLAG_VALUE) 245 printf ("const_true_rtx"); 246 else 247 { 248 printf ("GEN_INT ("); |
249 printf (HOST_WIDE_INT_PRINT_DEC, INTVAL (x)); | 249 printf (HOST_WIDE_INT_PRINT_DEC_C, INTVAL (x)); |
250 printf (")"); 251 } 252 return; 253 254 case CONST_DOUBLE: 255 /* These shouldn't be written in MD files. Instead, the appropriate 256 routines in varasm.c should be called. */ 257 abort (); --- 34 unchanged lines hidden (view full) --- 292 abort (); 293 } 294 printf (")"); 295} 296 297/* Generate the `gen_...' function for a DEFINE_INSN. */ 298 299static void | 250 printf (")"); 251 } 252 return; 253 254 case CONST_DOUBLE: 255 /* These shouldn't be written in MD files. Instead, the appropriate 256 routines in varasm.c should be called. */ 257 abort (); --- 34 unchanged lines hidden (view full) --- 292 abort (); 293 } 294 printf (")"); 295} 296 297/* Generate the `gen_...' function for a DEFINE_INSN. */ 298 299static void |
300gen_insn (insn) | 300gen_insn (insn, lineno) |
301 rtx insn; | 301 rtx insn; |
302 int lineno; |
|
302{ 303 int operands; 304 int i; 305 306 /* See if the pattern for this insn ends with a group of CLOBBERs of (hard) 307 registers or MATCH_SCRATCHes. If so, store away the information for 308 later. */ 309 --- 68 unchanged lines hidden (view full) --- 378 } 379 380 /* Don't mention instructions whose names are the null string 381 or begin with '*'. They are in the machine description just 382 to be recognized. */ 383 if (XSTR (insn, 0)[0] == 0 || XSTR (insn, 0)[0] == '*') 384 return; 385 | 303{ 304 int operands; 305 int i; 306 307 /* See if the pattern for this insn ends with a group of CLOBBERs of (hard) 308 registers or MATCH_SCRATCHes. If so, store away the information for 309 later. */ 310 --- 68 unchanged lines hidden (view full) --- 379 } 380 381 /* Don't mention instructions whose names are the null string 382 or begin with '*'. They are in the machine description just 383 to be recognized. */ 384 if (XSTR (insn, 0)[0] == 0 || XSTR (insn, 0)[0] == '*') 385 return; 386 |
387 printf ("/* %s:%d */\n", read_rtx_filename, lineno); 388 |
|
386 /* Find out how many operands this function has, 387 and also whether any of them have register constraints. */ 388 register_constraints = 0; 389 operands = max_operand_vec (insn, 1); 390 if (max_dup_opno >= operands) 391 fatal ("match_dup operand number has no match_operand"); 392 393 /* Output the function name and argument declarations. */ --- 122 unchanged lines hidden (view full) --- 516 Use emit_insn to add them to the sequence being accumulated. 517 But don't do this if the user's code has set `no_more' nonzero. */ 518 519 for (i = 0; i < XVECLEN (expand, 1); i++) 520 { 521 rtx next = XVECEXP (expand, 1, i); 522 if ((GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC) 523 || (GET_CODE (next) == PARALLEL | 389 /* Find out how many operands this function has, 390 and also whether any of them have register constraints. */ 391 register_constraints = 0; 392 operands = max_operand_vec (insn, 1); 393 if (max_dup_opno >= operands) 394 fatal ("match_dup operand number has no match_operand"); 395 396 /* Output the function name and argument declarations. */ --- 122 unchanged lines hidden (view full) --- 519 Use emit_insn to add them to the sequence being accumulated. 520 But don't do this if the user's code has set `no_more' nonzero. */ 521 522 for (i = 0; i < XVECLEN (expand, 1); i++) 523 { 524 rtx next = XVECEXP (expand, 1, i); 525 if ((GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC) 526 || (GET_CODE (next) == PARALLEL |
524 && GET_CODE (XVECEXP (next, 0, 0)) == SET 525 && GET_CODE (SET_DEST (XVECEXP (next, 0, 0))) == PC) | 527 && ((GET_CODE (XVECEXP (next, 0, 0)) == SET 528 && GET_CODE (SET_DEST (XVECEXP (next, 0, 0))) == PC) 529 || GET_CODE (XVECEXP (next, 0, 0)) == RETURN)) |
526 || GET_CODE (next) == RETURN) 527 printf (" emit_jump_insn ("); 528 else if ((GET_CODE (next) == SET && GET_CODE (SET_SRC (next)) == CALL) 529 || GET_CODE (next) == CALL 530 || (GET_CODE (next) == PARALLEL 531 && GET_CODE (XVECEXP (next, 0, 0)) == SET 532 && GET_CODE (SET_SRC (XVECEXP (next, 0, 0))) == CALL) 533 || (GET_CODE (next) == PARALLEL --- 13 unchanged lines hidden (view full) --- 547 printf (" emit_insn ("); 548 gen_exp (next, DEFINE_EXPAND, NULL); 549 printf (");\n"); 550 if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC 551 && GET_CODE (SET_SRC (next)) == LABEL_REF) 552 printf (" emit_barrier ();"); 553 } 554 | 530 || GET_CODE (next) == RETURN) 531 printf (" emit_jump_insn ("); 532 else if ((GET_CODE (next) == SET && GET_CODE (SET_SRC (next)) == CALL) 533 || GET_CODE (next) == CALL 534 || (GET_CODE (next) == PARALLEL 535 && GET_CODE (XVECEXP (next, 0, 0)) == SET 536 && GET_CODE (SET_SRC (XVECEXP (next, 0, 0))) == CALL) 537 || (GET_CODE (next) == PARALLEL --- 13 unchanged lines hidden (view full) --- 551 printf (" emit_insn ("); 552 gen_exp (next, DEFINE_EXPAND, NULL); 553 printf (");\n"); 554 if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC 555 && GET_CODE (SET_SRC (next)) == LABEL_REF) 556 printf (" emit_barrier ();"); 557 } 558 |
555 /* Call `gen_sequence' to make a SEQUENCE out of all the | 559 /* Call `get_insns' to extract the list of all the |
556 insns emitted within this gen_... function. */ 557 | 560 insns emitted within this gen_... function. */ 561 |
558 printf (" _val = gen_sequence ();\n"); | 562 printf (" _val = get_insns ();\n"); |
559 printf (" end_sequence ();\n"); 560 printf (" return _val;\n}\n\n"); 561} 562 | 563 printf (" end_sequence ();\n"); 564 printf (" return _val;\n}\n\n"); 565} 566 |
563/* Like gen_expand, but generates a SEQUENCE. */ | 567/* Like gen_expand, but generates insns resulting from splitting SPLIT. */ |
564 565static void 566gen_split (split) 567 rtx split; 568{ 569 int i; 570 int operands; 571 const char *const name = --- 87 unchanged lines hidden (view full) --- 659 printf (" emit_insn ("); 660 gen_exp (next, GET_CODE (split), used); 661 printf (");\n"); 662 if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC 663 && GET_CODE (SET_SRC (next)) == LABEL_REF) 664 printf (" emit_barrier ();"); 665 } 666 | 568 569static void 570gen_split (split) 571 rtx split; 572{ 573 int i; 574 int operands; 575 const char *const name = --- 87 unchanged lines hidden (view full) --- 663 printf (" emit_insn ("); 664 gen_exp (next, GET_CODE (split), used); 665 printf (");\n"); 666 if (GET_CODE (next) == SET && GET_CODE (SET_DEST (next)) == PC 667 && GET_CODE (SET_SRC (next)) == LABEL_REF) 668 printf (" emit_barrier ();"); 669 } 670 |
667 /* Call `gen_sequence' to make a SEQUENCE out of all the | 671 /* Call `get_insns' to make a list of all the |
668 insns emitted within this gen_... function. */ 669 | 672 insns emitted within this gen_... function. */ 673 |
670 printf (" _val = gen_sequence ();\n"); | 674 printf (" _val = get_insns ();\n"); |
671 printf (" end_sequence ();\n"); 672 printf (" return _val;\n}\n\n"); 673 674 free (used); 675} 676 677/* Write a function, `add_clobbers', that is given a PARALLEL of sufficient 678 size for the insn and an INSN_CODE, and inserts the required CLOBBERs at --- 154 unchanged lines hidden (view full) --- 833 printf ("#include \"insn-config.h\"\n"); 834 printf ("#include \"hard-reg-set.h\"\n"); 835 printf ("#include \"recog.h\"\n"); 836 printf ("#include \"resource.h\"\n"); 837 printf ("#include \"reload.h\"\n"); 838 printf ("#include \"toplev.h\"\n"); 839 printf ("#include \"ggc.h\"\n\n"); 840 printf ("#define FAIL return (end_sequence (), _val)\n"); | 675 printf (" end_sequence ();\n"); 676 printf (" return _val;\n}\n\n"); 677 678 free (used); 679} 680 681/* Write a function, `add_clobbers', that is given a PARALLEL of sufficient 682 size for the insn and an INSN_CODE, and inserts the required CLOBBERs at --- 154 unchanged lines hidden (view full) --- 837 printf ("#include \"insn-config.h\"\n"); 838 printf ("#include \"hard-reg-set.h\"\n"); 839 printf ("#include \"recog.h\"\n"); 840 printf ("#include \"resource.h\"\n"); 841 printf ("#include \"reload.h\"\n"); 842 printf ("#include \"toplev.h\"\n"); 843 printf ("#include \"ggc.h\"\n\n"); 844 printf ("#define FAIL return (end_sequence (), _val)\n"); |
841 printf ("#define DONE return (_val = gen_sequence (), end_sequence (), _val)\n"); | 845 printf ("#define DONE return (_val = get_insns (), end_sequence (), _val)\n\n"); |
842 843 /* Read the machine description. */ 844 845 while (1) 846 { 847 int line_no; 848 849 desc = read_md_rtx (&line_no, &insn_code_number); 850 if (desc == NULL) 851 break; 852 853 switch (GET_CODE (desc)) 854 { | 846 847 /* Read the machine description. */ 848 849 while (1) 850 { 851 int line_no; 852 853 desc = read_md_rtx (&line_no, &insn_code_number); 854 if (desc == NULL) 855 break; 856 857 switch (GET_CODE (desc)) 858 { |
855 case DEFINE_INSN: 856 gen_insn (desc); 857 break; | 859 case DEFINE_INSN: 860 gen_insn (desc, line_no); 861 break; |
858 | 862 |
859 case DEFINE_EXPAND: 860 gen_expand (desc); 861 break; | 863 case DEFINE_EXPAND: 864 printf ("/* %s:%d */\n", read_rtx_filename, line_no); 865 gen_expand (desc); 866 break; |
862 | 867 |
863 case DEFINE_SPLIT: 864 gen_split (desc); 865 break; | 868 case DEFINE_SPLIT: 869 printf ("/* %s:%d */\n", read_rtx_filename, line_no); 870 gen_split (desc); 871 break; |
866 | 872 |
867 case DEFINE_PEEPHOLE2: 868 gen_split (desc); 869 break; | 873 case DEFINE_PEEPHOLE2: 874 printf ("/* %s:%d */\n", read_rtx_filename, line_no); 875 gen_split (desc); 876 break; |
870 | 877 |
871 default: 872 break; 873 } | 878 default: 879 break; 880 } |
874 ++insn_index_number; 875 } 876 877 /* Write out the routines to add CLOBBERs to a pattern and say whether they 878 clobber a hard reg. */ 879 output_add_clobbers (); 880 output_added_clobbers_hard_reg_p (); 881 882 fflush (stdout); 883 return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE); 884} 885 886/* Define this so we can link with print-rtl.o to get debug_rtx function. */ 887const char * 888get_insn_name (code) 889 int code ATTRIBUTE_UNUSED; 890{ 891 return NULL; 892} | 881 ++insn_index_number; 882 } 883 884 /* Write out the routines to add CLOBBERs to a pattern and say whether they 885 clobber a hard reg. */ 886 output_add_clobbers (); 887 output_added_clobbers_hard_reg_p (); 888 889 fflush (stdout); 890 return (ferror (stdout) != 0 ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE); 891} 892 893/* Define this so we can link with print-rtl.o to get debug_rtx function. */ 894const char * 895get_insn_name (code) 896 int code ATTRIBUTE_UNUSED; 897{ 898 return NULL; 899} |