LLVM: Remove unused from llvm/bindings.zig and zig_llvm.h/.cpp
This commit is contained in:
624
src/zig_llvm.cpp
624
src/zig_llvm.cpp
@@ -24,9 +24,7 @@
|
||||
#include <llvm/Analysis/TargetLibraryInfo.h>
|
||||
#include <llvm/Analysis/TargetTransformInfo.h>
|
||||
#include <llvm/Bitcode/BitcodeWriter.h>
|
||||
#include <llvm/IR/DIBuilder.h>
|
||||
#include <llvm/IR/DiagnosticInfo.h>
|
||||
#include <llvm/IR/IRBuilder.h>
|
||||
#include <llvm/IR/InlineAsm.h>
|
||||
#include <llvm/IR/Instructions.h>
|
||||
#include <llvm/IR/LegacyPassManager.h>
|
||||
@@ -382,566 +380,10 @@ void ZigLLVMSetOptBisectLimit(LLVMContextRef context_ref, int limit) {
|
||||
unwrap(context_ref)->setOptPassGate(opt_bisect);
|
||||
}
|
||||
|
||||
LLVMValueRef ZigLLVMAddFunctionInAddressSpace(LLVMModuleRef M, const char *Name, LLVMTypeRef FunctionTy, unsigned AddressSpace) {
|
||||
Function* func = Function::Create(unwrap<FunctionType>(FunctionTy), GlobalValue::ExternalLinkage, AddressSpace, Name, unwrap(M));
|
||||
return wrap(func);
|
||||
}
|
||||
|
||||
void ZigLLVMSetTailCallKind(LLVMValueRef Call, enum ZigLLVMTailCallKind TailCallKind) {
|
||||
CallInst::TailCallKind TCK;
|
||||
switch (TailCallKind) {
|
||||
case ZigLLVMTailCallKindNone:
|
||||
TCK = CallInst::TCK_None;
|
||||
break;
|
||||
case ZigLLVMTailCallKindTail:
|
||||
TCK = CallInst::TCK_Tail;
|
||||
break;
|
||||
case ZigLLVMTailCallKindMustTail:
|
||||
TCK = CallInst::TCK_MustTail;
|
||||
break;
|
||||
case ZigLLVMTailCallKindNoTail:
|
||||
TCK = CallInst::TCK_NoTail;
|
||||
break;
|
||||
}
|
||||
unwrap<CallInst>(Call)->setTailCallKind(TCK);
|
||||
}
|
||||
|
||||
void ZigLLVMFnSetSubprogram(LLVMValueRef fn, ZigLLVMDISubprogram *subprogram) {
|
||||
assert( isa<Function>(unwrap(fn)) );
|
||||
Function *unwrapped_function = reinterpret_cast<Function*>(unwrap(fn));
|
||||
unwrapped_function->setSubprogram(reinterpret_cast<DISubprogram*>(subprogram));
|
||||
}
|
||||
|
||||
|
||||
ZigLLVMDIType *ZigLLVMCreateDebugPointerType(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIType *pointee_type,
|
||||
uint64_t size_in_bits, uint64_t align_in_bits, const char *name)
|
||||
{
|
||||
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createPointerType(
|
||||
reinterpret_cast<DIType*>(pointee_type), size_in_bits, align_in_bits, std::optional<unsigned>(), name);
|
||||
return reinterpret_cast<ZigLLVMDIType*>(di_type);
|
||||
}
|
||||
|
||||
ZigLLVMDIType *ZigLLVMCreateDebugBasicType(ZigLLVMDIBuilder *dibuilder, const char *name,
|
||||
uint64_t size_in_bits, unsigned encoding)
|
||||
{
|
||||
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createBasicType(
|
||||
name, size_in_bits, encoding);
|
||||
return reinterpret_cast<ZigLLVMDIType*>(di_type);
|
||||
}
|
||||
|
||||
struct ZigLLVMDIType *ZigLLVMDIBuilderCreateVectorType(struct ZigLLVMDIBuilder *dibuilder,
|
||||
uint64_t SizeInBits, uint32_t AlignInBits, struct ZigLLVMDIType *Ty, uint32_t elem_count)
|
||||
{
|
||||
SmallVector<Metadata *, 1> subrange;
|
||||
subrange.push_back(reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateSubrange(0, elem_count));
|
||||
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createVectorType(
|
||||
SizeInBits,
|
||||
AlignInBits,
|
||||
reinterpret_cast<DIType*>(Ty),
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateArray(subrange));
|
||||
return reinterpret_cast<ZigLLVMDIType*>(di_type);
|
||||
}
|
||||
|
||||
ZigLLVMDIType *ZigLLVMCreateDebugArrayType(ZigLLVMDIBuilder *dibuilder, uint64_t size_in_bits,
|
||||
uint64_t align_in_bits, ZigLLVMDIType *elem_type, int64_t elem_count)
|
||||
{
|
||||
SmallVector<Metadata *, 1> subrange;
|
||||
subrange.push_back(reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateSubrange(0, elem_count));
|
||||
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createArrayType(
|
||||
size_in_bits, align_in_bits,
|
||||
reinterpret_cast<DIType*>(elem_type),
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateArray(subrange));
|
||||
return reinterpret_cast<ZigLLVMDIType*>(di_type);
|
||||
}
|
||||
|
||||
ZigLLVMDIEnumerator *ZigLLVMCreateDebugEnumerator(ZigLLVMDIBuilder *dibuilder, const char *name, uint64_t val, bool isUnsigned) {
|
||||
DIEnumerator *di_enumerator = reinterpret_cast<DIBuilder*>(dibuilder)->createEnumerator(name, val, isUnsigned);
|
||||
return reinterpret_cast<ZigLLVMDIEnumerator*>(di_enumerator);
|
||||
}
|
||||
|
||||
ZigLLVMDIEnumerator *ZigLLVMCreateDebugEnumeratorOfArbitraryPrecision(ZigLLVMDIBuilder *dibuilder,
|
||||
const char *name, unsigned NumWords, const uint64_t Words[], unsigned int bits, bool isUnsigned)
|
||||
{
|
||||
DIEnumerator *di_enumerator = reinterpret_cast<DIBuilder*>(dibuilder)->createEnumerator(name,
|
||||
APSInt(APInt(bits, ArrayRef(Words, NumWords)), isUnsigned));
|
||||
return reinterpret_cast<ZigLLVMDIEnumerator*>(di_enumerator);
|
||||
}
|
||||
|
||||
ZigLLVMDIType *ZigLLVMCreateDebugEnumerationType(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIScope *scope,
|
||||
const char *name, ZigLLVMDIFile *file, unsigned line_number, uint64_t size_in_bits,
|
||||
uint64_t align_in_bits, ZigLLVMDIEnumerator **enumerator_array, int enumerator_array_len,
|
||||
ZigLLVMDIType *underlying_type, const char *unique_id)
|
||||
{
|
||||
SmallVector<Metadata *, 8> fields;
|
||||
for (int i = 0; i < enumerator_array_len; i += 1) {
|
||||
DIEnumerator *dienumerator = reinterpret_cast<DIEnumerator*>(enumerator_array[i]);
|
||||
fields.push_back(dienumerator);
|
||||
}
|
||||
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createEnumerationType(
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
name,
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
line_number, size_in_bits, align_in_bits,
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateArray(fields),
|
||||
reinterpret_cast<DIType*>(underlying_type),
|
||||
unique_id);
|
||||
return reinterpret_cast<ZigLLVMDIType*>(di_type);
|
||||
}
|
||||
|
||||
ZigLLVMDIType *ZigLLVMCreateDebugMemberType(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIScope *scope,
|
||||
const char *name, ZigLLVMDIFile *file, unsigned line, uint64_t size_in_bits,
|
||||
uint64_t align_in_bits, uint64_t offset_in_bits, unsigned flags, ZigLLVMDIType *type)
|
||||
{
|
||||
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createMemberType(
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
name,
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
line, size_in_bits, align_in_bits, offset_in_bits,
|
||||
static_cast<DINode::DIFlags>(flags),
|
||||
reinterpret_cast<DIType*>(type));
|
||||
return reinterpret_cast<ZigLLVMDIType*>(di_type);
|
||||
}
|
||||
|
||||
ZigLLVMDIType *ZigLLVMCreateDebugUnionType(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIScope *scope,
|
||||
const char *name, ZigLLVMDIFile *file, unsigned line_number, uint64_t size_in_bits,
|
||||
uint64_t align_in_bits, unsigned flags, ZigLLVMDIType **types_array, int types_array_len,
|
||||
unsigned run_time_lang, const char *unique_id)
|
||||
{
|
||||
SmallVector<Metadata *, 8> fields;
|
||||
for (int i = 0; i < types_array_len; i += 1) {
|
||||
DIType *ditype = reinterpret_cast<DIType*>(types_array[i]);
|
||||
fields.push_back(ditype);
|
||||
}
|
||||
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createUnionType(
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
name,
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
line_number, size_in_bits, align_in_bits,
|
||||
static_cast<DINode::DIFlags>(flags),
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateArray(fields),
|
||||
run_time_lang, unique_id);
|
||||
return reinterpret_cast<ZigLLVMDIType*>(di_type);
|
||||
}
|
||||
|
||||
ZigLLVMDIType *ZigLLVMCreateDebugStructType(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIScope *scope,
|
||||
const char *name, ZigLLVMDIFile *file, unsigned line_number, uint64_t size_in_bits,
|
||||
uint64_t align_in_bits, unsigned flags, ZigLLVMDIType *derived_from,
|
||||
ZigLLVMDIType **types_array, int types_array_len, unsigned run_time_lang, ZigLLVMDIType *vtable_holder,
|
||||
const char *unique_id)
|
||||
{
|
||||
SmallVector<Metadata *, 8> fields;
|
||||
for (int i = 0; i < types_array_len; i += 1) {
|
||||
DIType *ditype = reinterpret_cast<DIType*>(types_array[i]);
|
||||
fields.push_back(ditype);
|
||||
}
|
||||
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createStructType(
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
name,
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
line_number, size_in_bits, align_in_bits,
|
||||
static_cast<DINode::DIFlags>(flags),
|
||||
reinterpret_cast<DIType*>(derived_from),
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateArray(fields),
|
||||
run_time_lang,
|
||||
reinterpret_cast<DIType*>(vtable_holder),
|
||||
unique_id);
|
||||
return reinterpret_cast<ZigLLVMDIType*>(di_type);
|
||||
}
|
||||
|
||||
ZigLLVMDIType *ZigLLVMCreateReplaceableCompositeType(ZigLLVMDIBuilder *dibuilder, unsigned tag,
|
||||
const char *name, ZigLLVMDIScope *scope, ZigLLVMDIFile *file, unsigned line)
|
||||
{
|
||||
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createReplaceableCompositeType(
|
||||
tag, name,
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
line);
|
||||
return reinterpret_cast<ZigLLVMDIType*>(di_type);
|
||||
}
|
||||
|
||||
ZigLLVMDIType *ZigLLVMCreateDebugForwardDeclType(ZigLLVMDIBuilder *dibuilder, unsigned tag,
|
||||
const char *name, ZigLLVMDIScope *scope, ZigLLVMDIFile *file, unsigned line)
|
||||
{
|
||||
DIType *di_type = reinterpret_cast<DIBuilder*>(dibuilder)->createForwardDecl(
|
||||
tag, name,
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
line);
|
||||
return reinterpret_cast<ZigLLVMDIType*>(di_type);
|
||||
}
|
||||
|
||||
void ZigLLVMReplaceTemporary(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIType *type,
|
||||
ZigLLVMDIType *replacement)
|
||||
{
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->replaceTemporary(
|
||||
TempDIType(reinterpret_cast<DIType*>(type)),
|
||||
reinterpret_cast<DIType*>(replacement));
|
||||
}
|
||||
|
||||
void ZigLLVMReplaceDebugArrays(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIType *type,
|
||||
ZigLLVMDIType **types_array, int types_array_len)
|
||||
{
|
||||
SmallVector<Metadata *, 8> fields;
|
||||
for (int i = 0; i < types_array_len; i += 1) {
|
||||
DIType *ditype = reinterpret_cast<DIType*>(types_array[i]);
|
||||
fields.push_back(ditype);
|
||||
}
|
||||
DICompositeType *composite_type = (DICompositeType*)reinterpret_cast<DIType*>(type);
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->replaceArrays(
|
||||
composite_type,
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->getOrCreateArray(fields));
|
||||
}
|
||||
|
||||
ZigLLVMDIType *ZigLLVMCreateSubroutineType(ZigLLVMDIBuilder *dibuilder_wrapped,
|
||||
ZigLLVMDIType **types_array, int types_array_len, unsigned flags)
|
||||
{
|
||||
SmallVector<Metadata *, 8> types;
|
||||
for (int i = 0; i < types_array_len; i += 1) {
|
||||
DIType *ditype = reinterpret_cast<DIType*>(types_array[i]);
|
||||
types.push_back(ditype);
|
||||
}
|
||||
DIBuilder *dibuilder = reinterpret_cast<DIBuilder*>(dibuilder_wrapped);
|
||||
DISubroutineType *subroutine_type = dibuilder->createSubroutineType(
|
||||
dibuilder->getOrCreateTypeArray(types),
|
||||
static_cast<DINode::DIFlags>(flags));
|
||||
DIType *ditype = subroutine_type;
|
||||
return reinterpret_cast<ZigLLVMDIType*>(ditype);
|
||||
}
|
||||
|
||||
unsigned ZigLLVMEncoding_DW_ATE_unsigned(void) {
|
||||
return dwarf::DW_ATE_unsigned;
|
||||
}
|
||||
|
||||
unsigned ZigLLVMEncoding_DW_ATE_signed(void) {
|
||||
return dwarf::DW_ATE_signed;
|
||||
}
|
||||
|
||||
unsigned ZigLLVMEncoding_DW_ATE_float(void) {
|
||||
return dwarf::DW_ATE_float;
|
||||
}
|
||||
|
||||
unsigned ZigLLVMEncoding_DW_ATE_boolean(void) {
|
||||
return dwarf::DW_ATE_boolean;
|
||||
}
|
||||
|
||||
unsigned ZigLLVMEncoding_DW_ATE_unsigned_char(void) {
|
||||
return dwarf::DW_ATE_unsigned_char;
|
||||
}
|
||||
|
||||
unsigned ZigLLVMEncoding_DW_ATE_signed_char(void) {
|
||||
return dwarf::DW_ATE_signed_char;
|
||||
}
|
||||
|
||||
unsigned ZigLLVMLang_DW_LANG_C99(void) {
|
||||
return dwarf::DW_LANG_C99;
|
||||
}
|
||||
|
||||
unsigned ZigLLVMTag_DW_variable(void) {
|
||||
return dwarf::DW_TAG_variable;
|
||||
}
|
||||
|
||||
unsigned ZigLLVMTag_DW_structure_type(void) {
|
||||
return dwarf::DW_TAG_structure_type;
|
||||
}
|
||||
|
||||
unsigned ZigLLVMTag_DW_enumeration_type(void) {
|
||||
return dwarf::DW_TAG_enumeration_type;
|
||||
}
|
||||
|
||||
unsigned ZigLLVMTag_DW_union_type(void) {
|
||||
return dwarf::DW_TAG_union_type;
|
||||
}
|
||||
|
||||
ZigLLVMDIBuilder *ZigLLVMCreateDIBuilder(LLVMModuleRef module, bool allow_unresolved) {
|
||||
DIBuilder *di_builder = new(std::nothrow) DIBuilder(*unwrap(module), allow_unresolved);
|
||||
if (di_builder == nullptr)
|
||||
return nullptr;
|
||||
return reinterpret_cast<ZigLLVMDIBuilder *>(di_builder);
|
||||
}
|
||||
|
||||
void ZigLLVMDisposeDIBuilder(ZigLLVMDIBuilder *dbuilder) {
|
||||
DIBuilder *di_builder = reinterpret_cast<DIBuilder *>(dbuilder);
|
||||
delete di_builder;
|
||||
}
|
||||
|
||||
void ZigLLVMSetCurrentDebugLocation(LLVMBuilderRef builder,
|
||||
unsigned int line, unsigned int column, ZigLLVMDIScope *scope)
|
||||
{
|
||||
DIScope* di_scope = reinterpret_cast<DIScope*>(scope);
|
||||
DebugLoc debug_loc = DILocation::get(di_scope->getContext(), line, column, di_scope, nullptr, false);
|
||||
unwrap(builder)->SetCurrentDebugLocation(debug_loc);
|
||||
}
|
||||
|
||||
void ZigLLVMSetCurrentDebugLocation2(LLVMBuilderRef builder, unsigned int line,
|
||||
unsigned int column, ZigLLVMDIScope *scope, ZigLLVMDILocation *inlined_at)
|
||||
{
|
||||
DIScope* di_scope = reinterpret_cast<DIScope*>(scope);
|
||||
DebugLoc debug_loc = DILocation::get(di_scope->getContext(), line, column, di_scope,
|
||||
reinterpret_cast<DILocation *>(inlined_at), false);
|
||||
unwrap(builder)->SetCurrentDebugLocation(debug_loc);
|
||||
}
|
||||
|
||||
void ZigLLVMClearCurrentDebugLocation(LLVMBuilderRef builder) {
|
||||
unwrap(builder)->SetCurrentDebugLocation(DebugLoc());
|
||||
}
|
||||
|
||||
|
||||
ZigLLVMDILexicalBlock *ZigLLVMCreateLexicalBlock(ZigLLVMDIBuilder *dbuilder, ZigLLVMDIScope *scope,
|
||||
ZigLLVMDIFile *file, unsigned line, unsigned col)
|
||||
{
|
||||
DILexicalBlock *result = reinterpret_cast<DIBuilder*>(dbuilder)->createLexicalBlock(
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
line,
|
||||
col);
|
||||
return reinterpret_cast<ZigLLVMDILexicalBlock*>(result);
|
||||
}
|
||||
|
||||
ZigLLVMDILocalVariable *ZigLLVMCreateAutoVariable(ZigLLVMDIBuilder *dbuilder,
|
||||
ZigLLVMDIScope *scope, const char *name, ZigLLVMDIFile *file, unsigned line_no,
|
||||
ZigLLVMDIType *type, bool always_preserve, unsigned flags)
|
||||
{
|
||||
DILocalVariable *result = reinterpret_cast<DIBuilder*>(dbuilder)->createAutoVariable(
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
name,
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
line_no,
|
||||
reinterpret_cast<DIType*>(type),
|
||||
always_preserve,
|
||||
static_cast<DINode::DIFlags>(flags));
|
||||
return reinterpret_cast<ZigLLVMDILocalVariable*>(result);
|
||||
}
|
||||
|
||||
ZigLLVMDIGlobalVariableExpression *ZigLLVMCreateGlobalVariableExpression(ZigLLVMDIBuilder *dbuilder,
|
||||
ZigLLVMDIScope *scope, const char *name, const char *linkage_name, ZigLLVMDIFile *file,
|
||||
unsigned line_no, ZigLLVMDIType *di_type, bool is_local_to_unit)
|
||||
{
|
||||
return reinterpret_cast<ZigLLVMDIGlobalVariableExpression*>(reinterpret_cast<DIBuilder*>(dbuilder)->createGlobalVariableExpression(
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
name,
|
||||
linkage_name,
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
line_no,
|
||||
reinterpret_cast<DIType*>(di_type),
|
||||
is_local_to_unit));
|
||||
}
|
||||
|
||||
ZigLLVMDILocalVariable *ZigLLVMCreateParameterVariable(ZigLLVMDIBuilder *dbuilder,
|
||||
ZigLLVMDIScope *scope, const char *name, ZigLLVMDIFile *file, unsigned line_no,
|
||||
ZigLLVMDIType *type, bool always_preserve, unsigned flags, unsigned arg_no)
|
||||
{
|
||||
assert(arg_no != 0);
|
||||
DILocalVariable *result = reinterpret_cast<DIBuilder*>(dbuilder)->createParameterVariable(
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
name,
|
||||
arg_no,
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
line_no,
|
||||
reinterpret_cast<DIType*>(type),
|
||||
always_preserve,
|
||||
static_cast<DINode::DIFlags>(flags));
|
||||
return reinterpret_cast<ZigLLVMDILocalVariable*>(result);
|
||||
}
|
||||
|
||||
ZigLLVMDIScope *ZigLLVMLexicalBlockToScope(ZigLLVMDILexicalBlock *lexical_block) {
|
||||
DIScope *scope = reinterpret_cast<DILexicalBlock*>(lexical_block);
|
||||
return reinterpret_cast<ZigLLVMDIScope*>(scope);
|
||||
}
|
||||
|
||||
ZigLLVMDIScope *ZigLLVMCompileUnitToScope(ZigLLVMDICompileUnit *compile_unit) {
|
||||
DIScope *scope = reinterpret_cast<DICompileUnit*>(compile_unit);
|
||||
return reinterpret_cast<ZigLLVMDIScope*>(scope);
|
||||
}
|
||||
|
||||
ZigLLVMDIScope *ZigLLVMFileToScope(ZigLLVMDIFile *difile) {
|
||||
DIScope *scope = reinterpret_cast<DIFile*>(difile);
|
||||
return reinterpret_cast<ZigLLVMDIScope*>(scope);
|
||||
}
|
||||
|
||||
ZigLLVMDIScope *ZigLLVMSubprogramToScope(ZigLLVMDISubprogram *subprogram) {
|
||||
DIScope *scope = reinterpret_cast<DISubprogram*>(subprogram);
|
||||
return reinterpret_cast<ZigLLVMDIScope*>(scope);
|
||||
}
|
||||
|
||||
ZigLLVMDIScope *ZigLLVMTypeToScope(ZigLLVMDIType *type) {
|
||||
DIScope *scope = reinterpret_cast<DIType*>(type);
|
||||
return reinterpret_cast<ZigLLVMDIScope*>(scope);
|
||||
}
|
||||
|
||||
ZigLLVMDINode *ZigLLVMLexicalBlockToNode(ZigLLVMDILexicalBlock *lexical_block) {
|
||||
DINode *node = reinterpret_cast<DILexicalBlock*>(lexical_block);
|
||||
return reinterpret_cast<ZigLLVMDINode*>(node);
|
||||
}
|
||||
|
||||
ZigLLVMDINode *ZigLLVMCompileUnitToNode(ZigLLVMDICompileUnit *compile_unit) {
|
||||
DINode *node = reinterpret_cast<DICompileUnit*>(compile_unit);
|
||||
return reinterpret_cast<ZigLLVMDINode*>(node);
|
||||
}
|
||||
|
||||
ZigLLVMDINode *ZigLLVMFileToNode(ZigLLVMDIFile *difile) {
|
||||
DINode *node = reinterpret_cast<DIFile*>(difile);
|
||||
return reinterpret_cast<ZigLLVMDINode*>(node);
|
||||
}
|
||||
|
||||
ZigLLVMDINode *ZigLLVMSubprogramToNode(ZigLLVMDISubprogram *subprogram) {
|
||||
DINode *node = reinterpret_cast<DISubprogram*>(subprogram);
|
||||
return reinterpret_cast<ZigLLVMDINode*>(node);
|
||||
}
|
||||
|
||||
ZigLLVMDINode *ZigLLVMTypeToNode(ZigLLVMDIType *type) {
|
||||
DINode *node = reinterpret_cast<DIType*>(type);
|
||||
return reinterpret_cast<ZigLLVMDINode*>(node);
|
||||
}
|
||||
|
||||
ZigLLVMDINode *ZigLLVMScopeToNode(ZigLLVMDIScope *scope) {
|
||||
DINode *node = reinterpret_cast<DIScope*>(scope);
|
||||
return reinterpret_cast<ZigLLVMDINode*>(node);
|
||||
}
|
||||
|
||||
ZigLLVMDINode *ZigLLVMGlobalVariableToNode(ZigLLVMDIGlobalVariable *global_variable) {
|
||||
DINode *node = reinterpret_cast<DIGlobalVariable*>(global_variable);
|
||||
return reinterpret_cast<ZigLLVMDINode*>(node);
|
||||
}
|
||||
|
||||
void ZigLLVMSubprogramReplaceLinkageName(ZigLLVMDISubprogram *subprogram,
|
||||
ZigLLVMMDString *linkage_name)
|
||||
{
|
||||
MDString *linkage_name_md = reinterpret_cast<MDString*>(linkage_name);
|
||||
reinterpret_cast<DISubprogram*>(subprogram)->replaceLinkageName(linkage_name_md);
|
||||
}
|
||||
|
||||
void ZigLLVMGlobalVariableReplaceLinkageName(ZigLLVMDIGlobalVariable *global_variable,
|
||||
ZigLLVMMDString *linkage_name)
|
||||
{
|
||||
Metadata *linkage_name_md = reinterpret_cast<MDString*>(linkage_name);
|
||||
// NOTE: Operand index must match llvm::DIGlobalVariable
|
||||
reinterpret_cast<DIGlobalVariable*>(global_variable)->replaceOperandWith(5, linkage_name_md);
|
||||
}
|
||||
|
||||
ZigLLVMDICompileUnit *ZigLLVMCreateCompileUnit(ZigLLVMDIBuilder *dibuilder,
|
||||
unsigned lang, ZigLLVMDIFile *difile, const char *producer,
|
||||
bool is_optimized, const char *flags, unsigned runtime_version, const char *split_name,
|
||||
uint64_t dwo_id, bool emit_debug_info)
|
||||
{
|
||||
DICompileUnit *result = reinterpret_cast<DIBuilder*>(dibuilder)->createCompileUnit(
|
||||
lang,
|
||||
reinterpret_cast<DIFile*>(difile),
|
||||
producer, is_optimized, flags, runtime_version, split_name,
|
||||
(emit_debug_info ? DICompileUnit::DebugEmissionKind::FullDebug : DICompileUnit::DebugEmissionKind::NoDebug),
|
||||
dwo_id);
|
||||
return reinterpret_cast<ZigLLVMDICompileUnit*>(result);
|
||||
}
|
||||
|
||||
|
||||
ZigLLVMDIFile *ZigLLVMCreateFile(ZigLLVMDIBuilder *dibuilder, const char *filename, const char *directory) {
|
||||
DIFile *result = reinterpret_cast<DIBuilder*>(dibuilder)->createFile(filename, directory);
|
||||
return reinterpret_cast<ZigLLVMDIFile*>(result);
|
||||
}
|
||||
|
||||
ZigLLVMDISubprogram *ZigLLVMCreateFunction(ZigLLVMDIBuilder *dibuilder, ZigLLVMDIScope *scope,
|
||||
const char *name, const char *linkage_name, ZigLLVMDIFile *file, unsigned lineno,
|
||||
ZigLLVMDIType *fn_di_type, bool is_local_to_unit, bool is_definition, unsigned scope_line,
|
||||
unsigned flags, bool is_optimized, ZigLLVMDISubprogram *decl_subprogram)
|
||||
{
|
||||
DISubroutineType *di_sub_type = static_cast<DISubroutineType*>(reinterpret_cast<DIType*>(fn_di_type));
|
||||
DISubprogram *result = reinterpret_cast<DIBuilder*>(dibuilder)->createFunction(
|
||||
reinterpret_cast<DIScope*>(scope),
|
||||
name, linkage_name,
|
||||
reinterpret_cast<DIFile*>(file),
|
||||
lineno,
|
||||
di_sub_type,
|
||||
scope_line,
|
||||
static_cast<DINode::DIFlags>(flags),
|
||||
DISubprogram::toSPFlags(is_local_to_unit, is_definition, is_optimized),
|
||||
nullptr,
|
||||
reinterpret_cast<DISubprogram *>(decl_subprogram),
|
||||
nullptr);
|
||||
return reinterpret_cast<ZigLLVMDISubprogram*>(result);
|
||||
}
|
||||
|
||||
void ZigLLVMDIBuilderFinalize(ZigLLVMDIBuilder *dibuilder) {
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->finalize();
|
||||
}
|
||||
|
||||
LLVMValueRef ZigLLVMInsertDeclareAtEnd(ZigLLVMDIBuilder *dibuilder, LLVMValueRef storage,
|
||||
ZigLLVMDILocalVariable *var_info, ZigLLVMDILocation *debug_loc, LLVMBasicBlockRef basic_block_ref)
|
||||
{
|
||||
Instruction *result = reinterpret_cast<DIBuilder*>(dibuilder)->insertDeclare(
|
||||
unwrap(storage),
|
||||
reinterpret_cast<DILocalVariable *>(var_info),
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->createExpression(),
|
||||
reinterpret_cast<DILocation*>(debug_loc),
|
||||
static_cast<BasicBlock*>(unwrap(basic_block_ref)));
|
||||
return wrap(result);
|
||||
}
|
||||
|
||||
LLVMValueRef ZigLLVMInsertDbgValueIntrinsicAtEnd(ZigLLVMDIBuilder *dib, LLVMValueRef val,
|
||||
ZigLLVMDILocalVariable *var_info, ZigLLVMDILocation *debug_loc,
|
||||
LLVMBasicBlockRef basic_block_ref)
|
||||
{
|
||||
Instruction *result = reinterpret_cast<DIBuilder*>(dib)->insertDbgValueIntrinsic(
|
||||
unwrap(val),
|
||||
reinterpret_cast<DILocalVariable *>(var_info),
|
||||
reinterpret_cast<DIBuilder*>(dib)->createExpression(),
|
||||
reinterpret_cast<DILocation*>(debug_loc),
|
||||
static_cast<BasicBlock*>(unwrap(basic_block_ref)));
|
||||
return wrap(result);
|
||||
}
|
||||
|
||||
LLVMValueRef ZigLLVMInsertDeclare(ZigLLVMDIBuilder *dibuilder, LLVMValueRef storage,
|
||||
ZigLLVMDILocalVariable *var_info, ZigLLVMDILocation *debug_loc, LLVMValueRef insert_before_instr)
|
||||
{
|
||||
Instruction *result = reinterpret_cast<DIBuilder*>(dibuilder)->insertDeclare(
|
||||
unwrap(storage),
|
||||
reinterpret_cast<DILocalVariable *>(var_info),
|
||||
reinterpret_cast<DIBuilder*>(dibuilder)->createExpression(),
|
||||
reinterpret_cast<DILocation*>(debug_loc),
|
||||
static_cast<Instruction*>(unwrap(insert_before_instr)));
|
||||
return wrap(result);
|
||||
}
|
||||
|
||||
ZigLLVMDILocation *ZigLLVMGetDebugLoc(unsigned line, unsigned col, ZigLLVMDIScope *scope) {
|
||||
DIScope* di_scope = reinterpret_cast<DIScope*>(scope);
|
||||
DebugLoc debug_loc = DILocation::get(di_scope->getContext(), line, col, di_scope, nullptr, false);
|
||||
return reinterpret_cast<ZigLLVMDILocation*>(debug_loc.get());
|
||||
}
|
||||
|
||||
ZigLLVMDILocation *ZigLLVMGetDebugLoc2(unsigned line, unsigned col, ZigLLVMDIScope *scope,
|
||||
ZigLLVMDILocation *inlined_at) {
|
||||
DIScope* di_scope = reinterpret_cast<DIScope*>(scope);
|
||||
DebugLoc debug_loc = DILocation::get(di_scope->getContext(), line, col, di_scope,
|
||||
reinterpret_cast<DILocation *>(inlined_at), false);
|
||||
return reinterpret_cast<ZigLLVMDILocation*>(debug_loc.get());
|
||||
}
|
||||
|
||||
void ZigLLVMSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state) {
|
||||
if (on_state) {
|
||||
FastMathFlags fmf;
|
||||
fmf.setFast();
|
||||
unwrap(builder_wrapped)->setFastMathFlags(fmf);
|
||||
} else {
|
||||
unwrap(builder_wrapped)->clearFastMathFlags();
|
||||
}
|
||||
}
|
||||
|
||||
void ZigLLVMParseCommandLineOptions(size_t argc, const char *const *argv) {
|
||||
cl::ParseCommandLineOptions(argc, argv);
|
||||
}
|
||||
|
||||
void ZigLLVMAddModuleDebugInfoFlag(LLVMModuleRef module, bool produce_dwarf64) {
|
||||
unwrap(module)->addModuleFlag(Module::Warning, "Debug Info Version", DEBUG_METADATA_VERSION);
|
||||
unwrap(module)->addModuleFlag(Module::Warning, "Dwarf Version", 4);
|
||||
|
||||
if (produce_dwarf64) {
|
||||
unwrap(module)->addModuleFlag(Module::Warning, "DWARF64", 1);
|
||||
}
|
||||
}
|
||||
|
||||
void ZigLLVMAddModuleCodeViewFlag(LLVMModuleRef module) {
|
||||
unwrap(module)->addModuleFlag(Module::Warning, "Debug Info Version", DEBUG_METADATA_VERSION);
|
||||
unwrap(module)->addModuleFlag(Module::Warning, "CodeView", 1);
|
||||
}
|
||||
|
||||
void ZigLLVMSetModulePICLevel(LLVMModuleRef module) {
|
||||
unwrap(module)->setPICLevel(PICLevel::Level::BigPIC);
|
||||
}
|
||||
@@ -956,35 +398,6 @@ void ZigLLVMSetModuleCodeModel(LLVMModuleRef module, LLVMCodeModel code_model) {
|
||||
assert(!JIT);
|
||||
}
|
||||
|
||||
LLVMValueRef ZigLLVMBuildNSWShl(LLVMBuilderRef builder, LLVMValueRef LHS, LLVMValueRef RHS,
|
||||
const char *name)
|
||||
{
|
||||
return wrap(unwrap(builder)->CreateShl(unwrap(LHS), unwrap(RHS), name, false, true));
|
||||
}
|
||||
|
||||
LLVMValueRef ZigLLVMBuildNUWShl(LLVMBuilderRef builder, LLVMValueRef LHS, LLVMValueRef RHS,
|
||||
const char *name)
|
||||
{
|
||||
return wrap(unwrap(builder)->CreateShl(unwrap(LHS), unwrap(RHS), name, true, false));
|
||||
}
|
||||
|
||||
LLVMValueRef ZigLLVMBuildLShrExact(LLVMBuilderRef builder, LLVMValueRef LHS, LLVMValueRef RHS,
|
||||
const char *name)
|
||||
{
|
||||
return wrap(unwrap(builder)->CreateLShr(unwrap(LHS), unwrap(RHS), name, true));
|
||||
}
|
||||
|
||||
LLVMValueRef ZigLLVMBuildAShrExact(LLVMBuilderRef builder, LLVMValueRef LHS, LLVMValueRef RHS,
|
||||
const char *name)
|
||||
{
|
||||
return wrap(unwrap(builder)->CreateAShr(unwrap(LHS), unwrap(RHS), name, true));
|
||||
}
|
||||
|
||||
LLVMValueRef ZigLLVMBuildAllocaInAddressSpace(LLVMBuilderRef builder, LLVMTypeRef Ty,
|
||||
unsigned AddressSpace, const char *Name) {
|
||||
return wrap(unwrap(builder)->CreateAlloca(unwrap(Ty), AddressSpace, nullptr, Name));
|
||||
}
|
||||
|
||||
bool ZigLLVMWriteImportLibrary(const char *def_path, const ZigLLVM_ArchType arch,
|
||||
const char *output_lib_path, bool kill_at)
|
||||
{
|
||||
@@ -1134,43 +547,6 @@ bool ZigLLDLinkWasm(int argc, const char **argv, bool can_exit_early, bool disab
|
||||
return lld::wasm::link(args, llvm::outs(), llvm::errs(), can_exit_early, disable_output);
|
||||
}
|
||||
|
||||
void ZigLLVMTakeName(LLVMValueRef new_owner, LLVMValueRef victim) {
|
||||
unwrap(new_owner)->takeName(unwrap(victim));
|
||||
}
|
||||
|
||||
void ZigLLVMRemoveGlobalValue(LLVMValueRef GlobalVal) {
|
||||
unwrap<GlobalValue>(GlobalVal)->removeFromParent();
|
||||
}
|
||||
|
||||
void ZigLLVMEraseGlobalValue(LLVMValueRef GlobalVal) {
|
||||
unwrap<GlobalValue>(GlobalVal)->eraseFromParent();
|
||||
}
|
||||
|
||||
void ZigLLVMDeleteGlobalValue(LLVMValueRef GlobalVal) {
|
||||
auto *GV = unwrap<GlobalValue>(GlobalVal);
|
||||
assert(GV->getParent() == nullptr);
|
||||
switch (GV->getValueID()) {
|
||||
#define HANDLE_GLOBAL_VALUE(NAME) \
|
||||
case Value::NAME##Val: \
|
||||
delete static_cast<NAME *>(GV); \
|
||||
break;
|
||||
#include <llvm/IR/Value.def>
|
||||
default: llvm_unreachable("Expected global value");
|
||||
}
|
||||
}
|
||||
|
||||
void ZigLLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal) {
|
||||
unwrap<GlobalVariable>(GlobalVar)->setInitializer(ConstantVal ? unwrap<Constant>(ConstantVal) : nullptr);
|
||||
}
|
||||
|
||||
ZigLLVMDIGlobalVariable* ZigLLVMGlobalGetVariable(ZigLLVMDIGlobalVariableExpression *global_variable_expression) {
|
||||
return reinterpret_cast<ZigLLVMDIGlobalVariable*>(reinterpret_cast<DIGlobalVariableExpression*>(global_variable_expression)->getVariable());
|
||||
}
|
||||
|
||||
void ZigLLVMAttachMetaData(LLVMValueRef Val, ZigLLVMDIGlobalVariableExpression *global_variable_expression) {
|
||||
unwrap<GlobalVariable>(Val)->addDebugInfo(reinterpret_cast<DIGlobalVariableExpression*>(global_variable_expression));
|
||||
}
|
||||
|
||||
static_assert((Triple::ArchType)ZigLLVM_UnknownArch == Triple::UnknownArch, "");
|
||||
static_assert((Triple::ArchType)ZigLLVM_arm == Triple::arm, "");
|
||||
static_assert((Triple::ArchType)ZigLLVM_armeb == Triple::armeb, "");
|
||||
|
||||
Reference in New Issue
Block a user