]> git.ipfire.org Git - thirdparty/gcc.git/blob - liboffloadmic/runtime/ofldend.cpp
1e522b7f2fa01136ed75b3173634d7043a21876a
[thirdparty/gcc.git] / liboffloadmic / runtime / ofldend.cpp
1 /*
2 Copyright (c) 2014-2015 Intel Corporation. All Rights Reserved.
3
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
7
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.
16
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.
28 */
29
30
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
38
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
44
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 };
51
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 };
58
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 };
65
66 #ifdef MYO_SUPPORT
67
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
77
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
87
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
99
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
109
110 #endif // MYO_SUPPORT