]> git.ipfire.org Git - thirdparty/gcc.git/blob - liboffloadmic/runtime/ofldend.cpp
0256c5a0f2099b4b68529b19d2c31e110f61bd29
[thirdparty/gcc.git] / liboffloadmic / runtime / ofldend.cpp
1 /*
2 Copyright (c) 2014 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_host.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 SharedTableEntry __offload_myo_shared_table_end = { (const char*)-1, 0 };
73 #else // TARGET_WINNT
74 static SharedTableEntry __offload_myo_shared_table_end = { 0 };
75 #endif // TARGET_WINNT
76
77 #if HOST_LIBRARY
78 // offload myo shared var init section epilog
79 ALLOCATE(OFFLOAD_MYO_SHARED_INIT_TABLE_SECTION_END)
80 #ifdef TARGET_WINNT
81 __declspec(align(sizeof(InitTableEntry)))
82 static InitTableEntry __offload_myo_shared_init_table_end = { (const char*)-1, 0 };
83 #else // TARGET_WINNT
84 static InitTableEntry __offload_myo_shared_init_table_end = { 0 };
85 #endif // TARGET_WINNT
86 #endif // HOST_LIBRARY
87
88 // offload myo fptr section epilog
89 ALLOCATE(OFFLOAD_MYO_FPTR_TABLE_SECTION_END)
90 #ifdef TARGET_WINNT
91 __declspec(align(sizeof(FptrTableEntry)))
92 static FptrTableEntry __offload_myo_fptr_table_end = { (const char*)-1, 0, 0 };
93 #else // TARGET_WINNT
94 static FptrTableEntry __offload_myo_fptr_table_end = { 0 };
95 #endif // TARGET_WINNT
96
97 #endif // MYO_SUPPORT