| @@ -1902,6 +1902,127 @@ static void asm_floating_point_reg_arm_reg_transfer_opcode_tail(TCCState *s1, in · 1901 unmodified lines |
| 1902 | 1902 | } |
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | +static void asm_floating_point_vcvt_data_processing_opcode(TCCState *s1, int token) { |
| 1906 | + uint8_t coprocessor = 0; |
| 1907 | + Operand ops[3]; |
| 1908 | + uint8_t opcode1 = 11; |
| 1909 | + uint8_t opcode2 = 2; |
| 1910 | + |
| 1911 | + switch (ARM_INSTRUCTION_GROUP(token)) { |
| 1912 | + case TOK_ASM_vcvtreq_s32_f64: |
| 1913 | + case TOK_ASM_vcvtreq_u32_f64: |
| 1914 | + case TOK_ASM_vcvteq_s32_f64: |
| 1915 | + case TOK_ASM_vcvteq_u32_f64: |
| 1916 | + case TOK_ASM_vcvteq_f64_s32: |
| 1917 | + case TOK_ASM_vcvteq_f64_u32: |
| 1918 | + case TOK_ASM_vcvteq_f32_f64: |
| 1919 | + coprocessor = CP_DOUBLE_PRECISION_FLOAT; |
| 1920 | + break; |
| 1921 | + case TOK_ASM_vcvtreq_s32_f32: |
| 1922 | + case TOK_ASM_vcvtreq_u32_f32: |
| 1923 | + case TOK_ASM_vcvteq_s32_f32: |
| 1924 | + case TOK_ASM_vcvteq_u32_f32: |
| 1925 | + case TOK_ASM_vcvteq_f32_s32: |
| 1926 | + case TOK_ASM_vcvteq_f32_u32: |
| 1927 | + case TOK_ASM_vcvteq_f64_f32: |
| 1928 | + coprocessor = CP_SINGLE_PRECISION_FLOAT; |
| 1929 | + break; |
| 1930 | + default: |
| 1931 | + tcc_error("Unknown coprocessor for instruction '%s'", get_tok_str(token, NULL)); |
| 1932 | + return; |
| 1933 | + } |
| 1934 | + |
| 1935 | + parse_operand(s1, &ops[0]); |
| 1936 | + ops[1].type = OP_IM8; |
| 1937 | + ops[1].e.v = 8; |
| 1938 | + /* floating-point -> integer */ |
| 1939 | + switch (ARM_INSTRUCTION_GROUP(token)) { |
| 1940 | + case TOK_ASM_vcvtreq_s32_f32: |
| 1941 | + case TOK_ASM_vcvtreq_s32_f64: |
| 1942 | + case TOK_ASM_vcvteq_s32_f32: |
| 1943 | + case TOK_ASM_vcvteq_s32_f64: |
| 1944 | + ops[1].e.v |= 1; // signed |
| 1945 | + /* fall through */ |
| 1946 | + case TOK_ASM_vcvteq_u32_f32: |
| 1947 | + case TOK_ASM_vcvteq_u32_f64: |
| 1948 | + case TOK_ASM_vcvtreq_u32_f32: |
| 1949 | + case TOK_ASM_vcvtreq_u32_f64: |
| 1950 | + ops[1].e.v |= 4; // to_integer (opc2) |
| 1951 | + break; |
| 1952 | + /* floating-point size conversion */ |
| 1953 | + case TOK_ASM_vcvteq_f64_f32: |
| 1954 | + case TOK_ASM_vcvteq_f32_f64: |
| 1955 | + ops[1].e.v = 7; |
| 1956 | + break; |
| 1957 | + } |
| 1958 | + |
| 1959 | + if (tok == ',') |
| 1960 | + next(); |
| 1961 | + else |
| 1962 | + expect("','"); |
| 1963 | + parse_operand(s1, &ops[2]); |
| 1964 | + |
| 1965 | + switch (ARM_INSTRUCTION_GROUP(token)) { |
| 1966 | + /* floating-point -> integer */ |
| 1967 | + case TOK_ASM_vcvteq_s32_f32: |
| 1968 | + case TOK_ASM_vcvteq_s32_f64: |
| 1969 | + case TOK_ASM_vcvteq_u32_f32: |
| 1970 | + case TOK_ASM_vcvteq_u32_f64: |
| 1971 | + opcode2 |= 4; // round_zero |
| 1972 | + break; |
| 1973 | + |
| 1974 | + /* integer -> floating-point */ |
| 1975 | + case TOK_ASM_vcvteq_f64_s32: |
| 1976 | + case TOK_ASM_vcvteq_f32_s32: |
| 1977 | + opcode2 |= 4; // signed--special |
| 1978 | + break; |
| 1979 | + |
| 1980 | + /* floating-point size conversion */ |
| 1981 | + case TOK_ASM_vcvteq_f64_f32: |
| 1982 | + case TOK_ASM_vcvteq_f32_f64: |
| 1983 | + opcode2 |= 4; // always set |
| 1984 | + break; |
| 1985 | + } |
| 1986 | + |
| 1987 | + switch (ARM_INSTRUCTION_GROUP(token)) { |
| 1988 | + case TOK_ASM_vcvteq_f64_u32: |
| 1989 | + case TOK_ASM_vcvteq_f64_s32: |
| 1990 | + case TOK_ASM_vcvteq_f64_f32: |
| 1991 | + if (ops[0].type == OP_VREG64 && ops[2].type == OP_VREG32) { |
| 1992 | + } else { |
| 1993 | + expect("d<number>, s<number>"); |
| 1994 | + return; |
| 1995 | + } |
| 1996 | + break; |
| 1997 | + default: |
| 1998 | + if (coprocessor == CP_SINGLE_PRECISION_FLOAT) { |
| 1999 | + if (ops[0].type == OP_VREG32 && ops[2].type == OP_VREG32) { |
| 2000 | + } else { |
| 2001 | + expect("s<number>, s<number>"); |
| 2002 | + return; |
| 2003 | + } |
| 2004 | + } else if (coprocessor == CP_DOUBLE_PRECISION_FLOAT) { |
| 2005 | + if (ops[0].type == OP_VREG32 && ops[2].type == OP_VREG64) { |
| 2006 | + } else { |
| 2007 | + expect("s<number>, d<number>"); |
| 2008 | + return; |
| 2009 | + } |
| 2010 | + } |
| 2011 | + } |
| 2012 | + |
| 2013 | + if (ops[2].type == OP_VREG32) { |
| 2014 | + if (ops[2].reg & 1) |
| 2015 | + opcode2 |= 1; |
| 2016 | + ops[2].reg >>= 1; |
| 2017 | + } |
| 2018 | + if (ops[0].type == OP_VREG32) { |
| 2019 | + if (ops[0].reg & 1) |
| 2020 | + opcode1 |= 4; |
| 2021 | + ops[0].reg >>= 1; |
| 2022 | + } |
| 2023 | + asm_emit_coprocessor_opcode(condition_code_of_token(token), coprocessor, opcode1, ops[0].reg, (ops[1].type == OP_IM8) ? ops[1].e.v : ops[1].reg, (ops[2].type == OP_IM8) ? ops[2].e.v : ops[2].reg, opcode2, 0); |
| 2024 | +} |
| 2025 | + |
| 1905 | 2026 | static void asm_floating_point_data_processing_opcode(TCCState *s1, int token) { |
| 1906 | 2027 | uint8_t coprocessor = CP_SINGLE_PRECISION_FLOAT; |
| 1907 | 2028 | uint8_t opcode1 = 0; |
| @@ -1920,8 +2041,6 @@ static void asm_floating_point_data_processing_opcode(TCCState *s1, int token) { · 12 unmodified lines |
| 1920 | 2041 | VFMA 1?10 ?0? Must be unconditional |
| 1921 | 2042 | VFMS 1?10 ?1? Must be unconditional |
| 1922 | 2043 | |
| 1923 | | − VCVT* |
| 1924 | | − |
| 1925 | 2044 | VMOV Fd, Fm |
| 1926 | 2045 | VMOV Sn, Sm, Rd, Rn |
| 1927 | 2046 | VMOV Rd, Rn, Sn, Sm |
| @@ -2092,7 +2211,6 @@ static void asm_floating_point_data_processing_opcode(TCCState *s1, int token) { · 164 unmodified lines |
| 2092 | 2211 | ops[1].e.v = 0; |
| 2093 | 2212 | } |
| 2094 | 2213 | break; |
| 2095 | | − // TODO: vcvt; vcvtr |
| 2096 | 2214 | default: |
| 2097 | 2215 | expect("known floating point instruction"); |
| 2098 | 2216 | return; |
| @@ -2580,6 +2698,23 @@ ST_FUNC void asm_opcode(TCCState *s1, int token) · 481 unmodified lines |
| 2580 | 2698 | asm_floating_point_data_processing_opcode(s1, token); |
| 2581 | 2699 | return; |
| 2582 | 2700 | |
| 2701 | + case TOK_ASM_vcvtreq_s32_f32: |
| 2702 | + case TOK_ASM_vcvtreq_s32_f64: |
| 2703 | + case TOK_ASM_vcvteq_s32_f32: |
| 2704 | + case TOK_ASM_vcvteq_s32_f64: |
| 2705 | + case TOK_ASM_vcvtreq_u32_f32: |
| 2706 | + case TOK_ASM_vcvtreq_u32_f64: |
| 2707 | + case TOK_ASM_vcvteq_u32_f32: |
| 2708 | + case TOK_ASM_vcvteq_u32_f64: |
| 2709 | + case TOK_ASM_vcvteq_f64_s32: |
| 2710 | + case TOK_ASM_vcvteq_f32_s32: |
| 2711 | + case TOK_ASM_vcvteq_f64_u32: |
| 2712 | + case TOK_ASM_vcvteq_f32_u32: |
| 2713 | + case TOK_ASM_vcvteq_f64_f32: |
| 2714 | + case TOK_ASM_vcvteq_f32_f64: |
| 2715 | + asm_floating_point_vcvt_data_processing_opcode(s1, token); |
| 2716 | + return; |
| 2717 | + |
| 2583 | 2718 | case TOK_ASM_vpusheq: |
| 2584 | 2719 | case TOK_ASM_vpopeq: |
| 2585 | 2720 | case TOK_ASM_vldmeq: |