llvm.org GIT mirror llvm / 3111641
bindings: tab and indentation fixes of my previous commits git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141989 91177308-0d34-0410-b5e6-96231b3b80d8 Torok Edwin 7 years ago
2 changed file(s) with 56 addition(s) and 56 deletion(s). Raw diff Collapse all Expand all
294294 /* lltype -> string option */
295295 CAMLprim value llvm_struct_name(LLVMTypeRef Ty)
296296 {
297 CAMLparam0();
298 const char *C = LLVMGetStructName(Ty);
299 if (C) {
300 CAMLlocal1(result);
301 result = caml_alloc_small(1, 0);
302 Store_field(result, 0, caml_copy_string(C));
303 CAMLreturn(result);
304 }
305 CAMLreturn(Val_int(0));
297 CAMLparam0();
298 const char *C = LLVMGetStructName(Ty);
299 if (C) {
300 CAMLlocal1(result);
301 result = caml_alloc_small(1, 0);
302 Store_field(result, 0, caml_copy_string(C));
303 CAMLreturn(result);
304 }
305 CAMLreturn(Val_int(0));
306306 }
307307
308308 /* lltype -> lltype array */
474474
475475 /* llvalue -> string option */
476476 CAMLprim value llvm_get_mdstring(LLVMValueRef V) {
477 CAMLparam0();
478 const char *S;
479 unsigned Len;
480
481 if ((S = LLVMGetMDString(V, &Len))) {
482 CAMLlocal2(Option, Str);
483
484 Str = caml_alloc_string(Len);
485 memcpy(String_val(Str), S, Len);
486 Option = alloc(1,0);
487 Store_field(Option, 0, Str);
488 CAMLreturn(Option);
489 }
490 CAMLreturn(Val_int(0));
477 CAMLparam0();
478 const char *S;
479 unsigned Len;
480
481 if ((S = LLVMGetMDString(V, &Len))) {
482 CAMLlocal2(Option, Str);
483
484 Str = caml_alloc_string(Len);
485 memcpy(String_val(Str), S, Len);
486 Option = alloc(1,0);
487 Store_field(Option, 0, Str);
488 CAMLreturn(Option);
489 }
490 CAMLreturn(Val_int(0));
491491 }
492492
493493 CAMLprim value llvm_get_namedmd(LLVMModuleRef M, value name)
10151015
10161016 /* llvalue -> ICmp.t */
10171017 CAMLprim value llvm_instr_icmp_predicate(LLVMValueRef Val) {
1018 CAMLparam0();
1019 int x = LLVMGetICmpPredicate(Val);
1020 if (x) {
1021 value Option = alloc(1, 0);
1022 Field(Option, 0) = Val_int(x - LLVMIntEQ);
1023 CAMLreturn(Option);
1024 }
1025 CAMLreturn(Val_int(0));
1018 CAMLparam0();
1019 int x = LLVMGetICmpPredicate(Val);
1020 if (x) {
1021 value Option = alloc(1, 0);
1022 Field(Option, 0) = Val_int(x - LLVMIntEQ);
1023 CAMLreturn(Option);
1024 }
1025 CAMLreturn(Val_int(0));
10261026 }
10271027
10281028
308308
309309 const char *LLVMGetStructName(LLVMTypeRef Ty)
310310 {
311 StructType *Type = unwrap(Ty);
312 if (!Type->hasName())
313 return 0;
314 return Type->getName().data();
311 StructType *Type = unwrap(Ty);
312 if (!Type->hasName())
313 return 0;
314 return Type->getName().data();
315315 }
316316
317317 void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes,
532532 }
533533
534534 const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len) {
535 if (const MDString *S = dyn_cast(unwrap(V))) {
536 *Len = S->getString().size();
537 return S->getString().data();
538 }
539 *Len = 0;
540 return 0;
535 if (const MDString *S = dyn_cast(unwrap(V))) {
536 *Len = S->getString().size();
537 return S->getString().data();
538 }
539 *Len = 0;
540 return 0;
541541 }
542542
543543 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name)
544544 {
545 if (NamedMDNode *N = unwrap(M)->getNamedMetadata(name)) {
546 return N->getNumOperands();
547 }
548 return 0;
545 if (NamedMDNode *N = unwrap(M)->getNamedMetadata(name)) {
546 return N->getNumOperands();
547 }
548 return 0;
549549 }
550550
551551 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest)
552552 {
553 NamedMDNode *N = unwrap(M)->getNamedMetadata(name);
554 if (!N)
555 return;
556 for (unsigned i=0;igetNumOperands();i++)
557 Dest[i] = wrap(N->getOperand(i));
553 NamedMDNode *N = unwrap(M)->getNamedMetadata(name);
554 if (!N)
555 return;
556 for (unsigned i=0;igetNumOperands();i++)
557 Dest[i] = wrap(N->getOperand(i));
558558 }
559559
560560 /*--.. Operations on scalar constants ......................................--*/
15821582 }
15831583
15841584 LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst) {
1585 if (ICmpInst *I = dyn_cast(unwrap(Inst)))
1586 return (LLVMIntPredicate)I->getPredicate();
1587 if (ConstantExpr *CE = dyn_cast(unwrap(Inst)))
1588 if (CE->getOpcode() == Instruction::ICmp)
1589 return (LLVMIntPredicate)CE->getPredicate();
1590 return (LLVMIntPredicate)0;
1585 if (ICmpInst *I = dyn_cast(unwrap(Inst)))
1586 return (LLVMIntPredicate)I->getPredicate();
1587 if (ConstantExpr *CE = dyn_cast(unwrap(Inst)))
1588 if (CE->getOpcode() == Instruction::ICmp)
1589 return (LLVMIntPredicate)CE->getPredicate();
1590 return (LLVMIntPredicate)0;
15911591 }
15921592
15931593 /*--.. Call and invoke instructions ........................................--*/