@@ -2554,7 +2554,7 @@ mips64r6_deps="mips"
2554
2554
mipsfpu_deps=" mips"
2555
2555
mipsdsp_deps=" mips"
2556
2556
mipsdspr2_deps=" mips"
2557
- mmi_deps= " mips "
2557
+ mmi_deps_any= " loongson2 loongson3 "
2558
2558
msa_deps=" mipsfpu"
2559
2559
msa2_deps=" msa"
2560
2560
@@ -5005,8 +5005,6 @@ elif enabled bfin; then
5005
5005
5006
5006
elif enabled mips; then
5007
5007
5008
- cpuflags=" -march=$cpu "
5009
-
5010
5008
if [ " $cpu " != " generic" ]; then
5011
5009
disable mips32r2
5012
5010
disable mips32r5
@@ -5015,95 +5013,105 @@ elif enabled mips; then
5015
5013
disable mips64r6
5016
5014
disable loongson2
5017
5015
disable loongson3
5016
+ disable mipsdsp
5017
+ disable mipsdspr2
5018
+ disable msa
5019
+ disable mmi
5020
+
5021
+ cpuflags=" -march=$cpu "
5018
5022
5019
5023
case $cpu in
5020
- 24kc|24kf* |24kec|34kc|1004kc|24kef* |34kf* |1004kf* |74kc|74kf)
5024
+ # General ISA levels
5025
+ mips1|mips3)
5026
+ ;;
5027
+ mips32r2)
5028
+ enable msa
5021
5029
enable mips32r2
5022
- disable msa
5023
5030
;;
5024
- p5600|i6400|p6600)
5025
- disable mipsdsp
5026
- disable mipsdspr2
5031
+ mips32r5)
5032
+ enable msa
5033
+ enable mips32r2
5034
+ enable mips32r5
5027
5035
;;
5028
- loongson* )
5029
- enable loongson2
5036
+ mips64r2|mips64r5)
5037
+ enable msa
5038
+ enable mmi
5039
+ enable mips64r2
5030
5040
enable loongson3
5041
+ ;;
5042
+ # Cores from MIPS(MTI)
5043
+ 24kc)
5044
+ disable mipsfpu
5045
+ enable mips32r2
5046
+ ;;
5047
+ 24kf* |24kec|34kc|74Kc|1004kc)
5048
+ enable mips32r2
5049
+ ;;
5050
+ 24kef* |34kf* |1004kf* )
5051
+ enable mipsdsp
5052
+ enable mips32r2
5053
+ ;;
5054
+ p5600)
5055
+ enable msa
5056
+ enable mips32r2
5057
+ enable mips32r5
5058
+ check_cflags " -mtune=p5600" && check_cflags " -msched-weight -mload-store-pairs -funroll-loops"
5059
+ ;;
5060
+ i6400)
5061
+ enable mips64r6
5062
+ check_cflags " -mtune=i6400 -mabi=64" && check_cflags " -msched-weight -mload-store-pairs -funroll-loops" && check_ldflags " -mabi=64"
5063
+ ;;
5064
+ p6600)
5065
+ enable mips64r6
5066
+ check_cflags " -mtune=p6600 -mabi=64" && check_cflags " -msched-weight -mload-store-pairs -funroll-loops" && check_ldflags " -mabi=64"
5067
+ ;;
5068
+ # Cores from Loongson
5069
+ loongson2e|loongson2f|loongson3* )
5070
+ enable mmi
5031
5071
enable local_aligned
5032
5072
enable simd_align_16
5033
5073
enable fast_64bit
5034
5074
enable fast_clz
5035
5075
enable fast_cmov
5036
5076
enable fast_unaligned
5037
5077
disable aligned_stack
5038
- disable mipsdsp
5039
- disable mipsdspr2
5040
5078
# When gcc version less than 5.3.0, add -fno-expensive-optimizations flag.
5041
- if [ $cc == gcc ]; then
5042
- gcc_version=$( gcc -dumpversion)
5043
- if [ " $( echo " $gcc_version 5.3.0" | tr " " " \n" | sort -rV | head -n 1) " == " $gcc_version " ]; then
5044
- expensive_optimization_flag=" "
5045
- else
5079
+ if test " $cc_type " = " gcc" ; then
5080
+ case $gcc_basever in
5081
+ 2|2.* |3.* |4.* |5.0|5.1|5.2)
5046
5082
expensive_optimization_flag=" -fno-expensive-optimizations"
5047
- fi
5083
+ ;;
5084
+ * )
5085
+ expensive_optimization_flag=" "
5086
+ ;;
5087
+ esac
5048
5088
fi
5089
+
5049
5090
case $cpu in
5050
5091
loongson3* )
5092
+ enable loongson3
5093
+ enable msa
5051
5094
cpuflags=" -march=loongson3a -mhard-float $expensive_optimization_flag "
5052
5095
;;
5053
5096
loongson2e)
5097
+ enable loongson2
5054
5098
cpuflags=" -march=loongson2e -mhard-float $expensive_optimization_flag "
5055
5099
;;
5056
5100
loongson2f)
5101
+ enable loongson2
5057
5102
cpuflags=" -march=loongson2f -mhard-float $expensive_optimization_flag "
5058
5103
;;
5059
5104
esac
5060
5105
;;
5061
5106
* )
5062
- # Unknown CPU. Disable everything.
5063
- warn " unknown CPU. Disabling all MIPS optimizations."
5064
- disable mipsfpu
5065
- disable mipsdsp
5066
- disable mipsdspr2
5067
- disable msa
5068
- disable mmi
5107
+ warn " unknown MIPS CPU"
5069
5108
;;
5070
5109
esac
5071
5110
5072
- case $cpu in
5073
- 24kc)
5074
- disable mipsfpu
5075
- disable mipsdsp
5076
- disable mipsdspr2
5077
- ;;
5078
- 24kf* )
5079
- disable mipsdsp
5080
- disable mipsdspr2
5081
- ;;
5082
- 24kec|34kc|1004kc)
5083
- disable mipsfpu
5084
- disable mipsdspr2
5085
- ;;
5086
- 24kef* |34kf* |1004kf* )
5087
- disable mipsdspr2
5088
- ;;
5089
- 74kc)
5090
- disable mipsfpu
5091
- ;;
5092
- p5600)
5093
- enable mips32r5
5094
- check_cflags " -mtune=p5600" && check_cflags " -msched-weight -mload-store-pairs -funroll-loops"
5095
- ;;
5096
- i6400)
5097
- enable mips64r6
5098
- check_cflags " -mtune=i6400 -mabi=64" && check_cflags " -msched-weight -mload-store-pairs -funroll-loops" && check_ldflags " -mabi=64"
5099
- ;;
5100
- p6600)
5101
- enable mips64r6
5102
- check_cflags " -mtune=p6600 -mabi=64" && check_cflags " -msched-weight -mload-store-pairs -funroll-loops" && check_ldflags " -mabi=64"
5103
- ;;
5104
- esac
5105
5111
else
5106
- # We do not disable anything. Is up to the user to disable the unwanted features.
5112
+ disable mipsdsp
5113
+ disable mipsdspr2
5114
+ # Disable DSP stuff for generic CPU, it can't be detected at runtime.
5107
5115
warn ' generic cpu selected'
5108
5116
fi
5109
5117
@@ -5850,28 +5858,42 @@ EOF
5850
5858
5851
5859
elif enabled mips; then
5852
5860
5853
- enabled loongson2 && check_inline_asm loongson2 ' "dmult.g $8, $9, $10"'
5854
- enabled loongson3 && check_inline_asm loongson3 ' "gsldxc1 $f0, 0($2, $3)"'
5855
- enabled mmi && check_inline_asm mmi ' "punpcklhw $f0, $f0, $f0"'
5856
-
5857
- # Enable minimum ISA based on selected options
5861
+ # Check toolchain ISA level
5858
5862
if enabled mips64; then
5859
- enabled mips64r6 && check_inline_asm_flags mips64r6 ' "dlsa $0, $0, $0, 1"' ' -mips64r6'
5860
- enabled mips64r2 && check_inline_asm_flags mips64r2 ' "dext $0, $0, 0, 1"' ' -mips64r2'
5861
- disabled mips64r6 && disabled mips64r2 && check_inline_asm_flags mips64r1 ' "daddi $0, $0, 0"' ' -mips64'
5863
+ enabled mips64r6 && check_inline_asm mips64r6 ' "dlsa $0, $0, $0, 1"' &&
5864
+ disable mips64r2
5865
+
5866
+ enabled mips64r2 && check_inline_asm mips64r2 ' "dext $0, $0, 0, 1"'
5867
+
5868
+ disable mips32r6 && disable mips32r5 && disable mips32r2
5862
5869
else
5863
- enabled mips32r6 && check_inline_asm_flags mips32r6 ' "aui $0, $0, 0"' ' -mips32r6'
5864
- enabled mips32r5 && check_inline_asm_flags mips32r5 ' "eretnc"' ' -mips32r5'
5865
- enabled mips32r2 && check_inline_asm_flags mips32r2 ' "ext $0, $0, 0, 1"' ' -mips32r2'
5866
- disabled mips32r6 && disabled mips32r5 && disabled mips32r2 && check_inline_asm_flags mips32r1 ' "addi $0, $0, 0"' ' -mips32'
5870
+ enabled mips32r6 && check_inline_asm mips32r6 ' "aui $0, $0, 0"' &&
5871
+ disable mips32r5 && disable mips32r2
5872
+
5873
+ enabled mips32r5 && check_inline_asm mips32r5 ' "eretnc"'
5874
+ enabled mips32r2 && check_inline_asm mips32r2 ' "ext $0, $0, 0, 1"'
5875
+
5876
+ disable mips64r6 && disable mips64r5 && disable mips64r2
5867
5877
fi
5868
5878
5869
- enabled mipsfpu && check_inline_asm_flags mipsfpu ' "cvt.d.l $f0, $f2"' ' -mhard-float '
5879
+ enabled mipsfpu && check_inline_asm mipsfpu ' "cvt.d.l $f0, $f2"'
5870
5880
enabled mipsfpu && (enabled mips32r5 || enabled mips32r6 || enabled mips64r6) && check_inline_asm_flags mipsfpu ' "cvt.d.l $f0, $f1"' ' -mfp64'
5871
- enabled mipsfpu && enabled msa && check_inline_asm_flags msa ' "addvi.b $w0, $w1, 1" ' ' -mmsa ' && check_headers msa.h || disable msa
5881
+
5872
5882
enabled mipsdsp && check_inline_asm_flags mipsdsp ' "addu.qb $t0, $t1, $t2"' ' -mdsp'
5873
5883
enabled mipsdspr2 && check_inline_asm_flags mipsdspr2 ' "absq_s.qb $t0, $t1"' ' -mdspr2'
5874
- enabled msa && enabled msa2 && check_inline_asm_flags msa2 ' "nxbits.any.b $w0, $w0"' ' -mmsa2' && check_headers msa2.h || disable msa2
5884
+
5885
+ # MSA and MSA2 can be detected at runtime so we supply extra flags here
5886
+ enabled mipsfpu && enabled msa && check_inline_asm msa ' "addvi.b $w0, $w1, 1"' ' -mmsa' && append MSAFLAGS ' -mmsa'
5887
+ enabled msa && enabled msa2 && check_inline_asm msa2 ' "nxbits.any.b $w0, $w0"' ' -mmsa2' && append MSAFLAGS ' -mmsa2'
5888
+
5889
+ # loongson2 have no switch cflag so we can only probe toolchain ability
5890
+ enabled loongson2 && check_inline_asm loongson2 ' "dmult.g $8, $9, $10"' && disable loongson3
5891
+
5892
+ # loongson3 is paired with MMI
5893
+ enabled loongson3 && check_inline_asm loongson3 ' "gsldxc1 $f0, 0($2, $3)"' ' -mloongson-ext' && append MMIFLAGS ' -mloongson-ext'
5894
+
5895
+ # MMI can be detected at runtime too
5896
+ enabled mmi && check_inline_asm mmi ' "punpcklhw $f0, $f0, $f0"' ' -mloongson-mmi' && append MMIFLAGS ' -mloongson-mmi'
5875
5897
5876
5898
if enabled bigendian && enabled msa; then
5877
5899
disable msa
@@ -7447,6 +7469,8 @@ LDSOFLAGS=$LDSOFLAGS
7447
7469
SHFLAGS=$( echo $( $ldflags_filter $SHFLAGS ) )
7448
7470
ASMSTRIPFLAGS=$ASMSTRIPFLAGS
7449
7471
X86ASMFLAGS=$X86ASMFLAGS
7472
+ MSAFLAGS=$MSAFLAGS
7473
+ MMIFLAGS=$MMIFLAGS
7450
7474
BUILDSUF=$build_suffix
7451
7475
PROGSSUF=$progs_suffix
7452
7476
FULLNAME=$FULLNAME
0 commit comments