mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 07:30:43 +03:00
Multiple changes ...
* Use getVoidPtrType helper * Replace #define with constexpr
This commit is contained in:
parent
8ae2634fae
commit
fc4d884d2d
9 changed files with 20 additions and 23 deletions
|
@ -32,7 +32,8 @@
|
|||
# We also want an user-specified LLVM_ROOT_DIR to take precedence over the
|
||||
# system default locations such as /usr/local/bin. Executing find_program()
|
||||
# multiples times is the approach recommended in the docs.
|
||||
set(llvm_config_names llvm-config-17.0 llvm-config170 llvm-config-17
|
||||
set(llvm_config_names llvm-config-18.1 llvm-config181 llvm-config-18
|
||||
llvm-config-17.0 llvm-config170 llvm-config-17
|
||||
llvm-config-16.0 llvm-config160 llvm-config-16
|
||||
llvm-config-15.0 llvm-config150 llvm-config-15
|
||||
llvm-config-14.0 llvm-config140 llvm-config-14
|
||||
|
@ -49,12 +50,12 @@ if(APPLE)
|
|||
# extra fallbacks for MacPorts & Homebrew
|
||||
find_program(LLVM_CONFIG
|
||||
NAMES ${llvm_config_names}
|
||||
PATHS /opt/local/libexec/llvm-17/bin
|
||||
PATHS /opt/local/libexec/llvm-18/bin /opt/local/libexec/llvm-17/bin
|
||||
/opt/local/libexec/llvm-16/bin /opt/local/libexec/llvm-15/bin
|
||||
/opt/local/libexec/llvm-14/bin /opt/local/libexec/llvm-13/bin
|
||||
/opt/local/libexec/llvm-12/bin /opt/local/libexec/llvm-11/bin
|
||||
/opt/local/libexec/llvm/bin
|
||||
/usr/local/opt/llvm@17/bin
|
||||
/usr/local/opt/llvm@18/bin /usr/local/opt/llvm@17/bin
|
||||
/usr/local/opt/llvm@16/bin /usr/local/opt/llvm@15/bin
|
||||
/usr/local/opt/llvm@14/bin /usr/local/opt/llvm@13/bin
|
||||
/usr/local/opt/llvm@12/bin /usr/local/opt/llvm@11/bin
|
||||
|
|
|
@ -115,7 +115,7 @@ void emitLLVMUsedArray(IRState &irs) {
|
|||
return;
|
||||
}
|
||||
|
||||
auto *i8PtrType = LDC_getInt8PtrTy(irs.context());
|
||||
auto *i8PtrType = getVoidPtrType(irs.context());
|
||||
|
||||
// Convert all elements to i8* (the expected type for llvm.used)
|
||||
for (auto &elem : irs.usedArray) {
|
||||
|
|
|
@ -48,9 +48,9 @@
|
|||
using CodeGenFileType = llvm::CodeGenFileType;
|
||||
|
||||
#if LDC_LLVM_VER >= 1800
|
||||
#define CGFT_AssemblyFile CodeGenFileType::AssemblyFile
|
||||
#define CGFT_ObjectFile CodeGenFileType::ObjectFile
|
||||
#define CGFT_Null CodeGenFileType::Null
|
||||
constexpr llvm::CodeGenFileType CGFT_AssemblyFile = CodeGenFileType::AssemblyFile;
|
||||
constexpr llvm::CodeGenFileType CGFT_ObjectFile = CodeGenFileType::ObjectFile;
|
||||
constexpr llvm::CodeGenFileType CGFT_Null = CodeGenFileType::Null;
|
||||
#endif
|
||||
|
||||
#if LDC_LLVM_VER < 1700
|
||||
|
|
|
@ -185,9 +185,8 @@ llvm::GlobalVariable *getTypeDescriptor(IRState &irs, ClassDeclaration *cd) {
|
|||
|
||||
// Declare and initialize the TypeDescriptor.
|
||||
llvm::Constant *Fields[] = {
|
||||
classInfoPtr, // VFPtr
|
||||
llvm::ConstantPointerNull::get(
|
||||
LDC_getInt8PtrTy(gIR->context())), // Runtime data
|
||||
classInfoPtr, // VFPtr
|
||||
llvm::ConstantPointerNull::get(getVoidPtrType()), // Runtime data
|
||||
llvm::ConstantDataArray::getString(gIR->context(), TypeNameString)};
|
||||
llvm::StructType *TypeDescriptorType =
|
||||
getTypeDescriptorType(irs, classInfoPtr, TypeNameString);
|
||||
|
|
|
@ -910,7 +910,7 @@ void CodeGenPGO::emitCounterIncrement(const RootObject *S) const {
|
|||
assert(counter_it != (*RegionCounterMap).end() &&
|
||||
"Statement not found in PGO counter map!");
|
||||
unsigned counter = counter_it->second;
|
||||
auto *I8PtrTy = LDC_getInt8PtrTy(gIR->context());
|
||||
auto *I8PtrTy = getVoidPtrType();
|
||||
gIR->ir->CreateCall(GET_INTRINSIC_DECL(instrprof_increment),
|
||||
{llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy),
|
||||
gIR->ir->getInt64(FunctionHash),
|
||||
|
@ -1118,7 +1118,7 @@ void CodeGenPGO::valueProfile(uint32_t valueKind, llvm::Instruction *valueSite,
|
|||
if (ptrCastNeeded)
|
||||
value = gIR->ir->CreatePtrToInt(value, gIR->ir->getInt64Ty());
|
||||
|
||||
auto *i8PtrTy = LDC_getInt8PtrTy(gIR->context());
|
||||
auto *i8PtrTy = getVoidPtrType();
|
||||
llvm::Value *Args[5] = {
|
||||
llvm::ConstantExpr::getBitCast(FuncNameVar, i8PtrTy),
|
||||
gIR->ir->getInt64(FunctionHash), value, gIR->ir->getInt32(valueKind),
|
||||
|
|
|
@ -271,7 +271,7 @@ static LLType *getPtrToAtomicType(LLType *type) {
|
|||
#if LDC_LLVM_VER < 1800
|
||||
return LLType::getIntNPtrTy(gIR->context(), static_cast<unsigned>(N));
|
||||
#else
|
||||
return llvm::PointerType::get(gIR->context(), static_cast<unsigned>(N));
|
||||
return LLPointerType::getIntNPtrTy(gIR->context(), static_cast<unsigned>(N));
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
|
|
|
@ -738,7 +738,11 @@ LLPointerType *getPtrToType(LLType *t) {
|
|||
}
|
||||
|
||||
LLPointerType *getVoidPtrType() {
|
||||
return LLType::getInt8Ty(gIR->context())->getPointerTo();
|
||||
return getVoidPtrType(gIR->context());
|
||||
}
|
||||
|
||||
LLPointerType *getVoidPtrType(llvm::LLVMContext &C) {
|
||||
return LLType::getInt8Ty(C)->getPointerTo();
|
||||
}
|
||||
|
||||
llvm::ConstantPointerNull *getNullPtr(LLType *t) {
|
||||
|
|
|
@ -152,6 +152,7 @@ LLGlobalVariable *isaGlobalVar(LLValue *v);
|
|||
LLType *getI8Type();
|
||||
LLPointerType *getPtrToType(LLType *t);
|
||||
LLPointerType *getVoidPtrType();
|
||||
LLPointerType *getVoidPtrType(llvm::LLVMContext &C);
|
||||
llvm::ConstantPointerNull *getNullPtr(LLType *t);
|
||||
LLConstant *getNullValue(LLType *t);
|
||||
|
||||
|
@ -218,11 +219,3 @@ void DtoMemCpy(LLType *type, LLValue *dst, LLValue *src, bool withPadding = fals
|
|||
* Generates a call to C memcmp.
|
||||
*/
|
||||
LLValue *DtoMemCmp(LLValue *lhs, LLValue *rhs, LLValue *nbytes);
|
||||
|
||||
inline auto *LDC_getInt8PtrTy(llvm::LLVMContext &C) {
|
||||
#if LDC_LLVM_VER < 1800
|
||||
return llvm::Type::getInt8PtrTy(C);
|
||||
#else
|
||||
return llvm::PointerType::getUnqual(C);
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -663,7 +663,7 @@ TryCatchFinallyScopes::getLandingPadRef(CleanupCursor scope) {
|
|||
|
||||
namespace {
|
||||
llvm::LandingPadInst *createLandingPadInst(IRState &irs) {
|
||||
LLType *retType = LLStructType::get(LDC_getInt8PtrTy(irs.context()),
|
||||
LLType *retType = LLStructType::get(getVoidPtrType(irs.context()),
|
||||
LLType::getInt32Ty(irs.context()));
|
||||
if (!irs.func()->hasLLVMPersonalityFn()) {
|
||||
irs.func()->setLLVMPersonalityFn(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue