riscv-c.c revision 1.1.1.2
1/* RISC-V-specific code for C family languages. 2 Copyright (C) 2011-2018 Free Software Foundation, Inc. 3 Contributed by Andrew Waterman (andrew@sifive.com). 4 5This file is part of GCC. 6 7GCC is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 3, or (at your option) 10any later version. 11 12GCC is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with GCC; see the file COPYING3. If not see 19<http://www.gnu.org/licenses/>. */ 20 21#define IN_TARGET_CODE 1 22 23#include "config.h" 24#include "system.h" 25#include "coretypes.h" 26#include "tm.h" 27#include "c-family/c-common.h" 28#include "cpplib.h" 29 30#define builtin_define(TXT) cpp_define (pfile, TXT) 31 32/* Implement TARGET_CPU_CPP_BUILTINS. */ 33 34void 35riscv_cpu_cpp_builtins (cpp_reader *pfile) 36{ 37 builtin_define ("__riscv"); 38 39 if (TARGET_RVC) 40 builtin_define ("__riscv_compressed"); 41 42 if (TARGET_ATOMIC) 43 builtin_define ("__riscv_atomic"); 44 45 if (TARGET_MUL) 46 builtin_define ("__riscv_mul"); 47 if (TARGET_DIV) 48 builtin_define ("__riscv_div"); 49 if (TARGET_DIV && TARGET_MUL) 50 builtin_define ("__riscv_muldiv"); 51 52 builtin_define_with_int_value ("__riscv_xlen", UNITS_PER_WORD * 8); 53 if (TARGET_HARD_FLOAT) 54 builtin_define_with_int_value ("__riscv_flen", UNITS_PER_FP_REG * 8); 55 56 if (TARGET_HARD_FLOAT && TARGET_FDIV) 57 { 58 builtin_define ("__riscv_fdiv"); 59 builtin_define ("__riscv_fsqrt"); 60 } 61 62 switch (riscv_abi) 63 { 64 case ABI_ILP32: 65 case ABI_LP64: 66 builtin_define ("__riscv_float_abi_soft"); 67 break; 68 69 case ABI_ILP32F: 70 case ABI_LP64F: 71 builtin_define ("__riscv_float_abi_single"); 72 break; 73 74 case ABI_ILP32D: 75 case ABI_LP64D: 76 builtin_define ("__riscv_float_abi_double"); 77 break; 78 } 79 80 switch (riscv_cmodel) 81 { 82 case CM_MEDLOW: 83 builtin_define ("__riscv_cmodel_medlow"); 84 break; 85 86 case CM_MEDANY: 87 builtin_define ("__riscv_cmodel_medany"); 88 break; 89 90 case CM_PIC: 91 builtin_define ("__riscv_cmodel_pic"); 92 break; 93 } 94} 95