Skip to content

Commit 8bd5473

Browse files
committed
add range attribute to bindings
1 parent 00fb430 commit 8bd5473

3 files changed

Lines changed: 30 additions & 0 deletions

File tree

IRBindings.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,20 @@ LLVMValueRef LLVMGoGetInlineAsm(LLVMTypeRef Ty, char *AsmString,
8585
IsAlignStack,
8686
Dialect, CanThrow);
8787
}
88+
89+
LLVMAttributeRef LLVMGoCreateSmallRangeAttribute(
90+
LLVMContextRef C,
91+
unsigned KindID,
92+
unsigned bits,
93+
uint64_t lower,
94+
uint64_t upper
95+
) {
96+
return wrap(Attribute::get(
97+
*unwrap(C),
98+
(Attribute::AttrKind)KindID,
99+
ConstantRange(
100+
APInt(bits, lower),
101+
APInt(bits, upper)
102+
)
103+
));
104+
}

IRBindings.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ LLVMValueRef LLVMGoGetInlineAsm(LLVMTypeRef Ty, char *AsmString,
5555
LLVMBool IsAlignStack,
5656
LLVMInlineAsmDialect Dialect, LLVMBool CanThrow);
5757

58+
LLVMAttributeRef LLVMGoCreateSmallRangeAttribute(
59+
LLVMContextRef C,
60+
unsigned KindID,
61+
unsigned bits,
62+
uint64_t lower,
63+
uint64_t upper
64+
);
65+
5866
#ifdef __cplusplus
5967
}
6068
#endif

ir.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,11 @@ func (c Context) CreateTypeAttribute(kind uint, t Type) (a Attribute) {
395395
return
396396
}
397397

398+
func (c Context) CreateSmallRangeAttribute(kind uint, bits uint, lower, upper uint64) (a Attribute) {
399+
a.C = C.LLVMGoCreateSmallRangeAttribute(c.C, C.unsigned(kind), C.unsigned(bits), C.uint64_t(lower), C.uint64_t(upper))
400+
return
401+
}
402+
398403
func (a Attribute) GetTypeValue() (t Type) {
399404
t.C = C.LLVMGetTypeAttributeValue(a.C)
400405
return

0 commit comments

Comments
 (0)