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, 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_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 |
300gen_insn (insn, lineno) |
301 rtx insn; |
302 int lineno; |
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 |
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 |
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)) |
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 |
559 /* Call `get_insns' to extract the list of all the |
560 insns emitted within this gen_... function. */ 561 |
562 printf (" _val = get_insns ();\n"); |
563 printf (" end_sequence ();\n"); 564 printf (" return _val;\n}\n\n"); 565} 566 |
567/* Like gen_expand, but generates insns resulting from splitting SPLIT. */ |
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 |
671 /* Call `get_insns' to make a list of all the |
672 insns emitted within this gen_... function. */ 673 |
674 printf (" _val = get_insns ();\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"); |
845 printf ("#define DONE return (_val = get_insns (), end_sequence (), _val)\n\n"); |
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 { |
859 case DEFINE_INSN: 860 gen_insn (desc, line_no); 861 break; |
862 |
863 case DEFINE_EXPAND: 864 printf ("/* %s:%d */\n", read_rtx_filename, line_no); 865 gen_expand (desc); 866 break; |
867 |
868 case DEFINE_SPLIT: 869 printf ("/* %s:%d */\n", read_rtx_filename, line_no); 870 gen_split (desc); 871 break; |
872 |
873 case DEFINE_PEEPHOLE2: 874 printf ("/* %s:%d */\n", read_rtx_filename, line_no); 875 gen_split (desc); 876 break; |
877 |
878 default: 879 break; 880 } |
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} |