Skip to content
Open
Show file tree
Hide file tree
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
70 changes: 22 additions & 48 deletions clang/lib/Basic/Targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -705,13 +705,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
llvm::Triple HT(Opts.HostTriple);
switch (HT.getOS()) {
case llvm::Triple::Win32:
switch (HT.getEnvironment()) {
default: // Assume MSVC for unknown environments
case llvm::Triple::MSVC:
assert(HT.getArch() == llvm::Triple::x86 &&
"Unsupported host architecture");
return std::make_unique<MicrosoftX86_32SPIRTargetInfo>(Triple, Opts);
}
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);

case llvm::Triple::Linux:
return std::make_unique<LinuxTargetInfo<SPIR32TargetInfo>>(Triple, Opts);
default:
Expand All @@ -721,32 +717,20 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,

case llvm::Triple::spir64: {
llvm::Triple HT(Opts.HostTriple);
bool IsFPGASubArch = Triple.getSubArch() == llvm::Triple::SPIRSubArch_fpga;

switch (HT.getOS()) {
case llvm::Triple::Win32:
switch (HT.getEnvironment()) {
default: // Assume MSVC for unknown environments
case llvm::Triple::MSVC:
switch (HT.getArch()) {
case llvm::Triple::aarch64:
return std::make_unique<MicrosoftARM64_SPIR64TargetInfo>(Triple,
Opts);
case llvm::Triple::x86_64:
return std::make_unique<MicrosoftX86_64_SPIR64TargetInfo>(Triple,
Opts);
default:
llvm::report_fatal_error(
"Unsupported host architecture (not x86_64 or aarch64)");
}
switch (HT.getArch()) {
case llvm::Triple::aarch64:
return std::make_unique<WindowsARM64_SPIR64TargetInfo>(Triple, Opts);
case llvm::Triple::x86_64:
return std::make_unique<WindowsX86_64_SPIR64TargetInfo>(Triple, Opts);
default:
llvm::report_fatal_error(
"Unsupported host architecture (not x86_64 or aarch64)");
}
case llvm::Triple::Linux:
if (IsFPGASubArch)
return std::make_unique<LinuxTargetInfo<SPIR64FPGATargetInfo>>(Triple, Opts);
return std::make_unique<LinuxTargetInfo<SPIR64TargetInfo>>(Triple, Opts);
default:
if (IsFPGASubArch)
return std::make_unique<SPIR64FPGATargetInfo>(Triple, Opts);
return std::make_unique<SPIR64TargetInfo>(Triple, Opts);
}
}
Expand All @@ -761,13 +745,9 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
llvm::Triple HT(Opts.HostTriple);
switch (HT.getOS()) {
case llvm::Triple::Win32:
switch (HT.getEnvironment()) {
default: // Assume MSVC for unknown environments
case llvm::Triple::MSVC:
assert(HT.getArch() == llvm::Triple::x86 &&
"Unsupported host architecture");
return std::make_unique<MicrosoftX86_32SPIRV32TargetInfo>(Triple, Opts);
}
assert(HT.getArch() == llvm::Triple::x86 &&
"Unsupported host architecture");
return std::make_unique<WindowsX86_32SPIRV32TargetInfo>(Triple, Opts);
default:
return std::make_unique<SPIRV32TargetInfo>(Triple, Opts);
}
Expand All @@ -784,20 +764,14 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
llvm::Triple HT(Opts.HostTriple);
switch (HT.getOS()) {
case llvm::Triple::Win32:
switch (HT.getEnvironment()) {
default: // Assume MSVC for unknown environments
case llvm::Triple::MSVC:
switch (HT.getArch()) {
case llvm::Triple::aarch64:
return std::make_unique<MicrosoftARM64_SPIRV64TargetInfo>(Triple,
Opts);
case llvm::Triple::x86_64:
return std::make_unique<MicrosoftX86_64_SPIRV64TargetInfo>(Triple,
Opts);
default:
llvm::report_fatal_error(
"Unsupported host architecture (not x86_64 or aarch64)");
}
switch (HT.getArch()) {
case llvm::Triple::aarch64:
return std::make_unique<WindowsARM64_SPIRV64TargetInfo>(Triple, Opts);
case llvm::Triple::x86_64:
return std::make_unique<WindowsX86_64_SPIRV64TargetInfo>(Triple, Opts);
default:
llvm::report_fatal_error(
"Unsupported host architecture (not x86_64 or aarch64)");
}
default:
return std::make_unique<SPIRV64TargetInfo>(Triple, Opts);
Expand Down
137 changes: 2 additions & 135 deletions clang/lib/Basic/Targets/SPIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,24 +279,13 @@ class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo {
MacroBuilder &Builder) const override;
};

// spir64_fpga target
class LLVM_LIBRARY_VISIBILITY SPIR64FPGATargetInfo : public SPIR64TargetInfo {
public:
SPIR64FPGATargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: SPIR64TargetInfo(Triple, Opts) {}
virtual size_t getMaxBitIntWidth() const override { return 4096; }
};

// x86-32 SPIR Windows target
class LLVM_LIBRARY_VISIBILITY WindowsX86_32SPIRTargetInfo
: public WindowsTargetInfo<SPIR32TargetInfo> {
public:
WindowsX86_32SPIRTargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsTargetInfo<SPIR32TargetInfo>(Triple, Opts) {
DoubleAlign = LongLongAlign = 64;
WCharType = UnsignedShort;
Comment on lines -297 to -298

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.

}
: WindowsTargetInfo<SPIR32TargetInfo>(Triple, Opts) {}

BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
Expand All @@ -311,41 +300,16 @@ class LLVM_LIBRARY_VISIBILITY WindowsX86_32SPIRTargetInfo
}
};

// x86-32 SPIR Windows Visual Studio target
class LLVM_LIBRARY_VISIBILITY MicrosoftX86_32SPIRTargetInfo
: public WindowsX86_32SPIRTargetInfo {
public:
MicrosoftX86_32SPIRTargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsX86_32SPIRTargetInfo(Triple, Opts) {
}

void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsX86_32SPIRTargetInfo::getTargetDefines(Opts, Builder);
// The value of the following reflects processor type.
// 300=386, 400=486, 500=Pentium, 600=Blend (default)
// We lost the original triple, so we use the default.
// TBD should we keep these lines? Copied from X86.h.
Builder.defineMacro("_M_IX86", "600");
}
};

// x86-64 SPIR64 Windows target
class LLVM_LIBRARY_VISIBILITY WindowsX86_64_SPIR64TargetInfo
: public WindowsTargetInfo<SPIR64TargetInfo> {
Comment on lines 304 to 305

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.

public:
WindowsX86_64_SPIR64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsTargetInfo<SPIR64TargetInfo>(Triple, Opts) {
LongWidth = LongAlign = 32;
DoubleAlign = LongLongAlign = 64;
IntMaxType = SignedLongLong;
Int64Type = SignedLongLong;
SizeType = UnsignedLongLong;
PtrDiffType = SignedLongLong;
IntPtrType = SignedLongLong;
WCharType = UnsignedShort;
}

BuiltinVaListKind getBuiltinVaListKind() const override {
Expand All @@ -368,38 +332,16 @@ class LLVM_LIBRARY_VISIBILITY WindowsX86_64_SPIR64TargetInfo
const std::vector<std::string> &FeaturesVec) const override;
};

// x86-64 SPIR64 Windows Visual Studio target
class LLVM_LIBRARY_VISIBILITY MicrosoftX86_64_SPIR64TargetInfo
: public WindowsX86_64_SPIR64TargetInfo {
public:
MicrosoftX86_64_SPIR64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsX86_64_SPIR64TargetInfo(Triple, Opts) {
}

void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsX86_64_SPIR64TargetInfo::getTargetDefines(Opts, Builder);
Builder.defineMacro("_M_X64", "100");
Builder.defineMacro("_M_AMD64", "100");
}
};

// ARM64 SPIR64 Windows target
class LLVM_LIBRARY_VISIBILITY WindowsARM64_SPIR64TargetInfo
: public WindowsTargetInfo<SPIR64TargetInfo> {
public:
WindowsARM64_SPIR64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsTargetInfo<SPIR64TargetInfo>(Triple, Opts) {
LongWidth = LongAlign = 32;
DoubleAlign = LongLongAlign = 64;
IntMaxType = SignedLongLong;
Int64Type = SignedLongLong;
SizeType = UnsignedLongLong;
PtrDiffType = SignedLongLong;
IntPtrType = SignedLongLong;
WCharType = UnsignedShort;
}

BuiltinVaListKind getBuiltinVaListKind() const override {
Expand All @@ -412,20 +354,6 @@ class LLVM_LIBRARY_VISIBILITY WindowsARM64_SPIR64TargetInfo
}
};

// ARM64 SPIR64 Windows Visual Studio target
class LLVM_LIBRARY_VISIBILITY MicrosoftARM64_SPIR64TargetInfo
: public WindowsARM64_SPIR64TargetInfo {
public:
MicrosoftARM64_SPIR64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsARM64_SPIR64TargetInfo(Triple, Opts) {}

void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsARM64_SPIR64TargetInfo::getTargetDefines(Opts, Builder);
}
};

class LLVM_LIBRARY_VISIBILITY BaseSPIRVTargetInfo : public BaseSPIRTargetInfo {
public:
BaseSPIRVTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Expand Down Expand Up @@ -566,10 +494,7 @@ class LLVM_LIBRARY_VISIBILITY WindowsX86_32SPIRV32TargetInfo
public:
WindowsX86_32SPIRV32TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsTargetInfo<SPIRV32TargetInfo>(Triple, Opts) {
DoubleAlign = LongLongAlign = 64;
WCharType = UnsignedShort;
}
: WindowsTargetInfo<SPIRV32TargetInfo>(Triple, Opts) {}

BuiltinVaListKind getBuiltinVaListKind() const override {
return TargetInfo::CharPtrBuiltinVaList;
Expand All @@ -584,39 +509,16 @@ class LLVM_LIBRARY_VISIBILITY WindowsX86_32SPIRV32TargetInfo
}
};

// x86-32 SPIRV32 Windows Visual Studio target
class LLVM_LIBRARY_VISIBILITY MicrosoftX86_32SPIRV32TargetInfo
: public WindowsX86_32SPIRV32TargetInfo {
public:
MicrosoftX86_32SPIRV32TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsX86_32SPIRV32TargetInfo(Triple, Opts) {}

void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsX86_32SPIRV32TargetInfo::getTargetDefines(Opts, Builder);
// The value of the following reflects processor type.
// 300=386, 400=486, 500=Pentium, 600=Blend (default)
// We lost the original triple, so we use the default.
Builder.defineMacro("_M_IX86", "600");
}
};

// x86-64 SPIRV64 Windows target
class LLVM_LIBRARY_VISIBILITY WindowsX86_64_SPIRV64TargetInfo
: public WindowsTargetInfo<SPIRV64TargetInfo> {
public:
WindowsX86_64_SPIRV64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsTargetInfo<SPIRV64TargetInfo>(Triple, Opts) {
LongWidth = LongAlign = 32;
DoubleAlign = LongLongAlign = 64;
IntMaxType = SignedLongLong;
Int64Type = SignedLongLong;
SizeType = UnsignedLongLong;
PtrDiffType = SignedLongLong;
IntPtrType = SignedLongLong;
WCharType = UnsignedShort;
}

BuiltinVaListKind getBuiltinVaListKind() const override {
Expand All @@ -634,37 +536,16 @@ class LLVM_LIBRARY_VISIBILITY WindowsX86_64_SPIRV64TargetInfo
}
};

// x86-64 SPIRV64 Windows Visual Studio target
class LLVM_LIBRARY_VISIBILITY MicrosoftX86_64_SPIRV64TargetInfo
: public WindowsX86_64_SPIRV64TargetInfo {
public:
MicrosoftX86_64_SPIRV64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsX86_64_SPIRV64TargetInfo(Triple, Opts) {}

void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsX86_64_SPIRV64TargetInfo::getTargetDefines(Opts, Builder);
Builder.defineMacro("_M_X64", "100");
Builder.defineMacro("_M_AMD64", "100");
}
};

// ARM64 SPIRV64 Windows target
class LLVM_LIBRARY_VISIBILITY WindowsARM64_SPIRV64TargetInfo
: public WindowsTargetInfo<SPIRV64TargetInfo> {
public:
WindowsARM64_SPIRV64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsTargetInfo<SPIRV64TargetInfo>(Triple, Opts) {
LongWidth = LongAlign = 32;
DoubleAlign = LongLongAlign = 64;
IntMaxType = SignedLongLong;
Int64Type = SignedLongLong;
SizeType = UnsignedLongLong;
PtrDiffType = SignedLongLong;
IntPtrType = SignedLongLong;
WCharType = UnsignedShort;
}

BuiltinVaListKind getBuiltinVaListKind() const override {
Expand All @@ -677,20 +558,6 @@ class LLVM_LIBRARY_VISIBILITY WindowsARM64_SPIRV64TargetInfo
}
};

// ARM64 SPIRV64 Windows Visual Studio target
class LLVM_LIBRARY_VISIBILITY MicrosoftARM64_SPIRV64TargetInfo
: public WindowsARM64_SPIRV64TargetInfo {
public:
MicrosoftARM64_SPIRV64TargetInfo(const llvm::Triple &Triple,
const TargetOptions &Opts)
: WindowsARM64_SPIRV64TargetInfo(Triple, Opts) {}

void getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const override {
WindowsARM64_SPIRV64TargetInfo::getTargetDefines(Opts, Builder);
}
};

class LLVM_LIBRARY_VISIBILITY SPIRV64AMDGCNTargetInfo final
: public BaseSPIRVTargetInfo {
public:
Expand Down
24 changes: 0 additions & 24 deletions clang/test/CodeGenSYCL/sycl-host-intelfpga-bitint.cpp

This file was deleted.

31 changes: 0 additions & 31 deletions clang/test/CodeGenSYCL/sycl-intelfpga-bitint.cpp

This file was deleted.

Loading
Loading