Revise alwayslink in CodegenPasses and CodegenUtils

* Implements explicit registration of CodegenPasses
* Drops alwayslink from CodegenPasses and CodegenUtils
* Removes createHLOPreprocessingPass() from CodegenPasses header:
  * Implemented in `compiler/Dialect/Flow/Transforms/HLOToHLOPreprocessing.cpp`
  * Only added to the passManager within `compiler/Dialect/Flow/Transforms/Passes.cpp`
  * Also/Already declared in `compiler/Dialect/Flow/Transforms/Passes.h`
* Further, adjusts define guards to match Google C++ Style Guide

Closes https://github.com/google/iree/pull/1634

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/iree/pull/1634 from iml130:codegenpasses-alwayslink 5bd6499f74c41394e7a4ea5fd16fb5b41123d29e
PiperOrigin-RevId: 308267203
diff --git a/iree/compiler/Translation/CodegenPasses/BUILD b/iree/compiler/Translation/CodegenPasses/BUILD
index ed2fb6a..64b205d 100644
--- a/iree/compiler/Translation/CodegenPasses/BUILD
+++ b/iree/compiler/Translation/CodegenPasses/BUILD
@@ -65,5 +65,4 @@
         "@org_tensorflow//tensorflow/compiler/mlir/xla:hlo",
         "@org_tensorflow//tensorflow/compiler/mlir/xla:map_xla_to_scalar_op",
     ],
-    alwayslink = 1,
 )
diff --git a/iree/compiler/Translation/CodegenPasses/CMakeLists.txt b/iree/compiler/Translation/CodegenPasses/CMakeLists.txt
index 1d25247..97bf010 100644
--- a/iree/compiler/Translation/CodegenPasses/CMakeLists.txt
+++ b/iree/compiler/Translation/CodegenPasses/CMakeLists.txt
@@ -54,6 +54,5 @@
     iree::compiler::Dialect::IREE::IR
     iree::compiler::Translation::CodegenUtils
     tensorflow::mlir_xla
-  ALWAYSLINK
   PUBLIC
 )
diff --git a/iree/compiler/Translation/CodegenPasses/LinalgVectorTransform.cpp b/iree/compiler/Translation/CodegenPasses/LinalgVectorTransform.cpp
index 303a9a8..b6e7f42 100644
--- a/iree/compiler/Translation/CodegenPasses/LinalgVectorTransform.cpp
+++ b/iree/compiler/Translation/CodegenPasses/LinalgVectorTransform.cpp
@@ -41,5 +41,10 @@
     "iree-linalg-vector-transforms", "Lower linalg to vector dialect");
 
 }  // namespace
+
+std::unique_ptr<FunctionPass> createIREELinalgVectorTransformPass() {
+  return std::make_unique<IREELinalgVectorTransformPass>();
+}
+
 }  // namespace iree_compiler
 }  // namespace mlir
diff --git a/iree/compiler/Translation/CodegenPasses/Passes.h b/iree/compiler/Translation/CodegenPasses/Passes.h
index 4e2396c..beedd52 100644
--- a/iree/compiler/Translation/CodegenPasses/Passes.h
+++ b/iree/compiler/Translation/CodegenPasses/Passes.h
@@ -17,8 +17,8 @@
 // IREE specific passes used in the XLA to Linalg conversion
 //
 //===----------------------------------------------------------------------===//
-#ifndef IREE_COMPILER_TRANSLATION_CODEGENPASSES_PASSES_H
-#define IREE_COMPILER_TRANSLATION_CODEGENPASSES_PASSES_H
+#ifndef IREE_COMPILER_TRANSLATION_CODEGENPASSES_PASSES_H_
+#define IREE_COMPILER_TRANSLATION_CODEGENPASSES_PASSES_H_
 #include <memory>
 
 #include "mlir/IR/Function.h"
@@ -39,9 +39,6 @@
 /// memrefs.
 std::unique_ptr<OperationPass<mlir::ModuleOp>> createHALInterfaceToMemrefPass();
 
-/// Creates XLA-HLO preprocessing transformation pass.
-std::unique_ptr<OperationPass<FuncOp>> createHLOPreprocessingPass();
-
 /// Creates XLA-HLO to Linalg on buffers transformation pass.
 std::unique_ptr<OperationPass<FuncOp>> createHLOToLinalgOnBuffersPass();
 
@@ -52,6 +49,9 @@
 /// producer consumer fusion.
 std::unique_ptr<OperationPass<FuncOp>> createLinalgOnTensorsFusionPass();
 
+/// Creates IREE Linalg Vector transformation pass.
+std::unique_ptr<FunctionPass> createIREELinalgVectorTransformPass();
+
 /// Populates the patterns that convert from XLA to Linalg on tensors. Imports
 /// patterns from XLA, as well as some IREE specific modifications.
 void populateHLOToLinalgOnTensorsConversionPatterns(
@@ -68,7 +68,16 @@
 void populateHLOToLinalgOnTensorsConversionPatterns(
     MLIRContext *context, OwningRewritePatternList &patterns);
 
+/// Register all Codegen passes
+inline void registerCodegenPasses() {
+  createHALInterfaceToMemrefPass();
+  createHLOToLinalgOnBuffersPass();
+  createHLOToLinalgOnTensorsPass();
+  createLinalgOnTensorsFusionPass();
+  createIREELinalgVectorTransformPass();
+}
+
 }  // namespace iree_compiler
 }  // namespace mlir
 
-#endif  // IREE_COMPILER_TRANSLATION_CODEGENPASSES_PASSES_H
+#endif  // IREE_COMPILER_TRANSLATION_CODEGENPASSES_PASSES_H_
diff --git a/iree/compiler/Translation/CodegenUtils/BUILD b/iree/compiler/Translation/CodegenUtils/BUILD
index 6275b49..8bbd711 100644
--- a/iree/compiler/Translation/CodegenUtils/BUILD
+++ b/iree/compiler/Translation/CodegenUtils/BUILD
@@ -35,5 +35,4 @@
         "@llvm-project//mlir:StandardOps",
         "@llvm-project//mlir:Support",
     ],
-    alwayslink = 1,
 )
diff --git a/iree/compiler/Translation/CodegenUtils/CMakeLists.txt b/iree/compiler/Translation/CodegenUtils/CMakeLists.txt
index 9ffe3d3..386ef54 100644
--- a/iree/compiler/Translation/CodegenUtils/CMakeLists.txt
+++ b/iree/compiler/Translation/CodegenUtils/CMakeLists.txt
@@ -28,6 +28,5 @@
     MLIRSupport
     iree::compiler::Dialect::HAL::IR
     iree::compiler::Dialect::IREE::IR
-  ALWAYSLINK
   PUBLIC
 )
diff --git a/iree/compiler/Translation/CodegenUtils/CodegenUtils.h b/iree/compiler/Translation/CodegenUtils/CodegenUtils.h
index 014e745..affa51e 100644
--- a/iree/compiler/Translation/CodegenUtils/CodegenUtils.h
+++ b/iree/compiler/Translation/CodegenUtils/CodegenUtils.h
@@ -12,8 +12,8 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-#ifndef IREE_COMPILER_TRANSLATION_CODEGENUTILS_CODEGENUTILS_H
-#define IREE_COMPILER_TRANSLATION_CODEGENUTILS_CODEGENUTILS_H
+#ifndef IREE_COMPILER_TRANSLATION_CODEGENUTILS_CODEGENUTILS_H_
+#define IREE_COMPILER_TRANSLATION_CODEGENUTILS_CODEGENUTILS_H_
 
 #include "mlir/IR/Function.h"
 #include "mlir/Support/LogicalResult.h"
@@ -53,4 +53,4 @@
 }  // namespace iree_compiler
 }  // namespace mlir
 
-#endif  // IREE_COMPILER_TRANSLATION_CODEGENUTILS_CODEGENUTILS_H
+#endif  // IREE_COMPILER_TRANSLATION_CODEGENUTILS_CODEGENUTILS_H_
diff --git a/iree/tools/opt_main.cc b/iree/tools/opt_main.cc
index b9a869a..560fb52 100644
--- a/iree/tools/opt_main.cc
+++ b/iree/tools/opt_main.cc
@@ -17,6 +17,7 @@
 // Based on mlir-opt but without registering passes and dialects we don't care
 // about.
 
+#include "iree/compiler/Translation/CodegenPasses/Passes.h"
 #include "iree/compiler/Translation/SPIRV/init_translations.h"
 #include "iree/tools/init_compiler_modules.h"
 #include "iree/tools/init_dialects.h"
@@ -70,6 +71,7 @@
   mlir::iree_compiler::registerAllIreePasses();
   mlir::iree_compiler::registerHALTargetBackends();
   mlir::iree_compiler::registerSPRIVTranslation();
+  mlir::iree_compiler::registerCodegenPasses();
   llvm::InitLLVM y(argc, argv);
 
   // Register MLIRContext command-line options like