Skip to content

Commit

Permalink
[misc] Remove namespace macros (#6154)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
lin-hitonami and pre-commit-ci[bot] authored Sep 24, 2022
1 parent 114a16b commit 31f33df
Show file tree
Hide file tree
Showing 455 changed files with 930 additions and 1,477 deletions.
6 changes: 2 additions & 4 deletions c_api/src/taichi_llvm_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

#include "taichi_core_impl.h"

namespace taichi {
namespace lang {
namespace taichi::lang {
class LlvmRuntimeExecutor;
class MemoryPool;
struct CompileConfig;
} // namespace lang
} // namespace taichi
} // namespace taichi::lang

namespace capi {

Expand Down
1 change: 0 additions & 1 deletion docs/lang/articles/contribution/contributor_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,6 @@ Below we highlight some of the most widely used styles.
- Constant names should use the camel case, with a prefix `k`, for example, `constexpr int kTaichiMaxNumArgs = 64;`.
- Macros should start with `TI_`, for example, `TI_NOT_IMPLEMENTED`.
- In general, avoid using macros as much as possible.
- Avoid using `TI_NAMESPACE_BEGIN/END` in the new code.

### Rule of thumbs

Expand Down
4 changes: 2 additions & 2 deletions taichi/analysis/alias_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "taichi/ir/analysis.h"
#include "taichi/ir/statements.h"

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

namespace irpass::analysis {

Expand Down Expand Up @@ -168,4 +168,4 @@ bool maybe_same_address(Stmt *var1, Stmt *var2) {

} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
6 changes: 2 additions & 4 deletions taichi/analysis/arithmetic_interpretor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
#include "taichi/ir/type_utils.h"
#include "taichi/ir/visitors.h"

namespace taichi {
namespace lang {
namespace taichi::lang {
namespace {

using CodeRegion = ArithmeticInterpretor::CodeRegion;
Expand Down Expand Up @@ -180,5 +179,4 @@ std::optional<TypedConstant> ArithmeticInterpretor::evaluate(
return ev.run(region, init_ctx);
}

} // namespace lang
} // namespace taichi
} // namespace taichi::lang
6 changes: 2 additions & 4 deletions taichi/analysis/arithmetic_interpretor.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
#include "taichi/ir/statements.h"
#include "taichi/ir/type.h"

namespace taichi {
namespace lang {
namespace taichi::lang {

/**
* Interprets a sequence of CHI IR statements within a block (acts like a
Expand Down Expand Up @@ -96,5 +95,4 @@ class ArithmeticInterpretor {
const EvalContext &init_ctx) const;
};

} // namespace lang
} // namespace taichi
} // namespace taichi::lang
6 changes: 2 additions & 4 deletions taichi/analysis/bls_analyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include "taichi/system/profiler.h"
#include "taichi/ir/analysis.h"

namespace taichi {
namespace lang {
namespace taichi::lang {

BLSAnalyzer::BLSAnalyzer(OffloadedStmt *for_stmt, ScratchPads *pads)
: for_stmt_(for_stmt), pads_(pads) {
Expand Down Expand Up @@ -106,5 +105,4 @@ bool BLSAnalyzer::run() {
return analysis_ok_;
}

} // namespace lang
} // namespace taichi
} // namespace taichi::lang
6 changes: 2 additions & 4 deletions taichi/analysis/bls_analyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
#include "taichi/ir/statements.h"
#include "taichi/ir/scratch_pad.h"

namespace taichi {
namespace lang {
namespace taichi::lang {

// Figure out accessed SNodes, and their ranges in this for stmt
class BLSAnalyzer : public BasicStmtVisitor {
Expand Down Expand Up @@ -56,5 +55,4 @@ class BLSAnalyzer : public BasicStmtVisitor {
bool analysis_ok_{true};
};

} // namespace lang
} // namespace taichi
} // namespace taichi::lang
12 changes: 4 additions & 8 deletions taichi/analysis/build_cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#include "taichi/ir/statements.h"
#include "taichi/program/function.h"

namespace taichi {
namespace lang {
namespace taichi::lang {

struct CFGFuncKey {
FunctionKey func_key{"", -1, -1};
Expand All @@ -16,8 +15,7 @@ struct CFGFuncKey {
}
};

} // namespace lang
} // namespace taichi
} // namespace taichi::lang

namespace std {
template <>
Expand All @@ -29,8 +27,7 @@ struct hash<taichi::lang::CFGFuncKey> {
};
} // namespace std

namespace taichi {
namespace lang {
namespace taichi::lang {

/**
* Build a control-flow graph. The resulting graph is guaranteed to have an
Expand Down Expand Up @@ -460,5 +457,4 @@ std::unique_ptr<ControlFlowGraph> build_cfg(IRNode *root) {
}
} // namespace irpass::analysis

} // namespace lang
} // namespace taichi
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/check_fields_registered.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "taichi/ir/analysis.h"
#include "taichi/ir/visitors.h"

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

class FieldsRegisteredChecker : public BasicStmtVisitor {
public:
Expand Down Expand Up @@ -33,4 +33,4 @@ void check_fields_registered(IRNode *root) {
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/clone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include <unordered_map>

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

class IRCloner : public IRVisitor {
private:
Expand Down Expand Up @@ -139,4 +139,4 @@ std::unique_ptr<IRNode> clone(IRNode *root, Kernel *kernel) {
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/constexpr_propagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <unordered_set>
#include <functional>

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

namespace {

Expand Down Expand Up @@ -106,4 +106,4 @@ std::unordered_set<Stmt *> constexpr_prop(
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/count_statements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "taichi/ir/analysis.h"
#include "taichi/ir/visitors.h"

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

// Count all statements (including containers)
class StmtCounter : public BasicStmtVisitor {
Expand Down Expand Up @@ -41,4 +41,4 @@ int count_statements(IRNode *root) {
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/data_source_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "taichi/ir/analysis.h"
#include "taichi/ir/statements.h"

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

namespace irpass::analysis {

Expand Down Expand Up @@ -77,4 +77,4 @@ std::vector<Stmt *> get_store_destination(Stmt *store_stmt) {

} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/detect_fors_with_break.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <unordered_set>

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

class DetectForsWithBreak : public BasicStmtVisitor {
public:
Expand Down Expand Up @@ -50,4 +50,4 @@ std::unordered_set<Stmt *> detect_fors_with_break(IRNode *root) {
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/gather_deactivations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "taichi/ir/statements.h"
#include "taichi/ir/visitors.h"

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

class GatherDeactivations : public BasicStmtVisitor {
public:
Expand Down Expand Up @@ -36,4 +36,4 @@ std::unordered_set<SNode *> gather_deactivations(IRNode *root) {
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/gather_mesh_thread_local.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "taichi/ir/analysis.h"
#include "taichi/ir/statements.h"

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

using MeshElementTypeSet = std::unordered_set<mesh::MeshElementType>;

Expand Down Expand Up @@ -79,4 +79,4 @@ gather_mesh_thread_local(OffloadedStmt *offload, const CompileConfig &config) {

} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/gather_meshfor_relation_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "taichi/ir/analysis.h"
#include "taichi/ir/statements.h"

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

namespace irpass::analysis {

Expand Down Expand Up @@ -62,4 +62,4 @@ void gather_meshfor_relation_types(IRNode *node) {

} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/gather_snode_read_writes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "taichi/ir/analysis.h"
#include "taichi/ir/statements.h"

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

namespace irpass::analysis {

Expand Down Expand Up @@ -40,4 +40,4 @@ gather_snode_read_writes(IRNode *root) {
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/gather_statements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "taichi/ir/analysis.h"
#include "taichi/ir/visitors.h"

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

class StmtSearcher : public BasicStmtVisitor {
private:
Expand Down Expand Up @@ -37,4 +37,4 @@ std::vector<Stmt *> gather_statements(IRNode *root,
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/gather_uniquely_accessed_pointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "taichi/ir/visitors.h"
#include <algorithm>

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

class LoopUniqueStmtSearcher : public BasicStmtVisitor {
private:
Expand Down Expand Up @@ -385,4 +385,4 @@ void gather_uniquely_accessed_bit_structs(IRNode *root, AnalysisManager *amgr) {
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
6 changes: 2 additions & 4 deletions taichi/analysis/gather_uniquely_accessed_pointers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

#include "taichi/ir/pass.h"

namespace taichi {
namespace lang {
namespace taichi::lang {

class GatherUniquelyAccessedBitStructsPass : public Pass {
public:
Expand All @@ -16,5 +15,4 @@ class GatherUniquelyAccessedBitStructsPass : public Pass {
};
};

} // namespace lang
} // namespace taichi
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/gather_used_atomics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "taichi/ir/visitors.h"
#include <unordered_set>

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

class UsedAtomicsSearcher : public BasicStmtVisitor {
private:
Expand Down Expand Up @@ -49,4 +49,4 @@ std::unique_ptr<std::unordered_set<AtomicOpStmt *>> gather_used_atomics(
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
6 changes: 2 additions & 4 deletions taichi/analysis/gen_offline_cache_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
#include "taichi/program/function.h"
#include "taichi/program/program.h"

namespace taichi {
namespace lang {
namespace taichi::lang {

namespace {

Expand Down Expand Up @@ -656,5 +655,4 @@ void gen_offline_cache_key(Program *prog, IRNode *ast, std::ostream *os) {
ASTSerializer::run(prog, ast, os);
}

} // namespace lang
} // namespace taichi
} // namespace taichi::lang
4 changes: 2 additions & 2 deletions taichi/analysis/has_store_or_atomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "taichi/ir/statements.h"
#include "taichi/ir/visitors.h"

TLANG_NAMESPACE_BEGIN
namespace taichi::lang {

// Find if there is a store (or AtomicOpStmt).
class LocalStoreSearcher : public BasicStmtVisitor {
Expand Down Expand Up @@ -54,4 +54,4 @@ bool has_store_or_atomic(IRNode *root, const std::vector<Stmt *> &vars) {
}
} // namespace irpass::analysis

TLANG_NAMESPACE_END
} // namespace taichi::lang
Loading

0 comments on commit 31f33df

Please sign in to comment.