llvm.org GIT mirror llvm / 15ac8b9
Fix some Ocaml GC errors noticed upon review. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45336 91177308-0d34-0410-b5e6-96231b3b80d8 Gordon Henriksen 12 years ago
1 changed file(s) with 23 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
7171
7272 /* Llvm.lltype -> float -> t */
7373 CAMLprim value llvm_genericvalue_of_float(LLVMTypeRef Ty, value N) {
74 return alloc_generic_value(LLVMCreateGenericValueOfFloat(Ty, Double_val(N)));
74 CAMLparam1(N);
75 CAMLreturn(alloc_generic_value(
76 LLVMCreateGenericValueOfFloat(Ty, Double_val(N))));
7577 }
7678
7779 /* 'a -> t */
7880 CAMLprim value llvm_genericvalue_of_value(value V) {
79 return alloc_generic_value(LLVMCreateGenericValueOfPointer(Op_val(V)));
81 CAMLparam1(V);
82 CAMLreturn(alloc_generic_value(LLVMCreateGenericValueOfPointer(Op_val(V))));
8083 }
8184
8285 /* Llvm.lltype -> int -> t */
8689
8790 /* Llvm.lltype -> int32 -> t */
8891 CAMLprim value llvm_genericvalue_of_int32(LLVMTypeRef Ty, value Int32) {
89 return alloc_generic_value(LLVMCreateGenericValueOfInt(Ty, Int32_val(Int32),
90 1));
92 CAMLparam1(Int32);
93 CAMLreturn(alloc_generic_value(
94 LLVMCreateGenericValueOfInt(Ty, Int32_val(Int32), 1)));
9195 }
9296
9397 /* Llvm.lltype -> nativeint -> t */
9498 CAMLprim value llvm_genericvalue_of_nativeint(LLVMTypeRef Ty, value NatInt) {
95 return alloc_generic_value(LLVMCreateGenericValueOfInt(Ty,
96 Nativeint_val(NatInt),
97 1));
99 CAMLparam1(NatInt);
100 CAMLreturn(alloc_generic_value(
101 LLVMCreateGenericValueOfInt(Ty, Nativeint_val(NatInt), 1)));
98102 }
99103
100104 /* Llvm.lltype -> int64 -> t */
101105 CAMLprim value llvm_genericvalue_of_int64(LLVMTypeRef Ty, value Int64) {
102 return alloc_generic_value(LLVMCreateGenericValueOfInt(Ty, Int64_val(Int64),
103 1));
106 CAMLparam1(Int64);
107 CAMLreturn(alloc_generic_value(
108 LLVMCreateGenericValueOfInt(Ty, Int64_val(Int64), 1)));
104109 }
105110
106111 /* Llvm.lltype -> t -> float */
107112 CAMLprim value llvm_genericvalue_as_float(LLVMTypeRef Ty, value GenVal) {
108 return copy_double(LLVMGenericValueToFloat(Ty, Genericvalue_val(GenVal)));
113 CAMLparam1(GenVal);
114 CAMLreturn(copy_double(
115 LLVMGenericValueToFloat(Ty, Genericvalue_val(GenVal))));
109116 }
110117
111118 /* t -> 'a */
122129
123130 /* t -> int32 */
124131 CAMLprim value llvm_genericvalue_as_int32(value GenVal) {
132 CAMLparam1(GenVal);
125133 assert(LLVMGenericValueIntWidth(Genericvalue_val(GenVal)) <= 32
126134 && "Generic value too wide to treat as an int32!");
127 return copy_int32(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1));
135 CAMLreturn(copy_int32(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1)));
128136 }
129137
130138 /* t -> int64 */
131139 CAMLprim value llvm_genericvalue_as_int64(value GenVal) {
140 CAMLparam1(GenVal);
132141 assert(LLVMGenericValueIntWidth(Genericvalue_val(GenVal)) <= 64
133142 && "Generic value too wide to treat as an int64!");
134 return copy_int64(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1));
143 CAMLreturn(copy_int64(LLVMGenericValueToInt(Genericvalue_val(GenVal), 1)));
135144 }
136145
137146 /* t -> nativeint */
138147 CAMLprim value llvm_genericvalue_as_nativeint(value GenVal) {
148 CAMLparam1(GenVal);
139149 assert(LLVMGenericValueIntWidth(Genericvalue_val(GenVal)) <= 8 * sizeof(value)
140150 && "Generic value too wide to treat as a nativeint!");
141 return copy_nativeint(LLVMGenericValueToInt(Genericvalue_val(GenVal),1));
151 CAMLreturn(copy_nativeint(LLVMGenericValueToInt(Genericvalue_val(GenVal),1)));
142152 }
143153
144154