]>
Commit | Line | Data |
---|---|---|
5fd1486c PJ |
1 | /* segment.c -- Builtins for HSAIL segment related instructions. |
2 | ||
3 | Copyright (C) 2015-2016 Free Software Foundation, Inc. | |
4 | Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com> | |
5 | for General Processor Tech. | |
6 | ||
7 | Permission is hereby granted, free of charge, to any person obtaining a | |
8 | copy of this software and associated documentation files | |
9 | (the "Software"), to deal in the Software without restriction, including | |
10 | without limitation the rights to use, copy, modify, merge, publish, | |
11 | distribute, sublicense, and/or sell copies of the Software, and to | |
12 | permit persons to whom the Software is furnished to do so, subject to | |
13 | the following conditions: | |
14 | ||
15 | The above copyright notice and this permission notice shall be included | |
16 | in all copies or substantial portions of the Software. | |
17 | ||
18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | |
19 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | |
20 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | |
21 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | |
22 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | |
23 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | |
24 | USE OR OTHER DEALINGS IN THE SOFTWARE. | |
25 | */ | |
26 | ||
27 | #include "workitems.h" | |
28 | ||
29 | uint32_t | |
30 | __hsail_segmentp_private (uint64_t flat_addr, PHSAWorkItem *wi) | |
31 | { | |
32 | if (flat_addr == 0) | |
33 | return 1; | |
34 | else | |
35 | return (void *) flat_addr >= wi->wg->private_base_ptr | |
36 | && (void *) flat_addr | |
37 | < wi->wg->private_base_ptr + wi->wg->private_segment_total_size; | |
38 | } | |
39 | ||
40 | uint32_t | |
41 | __hsail_segmentp_group (uint64_t flat_addr, PHSAWorkItem *wi) | |
42 | { | |
43 | if (flat_addr == 0) | |
44 | return 1; | |
45 | else | |
46 | return (void *) flat_addr >= wi->wg->group_base_ptr | |
47 | && (void *) flat_addr < wi->wg->group_base_ptr | |
48 | + wi->launch_data->dp->group_segment_size; | |
49 | } | |
50 | ||
51 | uint32_t | |
52 | __hsail_segmentp_global (uint64_t flat_addr, PHSAWorkItem *wi) | |
53 | { | |
54 | return (flat_addr == 0 | |
55 | || (!__hsail_segmentp_private (flat_addr, wi) | |
56 | && !__hsail_segmentp_group (flat_addr, wi))); | |
57 | } |