Skip to content

Commit

Permalink
[Misc] Simplify/fix clang format. (#1214)
Browse files Browse the repository at this point in the history
  • Loading branch information
nobradovictt authored Nov 8, 2024
1 parent dca9c66 commit b288494
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 251 deletions.
226 changes: 2 additions & 224 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,224 +1,2 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: Align
AlignArrayOfStructures: None
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: true
AlignConsecutiveBitFields:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
PadOperators: false
AlignEscapedNewlines: Right
AlignOperands: Align
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
AttributeMacros:
- __capability
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAfterAttributes: Never
BreakAfterJavaFieldAnnotations: false
BreakArrays: true
BreakBeforeBinaryOperators: None
BreakBeforeConceptDeclarations: Always
BreakBeforeBraces: Attach
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
BreakStringLiterals: true
ColumnLimit: 80
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IfMacros:
- KJ_IF_MAYBE
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: '.*'
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: '(Test)?$'
IncludeIsMainSourceRegex: ''
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: false
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: None
IndentRequiresClause: true
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: false
InsertNewlineAtEOF: false
InsertTrailingCommas: None
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: BinPack
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
PPIndentWidth: -1
QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveSemicolon: false
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SortIncludes: CaseSensitive
SortJavaStaticImport: Before
SortUsingDeclarations: LexicographicNumeric
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInConditionalStatement: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Latest
StatementAttributeLikeMacros:
- Q_EMIT
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8
UseTab: Never
WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
...
BasedOnStyle: LLVM
AlwaysBreakTemplateDeclarations: Yes
6 changes: 3 additions & 3 deletions include/ttmlir/Dialect/TT/Utils/MemoryLayoutAnalysisParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//
// SPDX-License-Identifier: Apache-2.0

#ifndef TTMLIR_DIALECT_TT_UTILS_MEMORYLAYOUTANALYSIS_H
#define TTMLIR_DIALECT_TT_UTILS_MEMORYLAYOUTANALYSIS_H
#ifndef TTMLIR_DIALECT_TT_UTILS_MEMORYLAYOUTANALYSISPARAMS_H
#define TTMLIR_DIALECT_TT_UTILS_MEMORYLAYOUTANALYSISPARAMS_H

#include <llvm/ADT/StringSwitch.h>
#include <llvm/Support/CommandLine.h>
Expand Down Expand Up @@ -44,4 +44,4 @@ struct MemoryLayoutAnalysisPolicyTypeParser

} // namespace mlir::tt

#endif // TTMLIR_DIALECT_TT_UTILS_MEMORYLAYOUTANALYSIS_H
#endif // TTMLIR_DIALECT_TT_UTILS_MEMORYLAYOUTANALYSISPARAMS_H
3 changes: 2 additions & 1 deletion include/ttmlir/Dialect/TT/Utils/PhysicalCoreCoord.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ class PhysicalCoreCoordMapping {

// Make PhysicalCoreCoord hashable.
namespace llvm {
template <> struct DenseMapInfo<mlir::tt::PhysicalCoreCoord> {
template <>
struct DenseMapInfo<mlir::tt::PhysicalCoreCoord> {
static mlir::tt::PhysicalCoreCoord getEmptyKey() {
return mlir::tt::PhysicalCoreCoord{-1, -1, -1};
}
Expand Down
3 changes: 2 additions & 1 deletion include/ttmlir/Dialect/TTNN/Analysis/Edge.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ struct Edge {
} // namespace mlir::tt::ttnn

namespace std {
template <> struct hash<mlir::tt::ttnn::Edge> {
template <>
struct hash<mlir::tt::ttnn::Edge> {
size_t operator()(const mlir::tt::ttnn::Edge &edge) const noexcept {
llvm::hash_code code = llvm::hash_value(edge.operandIndex);
code = llvm::hash_combine(code, edge.producerOp);
Expand Down
1 change: 0 additions & 1 deletion include/ttmlir/Dialect/TTNN/Analysis/ShardSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "ttmlir/Dialect/TTNN/Analysis/Edge.h"
#include <algorithm>
#include <bitset>
#include <llvm/ADT/StringMap.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
Expand Down
3 changes: 2 additions & 1 deletion include/ttmlir/Dialect/TTNN/Analysis/TTNNAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
namespace mlir::tt::ttnn {
// Base class for all TTNN analyses.
//
template <class I, class R> class TTNNAnalysis {
template <class I, class R>
class TTNNAnalysis {
protected:
Operation *op;
bool isValid = false;
Expand Down
5 changes: 2 additions & 3 deletions include/ttmlir/Dialect/TTNN/Utils/OptimizerOverrides.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
//
// SPDX-License-Identifier: Apache-2.0

#ifndef TTMLIR_DIALECT_TT_UTILS_OVERRIDEPARAMS_H
#define TTMLIR_DIALECT_TT_UTILS_OVERRIDEPARAMS_H
#ifndef TTMLIR_DIALECT_TTNN_UTILS_OPTIMIZEROVERRIDES_H
#define TTMLIR_DIALECT_TTNN_UTILS_OPTIMIZEROVERRIDES_H

#include "ttmlir/Dialect/TT/IR/TTOpsTypes.h"
#include "ttmlir/Dialect/TTNN/IR/TTNNOpsAttrs.h"
#include <cstdint>
#include <llvm/Support/CommandLine.h>

namespace mlir::tt::ttnn {
Expand Down
6 changes: 4 additions & 2 deletions include/ttmlir/Target/Utils/FlatbufferObjectCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ struct FlatbufferObjectCache {

FlatbufferObjectCache(::flatbuffers::FlatBufferBuilder *fbb) : fbb(fbb) {}

template <typename T> struct offset_extract_t;
template <typename T>
struct offset_extract_t;
template <template <typename> typename OffsetT, typename T>
struct offset_extract_t<OffsetT<T>> {
using type = T;
};

uint32_t nextGlobalId() { return global_id++; }

template <typename MLIRTypeOrAttr> bool exists(MLIRTypeOrAttr obj) const {
template <typename MLIRTypeOrAttr>
bool exists(MLIRTypeOrAttr obj) const {
return objectMap.contains(obj.getAsOpaquePointer());
}

Expand Down
3 changes: 2 additions & 1 deletion include/ttmlir/Target/Utils/FuncOpToProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

namespace mlir::tt {

template <typename OpT> struct Program {
template <typename OpT>
struct Program {
::flatbuffers::FlatBufferBuilder *fbb;
const char *name;
std::vector<::flatbuffers::Offset<::tt::target::TensorRef>> inputs;
Expand Down
9 changes: 6 additions & 3 deletions include/ttmlir/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
#include "llvm/ADT/SmallVector.h"

namespace ttmlir::utils {
template <typename T> T alignUp(T ptr, T alignment) {
template <typename T>
T alignUp(T ptr, T alignment) {
return (ptr + alignment - 1) & ~(alignment - 1);
}

template <typename T> T alignDown(T ptr, T alignment) {
template <typename T>
T alignDown(T ptr, T alignment) {
return ptr & ~(alignment - 1);
}

Expand Down Expand Up @@ -56,7 +58,8 @@ llvm::SmallVector<int64_t> evalShape(mlir::AffineMap map, Vector shape) {
return result;
}

template <typename IntType> IntType volume(mlir::ArrayRef<IntType> shape) {
template <typename IntType>
IntType volume(mlir::ArrayRef<IntType> shape) {
IntType result = 1;
for (auto dim : shape) {
result *= dim;
Expand Down
Loading

0 comments on commit b288494

Please sign in to comment.