-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files #132252
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
7 commits
Select commit
Hold shift + click to select a range
82f50c1
[NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specif…
jthackray 7097d34
fixup! Rename files
jthackray 279ee64
fixup! Resolve s-barannikov's comments in CGBuiltin.h
jthackray 675dd5f
fixup! Merge in changes from llvm#132060
jthackray 1e1ccdf
fixup! Fix more PR comments
jthackray 4e40ab0
fixup! git mv AArch64.cpp -> ARM.cpp
jthackray 42645ef
fixup! Merge in changes from llvm#132362
jthackray 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
Large diffs are not rendered by default.
Oops, something went wrong.
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,105 @@ | ||
//===------ CGBuiltin.h - Emit LLVM Code for builtins ---------------------===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H | ||
#define LLVM_CLANG_LIB_CODEGEN_CGBUILTIN_H | ||
|
||
#include "CodeGenFunction.h" | ||
|
||
// Many of MSVC builtins are on x64, ARM and AArch64; to avoid repeating code, | ||
// we handle them here. | ||
enum class clang::CodeGen::CodeGenFunction::MSVCIntrin { | ||
_BitScanForward, | ||
_BitScanReverse, | ||
_InterlockedAnd, | ||
_InterlockedCompareExchange, | ||
_InterlockedDecrement, | ||
_InterlockedExchange, | ||
_InterlockedExchangeAdd, | ||
_InterlockedExchangeSub, | ||
_InterlockedIncrement, | ||
_InterlockedOr, | ||
_InterlockedXor, | ||
_InterlockedExchangeAdd_acq, | ||
_InterlockedExchangeAdd_rel, | ||
_InterlockedExchangeAdd_nf, | ||
_InterlockedExchange_acq, | ||
_InterlockedExchange_rel, | ||
_InterlockedExchange_nf, | ||
_InterlockedCompareExchange_acq, | ||
_InterlockedCompareExchange_rel, | ||
_InterlockedCompareExchange_nf, | ||
_InterlockedCompareExchange128, | ||
_InterlockedCompareExchange128_acq, | ||
_InterlockedCompareExchange128_rel, | ||
_InterlockedCompareExchange128_nf, | ||
_InterlockedOr_acq, | ||
_InterlockedOr_rel, | ||
_InterlockedOr_nf, | ||
_InterlockedXor_acq, | ||
_InterlockedXor_rel, | ||
_InterlockedXor_nf, | ||
_InterlockedAnd_acq, | ||
_InterlockedAnd_rel, | ||
_InterlockedAnd_nf, | ||
_InterlockedIncrement_acq, | ||
_InterlockedIncrement_rel, | ||
_InterlockedIncrement_nf, | ||
_InterlockedDecrement_acq, | ||
_InterlockedDecrement_rel, | ||
_InterlockedDecrement_nf, | ||
__fastfail, | ||
}; | ||
|
||
// Emit a simple intrinsic that has N scalar arguments and a return type | ||
// matching the argument type. It is assumed that only the first argument is | ||
// overloaded. | ||
template <unsigned N> | ||
llvm::Value *emitBuiltinWithOneOverloadedType(clang::CodeGen::CodeGenFunction &CGF, | ||
const clang::CallExpr *E, | ||
unsigned IntrinsicID, | ||
llvm::StringRef Name = "") { | ||
static_assert(N, "expect non-empty argument"); | ||
clang::SmallVector<llvm::Value *, N> Args; | ||
for (unsigned I = 0; I < N; ++I) | ||
Args.push_back(CGF.EmitScalarExpr(E->getArg(I))); | ||
llvm::Function *F = CGF.CGM.getIntrinsic(IntrinsicID, Args[0]->getType()); | ||
return CGF.Builder.CreateCall(F, Args, Name); | ||
} | ||
|
||
llvm::Value *emitUnaryMaybeConstrainedFPBuiltin(clang::CodeGen::CodeGenFunction &CGF, | ||
const clang::CallExpr *E, | ||
unsigned IntrinsicID, | ||
unsigned ConstrainedIntrinsicID); | ||
|
||
llvm::Value *EmitToInt(clang::CodeGen::CodeGenFunction &CGF, llvm::Value *V, | ||
clang::QualType T, llvm::IntegerType *IntType); | ||
|
||
llvm::Value *EmitFromInt(clang::CodeGen::CodeGenFunction &CGF, llvm::Value *V, | ||
clang::QualType T, llvm::Type *ResultType); | ||
|
||
clang::CodeGen::Address CheckAtomicAlignment(clang::CodeGen::CodeGenFunction &CGF, | ||
const clang::CallExpr *E); | ||
|
||
llvm::Value *MakeBinaryAtomicValue(clang::CodeGen::CodeGenFunction &CGF, | ||
llvm::AtomicRMWInst::BinOp Kind, | ||
const clang::CallExpr *E, | ||
llvm::AtomicOrdering Ordering = | ||
llvm::AtomicOrdering::SequentiallyConsistent); | ||
|
||
llvm::Value *EmitOverflowIntrinsic(clang::CodeGen::CodeGenFunction &CGF, | ||
const llvm::Intrinsic::ID IntrinsicID, | ||
llvm::Value *X, | ||
llvm::Value *Y, | ||
llvm::Value *&Carry); | ||
|
||
llvm::Value *MakeAtomicCmpXchgValue(clang::CodeGen::CodeGenFunction &CGF, | ||
const clang::CallExpr *E, | ||
bool ReturnBool); | ||
|
||
#endif | ||
jthackray marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
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.