File tree 1 file changed +56
-51
lines changed
src/cmd/internal/obj/arm64
1 file changed +56
-51
lines changed Original file line number Diff line number Diff line change @@ -1902,6 +1902,61 @@ func rclass(r int16) int {
1902
1902
return C_GOK
1903
1903
}
1904
1904
1905
+ // conclass classifies a constant.
1906
+ func conclass (v int64 ) int {
1907
+ if v == 0 {
1908
+ return C_ZCON
1909
+ }
1910
+ if isaddcon (v ) {
1911
+ if v <= 0xFFF {
1912
+ if isbitcon (uint64 (v )) {
1913
+ return C_ABCON0
1914
+ }
1915
+ return C_ADDCON0
1916
+ }
1917
+ if isbitcon (uint64 (v )) {
1918
+ return C_ABCON
1919
+ }
1920
+ if movcon (v ) >= 0 {
1921
+ return C_AMCON
1922
+ }
1923
+ if movcon (^ v ) >= 0 {
1924
+ return C_AMCON
1925
+ }
1926
+ return C_ADDCON
1927
+ }
1928
+
1929
+ t := movcon (v )
1930
+ if t >= 0 {
1931
+ if isbitcon (uint64 (v )) {
1932
+ return C_MBCON
1933
+ }
1934
+ return C_MOVCON
1935
+ }
1936
+
1937
+ t = movcon (^ v )
1938
+ if t >= 0 {
1939
+ if isbitcon (uint64 (v )) {
1940
+ return C_MBCON
1941
+ }
1942
+ return C_MOVCON
1943
+ }
1944
+
1945
+ if isbitcon (uint64 (v )) {
1946
+ return C_BITCON
1947
+ }
1948
+
1949
+ if isaddcon2 (v ) {
1950
+ return C_ADDCON2
1951
+ }
1952
+
1953
+ if uint64 (v ) == uint64 (uint32 (v )) || v == int64 (int32 (v )) {
1954
+ return C_LCON
1955
+ }
1956
+
1957
+ return C_VCON
1958
+ }
1959
+
1905
1960
// con32class reclassifies the constant of 32-bit instruction. Because the constant type is 32-bit,
1906
1961
// but saved in Offset which type is int64, con32class treats it as uint32 type and reclassifies it.
1907
1962
func (c * ctxt7 ) con32class (a * obj.Addr ) int {
@@ -2164,57 +2219,7 @@ func (c *ctxt7) aclass(a *obj.Addr) int {
2164
2219
if a .Reg != 0 && a .Reg != REGZERO {
2165
2220
break
2166
2221
}
2167
- v := c .instoffset
2168
- if v == 0 {
2169
- return C_ZCON
2170
- }
2171
- if isaddcon (v ) {
2172
- if v <= 0xFFF {
2173
- if isbitcon (uint64 (v )) {
2174
- return C_ABCON0
2175
- }
2176
- return C_ADDCON0
2177
- }
2178
- if isbitcon (uint64 (v )) {
2179
- return C_ABCON
2180
- }
2181
- if movcon (v ) >= 0 {
2182
- return C_AMCON
2183
- }
2184
- if movcon (^ v ) >= 0 {
2185
- return C_AMCON
2186
- }
2187
- return C_ADDCON
2188
- }
2189
-
2190
- t := movcon (v )
2191
- if t >= 0 {
2192
- if isbitcon (uint64 (v )) {
2193
- return C_MBCON
2194
- }
2195
- return C_MOVCON
2196
- }
2197
-
2198
- t = movcon (^ v )
2199
- if t >= 0 {
2200
- if isbitcon (uint64 (v )) {
2201
- return C_MBCON
2202
- }
2203
- return C_MOVCON
2204
- }
2205
-
2206
- if isbitcon (uint64 (v )) {
2207
- return C_BITCON
2208
- }
2209
-
2210
- if isaddcon2 (v ) {
2211
- return C_ADDCON2
2212
- }
2213
-
2214
- if uint64 (v ) == uint64 (uint32 (v )) || v == int64 (int32 (v )) {
2215
- return C_LCON
2216
- }
2217
- return C_VCON
2222
+ return conclass (c .instoffset )
2218
2223
2219
2224
case obj .NAME_EXTERN , obj .NAME_STATIC :
2220
2225
if a .Sym == nil {
You can’t perform that action at this time.
0 commit comments