25 lines · plain
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#include <clc/workitem/clc_get_global_offset.h>10 11#if __clang_major__ >= 812#define CONST_AS __constant13#elif __clang_major__ >= 714#define CONST_AS __attribute__((address_space(4)))15#else16#define CONST_AS __attribute__((address_space(2)))17#endif18 19_CLC_DEF _CLC_OVERLOAD size_t __clc_get_global_offset(uint dim) {20 CONST_AS uint *ptr = (CONST_AS uint *)__builtin_amdgcn_implicitarg_ptr();21 if (dim < 3)22 return ptr[dim + 1];23 return 0;24}25