Skip to content

[SPIRV] Get pointer size from datalayout #66096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 4 additions & 18 deletions llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,14 @@ static bool isAtLeastVer(uint32_t Target, uint32_t VerToCompareTo) {
return Target == 0 || Target >= VerToCompareTo;
}

static unsigned computePointerSize(const Triple &TT) {
const auto Arch = TT.getArch();
// TODO: unify this with pointers legalization.
assert(TT.isSPIRV());

if (Arch == Triple::spirv64)
return 64;

// TODO: this probably needs to be revisited:
// AFAIU Logical SPIR-V has no pointer size. So falling-back on ID size.
// Addressing mode can change how some pointers are handled
// (PhysicalStorageBuffer64).
return 32;
}

SPIRVSubtarget::SPIRVSubtarget(const Triple &TT, const std::string &CPU,
const std::string &FS,
const SPIRVTargetMachine &TM)
: SPIRVGenSubtargetInfo(TT, CPU, /*TuneCPU=*/CPU, FS),
PointerSize(computePointerSize(TT)), SPIRVVersion(0), OpenCLVersion(0),
InstrInfo(), FrameLowering(initSubtargetDependencies(CPU, FS)),
TLInfo(TM, *this), TargetTriple(TT) {
PointerSize(TM.getPointerSizeInBits(/* AS= */ 0)), SPIRVVersion(0),
OpenCLVersion(0), InstrInfo(),
FrameLowering(initSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
TargetTriple(TT) {
// The order of initialization is important.
initAvailableExtensions();
initAvailableExtInstSets();
Expand Down