Better compatibility with LLVM < 13 (#319)

* Update wrapper to add type attribute on LLVM < 13
This commit is contained in:
Christoffer Lerno
2021-11-09 22:53:13 +01:00
committed by GitHub
parent 137b474f44
commit df0b1df1df
4 changed files with 19 additions and 9 deletions

View File

@@ -1100,11 +1100,7 @@ void llvm_attribute_add_int(GenContext *context, LLVMValueRef value_to_add_attri
void llvm_attribute_add_type(GenContext *c, LLVMValueRef value_to_add_attribute_to, unsigned attribute_id, LLVMTypeRef type, int index)
{
#if LLVM_VERSION_MAJOR < 13
LLVMAttributeRef llvm_attr = LLVMCreateEnumAttribute(c->context, attribute_id, 0);
#else
LLVMAttributeRef llvm_attr = LLVMCreateTypeAttribute(c->context, attribute_id, type);
#endif
LLVMAddAttributeAtIndex(value_to_add_attribute_to, index, llvm_attr);
}
@@ -1115,11 +1111,7 @@ void llvm_attribute_add(GenContext *context, LLVMValueRef value_to_add_attribute
void llvm_attribute_add_call_type(GenContext *c, LLVMValueRef call, unsigned attribute_id, int index, LLVMTypeRef type)
{
#if LLVM_VERSION_MAJOR < 13
LLVMAttributeRef llvm_attr = LLVMCreateEnumAttribute(c->context, attribute_id, 0);
#else
LLVMAttributeRef llvm_attr = LLVMCreateTypeAttribute(c->context, attribute_id, type);
#endif
LLVMAddCallSiteAttribute(call, index, llvm_attr);
}

View File

@@ -187,6 +187,10 @@ void gencontext_end_file_emit(GenContext *c, Context *ast);
void gencontext_end_module(GenContext *context);
LLVMValueRef LLVMConstBswap(LLVMValueRef ConstantVal);
#ifndef LLVMCreateTypeAttribute
LLVMAttributeRef LLVMCreateTypeAttribute(LLVMContextRef C, unsigned KindID,
LLVMTypeRef type_ref);
#endif
// BE value
void llvm_value_addr(GenContext *c, BEValue *value);