mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-06 15:22:16 +00:00

This patch is based on the suggestion by @ChuanqiXu on discourse (https://discourse.llvm.org/t/alternatives-to-the-implementation-of-std-modules/71958) Instead of making a module partition per header every header gets an inc file which contains the exports per header. The std module then includes all public headers and these inc files. The one file per header is useful for testing purposes. The CI tests whether the exports of a header's module partition matches the "public" named declarations in the header. With one file per header this can still be done. The patch improves compilation time of files using "import std;" and the size of the std module. A comparision of the compilation speed using a libc++ test build/bin/llvm-lit -a -Dstd=c++23 -Denable_modules=std libcxx/test/std/modules/std.pass.cpp Which boils down to import std; int main(int, char**) { std::println("Hello modular world"); return 0; } and has -ftime-report enabled Before ===-------------------------------------------------------------------------=== Clang front-end time report ===-------------------------------------------------------------------------=== Total Execution Time: 8.6585 seconds (8.6619 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 4.5041 ( 57.2%) 0.4264 ( 54.4%) 4.9305 ( 56.9%) 4.9331 ( 57.0%) Clang front-end timer 3.2037 ( 40.7%) 0.2408 ( 30.7%) 3.4445 ( 39.8%) 3.4452 ( 39.8%) Reading modules 0.1665 ( 2.1%) 0.1170 ( 14.9%) 0.2835 ( 3.3%) 0.2837 ( 3.3%) Loading .../build/test/__config_module__/CMakeFiles/std.dir/std.pcm 7.8744 (100.0%) 0.7842 (100.0%) 8.6585 (100.0%) 8.6619 (100.0%) Total After ===-------------------------------------------------------------------------=== Clang front-end time report ===-------------------------------------------------------------------------=== Total Execution Time: 1.2420 seconds (1.2423 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 0.8892 ( 84.6%) 0.1698 ( 88.8%) 1.0590 ( 85.3%) 1.0590 ( 85.2%) Clang front-end timer 0.1533 ( 14.6%) 0.0168 ( 8.8%) 0.1701 ( 13.7%) 0.1704 ( 13.7%) Reading modules 0.0082 ( 0.8%) 0.0047 ( 2.5%) 0.0129 ( 1.0%) 0.0129 ( 1.0%) Loading .../build/test/__config_module__/CMakeFiles/std.dir/std.pcm 1.0507 (100.0%) 0.1913 (100.0%) 1.2420 (100.0%) 1.2423 (100.0%) Total Using "include <print>" instead of "import module;" ===-------------------------------------------------------------------------=== Clang front-end time report ===-------------------------------------------------------------------------=== Total Execution Time: 2.1507 seconds (2.1517 wall clock) ---User Time--- --System Time-- --User+System-- ---Wall Time--- --- Name --- 1.9714 (100.0%) 0.1793 (100.0%) 2.1507 (100.0%) 2.1517 (100.0%) Clang front-end timer 1.9714 (100.0%) 0.1793 (100.0%) 2.1507 (100.0%) 2.1517 (100.0%) Total It's possible to use the std module in external projects (https://libcxx.llvm.org/Modules.html#using-in-external-projects) Tested this with a private project to validate the size of the generated files: Before $ du -sch std-* 448M std-build 508K std-src 120K std-subbuild 449M total After $ du -sch std-* 29M std-build 1004K std-src 132K std-subbuild 30M total Reviewed By: ldionne, #libc Differential Revision: https://reviews.llvm.org/D156907
618 lines
12 KiB
C++
618 lines
12 KiB
C++
// -*- C++ -*-
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
export namespace std {
|
|
namespace ranges {
|
|
// [algorithms.results], algorithm result types
|
|
using std::ranges::in_found_result;
|
|
using std::ranges::in_fun_result;
|
|
using std::ranges::in_in_out_result;
|
|
using std::ranges::in_in_result;
|
|
using std::ranges::in_out_out_result;
|
|
using std::ranges::in_out_result;
|
|
// using std::ranges::in_value_result;
|
|
using std::ranges::min_max_result;
|
|
// using std::ranges::out_value_result;
|
|
} // namespace ranges
|
|
|
|
// [alg.nonmodifying], non-modifying sequence operations
|
|
// [alg.all.of], all of
|
|
using std::all_of;
|
|
namespace ranges {
|
|
using std::ranges::all_of;
|
|
}
|
|
|
|
// [alg.any.of], any of
|
|
using std::any_of;
|
|
namespace ranges {
|
|
using std::ranges::any_of;
|
|
}
|
|
|
|
// [alg.none.of], none of
|
|
using std::none_of;
|
|
namespace ranges {
|
|
using std::ranges::none_of;
|
|
}
|
|
|
|
// [alg.contains], contains
|
|
#if 0
|
|
namespace ranges {
|
|
using std::ranges::contains;
|
|
using std::ranges::contains_subrange;
|
|
} // namespace ranges
|
|
#endif
|
|
|
|
// [alg.foreach], for each
|
|
using std::for_each;
|
|
|
|
namespace ranges {
|
|
using std::ranges::for_each;
|
|
using std::ranges::for_each_result;
|
|
} // namespace ranges
|
|
|
|
using std::for_each_n;
|
|
|
|
namespace ranges {
|
|
using std::ranges::for_each_n_result;
|
|
|
|
using std::ranges::for_each_n;
|
|
} // namespace ranges
|
|
|
|
// [alg.find], find
|
|
using std::find;
|
|
using std::find_if;
|
|
using std::find_if_not;
|
|
|
|
namespace ranges {
|
|
using std::ranges::find;
|
|
using std::ranges::find_if;
|
|
using std::ranges::find_if_not;
|
|
} // namespace ranges
|
|
|
|
namespace ranges {
|
|
#if 0
|
|
using std::ranges::find_last;
|
|
using std::ranges::find_last_if;
|
|
using std::ranges::find_last_if_not;
|
|
#endif
|
|
} // namespace ranges
|
|
|
|
// [alg.find.end], find end
|
|
using std::find_end;
|
|
|
|
namespace ranges {
|
|
using std::ranges::find_end;
|
|
}
|
|
|
|
// [alg.find.first.of], find first
|
|
using std::find_first_of;
|
|
|
|
namespace ranges {
|
|
using std::ranges::find_first_of;
|
|
}
|
|
|
|
// [alg.adjacent.find], adjacent find
|
|
using std::adjacent_find;
|
|
|
|
namespace ranges {
|
|
using std::ranges::adjacent_find;
|
|
}
|
|
|
|
// [alg.count], count
|
|
using std::count;
|
|
using std::count_if;
|
|
|
|
namespace ranges {
|
|
using std::ranges::count;
|
|
using std::ranges::count_if;
|
|
} // namespace ranges
|
|
|
|
// [mismatch], mismatch
|
|
using std::mismatch;
|
|
|
|
namespace ranges {
|
|
using std::ranges::mismatch_result;
|
|
|
|
using std::ranges::mismatch;
|
|
} // namespace ranges
|
|
|
|
// [alg.equal], equal
|
|
using std::equal;
|
|
|
|
namespace ranges {
|
|
using std::ranges::equal;
|
|
}
|
|
|
|
// [alg.is.permutation], is permutation
|
|
using std::is_permutation;
|
|
|
|
namespace ranges {
|
|
using std::ranges::is_permutation;
|
|
}
|
|
|
|
// [alg.search], search
|
|
using std::search;
|
|
|
|
namespace ranges {
|
|
using std::ranges::search;
|
|
}
|
|
|
|
using std::search_n;
|
|
|
|
namespace ranges {
|
|
using std::ranges::search_n;
|
|
}
|
|
|
|
namespace ranges {
|
|
// [alg.starts.with], starts with
|
|
using std::ranges::starts_with;
|
|
|
|
#if 0
|
|
// [alg.ends.with], ends with
|
|
using std::ranges::ends_with;
|
|
|
|
// [alg.fold], fold
|
|
using std::ranges::fold_left;
|
|
using std::ranges::fold_left_first;
|
|
using std::ranges::fold_right;
|
|
using std::ranges::fold_right_last;
|
|
using std::ranges::fold_left_with_iter;
|
|
using std::ranges::fold_left_with_iter_result;
|
|
using std::ranges::fold_left_with_iter;
|
|
using std::ranges::fold_left_first_with_iter;
|
|
using std::ranges::fold_left_first_with_iter;
|
|
#endif
|
|
} // namespace ranges
|
|
|
|
// [alg.modifying.operations], mutating sequence operations
|
|
// [alg.copy], copy
|
|
using std::copy;
|
|
|
|
namespace ranges {
|
|
using std::ranges::copy;
|
|
using std::ranges::copy_result;
|
|
} // namespace ranges
|
|
|
|
using std::copy_n;
|
|
|
|
namespace ranges {
|
|
using std::ranges::copy_n;
|
|
using std::ranges::copy_n_result;
|
|
} // namespace ranges
|
|
|
|
using std::copy_if;
|
|
|
|
namespace ranges {
|
|
using std::ranges::copy_if;
|
|
using std::ranges::copy_if_result;
|
|
} // namespace ranges
|
|
|
|
using std::copy_backward;
|
|
|
|
namespace ranges {
|
|
using std::ranges::copy_backward;
|
|
using std::ranges::copy_backward_result;
|
|
} // namespace ranges
|
|
|
|
// [alg.move], move
|
|
using std::move;
|
|
|
|
namespace ranges {
|
|
using std::ranges::move;
|
|
using std::ranges::move_result;
|
|
} // namespace ranges
|
|
|
|
using std::move_backward;
|
|
|
|
namespace ranges {
|
|
using std::ranges::move_backward;
|
|
using std::ranges::move_backward_result;
|
|
} // namespace ranges
|
|
|
|
// [alg.swap], swap
|
|
using std::swap_ranges;
|
|
|
|
namespace ranges {
|
|
using std::ranges::swap_ranges;
|
|
using std::ranges::swap_ranges_result;
|
|
} // namespace ranges
|
|
|
|
using std::iter_swap;
|
|
|
|
// [alg.transform], transform
|
|
using std::transform;
|
|
|
|
namespace ranges {
|
|
using std::ranges::binary_transform_result;
|
|
using std::ranges::unary_transform_result;
|
|
|
|
using std::ranges::transform;
|
|
|
|
} // namespace ranges
|
|
|
|
using std::replace;
|
|
using std::replace_if;
|
|
|
|
namespace ranges {
|
|
using std::ranges::replace;
|
|
using std::ranges::replace_if;
|
|
} // namespace ranges
|
|
|
|
using std::replace_copy;
|
|
using std::replace_copy_if;
|
|
|
|
namespace ranges {
|
|
using std::ranges::replace_copy;
|
|
using std::ranges::replace_copy_if;
|
|
using std::ranges::replace_copy_if_result;
|
|
using std::ranges::replace_copy_result;
|
|
} // namespace ranges
|
|
|
|
// [alg.fill], fill
|
|
using std::fill;
|
|
using std::fill_n;
|
|
|
|
namespace ranges {
|
|
using std::ranges::fill;
|
|
using std::ranges::fill_n;
|
|
} // namespace ranges
|
|
|
|
// [alg.generate], generate
|
|
using std::generate;
|
|
using std::generate_n;
|
|
|
|
namespace ranges {
|
|
using std::ranges::generate;
|
|
using std::ranges::generate_n;
|
|
} // namespace ranges
|
|
|
|
// [alg.remove], remove
|
|
using std::remove;
|
|
using std::remove_if;
|
|
|
|
namespace ranges {
|
|
using std::ranges::remove;
|
|
using std::ranges::remove_if;
|
|
} // namespace ranges
|
|
|
|
using std::remove_copy;
|
|
using std::remove_copy_if;
|
|
namespace ranges {
|
|
using std::ranges::remove_copy;
|
|
using std::ranges::remove_copy_if;
|
|
using std::ranges::remove_copy_if_result;
|
|
using std::ranges::remove_copy_result;
|
|
} // namespace ranges
|
|
|
|
// [alg.unique], unique
|
|
using std::unique;
|
|
|
|
namespace ranges {
|
|
using std::ranges::unique;
|
|
}
|
|
|
|
using std::unique_copy;
|
|
|
|
namespace ranges {
|
|
using std::ranges::unique_copy;
|
|
using std::ranges::unique_copy_result;
|
|
} // namespace ranges
|
|
|
|
// [alg.reverse], reverse
|
|
using std::reverse;
|
|
|
|
namespace ranges {
|
|
using std::ranges::reverse;
|
|
}
|
|
|
|
using std::reverse_copy;
|
|
|
|
namespace ranges {
|
|
using std::ranges::reverse_copy;
|
|
using std::ranges::reverse_copy_result;
|
|
} // namespace ranges
|
|
|
|
// [alg.rotate], rotate
|
|
using std::rotate;
|
|
|
|
namespace ranges {
|
|
using std::ranges::rotate;
|
|
}
|
|
|
|
using std::rotate_copy;
|
|
|
|
namespace ranges {
|
|
using std::ranges::rotate_copy;
|
|
using std::ranges::rotate_copy_result;
|
|
} // namespace ranges
|
|
|
|
// [alg.random.sample], sample
|
|
using std::sample;
|
|
|
|
namespace ranges {
|
|
using std::ranges::sample;
|
|
}
|
|
|
|
// [alg.random.shuffle], shuffle
|
|
using std::shuffle;
|
|
|
|
namespace ranges {
|
|
using std::ranges::shuffle;
|
|
}
|
|
|
|
// [alg.shift], shift
|
|
using std::shift_left;
|
|
|
|
namespace ranges {
|
|
// using std::ranges::shift_left;
|
|
}
|
|
|
|
using std::shift_right;
|
|
|
|
namespace ranges {
|
|
// using std::ranges::shift_right;
|
|
}
|
|
|
|
// [alg.sorting], sorting and related operations
|
|
// [alg.sort], sorting
|
|
using std::sort;
|
|
|
|
namespace ranges {
|
|
using std::ranges::sort;
|
|
}
|
|
|
|
using std::stable_sort;
|
|
|
|
namespace ranges {
|
|
using std::ranges::stable_sort;
|
|
}
|
|
|
|
using std::partial_sort;
|
|
|
|
namespace ranges {
|
|
using std::ranges::partial_sort;
|
|
}
|
|
using std::partial_sort_copy;
|
|
|
|
namespace ranges {
|
|
using std::ranges::partial_sort_copy;
|
|
using std::ranges::partial_sort_copy_result;
|
|
} // namespace ranges
|
|
|
|
using std::is_sorted;
|
|
using std::is_sorted_until;
|
|
|
|
namespace ranges {
|
|
using std::ranges::is_sorted;
|
|
using std::ranges::is_sorted_until;
|
|
} // namespace ranges
|
|
|
|
// [alg.nth.element], Nth element
|
|
using std::nth_element;
|
|
|
|
namespace ranges {
|
|
using std::ranges::nth_element;
|
|
}
|
|
|
|
// [alg.binary.search], binary search
|
|
using std::lower_bound;
|
|
|
|
namespace ranges {
|
|
using std::ranges::lower_bound;
|
|
}
|
|
|
|
using std::upper_bound;
|
|
|
|
namespace ranges {
|
|
using std::ranges::upper_bound;
|
|
}
|
|
|
|
using std::equal_range;
|
|
|
|
namespace ranges {
|
|
using std::ranges::equal_range;
|
|
}
|
|
|
|
using std::binary_search;
|
|
|
|
namespace ranges {
|
|
using std::ranges::binary_search;
|
|
}
|
|
|
|
// [alg.partitions], partitions
|
|
using std::is_partitioned;
|
|
|
|
namespace ranges {
|
|
using std::ranges::is_partitioned;
|
|
}
|
|
|
|
using std::partition;
|
|
|
|
namespace ranges {
|
|
using std::ranges::partition;
|
|
}
|
|
|
|
using std::stable_partition;
|
|
|
|
namespace ranges {
|
|
using std::ranges::stable_partition;
|
|
}
|
|
|
|
using std::partition_copy;
|
|
|
|
namespace ranges {
|
|
using std::ranges::partition_copy;
|
|
using std::ranges::partition_copy_result;
|
|
} // namespace ranges
|
|
|
|
using std::partition_point;
|
|
|
|
namespace ranges {
|
|
using std::ranges::partition_point;
|
|
}
|
|
// [alg.merge], merge
|
|
using std::merge;
|
|
namespace ranges {
|
|
using std::ranges::merge;
|
|
using std::ranges::merge_result;
|
|
} // namespace ranges
|
|
|
|
using std::inplace_merge;
|
|
|
|
namespace ranges {
|
|
using std::ranges::inplace_merge;
|
|
}
|
|
|
|
// [alg.set.operations], set operations
|
|
using std::includes;
|
|
namespace ranges {
|
|
using std::ranges::includes;
|
|
}
|
|
|
|
using std::set_union;
|
|
|
|
namespace ranges {
|
|
using std::ranges::set_union;
|
|
using std::ranges::set_union_result;
|
|
} // namespace ranges
|
|
|
|
using std::set_intersection;
|
|
namespace ranges {
|
|
using std::ranges::set_intersection;
|
|
using std::ranges::set_intersection_result;
|
|
} // namespace ranges
|
|
|
|
using std::set_difference;
|
|
|
|
namespace ranges {
|
|
using std::ranges::set_difference;
|
|
using std::ranges::set_difference_result;
|
|
} // namespace ranges
|
|
|
|
using std::set_symmetric_difference;
|
|
|
|
namespace ranges {
|
|
using std::ranges::set_symmetric_difference_result;
|
|
|
|
using std::ranges::set_symmetric_difference;
|
|
} // namespace ranges
|
|
|
|
// [alg.heap.operations], heap operations
|
|
using std::push_heap;
|
|
|
|
namespace ranges {
|
|
using std::ranges::push_heap;
|
|
}
|
|
|
|
using std::pop_heap;
|
|
|
|
namespace ranges {
|
|
using std::ranges::pop_heap;
|
|
}
|
|
|
|
using std::make_heap;
|
|
|
|
namespace ranges {
|
|
using std::ranges::make_heap;
|
|
}
|
|
|
|
using std::sort_heap;
|
|
|
|
namespace ranges {
|
|
using std::ranges::sort_heap;
|
|
}
|
|
|
|
using std::is_heap;
|
|
|
|
namespace ranges {
|
|
using std::ranges::is_heap;
|
|
}
|
|
|
|
using std::is_heap_until;
|
|
|
|
namespace ranges {
|
|
using std::ranges::is_heap_until;
|
|
}
|
|
|
|
// [alg.min.max], minimum and maximum
|
|
using std::min;
|
|
|
|
namespace ranges {
|
|
using std::ranges::min;
|
|
}
|
|
|
|
using std::max;
|
|
|
|
namespace ranges {
|
|
using std::ranges::max;
|
|
}
|
|
|
|
using std::minmax;
|
|
|
|
namespace ranges {
|
|
using std::ranges::minmax_result;
|
|
|
|
using std::ranges::minmax;
|
|
} // namespace ranges
|
|
|
|
using std::min_element;
|
|
|
|
namespace ranges {
|
|
using std::ranges::min_element;
|
|
}
|
|
|
|
using std::max_element;
|
|
|
|
namespace ranges {
|
|
using std::ranges::max_element;
|
|
}
|
|
|
|
using std::minmax_element;
|
|
|
|
namespace ranges {
|
|
using std::ranges::minmax_element_result;
|
|
|
|
using std::ranges::minmax_element;
|
|
} // namespace ranges
|
|
// [alg.clamp], bounded value
|
|
using std::clamp;
|
|
|
|
namespace ranges {
|
|
using std::ranges::clamp;
|
|
}
|
|
|
|
// [alg.lex.comparison], lexicographical comparison
|
|
using std::lexicographical_compare;
|
|
|
|
namespace ranges {
|
|
using std::ranges::lexicographical_compare;
|
|
}
|
|
|
|
// [alg.three.way], three-way comparison algorithms
|
|
using std::lexicographical_compare_three_way;
|
|
|
|
// [alg.permutation.generators], permutations
|
|
using std::next_permutation;
|
|
|
|
namespace ranges {
|
|
using std::ranges::next_permutation_result;
|
|
|
|
using std::ranges::next_permutation;
|
|
} // namespace ranges
|
|
|
|
using std::prev_permutation;
|
|
|
|
namespace ranges {
|
|
using std::ranges::prev_permutation_result;
|
|
|
|
using std::ranges::prev_permutation;
|
|
} // namespace ranges
|
|
|
|
} // namespace std
|