diff options
Diffstat (limited to 'gcc/c-family/c-cppbuiltin.c')
-rw-r--r-- | gcc/c-family/c-cppbuiltin.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/gcc/c-family/c-cppbuiltin.c b/gcc/c-family/c-cppbuiltin.c index 3d4587e6db6..2f63feaa3fb 100644 --- a/gcc/c-family/c-cppbuiltin.c +++ b/gcc/c-family/c-cppbuiltin.c @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3. If not see #include "stor-layout.h" #include "flags.h" #include "c-pragma.h" +#include "c-upc-pts.h" #include "output.h" /* For user_label_prefix. */ #include "debug.h" /* For dwarf2out_do_cfi_asm. */ #include "common/common-target.h" @@ -766,6 +767,92 @@ cpp_iec_559_complex_value (void) return ret; } +/* Return the section name with any leading "__DATA," or "__TEXT," removed. + (Darwin adds them to the section name). */ +static const char * +strip_section_prefix (const char *section_name) +{ + const char *name = section_name; + if ((strncmp (name, "__DATA,", 7) == 0) + || (strncmp (name, "__TEXT,", 7) == 0)) + name += 7; + return name; +} + +/* Generate UPC specific pre-defined macros. */ + +static void +upc_cpp_builtins (cpp_reader * pfile) +{ + char def_buf[256]; + cpp_define (pfile, "__UPC__=1"); + cpp_define (pfile, "__GUPC__=1"); + /* Define __GCC_UPC__ for backward compatibility. */ + cpp_define (pfile, "__GCC_UPC__=1"); + cpp_define (pfile, "__UPC_VERSION__=201311L"); + (void) sprintf (def_buf, "UPC_MAX_BLOCK_SIZE=%lu", + (unsigned long) UPC_MAX_BLOCK_SIZE); + cpp_define (pfile, def_buf); + cpp_define (pfile, "__UPC_PTS_STRUCT_REP__=1"); + (void) sprintf (def_buf, "__UPC_VADDR_TYPE__=%s", UPC_PTS_VADDR_TYPE); + cpp_define (pfile, def_buf); + (void) sprintf (def_buf, "__UPC_THREAD_TYPE__=%s", UPC_PTS_THREAD_TYPE); + cpp_define (pfile, def_buf); + (void) sprintf (def_buf, "__UPC_PHASE_TYPE__=%s", UPC_PTS_PHASE_TYPE); + cpp_define (pfile, def_buf); + (void) sprintf (def_buf, "__UPC_PTS_ALIGN__=%d", + (2 * POINTER_SIZE) / BITS_PER_UNIT); + cpp_define (pfile, def_buf); + cpp_define (pfile, "__UPC_VADDR_FIRST__=1"); + (void) sprintf (def_buf, "__UPC_PTS_SIZE__=%d", UPC_PTS_SIZE); + cpp_define (pfile, def_buf); + (void) sprintf (def_buf, "__UPC_VADDR_SIZE__=%d", UPC_PTS_VADDR_SIZE); + cpp_define (pfile, def_buf); + (void) sprintf (def_buf, "__UPC_THREAD_SIZE__=%d", UPC_PTS_THREAD_SIZE); + cpp_define (pfile, def_buf); + (void) sprintf (def_buf, "__UPC_PHASE_SIZE__=%d", UPC_PTS_PHASE_SIZE); + cpp_define (pfile, def_buf); + if (flag_upc_threads) + { + cpp_define (pfile, "__UPC_STATIC_THREADS__=1"); + (void) sprintf (def_buf, "THREADS=%d", flag_upc_threads); + cpp_define (pfile, def_buf); + } + else + { + cpp_define (pfile, "__UPC_DYNAMIC_THREADS__=1"); + } + if (flag_upc_pthreads && (upc_pthreads_model == upc_pthreads_tls_model)) + { + cpp_define (pfile, "__UPC_PTHREADS_MODEL_TLS__=1"); + } + /* If debugging or instrumentation is enabled, + then disable inlining of the runtime. */ + if (flag_upc_debug || flag_upc_instrument) + flag_upc_inline_lib = 0; + /* If -f[no-]upc-inline-lib hasn't been asserted, force inlining of the + runtime library if optimization is enabled. */ + if (flag_upc_inline_lib < 0) + flag_upc_inline_lib = (optimize >= 1); + if (flag_upc_inline_lib) + cpp_define (parse_in, "__UPC_INLINE_LIB__=1"); + /* UPC profiling instrumentation code will be generated. */ + if (flag_upc_instrument) + { + cpp_define (parse_in, "__UPC_PUPC_INST__=1"); + } + if (targetm.upc.link_script_p ()) + { + cpp_define (parse_in, "__UPC_LINK_SCRIPT__=1"); + } + builtin_define_with_value ("__UPC_SHARED_SECTION_NAME__", + strip_section_prefix (targetm.upc.shared_section_name ()), 0); + builtin_define_with_value ("__UPC_PGM_INFO_SECTION_NAME__", + strip_section_prefix (targetm.upc.pgm_info_section_name ()), 0); + builtin_define_with_value ("__UPC_INIT_ARRAY_SECTION_NAME__", + strip_section_prefix (targetm.upc.init_array_section_name ()), 0); +} + /* Hook that registers front end and target-specific built-ins. */ void c_cpp_builtins (cpp_reader *pfile) @@ -1233,6 +1320,10 @@ c_cpp_builtins (cpp_reader *pfile) if (flag_openmp) cpp_define (pfile, "_OPENMP=201511"); + /* Add UPC defines */ + if (flag_upc) + upc_cpp_builtins (pfile); + for (i = 0; i < NUM_INT_N_ENTS; i ++) if (int_n_enabled_p[i]) { |