Skip to content

[clang][NFC] Remove redundant SPIR/SPIR-V TargetInfo types - #23055

Open
schittir wants to merge 5 commits into
intel:syclfrom
schittir:remove_unnecessary_targets
Open

[clang][NFC] Remove redundant SPIR/SPIR-V TargetInfo types#23055
schittir wants to merge 5 commits into
intel:syclfrom
schittir:remove_unnecessary_targets

Conversation

@schittir

@schittir schittir commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

This patch removes the now redundant six Microsoft SPIR/SPIRV device targets.
Follow-up for #22942 (comment)

The six Microsoft* device targets in SPIR.h differ from their Windows* bases
only in getTargetDefines(): the two x86-32 ones add _M_IX86, the two x86-64
ones add _M_X64/_M_AMD64, and the two AArch64 ones override getTargetDefines()
solely to forward to the base.

Those macros are already predefined from the host target via -aux-triple, so
the device-side copies are redundant.

Requested by Tom Honermann in
intel#22942 (comment)
…Target

With the Microsoft-specific SPIR/SPIR-V TargetInfo types gone, the `default:`
and `case llvm::Triple::MSVC:` labels select the same target, so the four
`switch (HT.getEnvironment())` blocks no longer distinguish anything.
@schittir
schittir requested a review from a team as a code owner August 28, 2026 19:25
@schittir schittir changed the title [clang][NFC] Remove unnecessary targets [clang][NFC] Remove the Microsoft-specific SPIR/SPIR-V TargetInfo types Aug 28, 2026
@schittir schittir changed the title [clang][NFC] Remove the Microsoft-specific SPIR/SPIR-V TargetInfo types [clang][NFC] Remove Microsoft-specific SPIR/SPIR-V TargetInfo types Aug 28, 2026

@tahonermann tahonermann left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but I'm wondering if there is more that can be removed.

Comment on lines 347 to 348
class LLVM_LIBRARY_VISIBILITY WindowsX86_64_SPIR64TargetInfo
: public WindowsTargetInfo<SPIR64TargetInfo> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to retain the Windows variants here? I was expecting them to be removable as well. Perhaps the places where these are still constructed can be replaced with, e.g., WindowsTargetInfo<SPIR64TargetInfo> matching what is done on Linux?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Properly doing this involves a pull down of upstream's host-delegating getBuiltinVaListKind, adding a protected adoptHostPointerTypes() called from the four concrete SPIR/SPIR-V constructors (guarded on matching pointer width, deliberately not from logical SPIRVTargetInfo), and a few more changes to CC_X86VectorCall, moving sse/sse2 into the base etc.

I tried to keep this PR NFC but would it make sense to just go ahead and do these?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the cleaner option from a git history perspective would be to wait for the pulldown to complete and then remove all of the obsolete cases. But I'm not opposed to going in stages either if that is your preference.

Comment thread clang/lib/Basic/Targets/SPIR.h Outdated
Comment on lines 314 to 315

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think all the FPGA related target support can be removed too. Would you mind removing those too?

Curiously, the FPGA targets appear to be named differently in xmain vs intel/llvm. e.g., SPIR64INTELFpgaTargetInfo vs SPIR64FPGATargetInfo.

@schittir schittir Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By all FPGA related target support, do you mean to include the builtins too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you referring to builtin functions? They presumably should be removed and, as far as I know, might have alreyad been removed. @premanandrao would be one to check with.

}
assert(HT.getArch() == llvm::Triple::x86 &&
"Unsupported host architecture");
return std::make_unique<WindowsX86_32SPIRTargetInfo>(Triple, Opts);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per one of my other comments, can this be changed to match what is done for Linux?

Suggested change
return std::make_unique<WindowsX86_32SPIRTargetInfo>(Triple, Opts);
return std::make_unique<WindowsTargetInfo<SPIR32TargetInfo>>(Triple, Opts);

…e host

BaseSPIRTargetInfo already copies LongWidth/LongAlign, DoubleAlign,
LongLongAlign, IntMaxType, Int64Type and WCharType from the host target, and
every MSVC host supplies exactly the values these constructors re-assigned.
Only SizeType/PtrDiffType/IntPtrType are kept, since the base class does not
copy those and the SPIR64/SPIRV64 defaults are wrong for a Windows host.
@tahonermann tahonermann added this to the SYCL 2020 Phase 1 milestone Aug 31, 2026
FPGA support has already been removed from the driver: -fintelfpga and
-fsycl-targets=spir64_fpga are rejected with err_drv_unsupported_opt_removed,
so SPIR64FPGATargetInfo was only reachable through a direct
-cc1 -triple spir64_fpga invocation.

Follow up for intel#22942
@schittir schittir changed the title [clang][NFC] Remove Microsoft-specific SPIR/SPIR-V TargetInfo types [clang][NFC] Remove redundant SPIR/SPIR-V TargetInfo types Aug 31, 2026
Comment on lines -297 to -298
DoubleAlign = LongLongAlign = 64;
WCharType = UnsignedShort;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These removals are dependent on llvm/llvm-project#208196 having been merged via pulldown, aren't they? Likewise for the other Windows... modification cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants