Add .clang-format for compiler subdirectory
This is LLVM style generated with
clang-format -style=llvm -dump-config > .clang-format
Ran clang-format -i *.cpp *.h under frameworks/rs/rsov/compiler
Test: mm
Change-Id: Idff461c51d6e88e22795ac0a9cfbe41bc8156bbe
diff --git a/rsov/compiler/.clang-format b/rsov/compiler/.clang-format
new file mode 100644
index 0000000..21c0dd4
--- /dev/null
+++ b/rsov/compiler/.clang-format
@@ -0,0 +1,95 @@
+---
+Language: Cpp
+# BasedOnStyle: LLVM
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlinesLeft: false
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterClass: false
+ AfterControlStatement: false
+ AfterEnum: false
+ AfterFunction: false
+ AfterNamespace: false
+ AfterObjCDeclaration: false
+ AfterStruct: false
+ AfterUnion: false
+ BeforeCatch: false
+ BeforeElse: false
+ IndentBraces: false
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Attach
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakAfterJavaFieldAnnotations: false
+BreakStringLiterals: true
+ColumnLimit: 80
+CommentPragmas: '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: true
+DerivePointerAlignment: false
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeCategories:
+ - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
+ Priority: 2
+ - Regex: '^(<|"(gtest|isl|json)/)'
+ Priority: 3
+ - Regex: '.*'
+ Priority: 1
+IncludeIsMainRegex: '$'
+IndentCaseLabels: false
+IndentWidth: 2
+IndentWrappedFunctionNames: false
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+ReflowComments: true
+SortIncludes: true
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp11
+TabWidth: 8
+UseTab: Never
+...
+
diff --git a/rsov/compiler/RSSPIRVWriter.cpp b/rsov/compiler/RSSPIRVWriter.cpp
index 39632c9..99d5e82 100644
--- a/rsov/compiler/RSSPIRVWriter.cpp
+++ b/rsov/compiler/RSSPIRVWriter.cpp
@@ -30,9 +30,9 @@
#include "llvm/Transforms/IPO.h"
#include "GlobalMergePass.h"
+#include "InlinePreparationPass.h"
#include "LinkerModule.h"
#include "ReflectionPass.h"
-#include "InlinePreparationPass.h"
#include <fstream>
#include <sstream>
diff --git a/rsov/compiler/ReflectionPass.cpp b/rsov/compiler/ReflectionPass.cpp
index 2a7b2de..539c1e4 100644
--- a/rsov/compiler/ReflectionPass.cpp
+++ b/rsov/compiler/ReflectionPass.cpp
@@ -21,8 +21,8 @@
#include "RSAllocationUtils.h"
#include "bcinfo/MetadataExtractor.h"
#include "llvm/ADT/StringSwitch.h"
-#include "llvm/IR/Module.h"
#include "llvm/IR/Instructions.h"
+#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
@@ -551,8 +551,9 @@
if (!RTMapping || !ArgTMapping)
return false;
- OS << '\n' << "%kernel_function_ty = OpTypeFunction " << RTMapping->SPIRVTy
- << ' ' << ArgTMapping->SPIRVTy;
+ OS << '\n'
+ << "%kernel_function_ty = OpTypeFunction " << RTMapping->SPIRVTy << ' '
+ << ArgTMapping->SPIRVTy;
const auto CoordsNum = unsigned(Kernel.coordsKind);
for (size_t i = 0; i != CoordsNum; ++i)
@@ -589,7 +590,8 @@
void ReflectionPass::emitGLGlobalInput() {
DEBUG(dbgs() << "emitGLGlobalInput\n");
- OS << '\n' << "%global_input_ptr_ty = OpTypePointer Input %v3uint\n"
+ OS << '\n'
+ << "%global_input_ptr_ty = OpTypePointer Input %v3uint\n"
<< "%global_invocation_id = OpVariable %global_input_ptr_ty Input\n";
}
@@ -625,9 +627,11 @@
if (!AMapping)
return false;
- OS << '\n' << A.VarName << "_image_ty"
+ OS << '\n'
+ << A.VarName << "_image_ty"
<< " = OpTypeImage " << AMapping->SPIRVScalarTy << " 2D 0 0 0 2 "
- << AMapping->SPIRVImageFormat << '\n' << A.VarName << "_image_ptr_ty"
+ << AMapping->SPIRVImageFormat << '\n'
+ << A.VarName << "_image_ptr_ty"
<< " = OpTypePointer UniformConstant " << A.VarName << "_image_ty\n";
OS << A.VarName << "_var = OpVariable " << A.VarName
@@ -671,8 +675,9 @@
const char *InstName) {
std::ostringstream OS;
- OS << '\n' << "%rs_linker_" << Name << " = OpFunction " << RType << " Pure "
- << FType << '\n';
+ OS << '\n'
+ << "%rs_linker_" << Name << " = OpFunction " << RType << " Pure " << FType
+ << '\n';
for (size_t i = 0, e = ArgTypes.size(); i < e; ++i)
OS << "%param" << Name << i << " = OpFunctionParameter " << ArgTypes[i]
@@ -685,7 +690,8 @@
for (size_t i = 0, e = ArgTypes.size(); i < e; ++i)
OS << " %param" << Name << i;
- OS << '\n' << " OpReturnValue %res" << Name << "\n"
+ OS << '\n'
+ << " OpReturnValue %res" << Name << "\n"
<< " OpFunctionEnd\n";
return OS.str();
diff --git a/rsov/compiler/rs2spirv.cpp b/rsov/compiler/rs2spirv.cpp
index eba784f..a13925c 100644
--- a/rsov/compiler/rs2spirv.cpp
+++ b/rsov/compiler/rs2spirv.cpp
@@ -15,6 +15,7 @@
*/
#include "RSSPIRVWriter.h"
+#include "unit_tests/TestRunner.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
@@ -27,7 +28,6 @@
#include "llvm/Support/Signals.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/raw_ostream.h"
-#include "unit_tests/TestRunner.h"
#include <fstream>
#include <iterator>