1# SPDX-License-Identifier: Apache-2.0 2 3set(riscv_mabi "lp") 4set(riscv_march "rv") 5 6if(CONFIG_64BIT) 7 string(CONCAT riscv_mabi ${riscv_mabi} "64") 8 string(CONCAT riscv_march ${riscv_march} "64") 9 list(APPEND TOOLCHAIN_C_FLAGS -mcmodel=medany) 10 list(APPEND TOOLCHAIN_LD_FLAGS -mcmodel=medany) 11else() 12 string(CONCAT riscv_mabi "i" ${riscv_mabi} "32") 13 string(CONCAT riscv_march ${riscv_march} "32") 14endif() 15 16if (CONFIG_RISCV_ISA_RV32E) 17 string(CONCAT riscv_mabi ${riscv_mabi} "e") 18 string(CONCAT riscv_march ${riscv_march} "e") 19else() 20 string(CONCAT riscv_march ${riscv_march} "i") 21endif() 22 23if (CONFIG_RISCV_ISA_EXT_M) 24 string(CONCAT riscv_march ${riscv_march} "m") 25endif() 26if (CONFIG_RISCV_ISA_EXT_A) 27 string(CONCAT riscv_march ${riscv_march} "a") 28endif() 29 30if(CONFIG_FPU) 31 if(CONFIG_CPU_HAS_FPU_DOUBLE_PRECISION) 32 if(CONFIG_FLOAT_HARD) 33 string(CONCAT riscv_mabi ${riscv_mabi} "d") 34 endif() 35 string(CONCAT riscv_march ${riscv_march} "fd") 36 else() 37 if(CONFIG_FLOAT_HARD) 38 string(CONCAT riscv_mabi ${riscv_mabi} "f") 39 endif() 40 string(CONCAT riscv_march ${riscv_march} "f") 41 endif() 42endif() 43 44if(CONFIG_RISCV_ISA_EXT_C) 45 string(CONCAT riscv_march ${riscv_march} "c") 46endif() 47 48if(CONFIG_RISCV_ISA_EXT_ZICSR) 49 string(CONCAT riscv_march ${riscv_march} "_zicsr") 50endif() 51 52if(CONFIG_RISCV_ISA_EXT_ZIFENCEI) 53 string(CONCAT riscv_march ${riscv_march} "_zifencei") 54endif() 55 56if(CONFIG_RISCV_ISA_EXT_ZBA) 57 string(CONCAT riscv_march ${riscv_march} "_zba") 58endif() 59 60if(CONFIG_RISCV_ISA_EXT_ZBB) 61 string(CONCAT riscv_march ${riscv_march} "_zbb") 62endif() 63 64if(CONFIG_RISCV_ISA_EXT_ZBC) 65 string(CONCAT riscv_march ${riscv_march} "_zbc") 66endif() 67 68if(CONFIG_RISCV_ISA_EXT_ZBS) 69 string(CONCAT riscv_march ${riscv_march} "_zbs") 70endif() 71 72list(APPEND TOOLCHAIN_C_FLAGS -mabi=${riscv_mabi} -march=${riscv_march}) 73list(APPEND TOOLCHAIN_LD_FLAGS NO_SPLIT -mabi=${riscv_mabi} -march=${riscv_march}) 74