From 182e98f439ae61096f85ca28e7ef20359742f8c4 Mon Sep 17 00:00:00 2001 From: froydnj Date: Fri, 4 Jun 2010 01:49:15 +0000 Subject: [PATCH] * final.c (output_asm_insn): Call targetm.asm_out.print_operand_punct_valid_p. Update comments. (output_operand): Call targetm.asm_out.print_operand. Update comments. (output_address): Call targetm.asm_out.print_operand_address. Update comments. * target.h (struct gcc_target): Add print_operand, print_operand_address, and print_operand_punct_valid_p fields. * targhooks.h (default_print_operand): Declare. (default_print_operand_address): Declare. (default_print_operand_punct_valid_p): Declare. * targhooks.c (default_print_operand): Define. (default_print_operand_address): Define. (default_print_operand_punct_valid_p): Define. * target-def.h (TARGET_PRINT_OPERAND): Define if not defined. (TARGET_PRINT_OPERAND_ADDRESS): Likewise. (TARGET_PRINT_OPERAND_PUNCT_VALID_P): Likewise. (TARGET_ASM_OUT): Add TARGET_PRINT_OPERAND, TARGET_PRINT_OPERAND_ADDRESS, and TARGET_PRINT_OPERAND_PUNCT_VALID_P. * vmsdbgout.c (addr_const_to_string): Update comment. * config/i386/i386.c (print_operand): Rename to... (ix86_print_operand): ...this. Make static. (print_operand_address): Rename to... (ix86_print_operand_address): ...this. Make static. Call ix86_print_operand instead of PRINT_OPERAND. (ix86_print_operand_punct_valid_p): New function. (TARGET_PRINT_OPERAND): Define. (TARGET_PRINT_OPERAND_ADDRESS): Define. (TARGET_PRINT_OPERAND_PUNCT_VALID_P): Define. * config/i386/i386.h (HI_REGISTER_NAMES): Update comment. (PRINT_OPERAND_PUNCT_VALID_P): Delete. (PRINT_OPERAND): Delete. (PRINT_OPERAND_ADDRESS): Delete. * config/i386/i386-protos.h (print_operand): Delete prototype. (print_operand_address): Delete prototype. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160245 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 37 +++++++++++++++++++++++++++++++++++++ gcc/config/i386/i386-protos.h | 2 -- gcc/config/i386/i386.c | 29 +++++++++++++++++++++-------- gcc/config/i386/i386.h | 17 ++--------------- gcc/final.c | 22 +++++++++------------- gcc/target-def.h | 17 ++++++++++++++++- gcc/target.h | 10 ++++++++++ gcc/targhooks.c | 40 ++++++++++++++++++++++++++++++++++++++++ gcc/targhooks.h | 3 +++ gcc/vmsdbgout.c | 4 ++-- 10 files changed, 140 insertions(+), 41 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e01dcbf..e0c0358 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,40 @@ +2010-06-03 Nathan Froyd + + * final.c (output_asm_insn): Call + targetm.asm_out.print_operand_punct_valid_p. Update comments. + (output_operand): Call targetm.asm_out.print_operand. Update comments. + (output_address): Call targetm.asm_out.print_operand_address. + Update comments. + * target.h (struct gcc_target): Add print_operand, + print_operand_address, and print_operand_punct_valid_p fields. + * targhooks.h (default_print_operand): Declare. + (default_print_operand_address): Declare. + (default_print_operand_punct_valid_p): Declare. + * targhooks.c (default_print_operand): Define. + (default_print_operand_address): Define. + (default_print_operand_punct_valid_p): Define. + * target-def.h (TARGET_PRINT_OPERAND): Define if not defined. + (TARGET_PRINT_OPERAND_ADDRESS): Likewise. + (TARGET_PRINT_OPERAND_PUNCT_VALID_P): Likewise. + (TARGET_ASM_OUT): Add TARGET_PRINT_OPERAND, + TARGET_PRINT_OPERAND_ADDRESS, and TARGET_PRINT_OPERAND_PUNCT_VALID_P. + * vmsdbgout.c (addr_const_to_string): Update comment. + * config/i386/i386.c (print_operand): Rename to... + (ix86_print_operand): ...this. Make static. + (print_operand_address): Rename to... + (ix86_print_operand_address): ...this. Make static. Call + ix86_print_operand instead of PRINT_OPERAND. + (ix86_print_operand_punct_valid_p): New function. + (TARGET_PRINT_OPERAND): Define. + (TARGET_PRINT_OPERAND_ADDRESS): Define. + (TARGET_PRINT_OPERAND_PUNCT_VALID_P): Define. + * config/i386/i386.h (HI_REGISTER_NAMES): Update comment. + (PRINT_OPERAND_PUNCT_VALID_P): Delete. + (PRINT_OPERAND): Delete. + (PRINT_OPERAND_ADDRESS): Delete. + * config/i386/i386-protos.h (print_operand): Delete prototype. + (print_operand_address): Delete prototype. + 2010-06-03 Richard Guenther PR tree-optimization/44403 diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h index eaff7ab..c1e6858 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -60,8 +60,6 @@ extern bool legitimate_pic_operand_p (rtx); extern int legitimate_pic_address_disp_p (rtx); extern void print_reg (rtx, int, FILE*); -extern void print_operand (FILE*, rtx, int); -extern void print_operand_address (FILE*, rtx); extern bool output_addr_const_extra (FILE*, rtx); extern void split_di (rtx[], int, rtx[], rtx[]); diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index de4fa72..645501a 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -10962,7 +10962,7 @@ output_pic_addr_const (FILE *file, rtx x, int code) } else /* We can't handle floating point constants; - PRINT_OPERAND must handle them. */ + TARGET_PRINT_OPERAND must handle them. */ output_operand_lossage ("floating constant misused"); break; @@ -11579,8 +11579,8 @@ get_some_local_dynamic_name (void) ; -- print a semicolon (after prefixes due to bug in older gas). */ -void -print_operand (FILE *file, rtx x, int code) +static void +ix86_print_operand (FILE *file, rtx x, int code) { if (code) { @@ -11615,7 +11615,7 @@ print_operand (FILE *file, rtx x, int code) if (!REG_P (x)) { putc ('[', file); - PRINT_OPERAND (file, x, 0); + ix86_print_operand (file, x, 0); putc (']', file); return; } @@ -11625,7 +11625,7 @@ print_operand (FILE *file, rtx x, int code) gcc_unreachable (); } - PRINT_OPERAND (file, x, 0); + ix86_print_operand (file, x, 0); return; @@ -11780,7 +11780,7 @@ print_operand (FILE *file, rtx x, int code) case 's': if (CONST_INT_P (x) || ! SHIFT_DOUBLE_OMITS_COUNT) { - PRINT_OPERAND (file, x, 0); + ix86_print_operand (file, x, 0); fputs (", ", file); } return; @@ -12177,11 +12177,17 @@ print_operand (FILE *file, rtx x, int code) output_addr_const (file, x); } } + +static bool +ix86_print_operand_punct_valid_p (unsigned char code) +{ + return (code == '*' || code == '+' || code == '&' || code == ';'); +} /* Print a memory operand whose address is ADDR. */ -void -print_operand_address (FILE *file, rtx addr) +static void +ix86_print_operand_address (FILE *file, rtx addr) { struct ix86_address parts; rtx base, index, disp; @@ -30676,6 +30682,13 @@ ix86_enum_va_list (int idx, const char **pname, tree *ptree) #undef TARGET_ASM_UNALIGNED_DI_OP #define TARGET_ASM_UNALIGNED_DI_OP TARGET_ASM_ALIGNED_DI_OP +#undef TARGET_PRINT_OPERAND +#define TARGET_PRINT_OPERAND ix86_print_operand +#undef TARGET_PRINT_OPERAND_ADDRESS +#define TARGET_PRINT_OPERAND_ADDRESS ix86_print_operand_address +#undef TARGET_PRINT_OPERAND_PUNCT_VALID_P +#define TARGET_PRINT_OPERAND_PUNCT_VALID_P ix86_print_operand_punct_valid_p + #undef TARGET_SCHED_ADJUST_COST #define TARGET_SCHED_ADJUST_COST ix86_adjust_cost #undef TARGET_SCHED_ISSUE_RATE diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 005664c..5e8fcad 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -1992,7 +1992,8 @@ do { \ For non floating point regs, the following are the HImode names. For float regs, the stack top is sometimes referred to as "%st(0)" - instead of just "%st". PRINT_OPERAND handles this with the "y" code. */ + instead of just "%st". TARGET_PRINT_OPERAND handles this with the + "y" code. */ #define HI_REGISTER_NAMES \ {"ax","dx","cx","bx","si","di","bp","sp", \ @@ -2162,20 +2163,6 @@ do { \ "call " CRT_MKSTR(__USER_LABEL_PREFIX__) #FUNC "\n" \ TEXT_SECTION_ASM_OP); -/* Print operand X (an rtx) in assembler syntax to file FILE. - CODE is a letter or dot (`z' in `%z0') or 0 if no letter was specified. - Effect of various CODE letters is described in i386.c near - print_operand function. */ - -#define PRINT_OPERAND_PUNCT_VALID_P(CODE) \ - ((CODE) == '*' || (CODE) == '+' || (CODE) == '&' || (CODE) == ';') - -#define PRINT_OPERAND(FILE, X, CODE) \ - print_operand ((FILE), (X), (CODE)) - -#define PRINT_OPERAND_ADDRESS(FILE, ADDR) \ - print_operand_address ((FILE), (ADDR)) - #define OUTPUT_ADDR_CONST_EXTRA(FILE, X, FAIL) \ do { \ if (! output_addr_const_extra (FILE, (X))) \ diff --git a/gcc/final.c b/gcc/final.c index 44f02ad..93fb170 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -3329,7 +3329,7 @@ output_asm_insn (const char *templ, rtx *operands) outputs an operand in a special way depending on the letter. Letters `acln' are implemented directly. Other letters are passed to `output_operand' so that - the PRINT_OPERAND macro can define them. */ + the TARGET_PRINT_OPERAND hook can define them. */ else if (ISALPHA (*p)) { int letter = *p++; @@ -3395,12 +3395,10 @@ output_asm_insn (const char *templ, rtx *operands) c = *p; } /* % followed by punctuation: output something for that - punctuation character alone, with no operand. - The PRINT_OPERAND macro decides what is actually done. */ -#ifdef PRINT_OPERAND_PUNCT_VALID_P - else if (PRINT_OPERAND_PUNCT_VALID_P ((unsigned char) *p)) + punctuation character alone, with no operand. The + TARGET_PRINT_OPERAND hook decides what is actually done. */ + else if (targetm.asm_out.print_operand_punct_valid_p ((unsigned char) *p)) output_operand (NULL_RTX, *p++); -#endif else output_operand_lossage ("invalid %%-code"); break; @@ -3472,14 +3470,13 @@ mark_symbol_refs_as_used (rtx x) } /* Print operand X using machine-dependent assembler syntax. - The macro PRINT_OPERAND is defined just to control this function. CODE is a non-digit that preceded the operand-number in the % spec, such as 'z' if the spec was `%z3'. CODE is 0 if there was no char between the % and the digits. When CODE is a non-letter, X is 0. The meanings of the letters are machine-dependent and controlled - by PRINT_OPERAND. */ + by TARGET_PRINT_OPERAND. */ static void output_operand (rtx x, int code ATTRIBUTE_UNUSED) @@ -3490,7 +3487,7 @@ output_operand (rtx x, int code ATTRIBUTE_UNUSED) /* X must not be a pseudo reg. */ gcc_assert (!x || !REG_P (x) || REGNO (x) < FIRST_PSEUDO_REGISTER); - PRINT_OPERAND (asm_out_file, x, code); + targetm.asm_out.print_operand (asm_out_file, x, code); if (x == NULL_RTX) return; @@ -3498,16 +3495,15 @@ output_operand (rtx x, int code ATTRIBUTE_UNUSED) for_each_rtx (&x, mark_symbol_ref_as_used, NULL); } -/* Print a memory reference operand for address X - using machine-dependent assembler syntax. - The macro PRINT_OPERAND_ADDRESS exists just to control this function. */ +/* Print a memory reference operand for address X using + machine-dependent assembler syntax. */ void output_address (rtx x) { bool changed = false; walk_alter_subreg (&x, &changed); - PRINT_OPERAND_ADDRESS (asm_out_file, x); + targetm.asm_out.print_operand_address (asm_out_file, x); } /* Print an integer constant expression in assembler syntax. diff --git a/gcc/target-def.h b/gcc/target-def.h index 1097723..b91a000 100644 --- a/gcc/target-def.h +++ b/gcc/target-def.h @@ -261,6 +261,18 @@ #define TARGET_ASM_TRAMPOLINE_TEMPLATE NULL +#ifndef TARGET_PRINT_OPERAND +#define TARGET_PRINT_OPERAND default_print_operand +#endif + +#ifndef TARGET_PRINT_OPERAND_ADDRESS +#define TARGET_PRINT_OPERAND_ADDRESS default_print_operand_address +#endif + +#ifndef TARGET_PRINT_OPERAND_PUNCT_VALID_P +#define TARGET_PRINT_OPERAND_PUNCT_VALID_P default_print_operand_punct_valid_p +#endif + #define TARGET_ASM_ALIGNED_INT_OP \ {TARGET_ASM_ALIGNED_HI_OP, \ TARGET_ASM_ALIGNED_SI_OP, \ @@ -314,7 +326,10 @@ TARGET_ASM_OUTPUT_ANCHOR, \ TARGET_ASM_OUTPUT_DWARF_DTPREL, \ TARGET_ASM_FINAL_POSTSCAN_INSN, \ - TARGET_ASM_TRAMPOLINE_TEMPLATE } + TARGET_ASM_TRAMPOLINE_TEMPLATE, \ + TARGET_PRINT_OPERAND, \ + TARGET_PRINT_OPERAND_ADDRESS, \ + TARGET_PRINT_OPERAND_PUNCT_VALID_P } /* Scheduler hooks. All of these default to null pointers, which haifa-sched.c looks for and handles. */ diff --git a/gcc/target.h b/gcc/target.h index e17cc21..c8be2b5 100644 --- a/gcc/target.h +++ b/gcc/target.h @@ -277,6 +277,16 @@ struct gcc_target /* Emit the trampoline template. This hook may be NULL. */ void (*trampoline_template) (FILE *); + + /* Emit a machine-specific insn operand. */ + void (*print_operand) (FILE *, rtx, int); + + /* Emit a machine-specific memory address. */ + void (*print_operand_address) (FILE *, rtx); + + /* Determine whether CODE is a valid punctuation character for the + `print_operand' hook. */ + bool (*print_operand_punct_valid_p)(unsigned char code); } asm_out; /* Functions relating to instruction scheduling. */ diff --git a/gcc/targhooks.c b/gcc/targhooks.c index da84019..f6dbebf 100644 --- a/gcc/targhooks.c +++ b/gcc/targhooks.c @@ -325,6 +325,46 @@ default_unwind_emit (FILE * stream ATTRIBUTE_UNUSED, gcc_unreachable (); } +/* Emit to STREAM the assembler syntax for insn operand X. */ + +void +default_print_operand (FILE *stream ATTRIBUTE_UNUSED, rtx x ATTRIBUTE_UNUSED, + int code ATTRIBUTE_UNUSED) +{ +#ifdef PRINT_OPERAND + PRINT_OPERAND (stream, x, code); +#else + gcc_unreachable (); +#endif +} + +/* Emit to STREAM the assembler syntax for an insn operand whose memory + address is X. */ + +void +default_print_operand_address (FILE *stream ATTRIBUTE_UNUSED, + rtx x ATTRIBUTE_UNUSED) +{ +#ifdef PRINT_OPERAND_ADDRESS + PRINT_OPERAND_ADDRESS (stream, x); +#else + gcc_unreachable (); +#endif +} + +/* Return true if CODE is a valid punctuation character for the + `print_operand' hook. */ + +bool +default_print_operand_punct_valid_p (unsigned char code ATTRIBUTE_UNUSED) +{ +#ifdef PRINT_OPERAND_PUNCT_VALID_P + return PRINT_OPERAND_PUNCT_VALID_P (code); +#else + return false; +#endif +} + /* True if MODE is valid for the target. By "valid", we mean able to be manipulated in non-trivial ways. In particular, this means all the arithmetic is supported. diff --git a/gcc/targhooks.h b/gcc/targhooks.h index be167e5e0..f6be95d 100644 --- a/gcc/targhooks.h +++ b/gcc/targhooks.h @@ -63,6 +63,9 @@ extern bool hook_callee_copies_named (CUMULATIVE_ARGS *ca, enum machine_mode, const_tree, bool); extern void default_unwind_emit (FILE *, rtx); +extern void default_print_operand (FILE *, rtx, int); +extern void default_print_operand_address (FILE *, rtx); +extern bool default_print_operand_punct_valid_p (unsigned char); extern bool default_scalar_mode_supported_p (enum machine_mode); extern bool default_decimal_float_supported_p (void); diff --git a/gcc/vmsdbgout.c b/gcc/vmsdbgout.c index 44e4dc8..6856ab3 100644 --- a/gcc/vmsdbgout.c +++ b/gcc/vmsdbgout.c @@ -491,8 +491,8 @@ addr_const_to_string (char *str, rtx x) strcat (str, buf1); } else - /* We can't handle floating point constants; PRINT_OPERAND must - handle them. */ + /* We can't handle floating point constants; + TARGET_PRINT_OPERAND must handle them. */ output_operand_lossage ("floating constant misused"); break; -- 2.7.4