Skip to content

[SYCL] Enable programs that include system headers on Windows #325

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
Jul 31, 2019

Conversation

mibintc
Copy link

@mibintc mibintc commented Jul 16, 2019

Add Windows-specific predefined type characteristics for wchar, builtin
VaListKind, and a temporary workaround for the vectorcall attribute
which is seen in the Microsoft headers.
We'll allow vectorcall to appear on function declarations, since they
occur in the Microsoft headers, but we won't allow or will ignore
vectorcall on function invocations from SYCL target. (The handling for
vectorcall is a work in progress.) Add Windows support for SPIR target.

Signed-off-by: Melanie Blower [email protected]

@mibintc
Copy link
Author

mibintc commented Jul 16, 2019

The previous version of this patch is here, #284

@v-klochkov
Copy link
Contributor

Melanie, please re-base this patch, it conflicts with changes from #324

@mibintc mibintc force-pushed the wintypes1 branch 2 times, most recently from 6f2216b to f6b9572 Compare July 22, 2019 19:48
v-klochkov
v-klochkov previously approved these changes Jul 22, 2019
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

It's not clear from the commit log message what problem this patch solves.
Could you elaborate on that, please?

@@ -56,9 +56,12 @@ static const unsigned SYCLAddrSpaceMap[] = {
};

class LLVM_LIBRARY_VISIBILITY SPIRTargetInfo : public TargetInfo {
private:
bool IsWindowsSYCL;
Copy link
Contributor

Choose a reason for hiding this comment

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

Typically just inheriting from this type for a WindowsSPIRTargetInfo would be the way to do this.

@@ -141,8 +152,15 @@ class LLVM_LIBRARY_VISIBILITY SPIR64TargetInfo : public SPIRTargetInfo {
SPIR64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
: SPIRTargetInfo(Triple, Opts) {
PointerWidth = PointerAlign = 64;
SizeType = TargetInfo::UnsignedLong;
PtrDiffType = IntPtrType = TargetInfo::SignedLong;
SizeType = TargetInfo::UnsignedLongLong;
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this break Linux stuff? This seems like it'll mess up a bunch of types.

Copy link
Author

Choose a reason for hiding this comment

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

Yes this needs to be fixed, thanks @erichkeane

Copy link
Contributor

Choose a reason for hiding this comment

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

I think size type must be defined by the host triple, not SPIR.
So I think, we shoudn't modify SPIR target at all.

CmdArgs.push_back(Args.MakeArgString("-fms-compatibility-version=" +
MSVT.getAsString()));
else {
const char *LowestMSVCSupported =
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this 2 lines?

Copy link
Author

Choose a reason for hiding this comment

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

because clang-format

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I mean, why is LowestMSVCSupported a separate variable instead of just being a constant in the line below?

Copy link
Author

Choose a reason for hiding this comment

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

I thought it was nicer this way, self documenting and all

Add Windows-specific predefined type characteristics for wchar, builtin
VaListKind, and allow the vectorcall attribute on function declarations.
Add Windows support for SPIR target.

Signed-off-by: Melanie Blower <[email protected]>
Copy link
Contributor

@v-klochkov v-klochkov left a comment

Choose a reason for hiding this comment

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

Looks good to me. Thank you for re-working the patch, fixing triple to unknown-unknown, and for signing&squashing the commit.

@mibintc mibintc deleted the wintypes1 branch August 20, 2019 19:19
asudarsa added a commit that referenced this pull request May 3, 2024
…ows for SPIRV32 and SPIRV64 targets (#13548)

This is text from OpenCL SPIR Spec 2.0
(https://registry.khronos.org/SPIR/specs/spir_spec-2.0.pdf)
The OpenCL size_t, ptrdiff_t,uintptr_t, intptr_t, atomic_size_t,
atomic_ptrdiff_t, atomic_uintptr_t and atomic_intptr_t data types are
mapped to LLVM i32 when the device address width is equal to 32 bits and
to LLVM i64 when the device address width is equal 64 bits.
After some analysis though, I see that the windows os based
customizations made for the SPIR target
(#325) are necessary for successful
compilation on windows.
Also, they do not seem to be violating the spec. It's just that 'long'
and 'long long' mean different things on windows and linux. On 64-bit
linux, long type has 8 bytes, but on 64-bit windows, long type has 4
bytes.
Hence, I have extended the SPIR target changes to the SPIR-V target as
well. This PR extends those changes for SPIRV32 and SPIRV64 targets and added
appropriate tests as well.
We would eventually want to submit this (and PR #325) upstream. 

Thanks

---------

Signed-off-by: Arvind Sudarsanam <[email protected]>
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.

5 participants