better parameter codegen

* ability to take address of a parameter (closes #97)
 * debug symbols work for parameters
This commit is contained in:
Andrew Kelley
2016-04-27 17:34:53 -07:00
parent 09042f1b0c
commit 4815c03caa
8 changed files with 209 additions and 158 deletions

View File

@@ -369,11 +369,15 @@ LLVMZigDIBuilder *LLVMZigCreateDIBuilder(LLVMModuleRef module, bool allow_unreso
return reinterpret_cast<LLVMZigDIBuilder *>(di_builder);
}
void LLVMZigSetCurrentDebugLocation(LLVMBuilderRef builder, int line, int column, LLVMZigDIScope *scope) {
void ZigLLVMSetCurrentDebugLocation(LLVMBuilderRef builder, int line, int column, LLVMZigDIScope *scope) {
unwrap(builder)->SetCurrentDebugLocation(DebugLoc::get(
line, column, reinterpret_cast<DIScope*>(scope)));
}
void ZigLLVMClearCurrentDebugLocation(LLVMBuilderRef builder) {
unwrap(builder)->SetCurrentDebugLocation(DebugLoc());
}
LLVMZigDILexicalBlock *LLVMZigCreateLexicalBlock(LLVMZigDIBuilder *dbuilder, LLVMZigDIScope *scope,
LLVMZigDIFile *file, unsigned line, unsigned col)
@@ -530,6 +534,21 @@ void LLVMZigSetFastMath(LLVMBuilderRef builder_wrapped, bool on_state) {
}
}
void ZigLLVMAddFunctionAttr(LLVMValueRef fn_ref, const char *attr_name, const char *attr_value) {
Function *func = unwrap<Function>(fn_ref);
const AttributeSet attr_set = func->getAttributes();
AttrBuilder attr_builder;
if (attr_value) {
attr_builder.addAttribute(attr_name, attr_value);
} else {
attr_builder.addAttribute(attr_name);
}
const AttributeSet new_attr_set = attr_set.addAttributes(func->getContext(),
AttributeSet::FunctionIndex, AttributeSet::get(func->getContext(),
AttributeSet::FunctionIndex, attr_builder));
func->setAttributes(new_attr_set);
}
static_assert((Triple::ArchType)ZigLLVM_LastArchType == Triple::LastArchType, "");
static_assert((Triple::VendorType)ZigLLVM_LastVendorType == Triple::LastVendorType, "");