mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-24 23:28:41 +00:00
ocaml/C bindings: getmdstring, add num_op, get_op should work on metadata too
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141286 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -456,7 +456,10 @@ LLVMValueRef LLVMGetUsedValue(LLVMUseRef U) {
|
||||
|
||||
/*--.. Operations on Users .................................................--*/
|
||||
LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index) {
|
||||
return wrap(unwrap<User>(Val)->getOperand(Index));
|
||||
Value *V = unwrap(Val);
|
||||
if (MDNode *MD = dyn_cast<MDNode>(V))
|
||||
return wrap(MD->getOperand(Index));
|
||||
return wrap(cast<User>(V)->getOperand(Index));
|
||||
}
|
||||
|
||||
void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op) {
|
||||
@@ -464,7 +467,10 @@ void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op) {
|
||||
}
|
||||
|
||||
int LLVMGetNumOperands(LLVMValueRef Val) {
|
||||
return unwrap<User>(Val)->getNumOperands();
|
||||
Value *V = unwrap(Val);
|
||||
if (MDNode *MD = dyn_cast<MDNode>(V))
|
||||
return MD->getNumOperands();
|
||||
return cast<User>(V)->getNumOperands();
|
||||
}
|
||||
|
||||
/*--.. Operations on constants of any type .................................--*/
|
||||
@@ -521,6 +527,32 @@ LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count) {
|
||||
return LLVMMDNodeInContext(LLVMGetGlobalContext(), Vals, Count);
|
||||
}
|
||||
|
||||
const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len) {
|
||||
if (const MDString *S = dyn_cast<MDString>(unwrap(V))) {
|
||||
*Len = S->getString().size();
|
||||
return S->getString().data();
|
||||
}
|
||||
*Len = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name)
|
||||
{
|
||||
if (NamedMDNode *N = unwrap(M)->getNamedMetadata(name)) {
|
||||
return N->getNumOperands();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest)
|
||||
{
|
||||
NamedMDNode *N = unwrap(M)->getNamedMetadata(name);
|
||||
if (!N)
|
||||
return;
|
||||
for (unsigned i=0;i<N->getNumOperands();i++)
|
||||
Dest[i] = wrap(N->getOperand(i));
|
||||
}
|
||||
|
||||
/*--.. Operations on scalar constants ......................................--*/
|
||||
|
||||
LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,
|
||||
|
Reference in New Issue
Block a user