-
Notifications
You must be signed in to change notification settings - Fork 797
[SYCL][NativeCPU] Build libclc target-independently. #17408
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
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4efb615
[SYCL][NativeCPU] Build libclc target-independently.
hvdijk 53b96e6
More updates.
hvdijk 8e51a35
Add comments, add check.
hvdijk b4a9128
Also check for -sycl-native-cpu-backend being passed.
hvdijk f23dc50
Check that -Wno-override-module -mllvm -sycl-native-cpu-backend appea…
hvdijk 430802a
Drop redundant native_cpu from dirs.
hvdijk 91cead1
Merge commit 'e4a826be9f4a46f8a6f2bcfa29a0e1ca3c8fd27b' into sycl
hvdijk 1dc268b
Preserve host target args
hvdijk 737de66
Change -target options to --target=.
hvdijk 2407272
Drop unnecessary check for no -sycl-opt after -Wno-override-module.
hvdijk fb0a596
Merge remote-tracking branch 'origin/heads/sycl' into target-independ…
hvdijk 35b4043
[NFC] Adjust comment style, use LangASMap.
hvdijk 14f05be
Merge remote-tracking branch 'origin/heads/sycl' into target-independ…
hvdijk abe8b20
clang-format
hvdijk b18fd5a
Silent conflict with last pulldown: OffloadTargetInfo::isTripleValid(…
hvdijk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
//===--- NativeCPU.cpp - Implement NativeCPU target feature support -------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file implements NativeCPU TargetInfo objects. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "NativeCPU.h" | ||
#include <llvm/TargetParser/Host.h> | ||
|
||
using namespace clang; | ||
using namespace clang::targets; | ||
|
||
static const LangASMap NativeCPUASMap = { | ||
0, // Default | ||
1, // opencl_global | ||
3, // opencl_local | ||
4, // opencl_constant | ||
0, // opencl_private | ||
0, // opencl_generic | ||
1, // opencl_global_device | ||
1, // opencl_global_host | ||
1, // cuda_device | ||
4, // cuda_constant | ||
3, // cuda_shared | ||
1, // sycl_global | ||
1, // sycl_global_device | ||
1, // sycl_global_host | ||
3, // sycl_local | ||
0, // sycl_private | ||
0, // ptr32_sptr | ||
0, // ptr32_uptr | ||
0, // ptr64 | ||
0, // hlsl_groupshared | ||
0, // hlsl_constant | ||
20, // wasm_funcref | ||
}; | ||
|
||
NativeCPUTargetInfo::NativeCPUTargetInfo(const llvm::Triple &, | ||
const TargetOptions &Opts) | ||
: TargetInfo(llvm::Triple()) { | ||
AddrSpaceMap = &NativeCPUASMap; | ||
UseAddrSpaceMapMangling = true; | ||
HasLegalHalfType = true; | ||
HasFloat16 = true; | ||
resetDataLayout("e"); | ||
|
||
llvm::Triple HostTriple([&] { | ||
// Take the default target triple if no other host triple is specified so | ||
// that system headers work. | ||
if (Opts.HostTriple.empty()) | ||
return llvm::sys::getDefaultTargetTriple(); | ||
|
||
return Opts.HostTriple; | ||
}()); | ||
if (HostTriple.getArch() != llvm::Triple::UnknownArch) { | ||
HostTarget = AllocateTarget(HostTriple, Opts); | ||
|
||
// Copy properties from host target. | ||
BoolWidth = HostTarget->getBoolWidth(); | ||
BoolAlign = HostTarget->getBoolAlign(); | ||
IntWidth = HostTarget->getIntWidth(); | ||
IntAlign = HostTarget->getIntAlign(); | ||
HalfWidth = HostTarget->getHalfWidth(); | ||
HalfAlign = HostTarget->getHalfAlign(); | ||
FloatWidth = HostTarget->getFloatWidth(); | ||
FloatAlign = HostTarget->getFloatAlign(); | ||
DoubleWidth = HostTarget->getDoubleWidth(); | ||
DoubleAlign = HostTarget->getDoubleAlign(); | ||
LongWidth = HostTarget->getLongWidth(); | ||
LongAlign = HostTarget->getLongAlign(); | ||
LongLongWidth = HostTarget->getLongLongWidth(); | ||
LongLongAlign = HostTarget->getLongLongAlign(); | ||
PointerWidth = HostTarget->getPointerWidth(LangAS::Default); | ||
PointerAlign = HostTarget->getPointerAlign(LangAS::Default); | ||
MinGlobalAlign = HostTarget->getMinGlobalAlign(/*TypeSize=*/0, | ||
/*HasNonWeakDef=*/true); | ||
NewAlign = HostTarget->getNewAlign(); | ||
DefaultAlignForAttributeAligned = | ||
HostTarget->getDefaultAlignForAttributeAligned(); | ||
SizeType = HostTarget->getSizeType(); | ||
PtrDiffType = HostTarget->getPtrDiffType(LangAS::Default); | ||
IntMaxType = HostTarget->getIntMaxType(); | ||
WCharType = HostTarget->getWCharType(); | ||
WIntType = HostTarget->getWIntType(); | ||
Char16Type = HostTarget->getChar16Type(); | ||
Char32Type = HostTarget->getChar32Type(); | ||
Int64Type = HostTarget->getInt64Type(); | ||
SigAtomicType = HostTarget->getSigAtomicType(); | ||
ProcessIDType = HostTarget->getProcessIDType(); | ||
|
||
UseBitFieldTypeAlignment = HostTarget->useBitFieldTypeAlignment(); | ||
UseZeroLengthBitfieldAlignment = | ||
HostTarget->useZeroLengthBitfieldAlignment(); | ||
UseExplicitBitFieldAlignment = HostTarget->useExplicitBitFieldAlignment(); | ||
ZeroLengthBitfieldBoundary = HostTarget->getZeroLengthBitfieldBoundary(); | ||
|
||
// This is a bit of a lie, but it controls __GCC_ATOMIC_XXX_LOCK_FREE, and | ||
// we need those macros to be identical on host and device, because (among | ||
// other things) they affect which standard library classes are defined, | ||
// and we need all classes to be defined on both the host and device. | ||
MaxAtomicInlineWidth = HostTarget->getMaxAtomicInlineWidth(); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
//===--- NativeCPU.h - Declare NativeCPU target feature support -*- C++ -*-===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// This file declares NativeCPU TargetInfo objects. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_LIB_BASIC_TARGETS_NATIVECPU_H | ||
#define LLVM_CLANG_LIB_BASIC_TARGETS_NATIVECPU_H | ||
|
||
#include "Targets.h" | ||
|
||
namespace clang { | ||
namespace targets { | ||
|
||
class LLVM_LIBRARY_VISIBILITY NativeCPUTargetInfo final : public TargetInfo { | ||
std::unique_ptr<TargetInfo> HostTarget; | ||
|
||
public: | ||
NativeCPUTargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts); | ||
|
||
void getTargetDefines(const LangOptions &Opts, | ||
MacroBuilder &Builder) const override { | ||
DefineStd(Builder, "NativeCPU", Opts); | ||
} | ||
|
||
SmallVector<Builtin::InfosShard> getTargetBuiltins() const override { | ||
return {}; | ||
} | ||
|
||
BuiltinVaListKind getBuiltinVaListKind() const override { | ||
if (HostTarget) | ||
return HostTarget->getBuiltinVaListKind(); | ||
|
||
return TargetInfo::VoidPtrBuiltinVaList; | ||
} | ||
|
||
bool validateAsmConstraint(const char *&Name, | ||
TargetInfo::ConstraintInfo &info) const override { | ||
return true; | ||
} | ||
|
||
std::string_view getClobbers() const override { return ""; } | ||
|
||
void setSupportedOpenCLOpts() override { supportAllOpenCLOpts(); } | ||
|
||
CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { | ||
if (HostTarget) | ||
return HostTarget->checkCallingConvention(CC); | ||
|
||
return TargetInfo::checkCallingConvention(CC); | ||
} | ||
|
||
protected: | ||
ArrayRef<const char *> getGCCRegNames() const override { return {}; } | ||
|
||
ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override { | ||
return {}; | ||
} | ||
|
||
bool hasBitIntType() const override { return true; } | ||
}; | ||
|
||
} // namespace targets | ||
} // namespace clang | ||
|
||
#endif // LLVM_CLANG_LIB_BASIC_TARGETS_NATIVECPU_H |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.