@@ -2793,29 +2793,134 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
27932793 bool no_cond_jump_promotion ;
27942794 } arch_stack_entry ;
27952795 static const arch_stack_entry * arch_stack_top ;
2796+ char * s ;
2797+ int e ;
2798+ const char * string ;
2799+ unsigned int j = 0 ;
2800+ i386_cpu_flags flags ;
27962801
27972802 SKIP_WHITESPACE ();
27982803
2799- if (!is_end_of_line [(unsigned char ) * input_line_pointer ])
2804+ if (is_end_of_line [(unsigned char ) * input_line_pointer ])
2805+ {
2806+ as_bad (_ ("missing cpu architecture" ));
2807+ input_line_pointer ++ ;
2808+ return ;
2809+ }
2810+
2811+ e = get_symbol_name (& s );
2812+ string = s ;
2813+
2814+ if (strcmp (string , "push" ) == 0 )
2815+ {
2816+ arch_stack_entry * top = XNEW (arch_stack_entry );
2817+
2818+ top -> name = cpu_arch_name ;
2819+ if (cpu_sub_arch_name )
2820+ top -> sub_name = xstrdup (cpu_sub_arch_name );
2821+ else
2822+ top -> sub_name = NULL ;
2823+ top -> flags = cpu_arch_flags ;
2824+ top -> isa = cpu_arch_isa ;
2825+ top -> isa_flags = cpu_arch_isa_flags ;
2826+ top -> flag_code = flag_code ;
2827+ top -> stackop_size = stackop_size ;
2828+ top -> no_cond_jump_promotion = no_cond_jump_promotion ;
2829+
2830+ top -> prev = arch_stack_top ;
2831+ arch_stack_top = top ;
2832+
2833+ (void ) restore_line_pointer (e );
2834+ demand_empty_rest_of_line ();
2835+ return ;
2836+ }
2837+
2838+ if (strcmp (string , "pop" ) == 0 )
28002839 {
2801- char * s ;
2802- int e = get_symbol_name (& s );
2803- const char * string = s ;
2804- unsigned int j = 0 ;
2805- i386_cpu_flags flags ;
2840+ const arch_stack_entry * top = arch_stack_top ;
28062841
2807- if (strcmp (string , "default" ) == 0 )
2842+ if (!top )
2843+ as_bad (_ (".arch stack is empty" ));
2844+ else if (top -> flag_code != flag_code
2845+ || top -> stackop_size != stackop_size )
2846+ {
2847+ static const unsigned int bits [] = {
2848+ [CODE_16BIT ] = 16 ,
2849+ [CODE_32BIT ] = 32 ,
2850+ [CODE_64BIT ] = 64 ,
2851+ };
2852+
2853+ as_bad (_ ("this `.arch pop' requires `.code%u%s' to be in effect" ),
2854+ bits [top -> flag_code ],
2855+ top -> stackop_size == LONG_MNEM_SUFFIX ? "gcc" : "" );
2856+ }
2857+ else
2858+ {
2859+ arch_stack_top = top -> prev ;
2860+
2861+ cpu_arch_name = top -> name ;
2862+ free (cpu_sub_arch_name );
2863+ cpu_sub_arch_name = top -> sub_name ;
2864+ cpu_arch_flags = top -> flags ;
2865+ cpu_arch_isa = top -> isa ;
2866+ cpu_arch_isa_flags = top -> isa_flags ;
2867+ no_cond_jump_promotion = top -> no_cond_jump_promotion ;
2868+
2869+ XDELETE (top );
2870+ }
2871+
2872+ (void ) restore_line_pointer (e );
2873+ demand_empty_rest_of_line ();
2874+ return ;
2875+ }
2876+
2877+ if (strcmp (string , "default" ) == 0 )
2878+ {
2879+ if (strcmp (default_arch , "iamcu" ) == 0 )
2880+ string = default_arch ;
2881+ else
28082882 {
2809- if (strcmp (default_arch , "iamcu" ) == 0 )
2810- string = default_arch ;
2883+ static const i386_cpu_flags cpu_unknown_flags = CPU_UNKNOWN_FLAGS ;
2884+
2885+ cpu_arch_name = NULL ;
2886+ free (cpu_sub_arch_name );
2887+ cpu_sub_arch_name = NULL ;
2888+ cpu_arch_flags = cpu_unknown_flags ;
2889+ if (flag_code == CODE_64BIT )
2890+ {
2891+ cpu_arch_flags .bitfield .cpu64 = 1 ;
2892+ cpu_arch_flags .bitfield .cpuno64 = 0 ;
2893+ }
28112894 else
28122895 {
2813- static const i386_cpu_flags cpu_unknown_flags = CPU_UNKNOWN_FLAGS ;
2896+ cpu_arch_flags .bitfield .cpu64 = 0 ;
2897+ cpu_arch_flags .bitfield .cpuno64 = 1 ;
2898+ }
2899+ cpu_arch_isa = PROCESSOR_UNKNOWN ;
2900+ cpu_arch_isa_flags = cpu_arch [flag_code == CODE_64BIT ].enable ;
2901+ if (!cpu_arch_tune_set )
2902+ {
2903+ cpu_arch_tune = cpu_arch_isa ;
2904+ cpu_arch_tune_flags = cpu_arch_isa_flags ;
2905+ }
2906+
2907+ j = ARRAY_SIZE (cpu_arch ) + 1 ;
2908+ }
2909+ }
2910+
2911+ for (; j < ARRAY_SIZE (cpu_arch ); j ++ )
2912+ {
2913+ if (strcmp (string + (* string == '.' ), cpu_arch [j ].name ) == 0
2914+ && (* string == '.' ) == (cpu_arch [j ].type == PROCESSOR_NONE ))
2915+ {
2916+ if (* string != '.' )
2917+ {
2918+ check_cpu_arch_compatible (string , cpu_arch [j ].enable );
28142919
2815- cpu_arch_name = NULL ;
2920+ cpu_arch_name = cpu_arch [ j ]. name ;
28162921 free (cpu_sub_arch_name );
28172922 cpu_sub_arch_name = NULL ;
2818- cpu_arch_flags = cpu_unknown_flags ;
2923+ cpu_arch_flags = cpu_arch [ j ]. enable ;
28192924 if (flag_code == CODE_64BIT )
28202925 {
28212926 cpu_arch_flags .bitfield .cpu64 = 1 ;
@@ -2826,173 +2931,71 @@ set_cpu_arch (int dummy ATTRIBUTE_UNUSED)
28262931 cpu_arch_flags .bitfield .cpu64 = 0 ;
28272932 cpu_arch_flags .bitfield .cpuno64 = 1 ;
28282933 }
2829- cpu_arch_isa = PROCESSOR_UNKNOWN ;
2830- cpu_arch_isa_flags = cpu_arch [flag_code == CODE_64BIT ].enable ;
2934+ cpu_arch_isa = cpu_arch [ j ]. type ;
2935+ cpu_arch_isa_flags = cpu_arch [j ].enable ;
28312936 if (!cpu_arch_tune_set )
28322937 {
28332938 cpu_arch_tune = cpu_arch_isa ;
28342939 cpu_arch_tune_flags = cpu_arch_isa_flags ;
28352940 }
2836-
2837- j = ARRAY_SIZE ( cpu_arch ) + 1 ;
2941+ pre_386_16bit_warned = false;
2942+ break ;
28382943 }
2839- }
2840- else if (strcmp (string , "push" ) == 0 )
2841- {
2842- arch_stack_entry * top = XNEW (arch_stack_entry );
28432944
2844- top -> name = cpu_arch_name ;
2845- if (cpu_sub_arch_name )
2846- top -> sub_name = xstrdup (cpu_sub_arch_name );
2847- else
2848- top -> sub_name = NULL ;
2849- top -> flags = cpu_arch_flags ;
2850- top -> isa = cpu_arch_isa ;
2851- top -> isa_flags = cpu_arch_isa_flags ;
2852- top -> flag_code = flag_code ;
2853- top -> stackop_size = stackop_size ;
2854- top -> no_cond_jump_promotion = no_cond_jump_promotion ;
2945+ if (cpu_flags_all_zero (& cpu_arch [j ].enable ))
2946+ continue ;
28552947
2856- top -> prev = arch_stack_top ;
2857- arch_stack_top = top ;
2948+ flags = cpu_flags_or (cpu_arch_flags , cpu_arch [j ].enable );
28582949
2859- (void ) restore_line_pointer (e );
2860- demand_empty_rest_of_line ();
2861- return ;
2862- }
2863- else if (strcmp (string , "pop" ) == 0 )
2864- {
2865- const arch_stack_entry * top = arch_stack_top ;
2866-
2867- if (!top )
2868- as_bad (_ (".arch stack is empty" ));
2869- else if (top -> flag_code != flag_code
2870- || top -> stackop_size != stackop_size )
2950+ if (!cpu_flags_equal (& flags , & cpu_arch_flags ))
28712951 {
2872- static const unsigned int bits [] = {
2873- [CODE_16BIT ] = 16 ,
2874- [CODE_32BIT ] = 32 ,
2875- [CODE_64BIT ] = 64 ,
2876- };
2877-
2878- as_bad (_ ("this `.arch pop' requires `.code%u%s' to be in effect" ),
2879- bits [top -> flag_code ],
2880- top -> stackop_size == LONG_MNEM_SUFFIX ? "gcc" : "" );
2952+ extend_cpu_sub_arch_name (string + 1 );
2953+ cpu_arch_flags = flags ;
2954+ cpu_arch_isa_flags = flags ;
28812955 }
28822956 else
2883- {
2884- arch_stack_top = top -> prev ;
2885-
2886- cpu_arch_name = top -> name ;
2887- free (cpu_sub_arch_name );
2888- cpu_sub_arch_name = top -> sub_name ;
2889- cpu_arch_flags = top -> flags ;
2890- cpu_arch_isa = top -> isa ;
2891- cpu_arch_isa_flags = top -> isa_flags ;
2892- no_cond_jump_promotion = top -> no_cond_jump_promotion ;
2893-
2894- XDELETE (top );
2895- }
2957+ cpu_arch_isa_flags
2958+ = cpu_flags_or (cpu_arch_isa_flags , cpu_arch [j ].enable );
28962959
28972960 (void ) restore_line_pointer (e );
28982961 demand_empty_rest_of_line ();
28992962 return ;
29002963 }
2964+ }
29012965
2902- for (; j < ARRAY_SIZE (cpu_arch ); j ++ )
2903- {
2904- if (strcmp (string + (* string == '.' ), cpu_arch [j ].name ) == 0
2905- && (* string == '.' ) == (cpu_arch [j ].type == PROCESSOR_NONE ))
2906- {
2907- if (* string != '.' )
2908- {
2909- check_cpu_arch_compatible (string , cpu_arch [j ].enable );
2910-
2911- cpu_arch_name = cpu_arch [j ].name ;
2912- free (cpu_sub_arch_name );
2913- cpu_sub_arch_name = NULL ;
2914- cpu_arch_flags = cpu_arch [j ].enable ;
2915- if (flag_code == CODE_64BIT )
2916- {
2917- cpu_arch_flags .bitfield .cpu64 = 1 ;
2918- cpu_arch_flags .bitfield .cpuno64 = 0 ;
2919- }
2920- else
2921- {
2922- cpu_arch_flags .bitfield .cpu64 = 0 ;
2923- cpu_arch_flags .bitfield .cpuno64 = 1 ;
2924- }
2925- cpu_arch_isa = cpu_arch [j ].type ;
2926- cpu_arch_isa_flags = cpu_arch [j ].enable ;
2927- if (!cpu_arch_tune_set )
2928- {
2929- cpu_arch_tune = cpu_arch_isa ;
2930- cpu_arch_tune_flags = cpu_arch_isa_flags ;
2931- }
2932- pre_386_16bit_warned = false;
2933- break ;
2934- }
2935-
2936- if (cpu_flags_all_zero (& cpu_arch [j ].enable ))
2937- continue ;
2938-
2939- flags = cpu_flags_or (cpu_arch_flags ,
2940- cpu_arch [j ].enable );
2941-
2942- if (!cpu_flags_equal (& flags , & cpu_arch_flags ))
2943- {
2944- extend_cpu_sub_arch_name (string + 1 );
2945- cpu_arch_flags = flags ;
2946- cpu_arch_isa_flags = flags ;
2947- }
2948- else
2949- cpu_arch_isa_flags
2950- = cpu_flags_or (cpu_arch_isa_flags ,
2951- cpu_arch [j ].enable );
2952- (void ) restore_line_pointer (e );
2953- demand_empty_rest_of_line ();
2954- return ;
2955- }
2956- }
2957-
2958- if (startswith (string , ".no" ) && j >= ARRAY_SIZE (cpu_arch ))
2959- {
2960- /* Disable an ISA extension. */
2961- for (j = 0 ; j < ARRAY_SIZE (cpu_arch ); j ++ )
2962- if (cpu_arch [j ].type == PROCESSOR_NONE
2963- && strcmp (string + 3 , cpu_arch [j ].name ) == 0 )
2966+ if (startswith (string , ".no" ) && j >= ARRAY_SIZE (cpu_arch ))
2967+ {
2968+ /* Disable an ISA extension. */
2969+ for (j = 0 ; j < ARRAY_SIZE (cpu_arch ); j ++ )
2970+ if (cpu_arch [j ].type == PROCESSOR_NONE
2971+ && strcmp (string + 3 , cpu_arch [j ].name ) == 0 )
2972+ {
2973+ flags = cpu_flags_and_not (cpu_arch_flags , cpu_arch [j ].disable );
2974+ if (!cpu_flags_equal (& flags , & cpu_arch_flags ))
29642975 {
2965- flags = cpu_flags_and_not (cpu_arch_flags ,
2966- cpu_arch [j ].disable );
2967- if (!cpu_flags_equal (& flags , & cpu_arch_flags ))
2968- {
2969- extend_cpu_sub_arch_name (string + 1 );
2970- cpu_arch_flags = flags ;
2971- cpu_arch_isa_flags = flags ;
2972- }
2973- (void ) restore_line_pointer (e );
2974- demand_empty_rest_of_line ();
2975- return ;
2976+ extend_cpu_sub_arch_name (string + 1 );
2977+ cpu_arch_flags = flags ;
2978+ cpu_arch_isa_flags = flags ;
29762979 }
2977- }
2978-
2979- if (j == ARRAY_SIZE (cpu_arch ))
2980- as_bad (_ ("no such architecture: `%s'" ), string );
29812980
2982- * input_line_pointer = e ;
2981+ (void ) restore_line_pointer (e );
2982+ demand_empty_rest_of_line ();
2983+ return ;
2984+ }
29832985 }
2984- else
2985- as_bad (_ ("missing cpu architecture" ));
2986+
2987+ if (j == ARRAY_SIZE (cpu_arch ))
2988+ as_bad (_ ("no such architecture: `%s'" ), string );
2989+
2990+ * input_line_pointer = e ;
29862991
29872992 no_cond_jump_promotion = 0 ;
29882993 if (* input_line_pointer == ','
29892994 && !is_end_of_line [(unsigned char ) input_line_pointer [1 ]])
29902995 {
2991- char * string ;
2992- char e ;
2993-
29942996 ++ input_line_pointer ;
2995- e = get_symbol_name (& string );
2997+ e = get_symbol_name (& s );
2998+ string = s ;
29962999
29973000 if (strcmp (string , "nojumps" ) == 0 )
29983001 no_cond_jump_promotion = 1 ;
0 commit comments