@@ -76,20 +76,20 @@ target triple = "{triple}"
76
76
; We also define the following LLVM structure types:
77
77
78
78
%string = type { %blockheader, [0 x i8] } ; 10-bit layout, 4-bit gc flags, 10 unused bits, 40-bit length (or buffer capacity for string pointed by stringbuffers), bytes
79
- %stringbuffer = type { i64, i64, %string* } ; 10-bit layout, 4-bit gc flags, 10 unused bits, 40-bit length, string length, current contents
80
- %map = type { { i8 * , i64 } } ; immer::map
81
- %rangemap = type { { { { { i32 (...)**, i32, i64 }*, { { i32 (...)**, i32, i32 }* } } } } } ; rng_map::RangeMap
82
- %set = type { { i8 * , i64 } } ; immer::set
83
- %iter = type { { i8 *, i8 * , i32, [14 x i8** ] }, { { i8 * , i64 } } } ; immer::map_iter / immer::set_iter
84
- %list = type { { i64, i32, i8 *, i8 * } } ; immer::flex_vector
85
- %mpz = type { i32, i32, i64 * } ; mpz_t
79
+ %stringbuffer = type { i64, i64, ptr } ; 10-bit layout, 4-bit gc flags, 10 unused bits, 40-bit length, string length, current contents
80
+ %map = type { { ptr , i64 } } ; immer::map
81
+ %rangemap = type { { { { ptr, { ptr } } } } } ; rng_map::RangeMap
82
+ %set = type { { ptr , i64 } } ; immer::set
83
+ %iter = type { { ptr, ptr , i32, [14 x ptr ] }, { { ptr , i64 } } } ; immer::map_iter / immer::set_iter
84
+ %list = type { { i64, i32, ptr, ptr } } ; immer::flex_vector
85
+ %mpz = type { i32, i32, ptr } ; mpz_t
86
86
%mpz_hdr = type { %blockheader, %mpz } ; 10-bit layout, 4-bit gc flags, 10 unused bits, 40-bit length, mpz_t
87
- %floating = type { i64, { i64, i32, i64, i64 * } } ; exp, mpfr_t
87
+ %floating = type { i64, { i64, i32, i64, ptr } } ; exp, mpfr_t
88
88
%floating_hdr = type { %blockheader, %floating } ; 10-bit layout, 4-bit gc flags, 10 unused bits, 40-bit length, floating
89
89
%blockheader = type { i64 }
90
- %block = type { %blockheader, [0 x i64 * ] } ; 16-bit layout, 8-bit length, 32-bit tag, children
90
+ %block = type { %blockheader, [0 x ptr ] } ; 16-bit layout, 8-bit length, 32-bit tag, children
91
91
92
- %layout = type { i8, %layoutitem* } ; number of children, array of children
92
+ %layout = type { i8, ptr } ; number of children, array of children
93
93
%layoutitem = type { i64, i16 } ; offset, category
94
94
95
95
; The layout of a block uniquely identifies the categories of its children as
@@ -111,8 +111,8 @@ target triple = "{triple}"
111
111
; %layoutN = type { %blockheader, [0 x i64 *], %map, %mpz *, %block * }
112
112
113
113
; Interface to the configuration parser
114
- declare %block* @parse_configuration(i8* )
115
- declare void @print_configuration(i8 *, %block * )
114
+ declare ptr @parse_configuration(ptr )
115
+ declare void @print_configuration(ptr, ptr )
116
116
)LLVM" ;
117
117
return target_dependent + rest;
118
118
}
@@ -147,7 +147,9 @@ llvm::Type *get_param_type(value_type sort, llvm::Module *module) {
147
147
case sort_category::Map:
148
148
case sort_category::RangeMap:
149
149
case sort_category::List:
150
- case sort_category::Set: type = llvm::PointerType::getUnqual (type); break ;
150
+ case sort_category::Set:
151
+ type = llvm::PointerType::getUnqual (module ->getContext ());
152
+ break ;
151
153
default : break ;
152
154
}
153
155
return type;
@@ -168,22 +170,15 @@ llvm::Type *getvalue_type(value_type sort, llvm::Module *module) {
168
170
return llvm::StructType::getTypeByName (module ->getContext (), list_struct);
169
171
case sort_category::Set:
170
172
return llvm::StructType::getTypeByName (module ->getContext (), set_struct);
171
- case sort_category::Int:
172
- return llvm::PointerType::getUnqual (
173
- llvm::StructType::getTypeByName (module ->getContext (), int_struct));
174
- case sort_category::Float:
175
- return llvm::PointerType::getUnqual (
176
- llvm::StructType::getTypeByName (module ->getContext (), float_struct));
177
- case sort_category::StringBuffer:
178
- return llvm::PointerType::getUnqual (
179
- llvm::StructType::getTypeByName (module ->getContext (), buffer_struct));
180
173
case sort_category::Bool: return llvm::Type::getInt1Ty (module ->getContext ());
181
174
case sort_category::MInt:
182
175
return llvm::IntegerType::get (module ->getContext (), sort.bits );
176
+ case sort_category::Int:
177
+ case sort_category::Float:
178
+ case sort_category::StringBuffer:
183
179
case sort_category::Symbol:
184
180
case sort_category::Variable:
185
- return llvm::PointerType::getUnqual (
186
- llvm::StructType::getTypeByName (module ->getContext (), block_struct));
181
+ return llvm::PointerType::getUnqual (module ->getContext ());
187
182
case sort_category::MapIter:
188
183
case sort_category::SetIter:
189
184
case sort_category::Uncomputed: abort ();
@@ -268,8 +263,7 @@ llvm::Value *allocate_term(
268
263
llvm::Type *alloc_type, llvm::Value *len, llvm::BasicBlock *block,
269
264
char const *alloc_fn) {
270
265
auto *malloc = create_malloc (
271
- block, llvm::Type::getInt64Ty (block->getContext ()), alloc_type, len,
272
- nullptr , kore_heap_alloc (alloc_fn, block->getModule ()));
266
+ block, len, kore_heap_alloc (alloc_fn, block->getModule ()));
273
267
274
268
set_debug_loc (malloc);
275
269
return malloc;
@@ -340,6 +334,7 @@ std::string escape(std::string const &str) {
340
334
llvm::Value *create_term::create_hook (
341
335
kore_composite_pattern *hook_att, kore_composite_pattern *pattern,
342
336
std::string const &location_stack) {
337
+ auto *ptr_ty = llvm::PointerType::getUnqual (ctx_);
343
338
assert (hook_att->get_arguments ().size () == 1 );
344
339
auto *str_pattern
345
340
= dynamic_cast <kore_string_pattern *>(hook_att->get_arguments ()[0 ].get ());
@@ -513,9 +508,8 @@ llvm::Value *create_term::create_hook(
513
508
auto *result = llvm::CallInst::Create (
514
509
get_or_insert_function (
515
510
module_, " hook_MINT_import" ,
516
- getvalue_type ({sort_category::Int, 0 }, module_),
517
- llvm::PointerType::getUnqual (ctx_), llvm::Type::getInt64Ty (ctx_),
518
- llvm::Type::getInt1Ty (ctx_)),
511
+ getvalue_type ({sort_category::Int, 0 }, module_), ptr_ty,
512
+ llvm::Type::getInt64Ty (ctx_), llvm::Type::getInt1Ty (ctx_)),
519
513
{ptr, llvm::ConstantInt::get (llvm::Type::getInt64Ty (ctx_), cat.bits ),
520
514
llvm::ConstantInt::getFalse (ctx_)},
521
515
" hook_MINT_uvalue" , current_block_);
@@ -565,9 +559,8 @@ llvm::Value *create_term::create_hook(
565
559
auto *result = llvm::CallInst::Create (
566
560
get_or_insert_function (
567
561
module_, " hook_MINT_import" ,
568
- getvalue_type ({sort_category::Int, 0 }, module_),
569
- llvm::PointerType::getUnqual (ctx_), llvm::Type::getInt64Ty (ctx_),
570
- llvm::Type::getInt1Ty (ctx_)),
562
+ getvalue_type ({sort_category::Int, 0 }, module_), ptr_ty,
563
+ llvm::Type::getInt64Ty (ctx_), llvm::Type::getInt1Ty (ctx_)),
571
564
{ptr, llvm::ConstantInt::get (llvm::Type::getInt64Ty (ctx_), cat.bits ),
572
565
llvm::ConstantInt::getTrue (ctx_)},
573
566
" hook_MINT_svalue" , current_block_);
@@ -582,7 +575,7 @@ llvm::Value *create_term::create_hook(
582
575
auto *type = getvalue_type (cat, module_);
583
576
llvm::Instruction *ptr = llvm::CallInst::Create (
584
577
get_or_insert_function (
585
- module_, " hook_MINT_export" , llvm::PointerType::getUnqual (ctx_) ,
578
+ module_, " hook_MINT_export" , ptr_ty ,
586
579
getvalue_type ({sort_category::Int, 0 }, module_),
587
580
llvm::Type::getInt64Ty (ctx_)),
588
581
{mpz, llvm::ConstantInt::get (llvm::Type::getInt64Ty (ctx_), cat.bits )},
@@ -784,7 +777,7 @@ llvm::Value *create_term::create_function_call(
784
777
types.insert (types.begin (), alloc_sret->getType ());
785
778
return_type = llvm::Type::getVoidTy (ctx_);
786
779
} else if (collection) {
787
- return_type = llvm::PointerType::getUnqual (return_type );
780
+ return_type = llvm::PointerType::getUnqual (ctx_ );
788
781
}
789
782
790
783
llvm::FunctionType *func_type
@@ -868,8 +861,7 @@ llvm::Value *create_term::not_injection_case(
868
861
new llvm::StoreInst (child_value, child_ptr, current_block_);
869
862
}
870
863
871
- auto *block_ptr = llvm::PointerType::getUnqual (
872
- llvm::StructType::getTypeByName (module_->getContext (), block_struct));
864
+ auto *block_ptr = llvm::PointerType::getUnqual (module_->getContext ());
873
865
auto *bitcast = new llvm::BitCastInst (block, block_ptr, " " , current_block_);
874
866
if (symbol_decl->attributes ().contains (attribute_set::key::Binder)) {
875
867
auto *call = llvm::CallInst::Create (
@@ -1056,6 +1048,7 @@ bool make_function(
1056
1048
std::vector<llvm::Type *> param_types;
1057
1049
std::vector<std::string> param_names;
1058
1050
std::vector<llvm::Metadata *> debug_args;
1051
+ auto *ptr_ty = llvm::PointerType::getUnqual (module ->getContext ());
1059
1052
for (auto &entry : vars) {
1060
1053
auto *sort
1061
1054
= dynamic_cast <kore_composite_sort *>(entry.second ->get_sort ().get ());
@@ -1070,9 +1063,7 @@ bool make_function(
1070
1063
case sort_category::Map:
1071
1064
case sort_category::RangeMap:
1072
1065
case sort_category::List:
1073
- case sort_category::Set:
1074
- param_type = llvm::PointerType::getUnqual (param_type);
1075
- break ;
1066
+ case sort_category::Set: param_type = ptr_ty; break ;
1076
1067
default : break ;
1077
1068
}
1078
1069
@@ -1086,9 +1077,7 @@ bool make_function(
1086
1077
case sort_category::Map:
1087
1078
case sort_category::RangeMap:
1088
1079
case sort_category::List:
1089
- case sort_category::Set:
1090
- return_type = llvm::PointerType::getUnqual (return_type);
1091
- break ;
1080
+ case sort_category::Set: return_type = ptr_ty; break ;
1092
1081
default : break ;
1093
1082
}
1094
1083
llvm::FunctionType *func_type
@@ -1203,7 +1192,7 @@ std::string make_apply_rule_function(
1203
1192
case sort_category::RangeMap:
1204
1193
case sort_category::List:
1205
1194
case sort_category::Set:
1206
- param_type = llvm::PointerType::getUnqual (param_type );
1195
+ param_type = llvm::PointerType::getUnqual (module -> getContext () );
1207
1196
break ;
1208
1197
default : break ;
1209
1198
}
0 commit comments