clang 24.0.0git
CIRABIClassifierAMDGPU.cpp
Go to the documentation of this file.
1//===- CIRABIClassifierAMDGPU.cpp - AMDGPU classification -----------------===//
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-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the AMDGPU classifier, which classifies with the LLVM
10// ABI Lowering Library's AMDGPU target.
11//
12//===----------------------------------------------------------------------===//
13
14#include "CIRABIClassifier.h"
15
17
18using namespace mlir;
19using namespace mlir::abi;
20using namespace cir;
21
22namespace {
23
24class AMDGPUABIClassifier final : public CIRABIClassifierCommon {
25public:
26 AMDGPUABIClassifier(const mlir::DataLayout &dl, mlir::ModuleOp modOp)
27 : CIRABIClassifierCommon(dl, modOp) {}
28
29 mlir::FailureOr<ArgClassification>
30 classifyVAArg(cir::VAArgOp vaArg) override {
31 vaArg->emitOpError()
32 << "not yet implemented in CallConvLowering for AMDGPU";
33 return mlir::failure();
34 }
35
36protected:
37 /// AMDGPU has no per-function feature that changes its ABI rules.
38 const llvm::abi::TargetInfo &getTargetInfo(cir::FuncOp) override;
39
40private:
41 std::unique_ptr<llvm::abi::TargetInfo> target;
42};
43
44const llvm::abi::TargetInfo &AMDGPUABIClassifier::getTargetInfo(cir::FuncOp) {
45 if (!target) {
46 // HIP passes a generic pointer kernel argument as a global one.
47 auto langOpts = modOp->getAttrOfType<cir::LoweringOptionsAttr>(
48 cir::CIRDialect::getLoweringOptionsAttrName());
49 target = llvm::abi::createAMDGPUTargetInfo(
50 typeMapper.getTypeBuilder(),
51 /*CoerceGenericPtrArgToGlobal=*/langOpts && langOpts.getHip());
52 }
53 return *target;
54}
55
56} // namespace
57
58std::unique_ptr<CIRABIClassifier>
59cir::createAMDGPUABIClassifier(const mlir::DataLayout &dl,
60 mlir::ModuleOp modOp) {
61 return std::make_unique<AMDGPUABIClassifier>(dl, modOp);
62}
Classifies through the LLVM ABI Lowering Library.
std::unique_ptr< CIRABIClassifier > createAMDGPUABIClassifier(const mlir::DataLayout &dl, mlir::ModuleOp modOp)
The AMDGPU classifier.