Author: zhuqing Date: 2011-09-15 04:23:06 -0400 (Thu, 15 Sep 2011) New Revision: 3737
Modified: trunk/osprey-gcc-4.2.0/gcc/c-decl.c trunk/osprey-gcc-4.2.0/gcc/c-parser.c trunk/osprey-gcc-4.2.0/gcc/tree.c trunk/osprey-gcc-4.2.0/gcc/tree.h trunk/osprey-gcc-4.2.0/gcc/varasm.c trunk/osprey/be/cg/cg.cxx trunk/osprey/be/com/stblock.cxx trunk/osprey/common/com/symtab_access.h trunk/osprey/common/com/symtab_defs.h trunk/osprey/wgen/wgen_decl.cxx Log: Fix bug847. 1. Put global asm code at where it defines 2. When there is global asm in source file, do not emit .org Code Review: Jian-Xin. Modified: trunk/osprey/be/cg/cg.cxx =================================================================== --- trunk/osprey/be/cg/cg.cxx 2011-09-13 07:17:29 UTC (rev 3736) +++ trunk/osprey/be/cg/cg.cxx 2011-09-15 08:23:06 UTC (rev 3737) @@ -803,7 +803,7 @@ // after it. In this scenario, don't emit .org. Also emit a // proper .align based on the alignment of the symbol instead of // .align 0. - if (LANG_Enable_Global_Asm) + if (LANG_Enable_Global_Asm || FILE_INFO_has_global_asm(File_info)) CG_file_scope_asm_seen = TRUE; #endif return rwn; Modified: trunk/osprey/be/com/stblock.cxx =================================================================== --- trunk/osprey/be/com/stblock.cxx 2011-09-13 07:17:29 UTC (rev 3736) +++ trunk/osprey/be/com/stblock.cxx 2011-09-15 08:23:06 UTC (rev 3737) @@ -224,7 +224,8 @@ /* Under -LANG:global_asm, the ASMs may have .section attributes, * so the compiler cannot be sure about offset/alignment of * compiler allocated objects, so use minimum alignment (bug 14506) */ - if ( /* Optimize_Space==FALSE */ LANG_Enable_Global_Asm == FALSE ) + if ( /* Optimize_Space==FALSE */ LANG_Enable_Global_Asm == FALSE || + FILE_INFO_has_global_asm(File_info)) #else if ( /* Optimize_Space==FALSE */ TRUE ) #endif Modified: trunk/osprey/common/com/symtab_access.h =================================================================== --- trunk/osprey/common/com/symtab_access.h 2011-09-13 07:17:29 UTC (rev 3736) +++ trunk/osprey/common/com/symtab_access.h 2011-09-15 08:23:06 UTC (rev 3737) @@ -2017,6 +2017,12 @@ inline void Clear_FILE_INFO_has_mp (FILE_INFO& f){ f.flags &= ~FI_HAS_MP; } +inline BOOL +FILE_INFO_has_global_asm (const FILE_INFO& f) { return f.flags & FI_HAS_GLOBAL_ASM; } +inline void +Set_FILE_INFO_has_global_asm (FILE_INFO& f) { f.flags |= FI_HAS_GLOBAL_ASM; } +inline void +Clear_FILE_INFO_has_global_asm (FILE_INFO& f) { f.flags &= ~FI_HAS_GLOBAL_ASM; } //---------------------------------------------------------------------- Modified: trunk/osprey/common/com/symtab_defs.h =================================================================== --- trunk/osprey/common/com/symtab_defs.h 2011-09-13 07:17:29 UTC (rev 3736) +++ trunk/osprey/common/com/symtab_defs.h 2011-09-15 08:23:06 UTC (rev 3737) @@ -872,7 +872,8 @@ FI_IPA = 0x1, // IPA generated file FI_NEEDS_LNO = 0x2, // needs to run LNO FI_HAS_INLINES = 0x4, // some PUs have PU_HAS_INLINES set - FI_HAS_MP = 0x8 // need to process MP constructs + FI_HAS_MP = 0x8, // need to process MP constructs + FI_HAS_GLOBAL_ASM = 0x10 // contains global asm, do not emit .org }; struct FILE_INFO Modified: trunk/osprey/wgen/wgen_decl.cxx =================================================================== --- trunk/osprey/wgen/wgen_decl.cxx 2011-09-13 07:17:29 UTC (rev 3736) +++ trunk/osprey/wgen/wgen_decl.cxx 2011-09-15 08:23:06 UTC (rev 3737) @@ -701,8 +701,17 @@ { } +static void WGEN_Assemble_Asm(char *asm_string); + void WGEN_Expand_Decl(gs_t decl, BOOL can_skip) { + if (decl != NULL && gs_code(decl) == GS_STRING_CST) { + char *asm_string = gs_tree_string_pointer(decl); + Set_FILE_INFO_has_global_asm(File_info); + WGEN_Assemble_Asm (asm_string); + return; + } + Is_True(decl != NULL && gs_tree_code_class(decl) == GS_TCC_DECLARATION, ("Argument to WGEN_Expand_Decl isn't a decl node")); /* Modified: trunk/osprey-gcc-4.2.0/gcc/c-decl.c =================================================================== --- trunk/osprey-gcc-4.2.0/gcc/c-decl.c 2011-09-13 07:17:29 UTC (rev 3736) +++ trunk/osprey-gcc-4.2.0/gcc/c-decl.c 2011-09-15 08:23:06 UTC (rev 3737) @@ -8063,10 +8063,6 @@ #ifdef KEY if (flag_spin_file) { - /* Bug 13913: above -O0, flag_unit_at_a_time causes a different - phase structure causing us to skip processing of global asm - statements. Output any such statements here. */ - cgraph_output_pending_asms (); remove_asm_file (); if (!errorcount) exit (EXIT_SUCCESS); Modified: trunk/osprey-gcc-4.2.0/gcc/c-parser.c =================================================================== --- trunk/osprey-gcc-4.2.0/gcc/c-parser.c 2011-09-13 07:17:29 UTC (rev 3736) +++ trunk/osprey-gcc-4.2.0/gcc/c-parser.c 2011-09-15 08:23:06 UTC (rev 3737) @@ -1445,12 +1445,22 @@ simple-asm-expr ; */ +#ifdef KEY +extern void gspin_gxx_emits_asm (tree t); +extern int flag_spin_file; +#endif + static void c_parser_asm_definition (c_parser *parser) { tree asm_str = c_parser_simple_asm_expr (parser); - if (asm_str) + if (asm_str) { cgraph_add_asm_node (asm_str); +#ifdef KEY + if (flag_spin_file) + gspin_gxx_emits_asm (asm_str); +#endif + } c_parser_skip_until_found (parser, CPP_SEMICOLON, "expected %<;%>"); } Modified: trunk/osprey-gcc-4.2.0/gcc/tree.c =================================================================== --- trunk/osprey-gcc-4.2.0/gcc/tree.c 2011-09-13 07:17:29 UTC (rev 3736) +++ trunk/osprey-gcc-4.2.0/gcc/tree.c 2011-09-15 08:23:06 UTC (rev 3737) @@ -9714,7 +9714,7 @@ gs_t gs_x (tree node); gs_t gs_x_func_decl (tree node); void gspin_gxx_emits_decl (tree t); -void gspin_gxx_emits_asm (char *str); +void gspin_gxx_emits_asm (tree str); void gspin_write (void); void gspin_init (void); void gspin_init_global_trees_list (void); @@ -12026,22 +12026,20 @@ /* Add T to list of asms emitted by g++. */ void -gspin_gxx_emits_asm (char *str) +gspin_gxx_emits_asm (tree t) { - gs_t asm_string_node, asm_list; + gs_t decl, decl_list; + decl = gs_x(t); - asm_string_node = __gs(IB_STRING); - _gs_s(asm_string_node, (gs_string_t) str, strlen(str) + 1); - - if (gs_code(gxx_emitted_asms_dot) == EMPTY) { - _gs_code(gxx_emitted_asms_dot, CONS); - gs_set_operand(gxx_emitted_asms_dot, 0, asm_string_node); - gs_set_operand(gxx_emitted_asms_dot, 1, __gs(EMPTY)); + if (gs_code(program_decls_dot) == EMPTY) { + _gs_code(program_decls_dot, CONS); + gs_set_operand(program_decls_dot, 0, decl); + gs_set_operand(program_decls_dot, 1, __gs(EMPTY)); return; } - asm_list = gs_cons(asm_string_node, gs_operand(gxx_emitted_asms_dot, 1)); - gs_set_operand(gxx_emitted_asms_dot, 1, asm_list); - gxx_emitted_asms_dot = asm_list; + decl_list = gs_cons(decl, gs_operand(program_decls_dot, 1)); + gs_set_operand(program_decls_dot, 1, decl_list); + program_decls_dot = decl_list; } void Modified: trunk/osprey-gcc-4.2.0/gcc/tree.h =================================================================== --- trunk/osprey-gcc-4.2.0/gcc/tree.h 2011-09-13 07:17:29 UTC (rev 3736) +++ trunk/osprey-gcc-4.2.0/gcc/tree.h 2011-09-15 08:23:06 UTC (rev 3737) @@ -4713,7 +4713,7 @@ extern gs_t gs_x_func_decl (tree node); extern void gspin_gxx_emits_decl (tree t); extern void gspin_gxx_emits_thunk_decl (tree t); -extern void gspin_gxx_emits_asm (char *str); +extern void gspin_gxx_emits_asm (tree t); extern void gspin_init_global_trees_list (void); extern int gspin_invoked (tree t); extern void gs_set_flag_value (tree t, unsigned int flag, bool value); Modified: trunk/osprey-gcc-4.2.0/gcc/varasm.c =================================================================== --- trunk/osprey-gcc-4.2.0/gcc/varasm.c 2011-09-13 07:17:29 UTC (rev 3736) +++ trunk/osprey-gcc-4.2.0/gcc/varasm.c 2011-09-15 08:23:06 UTC (rev 3737) @@ -70,7 +70,6 @@ #include "gspin-gcc-interface.h" #include "diagnostic.h" /* errorcount, sorrycount */ extern void gspin_gxx_emits_decl (tree); -extern void gspin_gxx_emits_asm (char *); extern int flag_spin_file; #endif @@ -1214,10 +1213,6 @@ if (TREE_CODE (string) == ADDR_EXPR) string = TREE_OPERAND (string, 0); -#ifdef KEY - if (flag_spin_file) - gspin_gxx_emits_asm ((char *)TREE_STRING_POINTER (string)); -#endif fprintf (asm_out_file, "\t%s\n", TREE_STRING_POINTER (string)); } ------------------------------------------------------------------------------ Doing More with Less: The Next Generation Virtual Desktop What are the key obstacles that have prevented many mid-market businesses from deploying virtual desktops? How do next-generation virtual desktops provide companies an easier-to-deploy, easier-to-manage and more affordable virtual desktop model.http://www.accelacomm.com/jaw/sfnl/114/51426474/ _______________________________________________ Open64-devel mailing list Open64-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/open64-devel