Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-Leo-Smith committed Feb 10, 2025
1 parent acf4da9 commit 0e75c1a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
9 changes: 1 addition & 8 deletions include/luisa/xir/builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,8 @@ class LC_XIR_API Builder {
Instruction *_insertion_point = nullptr;

private:
void _check_valid_insertion_point() const noexcept;

template<typename T, typename... Args>
[[nodiscard]] auto _create_and_append_instruction(Args &&...args) noexcept {
_check_valid_insertion_point();
auto inst = _pool->create<T>(std::forward<Args>(args)...);
append(inst);
return inst;
}
[[nodiscard]] auto _create_and_append_instruction(Args &&...args) noexcept -> T *;

public:
Builder() noexcept;
Expand Down
10 changes: 7 additions & 3 deletions src/xir/builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@

namespace luisa::compute::xir {

void Builder::_check_valid_insertion_point() const noexcept {
Builder::Builder() noexcept = default;

template<typename T, typename... Args>
auto Builder::_create_and_append_instruction(Args &&...args) noexcept -> T * {
LUISA_DEBUG_ASSERT(_insertion_point != nullptr, "Invalid insertion point.");
LUISA_DEBUG_ASSERT(_pool != nullptr, "Invalid pool.");
auto inst = _pool->create<T>(std::forward<Args>(args)...);
append(inst);
return inst;
}

Builder::Builder() noexcept = default;

void Builder::append(Instruction *inst) noexcept {
_insertion_point->insert_after_self(inst);
set_insertion_point(inst);
Expand Down

0 comments on commit 0e75c1a

Please sign in to comment.