Skip to content

Commit

Permalink
fix clang tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
Dwight Guth committed Mar 11, 2024
1 parent 9a6eb10 commit 272fbb8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 56 deletions.
2 changes: 1 addition & 1 deletion lib/ast/definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void kore_definition::insert_reserved_symbols() {
decl->get_symbol()->add_argument(kitem);
mod->add_declaration(std::move(decl));

for (auto cat : hooked_sorts_) {
for (auto const &cat : hooked_sorts_) {
switch (cat.first.cat) {
case sort_category::Map:
case sort_category::List:
Expand Down
5 changes: 3 additions & 2 deletions lib/codegen/Decision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,8 @@ std::pair<std::vector<llvm::Value *>, llvm::BasicBlock *> step_function_header(
{zero, llvm::ConstantInt::get(
llvm::Type::getInt64Ty(module->getContext()), i)},
"", collect);
llvm::Value *is_block, *are_block_ptr;
llvm::Value *is_block = nullptr;
llvm::Value *are_block_ptr = nullptr;
switch (types[i].cat) {
case sort_category::Map:
is_block = llvm::CallInst::Create(
Expand Down Expand Up @@ -1138,7 +1139,7 @@ std::pair<std::vector<llvm::Value *>, llvm::BasicBlock *> step_function_header(
i = 0;
std::vector<llvm::Value *> phis;
for (auto [ptr, pointee_ty] : root_ptrs) {
llvm::Value *loaded;
llvm::Value *loaded = nullptr;
switch (types[i].cat) {
case sort_category::Map:
loaded = llvm::CallInst::Create(
Expand Down
98 changes: 45 additions & 53 deletions runtime/collect/collect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,107 +340,99 @@ bool is_collection() {
}

bool store_map_for_gc(void **roots, map *ptr) {
if (get_arena_semispace_id_of_object(ptr) == ALWAYSGCSPACE_ID) {
void *mem = kore_alloc(sizeof(blockheader) + sizeof(map));
blockheader *hdr = (blockheader *)mem;
std::string name = "rawCollection_"
+ std::to_string((int)kllvm::sort_category::Map) + "{}";
*hdr = get_block_header_for_symbol(get_tag_for_symbol_name(name.c_str()));
map *child = (map *)(hdr + 1);
*child = *ptr;
*roots = mem;
return true;
} else {
if (get_arena_semispace_id_of_object(ptr) != ALWAYSGCSPACE_ID) {
*roots = ptr;
return false;
}
void *mem = kore_alloc(sizeof(blockheader) + sizeof(map));
auto *hdr = (blockheader *)mem;
std::string name = "rawCollection_"
+ std::to_string((int)kllvm::sort_category::Map) + "{}";
*hdr = get_block_header_for_symbol(get_tag_for_symbol_name(name.c_str()));
auto *child = (map *)(hdr + 1);
*child = *ptr;
*roots = mem;
return true;
}

bool store_set_for_gc(void **roots, set *ptr) {
if (get_arena_semispace_id_of_object(ptr) == ALWAYSGCSPACE_ID) {
void *mem = kore_alloc(sizeof(blockheader) + sizeof(set));
blockheader *hdr = (blockheader *)mem;
std::string name = "rawCollection_"
+ std::to_string((int)kllvm::sort_category::Set) + "{}";
*hdr = get_block_header_for_symbol(get_tag_for_symbol_name(name.c_str()));
set *child = (set *)(hdr + 1);
*child = *ptr;
*roots = mem;
return true;
} else {
if (get_arena_semispace_id_of_object(ptr) != ALWAYSGCSPACE_ID) {
*roots = ptr;
return false;
}
void *mem = kore_alloc(sizeof(blockheader) + sizeof(set));
auto *hdr = (blockheader *)mem;
std::string name = "rawCollection_"
+ std::to_string((int)kllvm::sort_category::Set) + "{}";
*hdr = get_block_header_for_symbol(get_tag_for_symbol_name(name.c_str()));
auto *child = (set *)(hdr + 1);
*child = *ptr;
*roots = mem;
return true;
}

bool store_list_for_gc(void **roots, list *ptr) {
if (get_arena_semispace_id_of_object(ptr) == ALWAYSGCSPACE_ID) {
void *mem = kore_alloc(sizeof(blockheader) + sizeof(list));
blockheader *hdr = (blockheader *)mem;
std::string name = "rawCollection_"
+ std::to_string((int)kllvm::sort_category::List) + "{}";
*hdr = get_block_header_for_symbol(get_tag_for_symbol_name(name.c_str()));
list *child = (list *)(hdr + 1);
*child = *ptr;
*roots = mem;
return true;
} else {
if (get_arena_semispace_id_of_object(ptr) != ALWAYSGCSPACE_ID) {
*roots = ptr;
return false;
}
void *mem = kore_alloc(sizeof(blockheader) + sizeof(list));
auto *hdr = (blockheader *)mem;
std::string name = "rawCollection_"
+ std::to_string((int)kllvm::sort_category::List) + "{}";
*hdr = get_block_header_for_symbol(get_tag_for_symbol_name(name.c_str()));
auto *child = (list *)(hdr + 1);
*child = *ptr;
*roots = mem;
return true;
}

bool store_rangemap_for_gc(void **roots, rangemap *ptr) {
if (get_arena_semispace_id_of_object(ptr) == ALWAYSGCSPACE_ID) {
void *mem = kore_alloc(sizeof(blockheader) + sizeof(rangemap));
blockheader *hdr = (blockheader *)mem;
std::string name = "rawCollection_"
+ std::to_string((int)kllvm::sort_category::RangeMap)
+ "{}";
*hdr = get_block_header_for_symbol(get_tag_for_symbol_name(name.c_str()));
rangemap *child = (rangemap *)(hdr + 1);
*child = *ptr;
*roots = mem;
return true;
} else {
if (get_arena_semispace_id_of_object(ptr) != ALWAYSGCSPACE_ID) {
*roots = ptr;
return false;
}
void *mem = kore_alloc(sizeof(blockheader) + sizeof(rangemap));
auto *hdr = (blockheader *)mem;
std::string name = "rawCollection_"
+ std::to_string((int)kllvm::sort_category::RangeMap)
+ "{}";
*hdr = get_block_header_for_symbol(get_tag_for_symbol_name(name.c_str()));
auto *child = (rangemap *)(hdr + 1);
*child = *ptr;
*roots = mem;
return true;
}

map *load_map_for_gc(void **roots, bool is_block) {
void *mem = *roots;
if (is_block) {
return (map *)(((char *)mem) + 8);
} else {
return (map *)mem;
}
return (map *)mem;
}

set *load_set_for_gc(void **roots, bool is_block) {
void *mem = *roots;
if (is_block) {
return (set *)(((char *)mem) + 8);
} else {
return (set *)mem;
}
return (set *)mem;
}

list *load_list_for_gc(void **roots, bool is_block) {
void *mem = *roots;
if (is_block) {
return (list *)(((char *)mem) + 8);
} else {
return (list *)mem;
}
return (list *)mem;
}

rangemap *load_rangemap_for_gc(void **roots, bool is_block) {
void *mem = *roots;
if (is_block) {
return (rangemap *)(((char *)mem) + 8);
} else {
return (rangemap *)mem;
}
return (rangemap *)mem;
}
}

0 comments on commit 272fbb8

Please sign in to comment.