[HIP] Add driver input type for HIP

Patch by Greg Rodgers.
Revised by Yaxun Liu.

Differential Revision: https://reviews.llvm.org/D45489

llvm-svn: 330279
This commit is contained in:
Yaxun Liu 2018-04-18 18:25:03 +00:00
parent 192c6ccf6d
commit 9809db703a
3 changed files with 22 additions and 6 deletions

View File

@ -46,6 +46,9 @@ TYPE("cl", CL, PP_C, "cl", "u")
TYPE("cuda-cpp-output", PP_CUDA, INVALID, "cui", "u")
TYPE("cuda", CUDA, PP_CUDA, "cu", "u")
TYPE("cuda", CUDA_DEVICE, PP_CUDA, "cu", "")
TYPE("hip-cpp-output", PP_HIP, INVALID, "cui", "u")
TYPE("hip", HIP, PP_HIP, "cu", "u")
TYPE("hip", HIP_DEVICE, PP_HIP, "cu", "")
TYPE("objective-c-cpp-output", PP_ObjC, INVALID, "mi", "u")
TYPE("objc-cpp-output", PP_ObjC_Alias, INVALID, "mi", "u")
TYPE("objective-c", ObjC, PP_ObjC, "m", "u")

View File

@ -2257,9 +2257,10 @@ class OffloadingActionBuilder final {
assert(!GpuArchList.empty() &&
"We should have at least one GPU architecture.");
// If the host input is not CUDA, we don't need to bother about this
// input.
if (IA->getType() != types::TY_CUDA) {
// If the host input is not CUDA or HIP, we don't need to bother about
// this input.
if (IA->getType() != types::TY_CUDA &&
IA->getType() != types::TY_HIP) {
// The builder will ignore this input.
IsActive = false;
return ABRT_Inactive;
@ -2272,9 +2273,12 @@ class OffloadingActionBuilder final {
return ABRT_Success;
// Replicate inputs for each GPU architecture.
for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I)
CudaDeviceActions.push_back(C.MakeAction<InputAction>(
IA->getInputArg(), types::TY_CUDA_DEVICE));
auto Ty = IA->getType() == types::TY_HIP ? types::TY_HIP_DEVICE
: types::TY_CUDA_DEVICE;
for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
CudaDeviceActions.push_back(
C.MakeAction<InputAction>(IA->getInputArg(), Ty));
}
return ABRT_Success;
}

View File

@ -102,6 +102,9 @@ bool types::isAcceptedByClang(ID Id) {
case TY_CL:
case TY_CUDA: case TY_PP_CUDA:
case TY_CUDA_DEVICE:
case TY_HIP:
case TY_PP_HIP:
case TY_HIP_DEVICE:
case TY_ObjC: case TY_PP_ObjC: case TY_PP_ObjC_Alias:
case TY_CXX: case TY_PP_CXX:
case TY_ObjCXX: case TY_PP_ObjCXX: case TY_PP_ObjCXX_Alias:
@ -141,6 +144,9 @@ bool types::isCXX(ID Id) {
case TY_ObjCXXHeader: case TY_PP_ObjCXXHeader:
case TY_CXXModule: case TY_PP_CXXModule:
case TY_CUDA: case TY_PP_CUDA: case TY_CUDA_DEVICE:
case TY_HIP:
case TY_PP_HIP:
case TY_HIP_DEVICE:
return true;
}
}
@ -166,6 +172,9 @@ bool types::isCuda(ID Id) {
case TY_CUDA:
case TY_PP_CUDA:
case TY_CUDA_DEVICE:
case TY_HIP:
case TY_PP_HIP:
case TY_HIP_DEVICE:
return true;
}
}