mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 15:13:08 +00:00
stage2 - add llvm bindings to create attributes with string values
This commit is contained in:
parent
1e94221190
commit
023e4b9fed
@ -1389,10 +1389,30 @@ pub const DeclGen = struct {
|
||||
val.addAttributeAtIndex(index, llvm_attr);
|
||||
}
|
||||
|
||||
fn addAttrString(
|
||||
dg: *DeclGen,
|
||||
val: *const llvm.Value,
|
||||
index: llvm.AttributeIndex,
|
||||
name: []const u8,
|
||||
value: []const u8,
|
||||
) void {
|
||||
const llvm_attr = dg.context.createStringAttribute(
|
||||
name.ptr,
|
||||
@intCast(c_uint, name.len),
|
||||
value.ptr,
|
||||
@intCast(c_uint, value.len),
|
||||
);
|
||||
val.addAttributeAtIndex(index, llvm_attr);
|
||||
}
|
||||
|
||||
fn addFnAttr(dg: DeclGen, val: *const llvm.Value, name: []const u8) void {
|
||||
dg.addAttr(val, std.math.maxInt(llvm.AttributeIndex), name);
|
||||
}
|
||||
|
||||
fn addFnAttrString(dg: *DeclGen, val: *const llvm.Value, name: []const u8, value: []const u8) void {
|
||||
dg.addAttrString(val, std.math.maxInt(llvm.AttributeIndex), name, value);
|
||||
}
|
||||
|
||||
fn removeFnAttr(fn_val: *const llvm.Value, name: []const u8) void {
|
||||
removeAttr(fn_val, std.math.maxInt(llvm.AttributeIndex), name);
|
||||
}
|
||||
|
||||
@ -28,6 +28,9 @@ pub const Context = opaque {
|
||||
pub const createEnumAttribute = LLVMCreateEnumAttribute;
|
||||
extern fn LLVMCreateEnumAttribute(*const Context, KindID: c_uint, Val: u64) *const Attribute;
|
||||
|
||||
pub const createStringAttribute = LLVMCreateStringAttribute;
|
||||
extern fn LLVMCreateStringAttribute(*const Context, Key: [*]const u8, Key_Len: c_uint, Value: [*]const u8, Value_Len: c_uint) *const Attribute;
|
||||
|
||||
pub const intType = LLVMIntTypeInContext;
|
||||
extern fn LLVMIntTypeInContext(C: *const Context, NumBits: c_uint) *const Type;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user