[K/N] LLVM: Add missing opaque pointer API
LLVMConstGEP2 and LLVMConstInBoundsGEP2 were forward declared in LLVM-11, but not implemented until LLVM-14. This patch adds these along with the missing LLVMAddAlias2. All three implementations are copied from llvm branch release/14.x
This commit is contained in:
committed by
Space Cloud
parent
61f825fbd4
commit
c1f72de6e5
@@ -1,9 +1,9 @@
|
||||
headers = llvm-c/Core.h llvm-c/Target.h llvm-c/Analysis.h llvm-c/BitWriter.h \
|
||||
llvm-c/BitReader.h llvm-c/Transforms/PassManagerBuilder.h llvm-c/Transforms/IPO.h \
|
||||
llvm-c/TargetMachine.h llvm-c/Target.h llvm-c/Linker.h llvm-c/Initialization.h \
|
||||
llvm-c/DebugInfo.h DebugInfoC.h CoverageMappingC.h CAPIExtensions.h RemoveRedundantSafepoints.h
|
||||
llvm-c/DebugInfo.h DebugInfoC.h CoverageMappingC.h CAPIExtensions.h RemoveRedundantSafepoints.h OpaquePointerAPI.h
|
||||
|
||||
headerFilter = llvm-c/* llvm-c/**/* DebugInfoC.h CoverageMappingC.h CAPIExtensions.h RemoveRedundantSafepoints.h
|
||||
headerFilter = llvm-c/* llvm-c/**/* DebugInfoC.h CoverageMappingC.h CAPIExtensions.h RemoveRedundantSafepoints.h OpaquePointerAPI.h
|
||||
|
||||
compilerOpts = -std=c99 \
|
||||
-Wall -W -Wno-unused-parameter -Wwrite-strings -Wmissing-field-initializers \
|
||||
@@ -81,7 +81,7 @@ excludedFunctions.mingw = LLVMDumpType
|
||||
excludedFunctions = LLVMInitializeAllAsmParsers LLVMInitializeAllAsmPrinters LLVMInitializeAllDisassemblers \
|
||||
LLVMInitializeAllTargetInfos LLVMInitializeAllTargetMCs LLVMInitializeAllTargets LLVMInitializeNativeTarget \
|
||||
LLVMInitializeNativeAsmParser LLVMInitializeNativeAsmPrinter LLVMInitializeNativeDisassembler \
|
||||
LLVMConstInBoundsGEP2 LLVMConstGEP2 LLVMIntPtrType LLVMIntPtrTypeForAS LLVMGetMDKindID LLVMInt1Type LLVMInt8Type \
|
||||
LLVMIntPtrType LLVMIntPtrTypeForAS LLVMGetMDKindID LLVMInt1Type LLVMInt8Type \
|
||||
LLVMInt16Type LLVMInt32Type LLVMInt64Type LLVMInt128Type LLVMIntType LLVMHalfType LLVMFloatType LLVMDoubleType \
|
||||
LLVMX86FP80Type LLVMFP128Type LLVMPPCFP128Type LLVMX86MMXType LLVMStructType LLVMVoidType LLVMLabelType \
|
||||
LLVMMDString LLVMMDNode LLVMConstString LLVMConstStruct LLVMAppendBasicBlock LLVMInsertBasicBlock LLVMCreateBuilder \
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "OpaquePointerAPI.h"
|
||||
|
||||
#include <llvm/IR/IntrinsicInst.h>
|
||||
#include <llvm/IR/Module.h>
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
/* These are the opaque pointer functions that are missing in llvm-11, which
|
||||
must be removed upon upgrading LLVM version.
|
||||
|
||||
Copied from llvm release/14.x.
|
||||
*/
|
||||
|
||||
LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy,
|
||||
unsigned AddrSpace, LLVMValueRef Aliasee,
|
||||
const char *Name) {
|
||||
return wrap(GlobalAlias::create(unwrap(ValueTy), AddrSpace,
|
||||
GlobalValue::ExternalLinkage, Name,
|
||||
unwrap<Constant>(Aliasee), unwrap(M)));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
|
||||
LLVMValueRef *ConstantIndices, unsigned NumIndices) {
|
||||
ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
|
||||
NumIndices);
|
||||
Constant *Val = unwrap<Constant>(ConstantVal);
|
||||
return wrap(ConstantExpr::getGetElementPtr(unwrap(Ty), Val, IdxList));
|
||||
}
|
||||
|
||||
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
|
||||
LLVMValueRef *ConstantIndices,
|
||||
unsigned NumIndices) {
|
||||
ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
|
||||
NumIndices);
|
||||
Constant *Val = unwrap<Constant>(ConstantVal);
|
||||
return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
#ifndef LIBLLVMEXT_OPAQUE_POINTER_API_H
|
||||
#define LIBLLVMEXT_OPAQUE_POINTER_API_H
|
||||
|
||||
#include <llvm-c/Core.h>
|
||||
#include <llvm-c/Target.h>
|
||||
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
/* These are the opaque pointer functions that are missing in llvm-11, which
|
||||
must be removed upon upgrading LLVM version.
|
||||
|
||||
Copied from llvm release/14.x.
|
||||
*/
|
||||
|
||||
// LLVMConstGEP2 and LLVMConstInBoundsGEP2 are already forward declared in Core.h
|
||||
LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
|
||||
LLVMValueRef *ConstantIndices, unsigned NumIndices);
|
||||
|
||||
LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
|
||||
LLVMValueRef *ConstantIndices,
|
||||
unsigned NumIndices);
|
||||
|
||||
LLVMValueRef LLVMAddAlias2(LLVMModuleRef M, LLVMTypeRef ValueTy,
|
||||
unsigned AddrSpace, LLVMValueRef Aliasee,
|
||||
const char *Name);
|
||||
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
#endif // LIBLLVMEXT_OPAQUE_POINTER_API_H
|
||||
|
||||
Reference in New Issue
Block a user