Skip to content

Commit

Permalink
[CIR][Transforms][TargetLowering][NFC] Add SPIR-V skeleton (#737)
Browse files Browse the repository at this point in the history
This NFC PR adds the SPIR-V `TargetLoweringInfo` with ABI stuff
unimplemented. It's useful for other target-specific information to land
first.
  • Loading branch information
seven-mile authored and lanza committed Nov 3, 2024
1 parent 57a6d37 commit dcb6ec2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ add_clang_library(TargetLowering
TargetInfo.cpp
TargetLoweringInfo.cpp
Targets/AArch64.cpp
Targets/SPIR.cpp
Targets/X86.cpp
Targets/LoweringPrepareAArch64CXXABI.cpp
Targets/LoweringPrepareItaniumCXXABI.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ createTargetLoweringInfo(LowerModule &LM) {
return createX86_64TargetLoweringInfo(LM, X86AVXABILevel::None);
}
}
case llvm::Triple::spirv64:
return createSPIRVTargetLoweringInfo(LM);
default:
llvm_unreachable("ABI NYI");
}
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/CIR/Dialect/Transforms/TargetLowering/TargetInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ std::unique_ptr<TargetLoweringInfo>
createAArch64TargetLoweringInfo(LowerModule &CGM,
::cir::AArch64ABIKind AVXLevel);

std::unique_ptr<TargetLoweringInfo>
createSPIRVTargetLoweringInfo(LowerModule &CGM);

} // namespace cir
} // namespace mlir

Expand Down
54 changes: 54 additions & 0 deletions clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/SPIR.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//===- SPIR.cpp - TargetInfo for SPIR and SPIR-V --------------------------===//
//
// 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 mlir {
namespace cir {

//===----------------------------------------------------------------------===//
// SPIR-V ABI Implementation
//===----------------------------------------------------------------------===//

namespace {

class SPIRVABIInfo : public ABIInfo {
public:
SPIRVABIInfo(LowerTypes &LT) : ABIInfo(LT) {}

private:
void computeInfo(LowerFunctionInfo &FI) const override {
llvm_unreachable("ABI NYI");
}
};

class SPIRVTargetLoweringInfo : public TargetLoweringInfo {
public:
SPIRVTargetLoweringInfo(LowerTypes &LT)
: TargetLoweringInfo(std::make_unique<SPIRVABIInfo>(LT)) {}
};

} // namespace

std::unique_ptr<TargetLoweringInfo>
createSPIRVTargetLoweringInfo(LowerModule &lowerModule) {
return std::make_unique<SPIRVTargetLoweringInfo>(lowerModule.getTypes());
}

} // namespace cir
} // namespace mlir

0 comments on commit dcb6ec2

Please sign in to comment.