-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CIR][CUDA] Skeleton of NVPTX target lowering info (#1358)
Added a skeleton of NVPTX target lowering info. This enables lowering of `simple.cu` (as it hardly tests device side functionalities), so a test of LLVM IR is also added onto it.
- Loading branch information
Showing
5 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/NVPTX.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//===- NVPTX.cpp - TargetInfo for NVPTX -----------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "ABIInfoImpl.h" | ||
#include "LowerFunctionInfo.h" | ||
#include "LowerTypes.h" | ||
#include "TargetInfo.h" | ||
#include "TargetLoweringInfo.h" | ||
#include "clang/CIR/ABIArgInfo.h" | ||
#include "clang/CIR/MissingFeatures.h" | ||
#include "llvm/Support/ErrorHandling.h" | ||
|
||
using ABIArgInfo = cir::ABIArgInfo; | ||
using MissingFeature = cir::MissingFeatures; | ||
|
||
namespace cir { | ||
|
||
//===----------------------------------------------------------------------===// | ||
// NVPTX ABI Implementation | ||
//===----------------------------------------------------------------------===// | ||
|
||
namespace { | ||
|
||
class NVPTXABIInfo : public ABIInfo { | ||
public: | ||
NVPTXABIInfo(LowerTypes <) : ABIInfo(lt) {} | ||
|
||
private: | ||
void computeInfo(LowerFunctionInfo &fi) const override { | ||
llvm_unreachable("NYI"); | ||
} | ||
}; | ||
|
||
class NVPTXTargetLoweringInfo : public TargetLoweringInfo { | ||
public: | ||
NVPTXTargetLoweringInfo(LowerTypes <) | ||
: TargetLoweringInfo(std::make_unique<NVPTXABIInfo>(lt)) {} | ||
|
||
unsigned getTargetAddrSpaceFromCIRAddrSpace( | ||
cir::AddressSpaceAttr addressSpaceAttr) const override { | ||
using Kind = cir::AddressSpaceAttr::Kind; | ||
switch (addressSpaceAttr.getValue()) { | ||
case Kind::offload_private: | ||
return 0; | ||
case Kind::offload_local: | ||
return 3; | ||
case Kind::offload_global: | ||
return 1; | ||
case Kind::offload_constant: | ||
return 2; | ||
case Kind::offload_generic: | ||
return 4; | ||
default: | ||
cir_cconv_unreachable("Unknown CIR address space for this target"); | ||
} | ||
} | ||
}; | ||
|
||
} // namespace | ||
|
||
std::unique_ptr<TargetLoweringInfo> | ||
createNVPTXTargetLoweringInfo(LowerModule &lowerModule) { | ||
return std::make_unique<NVPTXTargetLoweringInfo>(lowerModule.getTypes()); | ||
} | ||
|
||
} // namespace cir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters