PR 68115/libfortran
[official-gcc.git] / liboffloadmic / runtime / ofldend.cpp
blob1e522b7f2fa01136ed75b3173634d7043a21876a
1 /*
2 Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #if HOST_LIBRARY
32 #include "offload_table.h"
33 #include "offload_myo_host.h"
34 #else
35 #include "offload_target.h"
36 #include "offload_myo_target.h"
37 #endif
39 #ifdef TARGET_WINNT
40 #define ALLOCATE(name) __declspec(allocate(name))
41 #else // TARGET_WINNT
42 #define ALLOCATE(name) __attribute__((section(name)))
43 #endif // TARGET_WINNT
45 // offload entry table
46 ALLOCATE(OFFLOAD_ENTRY_TABLE_SECTION_END)
47 #ifdef TARGET_WINNT
48 __declspec(align(sizeof(FuncTable::Entry)))
49 #endif // TARGET_WINNT
50 static FuncTable::Entry __offload_entry_table_end = { (const char*)-1 };
52 // offload function table
53 ALLOCATE(OFFLOAD_FUNC_TABLE_SECTION_END)
54 #ifdef TARGET_WINNT
55 __declspec(align(sizeof(FuncTable::Entry)))
56 #endif // TARGET_WINNT
57 static FuncTable::Entry __offload_func_table_end = { (const char*)-1 };
59 // data table
60 ALLOCATE(OFFLOAD_VAR_TABLE_SECTION_END)
61 #ifdef TARGET_WINNT
62 __declspec(align(sizeof(VarTable::Entry)))
63 #endif // TARGET_WINNT
64 static VarTable::Entry __offload_var_table_end = { (const char*)-1 };
66 #ifdef MYO_SUPPORT
68 // offload myo shared var section epilog
69 ALLOCATE(OFFLOAD_MYO_SHARED_TABLE_SECTION_END)
70 #ifdef TARGET_WINNT
71 __declspec(align(sizeof(SharedTableEntry)))
72 static MYOVarTable::Entry __offload_myo_shared_var_end =
73 { (const char*)-1, 0 };
74 #else // TARGET_WINNT
75 static MYOVarTable::Entry __offload_myo_shared_var_end = { 0 };
76 #endif // TARGET_WINNT
78 // offload myo shared vtable section epilog
79 ALLOCATE(OFFLOAD_MYO_SHARED_VTABLE_SECTION_END)
80 #ifdef TARGET_WINNT
81 __declspec(align(sizeof(SharedTableEntry)))
82 static MYOVarTable::Entry __offload_myo_shared_vtable_end =
83 { (const char*)-1, 0 };
84 #else // TARGET_WINNT
85 static MYOVarTable::Entry __offload_myo_shared_vtable_end = { 0 };
86 #endif // TARGET_WINNT
88 //#if HOST_LIBRARY
89 // offload myo shared var init section epilog
90 ALLOCATE(OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_END)
91 #ifdef TARGET_WINNT
92 __declspec(align(sizeof(InitTableEntry)))
93 static MYOInitTable::Entry __offload_myo_init_table_end =
94 { (const char*)-1, 0 };
95 #else // TARGET_WINNT
96 static MYOInitTable::Entry __offload_myo_init_table_end = { 0 };
97 #endif // TARGET_WINNT
98 //#endif // HOST_LIBRARY
100 // offload myo fptr section epilog
101 ALLOCATE(OFFLOAD_MYO_FPTR_TABLE_SECTION_END)
102 #ifdef TARGET_WINNT
103 __declspec(align(sizeof(FptrTableEntry)))
104 static MYOFuncTable::Entry __offload_myo_fptr_table_end =
105 { (const char*)-1, 0, 0 };
106 #else // TARGET_WINNT
107 static MYOFuncTable::Entry __offload_myo_fptr_table_end = { 0 };
108 #endif // TARGET_WINNT
110 #endif // MYO_SUPPORT