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 std::optional<ArgClassification> classifyVAArg(cir::VAArgOp vaArg) override {
30 vaArg->emitOpError()
31 << "not yet implemented in CallConvLowering for AMDGPU";
32 return std::nullopt;
33 }
34
35protected:
36 /// AMDGPU has no per-function feature that changes its ABI rules.
37 const llvm::abi::TargetInfo &getTargetInfo(cir::FuncOp) override;
38
39private:
40 std::unique_ptr<llvm::abi::TargetInfo> target;
41};
42
43const llvm::abi::TargetInfo &AMDGPUABIClassifier::getTargetInfo(cir::FuncOp) {
44 if (!target) {
45 // HIP passes a generic pointer kernel argument as a global one.
46 auto langOpts = modOp->getAttrOfType<cir::LoweringLangOptionsAttr>(
47 cir::CIRDialect::getLoweringLangOptionsAttrName());
48 target = llvm::abi::createAMDGPUTargetInfo(
49 typeMapper.getTypeBuilder(),
50 /*CoerceGenericPtrArgToGlobal=*/langOpts && langOpts.getHip());
51 }
52 return *target;
53}
54
55} // namespace
56
57std::unique_ptr<CIRABIClassifier>
58cir::createAMDGPUABIClassifier(const mlir::DataLayout &dl,
59 mlir::ModuleOp modOp) {
60 return std::make_unique<AMDGPUABIClassifier>(dl, modOp);
61}
Classifies through the LLVM ABI Lowering Library.
std::unique_ptr< CIRABIClassifier > createAMDGPUABIClassifier(const mlir::DataLayout &dl, mlir::ModuleOp modOp)
The AMDGPU classifier.