[Mlir-commits] [mlir] bb9b5d3 - Revert "[mlir][CAPI] Proposal: Always building a libMLIRPublicAPI.so."

Alex Zinenko llvmlistbot at llvm.org
Fri Nov 6 10:00:35 PST 2020


Author: Alex Zinenko
Date: 2020-11-06T18:59:58+01:00
New Revision: bb9b5d39712e39e15b22b36e8138075cea0cd7b5

URL: https://github.com/llvm/llvm-project/commit/bb9b5d39712e39e15b22b36e8138075cea0cd7b5
DIFF: https://github.com/llvm/llvm-project/commit/bb9b5d39712e39e15b22b36e8138075cea0cd7b5.diff

LOG: Revert "[mlir][CAPI] Proposal: Always building a libMLIRPublicAPI.so."

This reverts commit 80fe2f61fac9f72825f907637a9c63aca32d8f14.

Broke linkage with GNU ld. See original review thread for more details.

Added: 
    

Modified: 
    mlir/cmake/modules/AddMLIR.cmake
    mlir/cmake/modules/AddMLIRPythonExtension.cmake
    mlir/include/mlir-c/AffineExpr.h
    mlir/include/mlir-c/AffineMap.h
    mlir/include/mlir-c/Diagnostics.h
    mlir/include/mlir-c/IR.h
    mlir/include/mlir-c/Pass.h
    mlir/include/mlir-c/Registration.h
    mlir/include/mlir-c/StandardAttributes.h
    mlir/include/mlir-c/StandardDialect.h
    mlir/include/mlir-c/StandardTypes.h
    mlir/include/mlir-c/Support.h
    mlir/include/mlir-c/Transforms.h
    mlir/lib/Bindings/Python/CMakeLists.txt
    mlir/lib/CAPI/CMakeLists.txt
    mlir/lib/CAPI/IR/CMakeLists.txt
    mlir/lib/CAPI/Registration/CMakeLists.txt
    mlir/lib/CAPI/Standard/CMakeLists.txt
    mlir/lib/CAPI/Transforms/CMakeLists.txt
    mlir/lib/CAPI/Transforms/Passes.cpp
    mlir/test/CAPI/CMakeLists.txt
    mlir/tools/mlir-tblgen/PassCAPIGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index 9709615c7d66..0d99c29c716a 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -165,33 +165,6 @@ function(add_mlir_library_install name)
   set_property(GLOBAL APPEND PROPERTY MLIR_EXPORTS ${name})
 endfunction()
 
-# Declare an mlir library which is part of the public C-API and will be
-# compiled and exported into libMLIRPublicAPI.so/MLIRPublicAPI.dll.
-# This shared library is built regardless of the overall setting of building
-# libMLIR.so (which exports the C++ implementation).
-function(add_mlir_public_c_api_library name)
-  add_mlir_library(${name}
-    ${ARGN}
-    # NOTE: Generates obj.${name} which is used for shared library building.
-    OBJECT
-    EXCLUDE_FROM_LIBMLIR
-    ADDITIONAL_HEADER_DIRS
-    ${MLIR_MAIN_INCLUDE_DIR}/mlir-c
-  )
-  # API libraries compile with hidden visibility and macros that enable
-  # exporting from the DLL. Only apply to the obj lib, which only affects
-  # the exports via a shared library.
-  set_target_properties(obj.${name}
-    PROPERTIES
-    CXX_VISIBILITY_PRESET hidden
-  )
-  target_compile_definitions(obj.${name}
-    PRIVATE
-    -DMLIR_CAPI_BUILDING_LIBRARY=1
-  )
-  set_property(GLOBAL APPEND PROPERTY MLIR_PUBLIC_C_API_LIBS ${name})
-endfunction()
-
 # Declare the library associated with a dialect.
 function(add_mlir_dialect_library name)
   set_property(GLOBAL APPEND PROPERTY MLIR_DIALECT_LIBS ${name})

diff  --git a/mlir/cmake/modules/AddMLIRPythonExtension.cmake b/mlir/cmake/modules/AddMLIRPythonExtension.cmake
index 07923129617d..e5e81d6a87c2 100644
--- a/mlir/cmake/modules/AddMLIRPythonExtension.cmake
+++ b/mlir/cmake/modules/AddMLIRPythonExtension.cmake
@@ -13,6 +13,9 @@ function(add_mlir_python_extension libname extname)
   if ("${ARG_SOURCES}" STREQUAL "")
     message(FATAL_ERROR " Missing SOURCES argument to add_mlir_python_extension(${libname}, ...")
   endif()
+  if(NOT LLVM_BUILD_LLVM_DYLIB)
+    message(FATAL_ERROR "Building MLIR Python extension require -DLLVM_BUILD_LLVM_DYLIB=ON")
+  endif()
 
   # Normally on unix-like platforms, extensions are built as "MODULE" libraries
   # and do not explicitly link to the python shared object. This allows for
@@ -82,23 +85,13 @@ function(add_mlir_python_extension libname extname)
   # to take place.
   set_target_properties(${libname} PROPERTIES CXX_VISIBILITY_PRESET "hidden")
 
-  # Python extensions depends *only* on the public API and LLVMSupport unless
-  # if further dependencies are added explicitly.
   target_link_libraries(${libname}
     PRIVATE
-    MLIRPublicAPI
-    LLVMSupport
+    MLIR # Always link to libMLIR.so
     ${ARG_LINK_LIBS}
     ${PYEXT_LIBADD}
   )
 
-  target_link_options(${libname}
-    PRIVATE
-      # On Linux, disable re-export of any static linked libraries that
-      # came through.
-      $<$<PLATFORM_ID:Linux>:LINKER:--exclude-libs,ALL>
-  )
-
   llvm_setup_rpath(${libname})
 
   ################################################################################

diff  --git a/mlir/include/mlir-c/AffineExpr.h b/mlir/include/mlir-c/AffineExpr.h
index 7ddd0289d8a5..df33c9cae7c7 100644
--- a/mlir/include/mlir-c/AffineExpr.h
+++ b/mlir/include/mlir-c/AffineExpr.h
@@ -42,132 +42,116 @@ DEFINE_C_API_STRUCT(MlirAffineExpr, const void);
 #undef DEFINE_C_API_STRUCT
 
 /// Gets the context that owns the affine expression.
-MLIR_CAPI_EXPORTED MlirContext
-mlirAffineExprGetContext(MlirAffineExpr affineExpr);
+MlirContext mlirAffineExprGetContext(MlirAffineExpr affineExpr);
 
 /** Prints an affine expression by sending chunks of the string representation
  * and forwarding `userData to `callback`. Note that the callback may be called
  * several times with consecutive chunks of the string. */
-MLIR_CAPI_EXPORTED void mlirAffineExprPrint(MlirAffineExpr affineExpr,
-                                            MlirStringCallback callback,
-                                            void *userData);
+void mlirAffineExprPrint(MlirAffineExpr affineExpr, MlirStringCallback callback,
+                         void *userData);
 
 /// Prints the affine expression to the standard error stream.
-MLIR_CAPI_EXPORTED void mlirAffineExprDump(MlirAffineExpr affineExpr);
+void mlirAffineExprDump(MlirAffineExpr affineExpr);
 
 /** Checks whether the given affine expression is made out of only symbols and
  * constants. */
-MLIR_CAPI_EXPORTED int
-mlirAffineExprIsSymbolicOrConstant(MlirAffineExpr affineExpr);
+int mlirAffineExprIsSymbolicOrConstant(MlirAffineExpr affineExpr);
 
 /** Checks whether the given affine expression is a pure affine expression, i.e.
  * mul, floordiv, ceildic, and mod is only allowed w.r.t constants. */
-MLIR_CAPI_EXPORTED int mlirAffineExprIsPureAffine(MlirAffineExpr affineExpr);
+int mlirAffineExprIsPureAffine(MlirAffineExpr affineExpr);
 
 /** Returns the greatest known integral divisor of this affine expression. The
  * result is always positive. */
-MLIR_CAPI_EXPORTED int64_t
-mlirAffineExprGetLargestKnownDivisor(MlirAffineExpr affineExpr);
+int64_t mlirAffineExprGetLargestKnownDivisor(MlirAffineExpr affineExpr);
 
 /// Checks whether the given affine expression is a multiple of 'factor'.
-MLIR_CAPI_EXPORTED int mlirAffineExprIsMultipleOf(MlirAffineExpr affineExpr,
-                                                  int64_t factor);
+int mlirAffineExprIsMultipleOf(MlirAffineExpr affineExpr, int64_t factor);
 
 /** Checks whether the given affine expression involves AffineDimExpr
  * 'position'. */
-MLIR_CAPI_EXPORTED int mlirAffineExprIsFunctionOfDim(MlirAffineExpr affineExpr,
-                                                     intptr_t position);
+int mlirAffineExprIsFunctionOfDim(MlirAffineExpr affineExpr, intptr_t position);
 
 //===----------------------------------------------------------------------===//
 // Affine Dimension Expression.
 //===----------------------------------------------------------------------===//
 
 /// Creates an affine dimension expression with 'position' in the context.
-MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineDimExprGet(MlirContext ctx,
-                                                       intptr_t position);
+MlirAffineExpr mlirAffineDimExprGet(MlirContext ctx, intptr_t position);
 
 /// Returns the position of the given affine dimension expression.
-MLIR_CAPI_EXPORTED intptr_t
-mlirAffineDimExprGetPosition(MlirAffineExpr affineExpr);
+intptr_t mlirAffineDimExprGetPosition(MlirAffineExpr affineExpr);
 
 //===----------------------------------------------------------------------===//
 // Affine Symbol Expression.
 //===----------------------------------------------------------------------===//
 
 /// Creates an affine symbol expression with 'position' in the context.
-MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineSymbolExprGet(MlirContext ctx,
-                                                          intptr_t position);
+MlirAffineExpr mlirAffineSymbolExprGet(MlirContext ctx, intptr_t position);
 
 /// Returns the position of the given affine symbol expression.
-MLIR_CAPI_EXPORTED intptr_t
-mlirAffineSymbolExprGetPosition(MlirAffineExpr affineExpr);
+intptr_t mlirAffineSymbolExprGetPosition(MlirAffineExpr affineExpr);
 
 //===----------------------------------------------------------------------===//
 // Affine Constant Expression.
 //===----------------------------------------------------------------------===//
 
 /// Creates an affine constant expression with 'constant' in the context.
-MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineConstantExprGet(MlirContext ctx,
-                                                            int64_t constant);
+MlirAffineExpr mlirAffineConstantExprGet(MlirContext ctx, int64_t constant);
 
 /// Returns the value of the given affine constant expression.
-MLIR_CAPI_EXPORTED int64_t
-mlirAffineConstantExprGetValue(MlirAffineExpr affineExpr);
+int64_t mlirAffineConstantExprGetValue(MlirAffineExpr affineExpr);
 
 //===----------------------------------------------------------------------===//
 // Affine Add Expression.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given affine expression is an add expression.
-MLIR_CAPI_EXPORTED int mlirAffineExprIsAAdd(MlirAffineExpr affineExpr);
+int mlirAffineExprIsAAdd(MlirAffineExpr affineExpr);
 
 /// Creates an affine add expression with 'lhs' and 'rhs'.
-MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineAddExprGet(MlirAffineExpr lhs,
-                                                       MlirAffineExpr rhs);
+MlirAffineExpr mlirAffineAddExprGet(MlirAffineExpr lhs, MlirAffineExpr rhs);
 
 //===----------------------------------------------------------------------===//
 // Affine Mul Expression.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given affine expression is an mul expression.
-MLIR_CAPI_EXPORTED int mlirAffineExprIsAMul(MlirAffineExpr affineExpr);
+int mlirAffineExprIsAMul(MlirAffineExpr affineExpr);
 
 /// Creates an affine mul expression with 'lhs' and 'rhs'.
-MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineMulExprGet(MlirAffineExpr lhs,
-                                                       MlirAffineExpr rhs);
+MlirAffineExpr mlirAffineMulExprGet(MlirAffineExpr lhs, MlirAffineExpr rhs);
 
 //===----------------------------------------------------------------------===//
 // Affine Mod Expression.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given affine expression is an mod expression.
-MLIR_CAPI_EXPORTED int mlirAffineExprIsAMod(MlirAffineExpr affineExpr);
+int mlirAffineExprIsAMod(MlirAffineExpr affineExpr);
 
 /// Creates an affine mod expression with 'lhs' and 'rhs'.
-MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineModExprGet(MlirAffineExpr lhs,
-                                                       MlirAffineExpr rhs);
+MlirAffineExpr mlirAffineModExprGet(MlirAffineExpr lhs, MlirAffineExpr rhs);
 
 //===----------------------------------------------------------------------===//
 // Affine FloorDiv Expression.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given affine expression is an floordiv expression.
-MLIR_CAPI_EXPORTED int mlirAffineExprIsAFloorDiv(MlirAffineExpr affineExpr);
+int mlirAffineExprIsAFloorDiv(MlirAffineExpr affineExpr);
 
 /// Creates an affine floordiv expression with 'lhs' and 'rhs'.
-MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineFloorDivExprGet(MlirAffineExpr lhs,
-                                                            MlirAffineExpr rhs);
+MlirAffineExpr mlirAffineFloorDivExprGet(MlirAffineExpr lhs,
+                                         MlirAffineExpr rhs);
 
 //===----------------------------------------------------------------------===//
 // Affine CeilDiv Expression.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given affine expression is an ceildiv expression.
-MLIR_CAPI_EXPORTED int mlirAffineExprIsACeilDiv(MlirAffineExpr affineExpr);
+int mlirAffineExprIsACeilDiv(MlirAffineExpr affineExpr);
 
 /// Creates an affine ceildiv expression with 'lhs' and 'rhs'.
-MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineCeilDivExprGet(MlirAffineExpr lhs,
-                                                           MlirAffineExpr rhs);
+MlirAffineExpr mlirAffineCeilDivExprGet(MlirAffineExpr lhs, MlirAffineExpr rhs);
 
 //===----------------------------------------------------------------------===//
 // Affine Binary Operation Expression.
@@ -175,13 +159,11 @@ MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineCeilDivExprGet(MlirAffineExpr lhs,
 
 /** Returns the left hand side affine expression of the given affine binary
  * operation expression. */
-MLIR_CAPI_EXPORTED MlirAffineExpr
-mlirAffineBinaryOpExprGetLHS(MlirAffineExpr affineExpr);
+MlirAffineExpr mlirAffineBinaryOpExprGetLHS(MlirAffineExpr affineExpr);
 
 /** Returns the right hand side affine expression of the given affine binary
  * operation expression. */
-MLIR_CAPI_EXPORTED MlirAffineExpr
-mlirAffineBinaryOpExprGetRHS(MlirAffineExpr affineExpr);
+MlirAffineExpr mlirAffineBinaryOpExprGetRHS(MlirAffineExpr affineExpr);
 
 #ifdef __cplusplus
 }

diff  --git a/mlir/include/mlir-c/AffineMap.h b/mlir/include/mlir-c/AffineMap.h
index 567faced6b85..f0fbe5a6740e 100644
--- a/mlir/include/mlir-c/AffineMap.h
+++ b/mlir/include/mlir-c/AffineMap.h
@@ -41,120 +41,114 @@ DEFINE_C_API_STRUCT(MlirAffineMap, const void);
 #undef DEFINE_C_API_STRUCT
 
 /// Gets the context that the given affine map was created with
-MLIR_CAPI_EXPORTED MlirContext mlirAffineMapGetContext(MlirAffineMap affineMap);
+MlirContext mlirAffineMapGetContext(MlirAffineMap affineMap);
 
 /// Checks whether an affine map is null.
-static inline int mlirAffineMapIsNull(MlirAffineMap affineMap) {
+inline int mlirAffineMapIsNull(MlirAffineMap affineMap) {
   return !affineMap.ptr;
 }
 
 /// Checks if two affine maps are equal.
-MLIR_CAPI_EXPORTED int mlirAffineMapEqual(MlirAffineMap a1, MlirAffineMap a2);
+int mlirAffineMapEqual(MlirAffineMap a1, MlirAffineMap a2);
 
 /** Prints an affine map by sending chunks of the string representation and
  * forwarding `userData to `callback`. Note that the callback may be called
  * several times with consecutive chunks of the string. */
-MLIR_CAPI_EXPORTED void mlirAffineMapPrint(MlirAffineMap affineMap,
-                                           MlirStringCallback callback,
-                                           void *userData);
+void mlirAffineMapPrint(MlirAffineMap affineMap, MlirStringCallback callback,
+                        void *userData);
 
 /// Prints the affine map to the standard error stream.
-MLIR_CAPI_EXPORTED void mlirAffineMapDump(MlirAffineMap affineMap);
+void mlirAffineMapDump(MlirAffineMap affineMap);
 
 /** Creates a zero result affine map with no dimensions or symbols in the
  * context. The affine map is owned by the context. */
-MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapEmptyGet(MlirContext ctx);
+MlirAffineMap mlirAffineMapEmptyGet(MlirContext ctx);
 
 /** Creates a zero result affine map of the given dimensions and symbols in the
  * context. The affine map is owned by the context. */
-MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapGet(MlirContext ctx,
-                                                  intptr_t dimCount,
-                                                  intptr_t symbolCount);
+MlirAffineMap mlirAffineMapGet(MlirContext ctx, intptr_t dimCount,
+                               intptr_t symbolCount);
 
 /** Creates a single constant result affine map in the context. The affine map
  * is owned by the context. */
-MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapConstantGet(MlirContext ctx,
-                                                          int64_t val);
+MlirAffineMap mlirAffineMapConstantGet(MlirContext ctx, int64_t val);
 
 /** Creates an affine map with 'numDims' identity in the context. The affine map
  * is owned by the context. */
-MLIR_CAPI_EXPORTED MlirAffineMap
-mlirAffineMapMultiDimIdentityGet(MlirContext ctx, intptr_t numDims);
+MlirAffineMap mlirAffineMapMultiDimIdentityGet(MlirContext ctx,
+                                               intptr_t numDims);
 
 /** Creates an identity affine map on the most minor dimensions in the context.
  * The affine map is owned by the context. The function asserts that the number
  * of dimensions is greater or equal to the number of results. */
-MLIR_CAPI_EXPORTED MlirAffineMap
-mlirAffineMapMinorIdentityGet(MlirContext ctx, intptr_t dims, intptr_t results);
+MlirAffineMap mlirAffineMapMinorIdentityGet(MlirContext ctx, intptr_t dims,
+                                            intptr_t results);
 
 /** Creates an affine map with a permutation expression and its size in the
  * context. The permutation expression is a non-empty vector of integers.
  * The elements of the permutation vector must be continuous from 0 and cannot
  * be repeated (i.e. `[1,2,0]` is a valid permutation. `[2,0]` or `[1,1,2]` is
  * an invalid invalid permutation.) The affine map is owned by the context. */
-MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapPermutationGet(
-    MlirContext ctx, intptr_t size, unsigned *permutation);
+MlirAffineMap mlirAffineMapPermutationGet(MlirContext ctx, intptr_t size,
+                                          unsigned *permutation);
 
 /** Checks whether the given affine map is an identity affine map. The function
  * asserts that the number of dimensions is greater or equal to the number of
  * results. */
-MLIR_CAPI_EXPORTED int mlirAffineMapIsIdentity(MlirAffineMap affineMap);
+int mlirAffineMapIsIdentity(MlirAffineMap affineMap);
 
 /// Checks whether the given affine map is a minor identity affine map.
-MLIR_CAPI_EXPORTED int mlirAffineMapIsMinorIdentity(MlirAffineMap affineMap);
+int mlirAffineMapIsMinorIdentity(MlirAffineMap affineMap);
 
 /// Checks whether the given affine map is an empty affine map.
-MLIR_CAPI_EXPORTED int mlirAffineMapIsEmpty(MlirAffineMap affineMap);
+int mlirAffineMapIsEmpty(MlirAffineMap affineMap);
 
 /** Checks whether the given affine map is a single result constant affine
  * map. */
-MLIR_CAPI_EXPORTED int mlirAffineMapIsSingleConstant(MlirAffineMap affineMap);
+int mlirAffineMapIsSingleConstant(MlirAffineMap affineMap);
 
 /** Returns the constant result of the given affine map. The function asserts
  * that the map has a single constant result. */
-MLIR_CAPI_EXPORTED int64_t
-mlirAffineMapGetSingleConstantResult(MlirAffineMap affineMap);
+int64_t mlirAffineMapGetSingleConstantResult(MlirAffineMap affineMap);
 
 /// Returns the number of dimensions of the given affine map.
-MLIR_CAPI_EXPORTED intptr_t mlirAffineMapGetNumDims(MlirAffineMap affineMap);
+intptr_t mlirAffineMapGetNumDims(MlirAffineMap affineMap);
 
 /// Returns the number of symbols of the given affine map.
-MLIR_CAPI_EXPORTED intptr_t mlirAffineMapGetNumSymbols(MlirAffineMap affineMap);
+intptr_t mlirAffineMapGetNumSymbols(MlirAffineMap affineMap);
 
 /// Returns the number of results of the given affine map.
-MLIR_CAPI_EXPORTED intptr_t mlirAffineMapGetNumResults(MlirAffineMap affineMap);
+intptr_t mlirAffineMapGetNumResults(MlirAffineMap affineMap);
 
 /** Returns the number of inputs (dimensions + symbols) of the given affine
  * map. */
-MLIR_CAPI_EXPORTED intptr_t mlirAffineMapGetNumInputs(MlirAffineMap affineMap);
+intptr_t mlirAffineMapGetNumInputs(MlirAffineMap affineMap);
 
 /** Checks whether the given affine map represents a subset of a symbol-less
  * permutation map. */
-MLIR_CAPI_EXPORTED int
-mlirAffineMapIsProjectedPermutation(MlirAffineMap affineMap);
+int mlirAffineMapIsProjectedPermutation(MlirAffineMap affineMap);
 
 /** Checks whether the given affine map represents a symbol-less permutation
  * map. */
-MLIR_CAPI_EXPORTED int mlirAffineMapIsPermutation(MlirAffineMap affineMap);
+int mlirAffineMapIsPermutation(MlirAffineMap affineMap);
 
 /// Returns the affine map consisting of the `resultPos` subset.
-MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapGetSubMap(MlirAffineMap affineMap,
-                                                        intptr_t size,
-                                                        intptr_t *resultPos);
+MlirAffineMap mlirAffineMapGetSubMap(MlirAffineMap affineMap, intptr_t size,
+                                     intptr_t *resultPos);
 
 /** Returns the affine map consisting of the most major `numResults` results.
  * Returns the null AffineMap if the `numResults` is equal to zero.
  * Returns the `affineMap` if `numResults` is greater or equals to number of
  * results of the given affine map. */
-MLIR_CAPI_EXPORTED MlirAffineMap
-mlirAffineMapGetMajorSubMap(MlirAffineMap affineMap, intptr_t numResults);
+MlirAffineMap mlirAffineMapGetMajorSubMap(MlirAffineMap affineMap,
+                                          intptr_t numResults);
 
 /** Returns the affine map consisting of the most minor `numResults` results.
  * Returns the null AffineMap if the `numResults` is equal to zero.
  * Returns the `affineMap` if `numResults` is greater or equals to number of
  * results of the given affine map. */
-MLIR_CAPI_EXPORTED MlirAffineMap
-mlirAffineMapGetMinorSubMap(MlirAffineMap affineMap, intptr_t numResults);
+MlirAffineMap mlirAffineMapGetMinorSubMap(MlirAffineMap affineMap,
+                                          intptr_t numResults);
 
 #ifdef __cplusplus
 }

diff  --git a/mlir/include/mlir-c/Diagnostics.h b/mlir/include/mlir-c/Diagnostics.h
index cc6d15be6061..9de5e3089a6d 100644
--- a/mlir/include/mlir-c/Diagnostics.h
+++ b/mlir/include/mlir-c/Diagnostics.h
@@ -48,43 +48,37 @@ typedef uint64_t MlirDiagnosticHandlerID;
 typedef MlirLogicalResult (*MlirDiagnosticHandler)(MlirDiagnostic);
 
 /// Prints a diagnostic using the provided callback.
-MLIR_CAPI_EXPORTED void mlirDiagnosticPrint(MlirDiagnostic diagnostic,
-                                            MlirStringCallback callback,
-                                            void *userData);
+void mlirDiagnosticPrint(MlirDiagnostic diagnostic, MlirStringCallback callback,
+                         void *userData);
 
 /// Returns the location at which the diagnostic is reported.
-MLIR_CAPI_EXPORTED MlirLocation
-mlirDiagnosticGetLocation(MlirDiagnostic diagnostic);
+MlirLocation mlirDiagnosticGetLocation(MlirDiagnostic diagnostic);
 
 /// Returns the severity of the diagnostic.
-MLIR_CAPI_EXPORTED MlirDiagnosticSeverity
-mlirDiagnosticGetSeverity(MlirDiagnostic diagnostic);
+MlirDiagnosticSeverity mlirDiagnosticGetSeverity(MlirDiagnostic diagnostic);
 
 /// Returns the number of notes attached to the diagnostic.
-MLIR_CAPI_EXPORTED intptr_t
-mlirDiagnosticGetNumNotes(MlirDiagnostic diagnostic);
+intptr_t mlirDiagnosticGetNumNotes(MlirDiagnostic diagnostic);
 
 /** Returns `pos`-th note attached to the diagnostic. Expects `pos` to be a
  * valid zero-based index into the list of notes. */
-MLIR_CAPI_EXPORTED MlirDiagnostic
-mlirDiagnosticGetNote(MlirDiagnostic diagnostic, intptr_t pos);
+MlirDiagnostic mlirDiagnosticGetNote(MlirDiagnostic diagnostic, intptr_t pos);
 
 /** Attaches the diagnostic handler to the context. Handlers are invoked in the
  * reverse order of attachment until one of them processes the diagnostic
  * completely. Returns an identifier that can be used to detach the handler. */
-MLIR_CAPI_EXPORTED MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler(
-    MlirContext context, MlirDiagnosticHandler handler);
+MlirDiagnosticHandlerID
+mlirContextAttachDiagnosticHandler(MlirContext context,
+                                   MlirDiagnosticHandler handler);
 
 /** Detaches an attached diagnostic handler from the context given its
  * identifier. */
-MLIR_CAPI_EXPORTED void
-mlirContextDetachDiagnosticHandler(MlirContext context,
-                                   MlirDiagnosticHandlerID id);
+void mlirContextDetachDiagnosticHandler(MlirContext context,
+                                        MlirDiagnosticHandlerID id);
 
 /** Emits an error at the given location through the diagnostics engine. Used
  * for testing purposes. */
-MLIR_CAPI_EXPORTED void mlirEmitError(MlirLocation location,
-                                      const char *message);
+void mlirEmitError(MlirLocation location, const char *message);
 
 #ifdef __cplusplus
 }

diff  --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h
index de557c475b55..0a264ed25afe 100644
--- a/mlir/include/mlir-c/IR.h
+++ b/mlir/include/mlir-c/IR.h
@@ -79,10 +79,10 @@ typedef struct MlirNamedAttribute MlirNamedAttribute;
 //===----------------------------------------------------------------------===//
 
 /// Creates an MLIR context and transfers its ownership to the caller.
-MLIR_CAPI_EXPORTED MlirContext mlirContextCreate();
+MlirContext mlirContextCreate();
 
 /// Checks if two contexts are equal.
-MLIR_CAPI_EXPORTED int mlirContextEqual(MlirContext ctx1, MlirContext ctx2);
+int mlirContextEqual(MlirContext ctx1, MlirContext ctx2);
 
 /// Checks whether a context is null.
 static inline int mlirContextIsNull(MlirContext context) {
@@ -90,40 +90,36 @@ static inline int mlirContextIsNull(MlirContext context) {
 }
 
 /// Takes an MLIR context owned by the caller and destroys it.
-MLIR_CAPI_EXPORTED void mlirContextDestroy(MlirContext context);
+void mlirContextDestroy(MlirContext context);
 
 /// Sets whether unregistered dialects are allowed in this context.
-MLIR_CAPI_EXPORTED void
-mlirContextSetAllowUnregisteredDialects(MlirContext context, int allow);
+void mlirContextSetAllowUnregisteredDialects(MlirContext context, int allow);
 
 /// Returns whether the context allows unregistered dialects.
-MLIR_CAPI_EXPORTED int
-mlirContextGetAllowUnregisteredDialects(MlirContext context);
+int mlirContextGetAllowUnregisteredDialects(MlirContext context);
 
 /** Returns the number of dialects registered with the given context. A
  * registered dialect will be loaded if needed by the parser. */
-MLIR_CAPI_EXPORTED intptr_t
-mlirContextGetNumRegisteredDialects(MlirContext context);
+intptr_t mlirContextGetNumRegisteredDialects(MlirContext context);
 
 /** Returns the number of dialects loaded by the context.
  */
-MLIR_CAPI_EXPORTED intptr_t
-mlirContextGetNumLoadedDialects(MlirContext context);
+intptr_t mlirContextGetNumLoadedDialects(MlirContext context);
 
 /** Gets the dialect instance owned by the given context using the dialect
  * namespace to identify it, loads (i.e., constructs the instance of) the
  * dialect if necessary. If the dialect is not registered with the context,
  * returns null. Use mlirContextLoad<Name>Dialect to load an unregistered
  * dialect. */
-MLIR_CAPI_EXPORTED MlirDialect mlirContextGetOrLoadDialect(MlirContext context,
-                                                           MlirStringRef name);
+MlirDialect mlirContextGetOrLoadDialect(MlirContext context,
+                                        MlirStringRef name);
 
 //===----------------------------------------------------------------------===//
 // Dialect API.
 //===----------------------------------------------------------------------===//
 
 /// Returns the context that owns the dialect.
-MLIR_CAPI_EXPORTED MlirContext mlirDialectGetContext(MlirDialect dialect);
+MlirContext mlirDialectGetContext(MlirDialect dialect);
 
 /// Checks if the dialect is null.
 static inline int mlirDialectIsNull(MlirDialect dialect) {
@@ -132,60 +128,56 @@ static inline int mlirDialectIsNull(MlirDialect dialect) {
 
 /** Checks if two dialects that belong to the same context are equal. Dialects
  * from 
diff erent contexts will not compare equal. */
-MLIR_CAPI_EXPORTED int mlirDialectEqual(MlirDialect dialect1,
-                                        MlirDialect dialect2);
+int mlirDialectEqual(MlirDialect dialect1, MlirDialect dialect2);
 
 /// Returns the namespace of the given dialect.
-MLIR_CAPI_EXPORTED MlirStringRef mlirDialectGetNamespace(MlirDialect dialect);
+MlirStringRef mlirDialectGetNamespace(MlirDialect dialect);
 
 //===----------------------------------------------------------------------===//
 // Location API.
 //===----------------------------------------------------------------------===//
 
 /// Creates an File/Line/Column location owned by the given context.
-MLIR_CAPI_EXPORTED MlirLocation mlirLocationFileLineColGet(MlirContext context,
-                                                           const char *filename,
-                                                           unsigned line,
-                                                           unsigned col);
+MlirLocation mlirLocationFileLineColGet(MlirContext context,
+                                        const char *filename, unsigned line,
+                                        unsigned col);
 
 /// Creates a location with unknown position owned by the given context.
-MLIR_CAPI_EXPORTED MlirLocation mlirLocationUnknownGet(MlirContext context);
+MlirLocation mlirLocationUnknownGet(MlirContext context);
 
 /// Gets the context that a location was created with.
-MLIR_CAPI_EXPORTED MlirContext mlirLocationGetContext(MlirLocation location);
+MlirContext mlirLocationGetContext(MlirLocation location);
 
 /** Prints a location by sending chunks of the string representation and
  * forwarding `userData to `callback`. Note that the callback may be called
  * several times with consecutive chunks of the string. */
-MLIR_CAPI_EXPORTED void mlirLocationPrint(MlirLocation location,
-                                          MlirStringCallback callback,
-                                          void *userData);
+void mlirLocationPrint(MlirLocation location, MlirStringCallback callback,
+                       void *userData);
 
 //===----------------------------------------------------------------------===//
 // Module API.
 //===----------------------------------------------------------------------===//
 
 /// Creates a new, empty module and transfers ownership to the caller.
-MLIR_CAPI_EXPORTED MlirModule mlirModuleCreateEmpty(MlirLocation location);
+MlirModule mlirModuleCreateEmpty(MlirLocation location);
 
 /// Parses a module from the string and transfers ownership to the caller.
-MLIR_CAPI_EXPORTED MlirModule mlirModuleCreateParse(MlirContext context,
-                                                    const char *module);
+MlirModule mlirModuleCreateParse(MlirContext context, const char *module);
 
 /// Gets the context that a module was created with.
-MLIR_CAPI_EXPORTED MlirContext mlirModuleGetContext(MlirModule module);
+MlirContext mlirModuleGetContext(MlirModule module);
 
 /// Gets the body of the module, i.e. the only block it contains.
-MLIR_CAPI_EXPORTED MlirBlock mlirModuleGetBody(MlirModule module);
+MlirBlock mlirModuleGetBody(MlirModule module);
 
 /// Checks whether a module is null.
 static inline int mlirModuleIsNull(MlirModule module) { return !module.ptr; }
 
 /// Takes a module owned by the caller and deletes it.
-MLIR_CAPI_EXPORTED void mlirModuleDestroy(MlirModule module);
+void mlirModuleDestroy(MlirModule module);
 
 /// Views the module as a generic operation.
-MLIR_CAPI_EXPORTED MlirOperation mlirModuleGetOperation(MlirModule module);
+MlirOperation mlirModuleGetOperation(MlirModule module);
 
 //===----------------------------------------------------------------------===//
 // Operation state.
@@ -218,25 +210,19 @@ struct MlirOperationState {
 typedef struct MlirOperationState MlirOperationState;
 
 /// Constructs an operation state from a name and a location.
-MLIR_CAPI_EXPORTED MlirOperationState mlirOperationStateGet(const char *name,
-                                                            MlirLocation loc);
+MlirOperationState mlirOperationStateGet(const char *name, MlirLocation loc);
 
 /// Adds a list of components to the operation state.
-MLIR_CAPI_EXPORTED void mlirOperationStateAddResults(MlirOperationState *state,
-                                                     intptr_t n,
-                                                     MlirType *results);
-MLIR_CAPI_EXPORTED void mlirOperationStateAddOperands(MlirOperationState *state,
-                                                      intptr_t n,
-                                                      MlirValue *operands);
-MLIR_CAPI_EXPORTED void
-mlirOperationStateAddOwnedRegions(MlirOperationState *state, intptr_t n,
-                                  MlirRegion *regions);
-MLIR_CAPI_EXPORTED void
-mlirOperationStateAddSuccessors(MlirOperationState *state, intptr_t n,
-                                MlirBlock *successors);
-MLIR_CAPI_EXPORTED void
-mlirOperationStateAddAttributes(MlirOperationState *state, intptr_t n,
-                                MlirNamedAttribute *attributes);
+void mlirOperationStateAddResults(MlirOperationState *state, intptr_t n,
+                                  MlirType *results);
+void mlirOperationStateAddOperands(MlirOperationState *state, intptr_t n,
+                                   MlirValue *operands);
+void mlirOperationStateAddOwnedRegions(MlirOperationState *state, intptr_t n,
+                                       MlirRegion *regions);
+void mlirOperationStateAddSuccessors(MlirOperationState *state, intptr_t n,
+                                     MlirBlock *successors);
+void mlirOperationStateAddAttributes(MlirOperationState *state, intptr_t n,
+                                     MlirNamedAttribute *attributes);
 
 //===----------------------------------------------------------------------===//
 // Op Printing flags API.
@@ -247,177 +233,158 @@ mlirOperationStateAddAttributes(MlirOperationState *state, intptr_t n,
 
 /** Creates new printing flags with defaults, intended for customization.
  * Must be freed with a call to mlirOpPrintingFlagsDestroy(). */
-MLIR_CAPI_EXPORTED MlirOpPrintingFlags mlirOpPrintingFlagsCreate();
+MlirOpPrintingFlags mlirOpPrintingFlagsCreate();
 
 /// Destroys printing flags created with mlirOpPrintingFlagsCreate.
-MLIR_CAPI_EXPORTED void mlirOpPrintingFlagsDestroy(MlirOpPrintingFlags flags);
+void mlirOpPrintingFlagsDestroy(MlirOpPrintingFlags flags);
 
 /** Enables the elision of large elements attributes by printing a lexically
  * valid but otherwise meaningless form instead of the element data. The
  * `largeElementLimit` is used to configure what is considered to be a "large"
  * ElementsAttr by providing an upper limit to the number of elements. */
-MLIR_CAPI_EXPORTED void
-mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags,
-                                           intptr_t largeElementLimit);
+void mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags,
+                                                intptr_t largeElementLimit);
 
 /** Enable printing of debug information. If 'prettyForm' is set to true,
  * debug information is printed in a more readable 'pretty' form. Note: The
  * IR generated with 'prettyForm' is not parsable. */
-MLIR_CAPI_EXPORTED void
-mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, int prettyForm);
+void mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags,
+                                        int prettyForm);
 
 /// Always print operations in the generic form.
-MLIR_CAPI_EXPORTED void
-mlirOpPrintingFlagsPrintGenericOpForm(MlirOpPrintingFlags flags);
+void mlirOpPrintingFlagsPrintGenericOpForm(MlirOpPrintingFlags flags);
 
 /** Use local scope when printing the operation. This allows for using the
  * printer in a more localized and thread-safe setting, but may not
  * necessarily be identical to what the IR will look like when dumping
  * the full module. */
-MLIR_CAPI_EXPORTED void
-mlirOpPrintingFlagsUseLocalScope(MlirOpPrintingFlags flags);
+void mlirOpPrintingFlagsUseLocalScope(MlirOpPrintingFlags flags);
 
 //===----------------------------------------------------------------------===//
 // Operation API.
 //===----------------------------------------------------------------------===//
 
 /// Creates an operation and transfers ownership to the caller.
-MLIR_CAPI_EXPORTED MlirOperation
-mlirOperationCreate(const MlirOperationState *state);
+MlirOperation mlirOperationCreate(const MlirOperationState *state);
 
 /// Takes an operation owned by the caller and destroys it.
-MLIR_CAPI_EXPORTED void mlirOperationDestroy(MlirOperation op);
+void mlirOperationDestroy(MlirOperation op);
 
 /// Checks whether the underlying operation is null.
 static inline int mlirOperationIsNull(MlirOperation op) { return !op.ptr; }
 
 /** Checks whether two operation handles point to the same operation. This does
  * not perform deep comparison. */
-MLIR_CAPI_EXPORTED int mlirOperationEqual(MlirOperation op,
-                                          MlirOperation other);
+int mlirOperationEqual(MlirOperation op, MlirOperation other);
 
 /// Gets the name of the operation as an identifier.
-MLIR_CAPI_EXPORTED MlirIdentifier mlirOperationGetName(MlirOperation op);
+MlirIdentifier mlirOperationGetName(MlirOperation op);
 
 /** Gets the block that owns this operation, returning null if the operation is
  * not owned. */
-MLIR_CAPI_EXPORTED MlirBlock mlirOperationGetBlock(MlirOperation op);
+MlirBlock mlirOperationGetBlock(MlirOperation op);
 
 /** Gets the operation that owns this operation, returning null if the operation
  * is not owned. */
-MLIR_CAPI_EXPORTED MlirOperation
-mlirOperationGetParentOperation(MlirOperation op);
+MlirOperation mlirOperationGetParentOperation(MlirOperation op);
 
 /// Returns the number of regions attached to the given operation.
-MLIR_CAPI_EXPORTED intptr_t mlirOperationGetNumRegions(MlirOperation op);
+intptr_t mlirOperationGetNumRegions(MlirOperation op);
 
 /// Returns `pos`-th region attached to the operation.
-MLIR_CAPI_EXPORTED MlirRegion mlirOperationGetRegion(MlirOperation op,
-                                                     intptr_t pos);
+MlirRegion mlirOperationGetRegion(MlirOperation op, intptr_t pos);
 
 /** Returns an operation immediately following the given operation it its
  * enclosing block. */
-MLIR_CAPI_EXPORTED MlirOperation mlirOperationGetNextInBlock(MlirOperation op);
+MlirOperation mlirOperationGetNextInBlock(MlirOperation op);
 
 /// Returns the number of operands of the operation.
-MLIR_CAPI_EXPORTED intptr_t mlirOperationGetNumOperands(MlirOperation op);
+intptr_t mlirOperationGetNumOperands(MlirOperation op);
 
 /// Returns `pos`-th operand of the operation.
-MLIR_CAPI_EXPORTED MlirValue mlirOperationGetOperand(MlirOperation op,
-                                                     intptr_t pos);
+MlirValue mlirOperationGetOperand(MlirOperation op, intptr_t pos);
 
 /// Returns the number of results of the operation.
-MLIR_CAPI_EXPORTED intptr_t mlirOperationGetNumResults(MlirOperation op);
+intptr_t mlirOperationGetNumResults(MlirOperation op);
 
 /// Returns `pos`-th result of the operation.
-MLIR_CAPI_EXPORTED MlirValue mlirOperationGetResult(MlirOperation op,
-                                                    intptr_t pos);
+MlirValue mlirOperationGetResult(MlirOperation op, intptr_t pos);
 
 /// Returns the number of successor blocks of the operation.
-MLIR_CAPI_EXPORTED intptr_t mlirOperationGetNumSuccessors(MlirOperation op);
+intptr_t mlirOperationGetNumSuccessors(MlirOperation op);
 
 /// Returns `pos`-th successor of the operation.
-MLIR_CAPI_EXPORTED MlirBlock mlirOperationGetSuccessor(MlirOperation op,
-                                                       intptr_t pos);
+MlirBlock mlirOperationGetSuccessor(MlirOperation op, intptr_t pos);
 
 /// Returns the number of attributes attached to the operation.
-MLIR_CAPI_EXPORTED intptr_t mlirOperationGetNumAttributes(MlirOperation op);
+intptr_t mlirOperationGetNumAttributes(MlirOperation op);
 
 /// Return `pos`-th attribute of the operation.
-MLIR_CAPI_EXPORTED MlirNamedAttribute
-mlirOperationGetAttribute(MlirOperation op, intptr_t pos);
+MlirNamedAttribute mlirOperationGetAttribute(MlirOperation op, intptr_t pos);
 
 /// Returns an attribute attached to the operation given its name.
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirOperationGetAttributeByName(MlirOperation op, const char *name);
+MlirAttribute mlirOperationGetAttributeByName(MlirOperation op,
+                                              const char *name);
 
 /** Sets an attribute by name, replacing the existing if it exists or
  * adding a new one otherwise. */
-MLIR_CAPI_EXPORTED void mlirOperationSetAttributeByName(MlirOperation op,
-                                                        const char *name,
-                                                        MlirAttribute attr);
+void mlirOperationSetAttributeByName(MlirOperation op, const char *name,
+                                     MlirAttribute attr);
 
 /** Removes an attribute by name. Returns 0 if the attribute was not found
  * and !0 if removed. */
-MLIR_CAPI_EXPORTED int mlirOperationRemoveAttributeByName(MlirOperation op,
-                                                          const char *name);
+int mlirOperationRemoveAttributeByName(MlirOperation op, const char *name);
 
 /** Prints an operation by sending chunks of the string representation and
  * forwarding `userData to `callback`. Note that the callback may be called
  * several times with consecutive chunks of the string. */
-MLIR_CAPI_EXPORTED void mlirOperationPrint(MlirOperation op,
-                                           MlirStringCallback callback,
-                                           void *userData);
+void mlirOperationPrint(MlirOperation op, MlirStringCallback callback,
+                        void *userData);
 
 /** Same as mlirOperationPrint but accepts flags controlling the printing
  * behavior. */
-MLIR_CAPI_EXPORTED void mlirOperationPrintWithFlags(MlirOperation op,
-                                                    MlirOpPrintingFlags flags,
-                                                    MlirStringCallback callback,
-                                                    void *userData);
+void mlirOperationPrintWithFlags(MlirOperation op, MlirOpPrintingFlags flags,
+                                 MlirStringCallback callback, void *userData);
 
 /// Prints an operation to stderr.
-MLIR_CAPI_EXPORTED void mlirOperationDump(MlirOperation op);
+void mlirOperationDump(MlirOperation op);
 
 //===----------------------------------------------------------------------===//
 // Region API.
 //===----------------------------------------------------------------------===//
 
 /// Creates a new empty region and transfers ownership to the caller.
-MLIR_CAPI_EXPORTED MlirRegion mlirRegionCreate();
+MlirRegion mlirRegionCreate();
 
 /// Takes a region owned by the caller and destroys it.
-MLIR_CAPI_EXPORTED void mlirRegionDestroy(MlirRegion region);
+void mlirRegionDestroy(MlirRegion region);
 
 /// Checks whether a region is null.
 static inline int mlirRegionIsNull(MlirRegion region) { return !region.ptr; }
 
 /// Gets the first block in the region.
-MLIR_CAPI_EXPORTED MlirBlock mlirRegionGetFirstBlock(MlirRegion region);
+MlirBlock mlirRegionGetFirstBlock(MlirRegion region);
 
 /// Takes a block owned by the caller and appends it to the given region.
-MLIR_CAPI_EXPORTED void mlirRegionAppendOwnedBlock(MlirRegion region,
-                                                   MlirBlock block);
+void mlirRegionAppendOwnedBlock(MlirRegion region, MlirBlock block);
 
 /** Takes a block owned by the caller and inserts it at `pos` to the given
  * region. This is an expensive operation that linearly scans the region, prefer
  * insertAfter/Before instead. */
-MLIR_CAPI_EXPORTED void
-mlirRegionInsertOwnedBlock(MlirRegion region, intptr_t pos, MlirBlock block);
+void mlirRegionInsertOwnedBlock(MlirRegion region, intptr_t pos,
+                                MlirBlock block);
 
 /** Takes a block owned by the caller and inserts it after the (non-owned)
  * reference block in the given region. The reference block must belong to the
  * region. If the reference block is null, prepends the block to the region. */
-MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockAfter(MlirRegion region,
-                                                        MlirBlock reference,
-                                                        MlirBlock block);
+void mlirRegionInsertOwnedBlockAfter(MlirRegion region, MlirBlock reference,
+                                     MlirBlock block);
 
 /** Takes a block owned by the caller and inserts it before the (non-owned)
  * reference block in the given region. The reference block must belong to the
  * region. If the reference block is null, appends the block to the region. */
-MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockBefore(MlirRegion region,
-                                                         MlirBlock reference,
-                                                         MlirBlock block);
+void mlirRegionInsertOwnedBlockBefore(MlirRegion region, MlirBlock reference,
+                                      MlirBlock block);
 
 //===----------------------------------------------------------------------===//
 // Block API.
@@ -425,65 +392,62 @@ MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockBefore(MlirRegion region,
 
 /** Creates a new empty block with the given argument types and transfers
  * ownership to the caller. */
-MLIR_CAPI_EXPORTED MlirBlock mlirBlockCreate(intptr_t nArgs, MlirType *args);
+MlirBlock mlirBlockCreate(intptr_t nArgs, MlirType *args);
 
 /// Takes a block owned by the caller and destroys it.
-MLIR_CAPI_EXPORTED void mlirBlockDestroy(MlirBlock block);
+void mlirBlockDestroy(MlirBlock block);
 
 /// Checks whether a block is null.
 static inline int mlirBlockIsNull(MlirBlock block) { return !block.ptr; }
 
 /** Checks whether two blocks handles point to the same block. This does not
  * perform deep comparison. */
-MLIR_CAPI_EXPORTED int mlirBlockEqual(MlirBlock block, MlirBlock other);
+int mlirBlockEqual(MlirBlock block, MlirBlock other);
 
 /** Returns the block immediately following the given block in its parent
  * region. */
-MLIR_CAPI_EXPORTED MlirBlock mlirBlockGetNextInRegion(MlirBlock block);
+MlirBlock mlirBlockGetNextInRegion(MlirBlock block);
 
 /// Returns the first operation in the block.
-MLIR_CAPI_EXPORTED MlirOperation mlirBlockGetFirstOperation(MlirBlock block);
+MlirOperation mlirBlockGetFirstOperation(MlirBlock block);
 
 /// Returns the terminator operation in the block or null if no terminator.
-MLIR_CAPI_EXPORTED MlirOperation mlirBlockGetTerminator(MlirBlock block);
+MlirOperation mlirBlockGetTerminator(MlirBlock block);
 
 /// Takes an operation owned by the caller and appends it to the block.
-MLIR_CAPI_EXPORTED void mlirBlockAppendOwnedOperation(MlirBlock block,
-                                                      MlirOperation operation);
+void mlirBlockAppendOwnedOperation(MlirBlock block, MlirOperation operation);
 
 /** Takes an operation owned by the caller and inserts it as `pos` to the block.
    This is an expensive operation that scans the block linearly, prefer
    insertBefore/After instead. */
-MLIR_CAPI_EXPORTED void mlirBlockInsertOwnedOperation(MlirBlock block,
-                                                      intptr_t pos,
-                                                      MlirOperation operation);
+void mlirBlockInsertOwnedOperation(MlirBlock block, intptr_t pos,
+                                   MlirOperation operation);
 
 /** Takes an operation owned by the caller and inserts it after the (non-owned)
  * reference operation in the given block. If the reference is null, prepends
  * the operation. Otherwise, the reference must belong to the block. */
-MLIR_CAPI_EXPORTED void
-mlirBlockInsertOwnedOperationAfter(MlirBlock block, MlirOperation reference,
-                                   MlirOperation operation);
+void mlirBlockInsertOwnedOperationAfter(MlirBlock block,
+                                        MlirOperation reference,
+                                        MlirOperation operation);
 
 /** Takes an operation owned by the caller and inserts it before the (non-owned)
  * reference operation in the given block. If the reference is null, appends the
  * operation. Otherwise, the reference must belong to the block. */
-MLIR_CAPI_EXPORTED void
-mlirBlockInsertOwnedOperationBefore(MlirBlock block, MlirOperation reference,
-                                    MlirOperation operation);
+void mlirBlockInsertOwnedOperationBefore(MlirBlock block,
+                                         MlirOperation reference,
+                                         MlirOperation operation);
 
 /// Returns the number of arguments of the block.
-MLIR_CAPI_EXPORTED intptr_t mlirBlockGetNumArguments(MlirBlock block);
+intptr_t mlirBlockGetNumArguments(MlirBlock block);
 
 /// Returns `pos`-th argument of the block.
-MLIR_CAPI_EXPORTED MlirValue mlirBlockGetArgument(MlirBlock block,
-                                                  intptr_t pos);
+MlirValue mlirBlockGetArgument(MlirBlock block, intptr_t pos);
 
 /** Prints a block by sending chunks of the string representation and
  * forwarding `userData to `callback`. Note that the callback may be called
  * several times with consecutive chunks of the string. */
-MLIR_CAPI_EXPORTED void
-mlirBlockPrint(MlirBlock block, MlirStringCallback callback, void *userData);
+void mlirBlockPrint(MlirBlock block, MlirStringCallback callback,
+                    void *userData);
 
 //===----------------------------------------------------------------------===//
 // Value API.
@@ -493,116 +457,108 @@ mlirBlockPrint(MlirBlock block, MlirStringCallback callback, void *userData);
 static inline int mlirValueIsNull(MlirValue value) { return !value.ptr; }
 
 /// Returns 1 if the value is a block argument, 0 otherwise.
-MLIR_CAPI_EXPORTED int mlirValueIsABlockArgument(MlirValue value);
+int mlirValueIsABlockArgument(MlirValue value);
 
 /// Returns 1 if the value is an operation result, 0 otherwise.
-MLIR_CAPI_EXPORTED int mlirValueIsAOpResult(MlirValue value);
+int mlirValueIsAOpResult(MlirValue value);
 
 /** Returns the block in which this value is defined as an argument. Asserts if
  * the value is not a block argument. */
-MLIR_CAPI_EXPORTED MlirBlock mlirBlockArgumentGetOwner(MlirValue value);
+MlirBlock mlirBlockArgumentGetOwner(MlirValue value);
 
 /// Returns the position of the value in the argument list of its block.
-MLIR_CAPI_EXPORTED intptr_t mlirBlockArgumentGetArgNumber(MlirValue value);
+intptr_t mlirBlockArgumentGetArgNumber(MlirValue value);
 
 /// Sets the type of the block argument to the given type.
-MLIR_CAPI_EXPORTED void mlirBlockArgumentSetType(MlirValue value,
-                                                 MlirType type);
+void mlirBlockArgumentSetType(MlirValue value, MlirType type);
 
 /** Returns an operation that produced this value as its result. Asserts if the
  * value is not an op result. */
-MLIR_CAPI_EXPORTED MlirOperation mlirOpResultGetOwner(MlirValue value);
+MlirOperation mlirOpResultGetOwner(MlirValue value);
 
 /** Returns the position of the value in the list of results of the operation
  * that produced it. */
-MLIR_CAPI_EXPORTED intptr_t mlirOpResultGetResultNumber(MlirValue value);
+intptr_t mlirOpResultGetResultNumber(MlirValue value);
 
 /// Returns the type of the value.
-MLIR_CAPI_EXPORTED MlirType mlirValueGetType(MlirValue value);
+MlirType mlirValueGetType(MlirValue value);
 
 /// Prints the value to the standard error stream.
-MLIR_CAPI_EXPORTED void mlirValueDump(MlirValue value);
+void mlirValueDump(MlirValue value);
 
 /** Prints a value by sending chunks of the string representation and
  * forwarding `userData to `callback`. Note that the callback may be called
  * several times with consecutive chunks of the string. */
-MLIR_CAPI_EXPORTED void
-mlirValuePrint(MlirValue value, MlirStringCallback callback, void *userData);
+void mlirValuePrint(MlirValue value, MlirStringCallback callback,
+                    void *userData);
 
 //===----------------------------------------------------------------------===//
 // Type API.
 //===----------------------------------------------------------------------===//
 
 /// Parses a type. The type is owned by the context.
-MLIR_CAPI_EXPORTED MlirType mlirTypeParseGet(MlirContext context,
-                                             const char *type);
+MlirType mlirTypeParseGet(MlirContext context, const char *type);
 
 /// Gets the context that a type was created with.
-MLIR_CAPI_EXPORTED MlirContext mlirTypeGetContext(MlirType type);
+MlirContext mlirTypeGetContext(MlirType type);
 
 /// Checks whether a type is null.
 static inline int mlirTypeIsNull(MlirType type) { return !type.ptr; }
 
 /// Checks if two types are equal.
-MLIR_CAPI_EXPORTED int mlirTypeEqual(MlirType t1, MlirType t2);
+int mlirTypeEqual(MlirType t1, MlirType t2);
 
 /** Prints a location by sending chunks of the string representation and
  * forwarding `userData to `callback`. Note that the callback may be called
  * several times with consecutive chunks of the string. */
-MLIR_CAPI_EXPORTED void
-mlirTypePrint(MlirType type, MlirStringCallback callback, void *userData);
+void mlirTypePrint(MlirType type, MlirStringCallback callback, void *userData);
 
 /// Prints the type to the standard error stream.
-MLIR_CAPI_EXPORTED void mlirTypeDump(MlirType type);
+void mlirTypeDump(MlirType type);
 
 //===----------------------------------------------------------------------===//
 // Attribute API.
 //===----------------------------------------------------------------------===//
 
 /// Parses an attribute. The attribute is owned by the context.
-MLIR_CAPI_EXPORTED MlirAttribute mlirAttributeParseGet(MlirContext context,
-                                                       const char *attr);
+MlirAttribute mlirAttributeParseGet(MlirContext context, const char *attr);
 
 /// Gets the context that an attribute was created with.
-MLIR_CAPI_EXPORTED MlirContext mlirAttributeGetContext(MlirAttribute attribute);
+MlirContext mlirAttributeGetContext(MlirAttribute attribute);
 
 /// Gets the type of this attribute.
-MLIR_CAPI_EXPORTED MlirType mlirAttributeGetType(MlirAttribute attribute);
+MlirType mlirAttributeGetType(MlirAttribute attribute);
 
 /// Checks whether an attribute is null.
 static inline int mlirAttributeIsNull(MlirAttribute attr) { return !attr.ptr; }
 
 /// Checks if two attributes are equal.
-MLIR_CAPI_EXPORTED int mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2);
+int mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2);
 
 /** Prints an attribute by sending chunks of the string representation and
  * forwarding `userData to `callback`. Note that the callback may be called
  * several times with consecutive chunks of the string. */
-MLIR_CAPI_EXPORTED void mlirAttributePrint(MlirAttribute attr,
-                                           MlirStringCallback callback,
-                                           void *userData);
+void mlirAttributePrint(MlirAttribute attr, MlirStringCallback callback,
+                        void *userData);
 
 /// Prints the attribute to the standard error stream.
-MLIR_CAPI_EXPORTED void mlirAttributeDump(MlirAttribute attr);
+void mlirAttributeDump(MlirAttribute attr);
 
 /// Associates an attribute with the name. Takes ownership of neither.
-MLIR_CAPI_EXPORTED MlirNamedAttribute mlirNamedAttributeGet(const char *name,
-                                                            MlirAttribute attr);
+MlirNamedAttribute mlirNamedAttributeGet(const char *name, MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // Identifier API.
 //===----------------------------------------------------------------------===//
 
 /// Gets an identifier with the given string value.
-MLIR_CAPI_EXPORTED MlirIdentifier mlirIdentifierGet(MlirContext context,
-                                                    MlirStringRef str);
+MlirIdentifier mlirIdentifierGet(MlirContext context, MlirStringRef str);
 
 /// Checks whether two identifiers are the same.
-MLIR_CAPI_EXPORTED int mlirIdentifierEqual(MlirIdentifier ident,
-                                           MlirIdentifier other);
+int mlirIdentifierEqual(MlirIdentifier ident, MlirIdentifier other);
 
 /// Gets the string value of the identifier.
-MLIR_CAPI_EXPORTED MlirStringRef mlirIdentifierStr(MlirIdentifier ident);
+MlirStringRef mlirIdentifierStr(MlirIdentifier ident);
 
 #ifdef __cplusplus
 }

diff  --git a/mlir/include/mlir-c/Pass.h b/mlir/include/mlir-c/Pass.h
index 7e56dd3388c2..ad4faea4a5f9 100644
--- a/mlir/include/mlir-c/Pass.h
+++ b/mlir/include/mlir-c/Pass.h
@@ -48,57 +48,55 @@ DEFINE_C_API_STRUCT(MlirOpPassManager, void);
 #undef DEFINE_C_API_STRUCT
 
 /// Create a new top-level PassManager.
-MLIR_CAPI_EXPORTED MlirPassManager mlirPassManagerCreate(MlirContext ctx);
+MlirPassManager mlirPassManagerCreate(MlirContext ctx);
 
 /// Destroy the provided PassManager.
-MLIR_CAPI_EXPORTED void mlirPassManagerDestroy(MlirPassManager passManager);
+void mlirPassManagerDestroy(MlirPassManager passManager);
 
 /// Cast a top-level PassManager to a generic OpPassManager.
-MLIR_CAPI_EXPORTED MlirOpPassManager
+MlirOpPassManager
 mlirPassManagerGetAsOpPassManager(MlirPassManager passManager);
 
 /// Run the provided `passManager` on the given `module`.
-MLIR_CAPI_EXPORTED MlirLogicalResult
-mlirPassManagerRun(MlirPassManager passManager, MlirModule module);
+MlirLogicalResult mlirPassManagerRun(MlirPassManager passManager,
+                                     MlirModule module);
 
 /** Nest an OpPassManager under the top-level PassManager, the nested
  * passmanager will only run on operations matching the provided name.
  * The returned OpPassManager will be destroyed when the parent is destroyed.
  * To further nest more OpPassManager under the newly returned one, see
  * `mlirOpPassManagerNest` below. */
-MLIR_CAPI_EXPORTED MlirOpPassManager mlirPassManagerGetNestedUnder(
-    MlirPassManager passManager, MlirStringRef operationName);
+MlirOpPassManager mlirPassManagerGetNestedUnder(MlirPassManager passManager,
+                                                MlirStringRef operationName);
 
 /** Nest an OpPassManager under the provided OpPassManager, the nested
  * passmanager will only run on operations matching the provided name.
  * The returned OpPassManager will be destroyed when the parent is destroyed. */
-MLIR_CAPI_EXPORTED MlirOpPassManager mlirOpPassManagerGetNestedUnder(
-    MlirOpPassManager passManager, MlirStringRef operationName);
+MlirOpPassManager mlirOpPassManagerGetNestedUnder(MlirOpPassManager passManager,
+                                                  MlirStringRef operationName);
 
 /** Add a pass and transfer ownership to the provided top-level mlirPassManager.
  * If the pass is not a generic operation pass or a ModulePass, a new
  * OpPassManager is implicitly nested under the provided PassManager. */
-MLIR_CAPI_EXPORTED void mlirPassManagerAddOwnedPass(MlirPassManager passManager,
-                                                    MlirPass pass);
+void mlirPassManagerAddOwnedPass(MlirPassManager passManager, MlirPass pass);
 
 /** Add a pass and transfer ownership to the provided mlirOpPassManager. If the
  * pass is not a generic operation pass or matching the type of the provided
  * PassManager, a new OpPassManager is implicitly nested under the provided
  * PassManager. */
-MLIR_CAPI_EXPORTED void
-mlirOpPassManagerAddOwnedPass(MlirOpPassManager passManager, MlirPass pass);
+void mlirOpPassManagerAddOwnedPass(MlirOpPassManager passManager,
+                                   MlirPass pass);
 
 /** Print a textual MLIR pass pipeline by sending chunks of the string
  * representation and forwarding `userData to `callback`. Note that the callback
  * may be called several times with consecutive chunks of the string. */
-MLIR_CAPI_EXPORTED void mlirPrintPassPipeline(MlirOpPassManager passManager,
-                                              MlirStringCallback callback,
-                                              void *userData);
+void mlirPrintPassPipeline(MlirOpPassManager passManager,
+                           MlirStringCallback callback, void *userData);
 
 /** Parse a textual MLIR pass pipeline and add it to the provided OpPassManager.
  */
-MLIR_CAPI_EXPORTED MlirLogicalResult
-mlirParsePassPipeline(MlirOpPassManager passManager, MlirStringRef pipeline);
+MlirLogicalResult mlirParsePassPipeline(MlirOpPassManager passManager,
+                                        MlirStringRef pipeline);
 
 #ifdef __cplusplus
 }

diff  --git a/mlir/include/mlir-c/Registration.h b/mlir/include/mlir-c/Registration.h
index 6bb885ef642a..92f9cb010440 100644
--- a/mlir/include/mlir-c/Registration.h
+++ b/mlir/include/mlir-c/Registration.h
@@ -19,7 +19,7 @@ extern "C" {
 /** Registers all dialects known to core MLIR with the provided Context.
  * This is needed before creating IR for these Dialects.
  */
-MLIR_CAPI_EXPORTED void mlirRegisterAllDialects(MlirContext context);
+void mlirRegisterAllDialects(MlirContext context);
 
 #ifdef __cplusplus
 }

diff  --git a/mlir/include/mlir-c/StandardAttributes.h b/mlir/include/mlir-c/StandardAttributes.h
index 81f8fd366f31..c7ff555a69c7 100644
--- a/mlir/include/mlir-c/StandardAttributes.h
+++ b/mlir/include/mlir-c/StandardAttributes.h
@@ -27,59 +27,56 @@ extern "C" {
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is an affine map attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAAffineMap(MlirAttribute attr);
+int mlirAttributeIsAAffineMap(MlirAttribute attr);
 
 /** Creates an affine map attribute wrapping the given map. The attribute
  * belongs to the same context as the affine map. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirAffineMapAttrGet(MlirAffineMap map);
+MlirAttribute mlirAffineMapAttrGet(MlirAffineMap map);
 
 /// Returns the affine map wrapped in the given affine map attribute.
-MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapAttrGetValue(MlirAttribute attr);
+MlirAffineMap mlirAffineMapAttrGetValue(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // Array attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is an array attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAArray(MlirAttribute attr);
+int mlirAttributeIsAArray(MlirAttribute attr);
 
 /** Creates an array element containing the given list of elements in the given
  * context. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirArrayAttrGet(MlirContext ctx,
-                                                  intptr_t numElements,
-                                                  MlirAttribute *elements);
+MlirAttribute mlirArrayAttrGet(MlirContext ctx, intptr_t numElements,
+                               MlirAttribute *elements);
 
 /// Returns the number of elements stored in the given array attribute.
-MLIR_CAPI_EXPORTED intptr_t mlirArrayAttrGetNumElements(MlirAttribute attr);
+intptr_t mlirArrayAttrGetNumElements(MlirAttribute attr);
 
 /// Returns pos-th element stored in the given array attribute.
-MLIR_CAPI_EXPORTED MlirAttribute mlirArrayAttrGetElement(MlirAttribute attr,
-                                                         intptr_t pos);
+MlirAttribute mlirArrayAttrGetElement(MlirAttribute attr, intptr_t pos);
 
 //===----------------------------------------------------------------------===//
 // Dictionary attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is a dictionary attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsADictionary(MlirAttribute attr);
+int mlirAttributeIsADictionary(MlirAttribute attr);
 
 /** Creates a dictionary attribute containing the given list of elements in the
  * provided context. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirDictionaryAttrGet(
-    MlirContext ctx, intptr_t numElements, MlirNamedAttribute *elements);
+MlirAttribute mlirDictionaryAttrGet(MlirContext ctx, intptr_t numElements,
+                                    MlirNamedAttribute *elements);
 
 /// Returns the number of attributes contained in a dictionary attribute.
-MLIR_CAPI_EXPORTED intptr_t
-mlirDictionaryAttrGetNumElements(MlirAttribute attr);
+intptr_t mlirDictionaryAttrGetNumElements(MlirAttribute attr);
 
 /// Returns pos-th element of the given dictionary attribute.
-MLIR_CAPI_EXPORTED MlirNamedAttribute
-mlirDictionaryAttrGetElement(MlirAttribute attr, intptr_t pos);
+MlirNamedAttribute mlirDictionaryAttrGetElement(MlirAttribute attr,
+                                                intptr_t pos);
 
 /** Returns the dictionary attribute element with the given name or NULL if the
  * given name does not exist in the dictionary. */
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDictionaryAttrGetElementByName(MlirAttribute attr, const char *name);
+MlirAttribute mlirDictionaryAttrGetElementByName(MlirAttribute attr,
+                                                 const char *name);
 
 //===----------------------------------------------------------------------===//
 // Floating point attribute.
@@ -89,22 +86,21 @@ mlirDictionaryAttrGetElementByName(MlirAttribute attr, const char *name);
  * relevant functions here. */
 
 /// Checks whether the given attribute is a floating point attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAFloat(MlirAttribute attr);
+int mlirAttributeIsAFloat(MlirAttribute attr);
 
 /** Creates a floating point attribute in the given context with the given
  * double value and double-precision FP semantics. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirFloatAttrDoubleGet(MlirContext ctx,
-                                                        MlirType type,
-                                                        double value);
+MlirAttribute mlirFloatAttrDoubleGet(MlirContext ctx, MlirType type,
+                                     double value);
 
 /** Same as "mlirFloatAttrDoubleGet", but if the type is not valid for a
  * construction of a FloatAttr, returns a null MlirAttribute. */
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirFloatAttrDoubleGetChecked(MlirType type, double value, MlirLocation loc);
+MlirAttribute mlirFloatAttrDoubleGetChecked(MlirType type, double value,
+                                            MlirLocation loc);
 
 /** Returns the value stored in the given floating point attribute, interpreting
  * the value as double. */
-MLIR_CAPI_EXPORTED double mlirFloatAttrGetValueDouble(MlirAttribute attr);
+double mlirFloatAttrGetValueDouble(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // Integer attribute.
@@ -114,184 +110,172 @@ MLIR_CAPI_EXPORTED double mlirFloatAttrGetValueDouble(MlirAttribute attr);
  * relevant functions here. */
 
 /// Checks whether the given attribute is an integer attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAInteger(MlirAttribute attr);
+int mlirAttributeIsAInteger(MlirAttribute attr);
 
 /** Creates an integer attribute of the given type with the given integer
  * value. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirIntegerAttrGet(MlirType type,
-                                                    int64_t value);
+MlirAttribute mlirIntegerAttrGet(MlirType type, int64_t value);
 
 /** Returns the value stored in the given integer attribute, assuming the value
  * fits into a 64-bit integer. */
-MLIR_CAPI_EXPORTED int64_t mlirIntegerAttrGetValueInt(MlirAttribute attr);
+int64_t mlirIntegerAttrGetValueInt(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // Bool attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is a bool attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsABool(MlirAttribute attr);
+int mlirAttributeIsABool(MlirAttribute attr);
 
 /// Creates a bool attribute in the given context with the given value.
-MLIR_CAPI_EXPORTED MlirAttribute mlirBoolAttrGet(MlirContext ctx, int value);
+MlirAttribute mlirBoolAttrGet(MlirContext ctx, int value);
 
 /// Returns the value stored in the given bool attribute.
-MLIR_CAPI_EXPORTED int mlirBoolAttrGetValue(MlirAttribute attr);
+int mlirBoolAttrGetValue(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // Integer set attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is an integer set attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAIntegerSet(MlirAttribute attr);
+int mlirAttributeIsAIntegerSet(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // Opaque attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is an opaque attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAOpaque(MlirAttribute attr);
+int mlirAttributeIsAOpaque(MlirAttribute attr);
 
 /** Creates an opaque attribute in the given context associated with the dialect
  * identified by its namespace. The attribute contains opaque byte data of the
  * specified length (data need not be null-terminated). */
-MLIR_CAPI_EXPORTED MlirAttribute mlirOpaqueAttrGet(MlirContext ctx,
-                                                   const char *dialectNamespace,
-                                                   intptr_t dataLength,
-                                                   const char *data,
-                                                   MlirType type);
+MlirAttribute mlirOpaqueAttrGet(MlirContext ctx, const char *dialectNamespace,
+                                intptr_t dataLength, const char *data,
+                                MlirType type);
 
 /** Returns the namespace of the dialect with which the given opaque attribute
  * is associated. The namespace string is owned by the context. */
-MLIR_CAPI_EXPORTED const char *
-mlirOpaqueAttrGetDialectNamespace(MlirAttribute attr);
+const char *mlirOpaqueAttrGetDialectNamespace(MlirAttribute attr);
 
 /** Returns the raw data as a string reference. The data remains live as long as
  * the context in which the attribute lives. */
-MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueAttrGetData(MlirAttribute attr);
+MlirStringRef mlirOpaqueAttrGetData(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // String attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is a string attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAString(MlirAttribute attr);
+int mlirAttributeIsAString(MlirAttribute attr);
 
 /** Creates a string attribute in the given context containing the given string.
  * The string need not be null-terminated and its length must be specified. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirStringAttrGet(MlirContext ctx,
-                                                   intptr_t length,
-                                                   const char *data);
+MlirAttribute mlirStringAttrGet(MlirContext ctx, intptr_t length,
+                                const char *data);
 
 /** Creates a string attribute in the given context containing the given string.
  * The string need not be null-terminated and its length must be specified.
  * Additionally, the attribute has the given type. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirStringAttrTypedGet(MlirType type,
-                                                        intptr_t length,
-                                                        const char *data);
+MlirAttribute mlirStringAttrTypedGet(MlirType type, intptr_t length,
+                                     const char *data);
 
 /** Returns the attribute values as a string reference. The data remains live as
  * long as the context in which the attribute lives. */
-MLIR_CAPI_EXPORTED MlirStringRef mlirStringAttrGetValue(MlirAttribute attr);
+MlirStringRef mlirStringAttrGetValue(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // SymbolRef attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is a symbol reference attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsASymbolRef(MlirAttribute attr);
+int mlirAttributeIsASymbolRef(MlirAttribute attr);
 
 /** Creates a symbol reference attribute in the given context referencing a
  * symbol identified by the given string inside a list of nested references.
  * Each of the references in the list must not be nested. The string need not be
  * null-terminated and its length must be specified. */
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirSymbolRefAttrGet(MlirContext ctx, intptr_t length, const char *symbol,
-                     intptr_t numReferences, MlirAttribute *references);
+MlirAttribute mlirSymbolRefAttrGet(MlirContext ctx, intptr_t length,
+                                   const char *symbol, intptr_t numReferences,
+                                   MlirAttribute *references);
 
 /** Returns the string reference to the root referenced symbol. The data remains
  * live as long as the context in which the attribute lives. */
-MLIR_CAPI_EXPORTED MlirStringRef
-mlirSymbolRefAttrGetRootReference(MlirAttribute attr);
+MlirStringRef mlirSymbolRefAttrGetRootReference(MlirAttribute attr);
 
 /** Returns the string reference to the leaf referenced symbol. The data remains
  * live as long as the context in which the attribute lives. */
-MLIR_CAPI_EXPORTED MlirStringRef
-mlirSymbolRefAttrGetLeafReference(MlirAttribute attr);
+MlirStringRef mlirSymbolRefAttrGetLeafReference(MlirAttribute attr);
 
 /** Returns the number of references nested in the given symbol reference
  * attribute. */
-MLIR_CAPI_EXPORTED intptr_t
-mlirSymbolRefAttrGetNumNestedReferences(MlirAttribute attr);
+intptr_t mlirSymbolRefAttrGetNumNestedReferences(MlirAttribute attr);
 
 /// Returns pos-th reference nested in the given symbol reference attribute.
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirSymbolRefAttrGetNestedReference(MlirAttribute attr, intptr_t pos);
+MlirAttribute mlirSymbolRefAttrGetNestedReference(MlirAttribute attr,
+                                                  intptr_t pos);
 
 //===----------------------------------------------------------------------===//
 // Flat SymbolRef attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is a flat symbol reference attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAFlatSymbolRef(MlirAttribute attr);
+int mlirAttributeIsAFlatSymbolRef(MlirAttribute attr);
 
 /** Creates a flat symbol reference attribute in the given context referencing a
  * symbol identified by the given string. The string need not be null-terminated
  * and its length must be specified. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirFlatSymbolRefAttrGet(MlirContext ctx,
-                                                          intptr_t length,
-                                                          const char *symbol);
+MlirAttribute mlirFlatSymbolRefAttrGet(MlirContext ctx, intptr_t length,
+                                       const char *symbol);
 
 /** Returns the referenced symbol as a string reference. The data remains live
  * as long as the context in which the attribute lives. */
-MLIR_CAPI_EXPORTED MlirStringRef
-mlirFlatSymbolRefAttrGetValue(MlirAttribute attr);
+MlirStringRef mlirFlatSymbolRefAttrGetValue(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // Type attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is a type attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAType(MlirAttribute attr);
+int mlirAttributeIsAType(MlirAttribute attr);
 
 /** Creates a type attribute wrapping the given type in the same context as the
  * type. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirTypeAttrGet(MlirType type);
+MlirAttribute mlirTypeAttrGet(MlirType type);
 
 /// Returns the type stored in the given type attribute.
-MLIR_CAPI_EXPORTED MlirType mlirTypeAttrGetValue(MlirAttribute attr);
+MlirType mlirTypeAttrGetValue(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // Unit attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is a unit attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAUnit(MlirAttribute attr);
+int mlirAttributeIsAUnit(MlirAttribute attr);
 
 /// Creates a unit attribute in the given context.
-MLIR_CAPI_EXPORTED MlirAttribute mlirUnitAttrGet(MlirContext ctx);
+MlirAttribute mlirUnitAttrGet(MlirContext ctx);
 
 //===----------------------------------------------------------------------===//
 // Elements attributes.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is an elements attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAElements(MlirAttribute attr);
+int mlirAttributeIsAElements(MlirAttribute attr);
 
 /// Returns the element at the given rank-dimensional index.
-MLIR_CAPI_EXPORTED MlirAttribute mlirElementsAttrGetValue(MlirAttribute attr,
-                                                          intptr_t rank,
-                                                          uint64_t *idxs);
+MlirAttribute mlirElementsAttrGetValue(MlirAttribute attr, intptr_t rank,
+                                       uint64_t *idxs);
 
 /** Checks whether the given rank-dimensional index is valid in the given
  * elements attribute. */
-MLIR_CAPI_EXPORTED int
-mlirElementsAttrIsValidIndex(MlirAttribute attr, intptr_t rank, uint64_t *idxs);
+int mlirElementsAttrIsValidIndex(MlirAttribute attr, intptr_t rank,
+                                 uint64_t *idxs);
 
 /** Gets the total number of elements in the given elements attribute. In order
  * to iterate over the attribute, obtain its type, which must be a statically
  * shaped type and use its sizes to build a multi-dimensional index. */
-MLIR_CAPI_EXPORTED int64_t mlirElementsAttrGetNumElements(MlirAttribute attr);
+int64_t mlirElementsAttrGetNumElements(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // Dense elements attribute.
@@ -302,107 +286,100 @@ MLIR_CAPI_EXPORTED int64_t mlirElementsAttrGetNumElements(MlirAttribute attr);
  * relevant functions here. */
 
 /// Checks whether the given attribute is a dense elements attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsADenseElements(MlirAttribute attr);
-MLIR_CAPI_EXPORTED int mlirAttributeIsADenseIntElements(MlirAttribute attr);
-MLIR_CAPI_EXPORTED int mlirAttributeIsADenseFPElements(MlirAttribute attr);
+int mlirAttributeIsADenseElements(MlirAttribute attr);
+int mlirAttributeIsADenseIntElements(MlirAttribute attr);
+int mlirAttributeIsADenseFPElements(MlirAttribute attr);
 
 /** Creates a dense elements attribute with the given Shaped type and elements
  * in the same context as the type. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrGet(
-    MlirType shapedType, intptr_t numElements, MlirAttribute *elements);
+MlirAttribute mlirDenseElementsAttrGet(MlirType shapedType,
+                                       intptr_t numElements,
+                                       MlirAttribute *elements);
 
 /** Creates a dense elements attribute with the given Shaped type containing a
  * single replicated element (splat). */
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrSplatGet(MlirType shapedType, MlirAttribute element);
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrBoolSplatGet(MlirType shapedType, int element);
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrUInt32SplatGet(MlirType shapedType, uint32_t element);
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrInt32SplatGet(MlirType shapedType, int32_t element);
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrUInt64SplatGet(MlirType shapedType, uint64_t element);
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrInt64SplatGet(MlirType shapedType, int64_t element);
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrFloatSplatGet(MlirType shapedType, float element);
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrDoubleSplatGet(MlirType shapedType, double element);
+MlirAttribute mlirDenseElementsAttrSplatGet(MlirType shapedType,
+                                            MlirAttribute element);
+MlirAttribute mlirDenseElementsAttrBoolSplatGet(MlirType shapedType,
+                                                int element);
+MlirAttribute mlirDenseElementsAttrUInt32SplatGet(MlirType shapedType,
+                                                  uint32_t element);
+MlirAttribute mlirDenseElementsAttrInt32SplatGet(MlirType shapedType,
+                                                 int32_t element);
+MlirAttribute mlirDenseElementsAttrUInt64SplatGet(MlirType shapedType,
+                                                  uint64_t element);
+MlirAttribute mlirDenseElementsAttrInt64SplatGet(MlirType shapedType,
+                                                 int64_t element);
+MlirAttribute mlirDenseElementsAttrFloatSplatGet(MlirType shapedType,
+                                                 float element);
+MlirAttribute mlirDenseElementsAttrDoubleSplatGet(MlirType shapedType,
+                                                  double element);
 
 /** Creates a dense elements attribute with the given shaped type from elements
  * of a specific type. Expects the element type of the shaped type to match the
  * data element type. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrBoolGet(
-    MlirType shapedType, intptr_t numElements, const int *elements);
-MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt32Get(
-    MlirType shapedType, intptr_t numElements, const uint32_t *elements);
-MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrInt32Get(
-    MlirType shapedType, intptr_t numElements, const int32_t *elements);
-MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt64Get(
-    MlirType shapedType, intptr_t numElements, const uint64_t *elements);
-MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrInt64Get(
-    MlirType shapedType, intptr_t numElements, const int64_t *elements);
-MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrFloatGet(
-    MlirType shapedType, intptr_t numElements, const float *elements);
-MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrDoubleGet(
-    MlirType shapedType, intptr_t numElements, const double *elements);
+MlirAttribute mlirDenseElementsAttrBoolGet(MlirType shapedType,
+                                           intptr_t numElements,
+                                           const int *elements);
+MlirAttribute mlirDenseElementsAttrUInt32Get(MlirType shapedType,
+                                             intptr_t numElements,
+                                             const uint32_t *elements);
+MlirAttribute mlirDenseElementsAttrInt32Get(MlirType shapedType,
+                                            intptr_t numElements,
+                                            const int32_t *elements);
+MlirAttribute mlirDenseElementsAttrUInt64Get(MlirType shapedType,
+                                             intptr_t numElements,
+                                             const uint64_t *elements);
+MlirAttribute mlirDenseElementsAttrInt64Get(MlirType shapedType,
+                                            intptr_t numElements,
+                                            const int64_t *elements);
+MlirAttribute mlirDenseElementsAttrFloatGet(MlirType shapedType,
+                                            intptr_t numElements,
+                                            const float *elements);
+MlirAttribute mlirDenseElementsAttrDoubleGet(MlirType shapedType,
+                                             intptr_t numElements,
+                                             const double *elements);
 
 /** Creates a dense elements attribute with the given shaped type from string
  * elements. The strings need not be null-terminated and their lengths are
  * provided as a separate argument co-indexed with the strs argument. */
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrStringGet(MlirType shapedType, intptr_t numElements,
-                               intptr_t *strLengths, const char **strs);
+MlirAttribute mlirDenseElementsAttrStringGet(MlirType shapedType,
+                                             intptr_t numElements,
+                                             intptr_t *strLengths,
+                                             const char **strs);
 /** Creates a dense elements attribute that has the same data as the given dense
  * elements attribute and a 
diff erent shaped type. The new type must have the
  * same total number of elements. */
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrReshapeGet(MlirAttribute attr, MlirType shapedType);
+MlirAttribute mlirDenseElementsAttrReshapeGet(MlirAttribute attr,
+                                              MlirType shapedType);
 
 /** Checks whether the given dense elements attribute contains a single
  * replicated value (splat). */
-MLIR_CAPI_EXPORTED int mlirDenseElementsAttrIsSplat(MlirAttribute attr);
+int mlirDenseElementsAttrIsSplat(MlirAttribute attr);
 
 /** Returns the single replicated value (splat) of a specific type contained by
  * the given dense elements attribute. */
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirDenseElementsAttrGetSplatValue(MlirAttribute attr);
-MLIR_CAPI_EXPORTED int
-mlirDenseElementsAttrGetBoolSplatValue(MlirAttribute attr);
-MLIR_CAPI_EXPORTED int32_t
-mlirDenseElementsAttrGetInt32SplatValue(MlirAttribute attr);
-MLIR_CAPI_EXPORTED uint32_t
-mlirDenseElementsAttrGetUInt32SplatValue(MlirAttribute attr);
-MLIR_CAPI_EXPORTED int64_t
-mlirDenseElementsAttrGetInt64SplatValue(MlirAttribute attr);
-MLIR_CAPI_EXPORTED uint64_t
-mlirDenseElementsAttrGetUInt64SplatValue(MlirAttribute attr);
-MLIR_CAPI_EXPORTED float
-mlirDenseElementsAttrGetFloatSplatValue(MlirAttribute attr);
-MLIR_CAPI_EXPORTED double
-mlirDenseElementsAttrGetDoubleSplatValue(MlirAttribute attr);
-MLIR_CAPI_EXPORTED MlirStringRef
-mlirDenseElementsAttrGetStringSplatValue(MlirAttribute attr);
+MlirAttribute mlirDenseElementsAttrGetSplatValue(MlirAttribute attr);
+int mlirDenseElementsAttrGetBoolSplatValue(MlirAttribute attr);
+int32_t mlirDenseElementsAttrGetInt32SplatValue(MlirAttribute attr);
+uint32_t mlirDenseElementsAttrGetUInt32SplatValue(MlirAttribute attr);
+int64_t mlirDenseElementsAttrGetInt64SplatValue(MlirAttribute attr);
+uint64_t mlirDenseElementsAttrGetUInt64SplatValue(MlirAttribute attr);
+float mlirDenseElementsAttrGetFloatSplatValue(MlirAttribute attr);
+double mlirDenseElementsAttrGetDoubleSplatValue(MlirAttribute attr);
+MlirStringRef mlirDenseElementsAttrGetStringSplatValue(MlirAttribute attr);
 
 /** Returns the pos-th value (flat contiguous indexing) of a specific type
  * contained by the given dense elements attribute. */
-MLIR_CAPI_EXPORTED int mlirDenseElementsAttrGetBoolValue(MlirAttribute attr,
-                                                         intptr_t pos);
-MLIR_CAPI_EXPORTED int32_t
-mlirDenseElementsAttrGetInt32Value(MlirAttribute attr, intptr_t pos);
-MLIR_CAPI_EXPORTED uint32_t
-mlirDenseElementsAttrGetUInt32Value(MlirAttribute attr, intptr_t pos);
-MLIR_CAPI_EXPORTED int64_t
-mlirDenseElementsAttrGetInt64Value(MlirAttribute attr, intptr_t pos);
-MLIR_CAPI_EXPORTED uint64_t
-mlirDenseElementsAttrGetUInt64Value(MlirAttribute attr, intptr_t pos);
-MLIR_CAPI_EXPORTED float mlirDenseElementsAttrGetFloatValue(MlirAttribute attr,
-                                                            intptr_t pos);
-MLIR_CAPI_EXPORTED double
-mlirDenseElementsAttrGetDoubleValue(MlirAttribute attr, intptr_t pos);
-MLIR_CAPI_EXPORTED MlirStringRef
-mlirDenseElementsAttrGetStringValue(MlirAttribute attr, intptr_t pos);
+int mlirDenseElementsAttrGetBoolValue(MlirAttribute attr, intptr_t pos);
+int32_t mlirDenseElementsAttrGetInt32Value(MlirAttribute attr, intptr_t pos);
+uint32_t mlirDenseElementsAttrGetUInt32Value(MlirAttribute attr, intptr_t pos);
+int64_t mlirDenseElementsAttrGetInt64Value(MlirAttribute attr, intptr_t pos);
+uint64_t mlirDenseElementsAttrGetUInt64Value(MlirAttribute attr, intptr_t pos);
+float mlirDenseElementsAttrGetFloatValue(MlirAttribute attr, intptr_t pos);
+double mlirDenseElementsAttrGetDoubleValue(MlirAttribute attr, intptr_t pos);
+MlirStringRef mlirDenseElementsAttrGetStringValue(MlirAttribute attr,
+                                                  intptr_t pos);
 
 //===----------------------------------------------------------------------===//
 // Opaque elements attribute.
@@ -411,32 +388,31 @@ mlirDenseElementsAttrGetStringValue(MlirAttribute attr, intptr_t pos);
 // TODO: expose Dialect to the bindings and implement accessors here.
 
 /// Checks whether the given attribute is an opaque elements attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsAOpaqueElements(MlirAttribute attr);
+int mlirAttributeIsAOpaqueElements(MlirAttribute attr);
 
 //===----------------------------------------------------------------------===//
 // Sparse elements attribute.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given attribute is a sparse elements attribute.
-MLIR_CAPI_EXPORTED int mlirAttributeIsASparseElements(MlirAttribute attr);
+int mlirAttributeIsASparseElements(MlirAttribute attr);
 
 /** Creates a sparse elements attribute of the given shape from a list of
  * indices and a list of associated values. Both lists are expected to be dense
  * elements attributes with the same number of elements. The list of indices is
  * expected to contain 64-bit integers. The attribute is created in the same
  * context as the type. */
-MLIR_CAPI_EXPORTED MlirAttribute mlirSparseElementsAttribute(
-    MlirType shapedType, MlirAttribute denseIndices, MlirAttribute denseValues);
+MlirAttribute mlirSparseElementsAttribute(MlirType shapedType,
+                                          MlirAttribute denseIndices,
+                                          MlirAttribute denseValues);
 
 /** Returns the dense elements attribute containing 64-bit integer indices of
  * non-null elements in the given sparse elements attribute. */
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirSparseElementsAttrGetIndices(MlirAttribute attr);
+MlirAttribute mlirSparseElementsAttrGetIndices(MlirAttribute attr);
 
 /** Returns the dense elements attribute containing the non-null elements in the
  * given sparse elements attribute. */
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirSparseElementsAttrGetValues(MlirAttribute attr);
+MlirAttribute mlirSparseElementsAttrGetValues(MlirAttribute attr);
 
 #ifdef __cplusplus
 }

diff  --git a/mlir/include/mlir-c/StandardDialect.h b/mlir/include/mlir-c/StandardDialect.h
index 191872103104..fe4786c12d5a 100644
--- a/mlir/include/mlir-c/StandardDialect.h
+++ b/mlir/include/mlir-c/StandardDialect.h
@@ -26,15 +26,14 @@ extern "C" {
 
 /** Registers the Standard dialect with the given context. This allows the
  * dialect to be loaded dynamically if needed when parsing. */
-MLIR_CAPI_EXPORTED void mlirContextRegisterStandardDialect(MlirContext context);
+void mlirContextRegisterStandardDialect(MlirContext context);
 
 /** Loads the Standard dialect into the given context. The dialect does _not_
  * have to be registered in advance. */
-MLIR_CAPI_EXPORTED MlirDialect
-mlirContextLoadStandardDialect(MlirContext context);
+MlirDialect mlirContextLoadStandardDialect(MlirContext context);
 
 /// Returns the namespace of the Standard dialect, suitable for loading it.
-MLIR_CAPI_EXPORTED MlirStringRef mlirStandardDialectGetNamespace();
+MlirStringRef mlirStandardDialectGetNamespace();
 
 #ifdef __cplusplus
 }

diff  --git a/mlir/include/mlir-c/StandardTypes.h b/mlir/include/mlir-c/StandardTypes.h
index ff53910cb154..7e31b167ce57 100644
--- a/mlir/include/mlir-c/StandardTypes.h
+++ b/mlir/include/mlir-c/StandardTypes.h
@@ -23,295 +23,276 @@ extern "C" {
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is an integer type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAInteger(MlirType type);
+int mlirTypeIsAInteger(MlirType type);
 
 /** Creates a signless integer type of the given bitwidth in the context. The
  * type is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeGet(MlirContext ctx,
-                                               unsigned bitwidth);
+MlirType mlirIntegerTypeGet(MlirContext ctx, unsigned bitwidth);
 
 /** Creates a signed integer type of the given bitwidth in the context. The type
  * is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeSignedGet(MlirContext ctx,
-                                                     unsigned bitwidth);
+MlirType mlirIntegerTypeSignedGet(MlirContext ctx, unsigned bitwidth);
 
 /** Creates an unsigned integer type of the given bitwidth in the context. The
  * type is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeUnsignedGet(MlirContext ctx,
-                                                       unsigned bitwidth);
+MlirType mlirIntegerTypeUnsignedGet(MlirContext ctx, unsigned bitwidth);
 
 /// Returns the bitwidth of an integer type.
-MLIR_CAPI_EXPORTED unsigned mlirIntegerTypeGetWidth(MlirType type);
+unsigned mlirIntegerTypeGetWidth(MlirType type);
 
 /// Checks whether the given integer type is signless.
-MLIR_CAPI_EXPORTED int mlirIntegerTypeIsSignless(MlirType type);
+int mlirIntegerTypeIsSignless(MlirType type);
 
 /// Checks whether the given integer type is signed.
-MLIR_CAPI_EXPORTED int mlirIntegerTypeIsSigned(MlirType type);
+int mlirIntegerTypeIsSigned(MlirType type);
 
 /// Checks whether the given integer type is unsigned.
-MLIR_CAPI_EXPORTED int mlirIntegerTypeIsUnsigned(MlirType type);
+int mlirIntegerTypeIsUnsigned(MlirType type);
 
 //===----------------------------------------------------------------------===//
 // Index type.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is an index type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAIndex(MlirType type);
+int mlirTypeIsAIndex(MlirType type);
 
 /** Creates an index type in the given context. The type is owned by the
  * context. */
-MLIR_CAPI_EXPORTED MlirType mlirIndexTypeGet(MlirContext ctx);
+MlirType mlirIndexTypeGet(MlirContext ctx);
 
 //===----------------------------------------------------------------------===//
 // Floating-point types.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is a bf16 type.
-MLIR_CAPI_EXPORTED int mlirTypeIsABF16(MlirType type);
+int mlirTypeIsABF16(MlirType type);
 
 /** Creates a bf16 type in the given context. The type is owned by the
  * context. */
-MLIR_CAPI_EXPORTED MlirType mlirBF16TypeGet(MlirContext ctx);
+MlirType mlirBF16TypeGet(MlirContext ctx);
 
 /// Checks whether the given type is an f16 type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAF16(MlirType type);
+int mlirTypeIsAF16(MlirType type);
 
 /** Creates an f16 type in the given context. The type is owned by the
  * context. */
-MLIR_CAPI_EXPORTED MlirType mlirF16TypeGet(MlirContext ctx);
+MlirType mlirF16TypeGet(MlirContext ctx);
 
 /// Checks whether the given type is an f32 type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAF32(MlirType type);
+int mlirTypeIsAF32(MlirType type);
 
 /** Creates an f32 type in the given context. The type is owned by the
  * context. */
-MLIR_CAPI_EXPORTED MlirType mlirF32TypeGet(MlirContext ctx);
+MlirType mlirF32TypeGet(MlirContext ctx);
 
 /// Checks whether the given type is an f64 type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAF64(MlirType type);
+int mlirTypeIsAF64(MlirType type);
 
 /** Creates a f64 type in the given context. The type is owned by the
  * context. */
-MLIR_CAPI_EXPORTED MlirType mlirF64TypeGet(MlirContext ctx);
+MlirType mlirF64TypeGet(MlirContext ctx);
 
 //===----------------------------------------------------------------------===//
 // None type.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is a None type.
-MLIR_CAPI_EXPORTED int mlirTypeIsANone(MlirType type);
+int mlirTypeIsANone(MlirType type);
 
 /** Creates a None type in the given context. The type is owned by the
  * context. */
-MLIR_CAPI_EXPORTED MlirType mlirNoneTypeGet(MlirContext ctx);
+MlirType mlirNoneTypeGet(MlirContext ctx);
 
 //===----------------------------------------------------------------------===//
 // Complex type.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is a Complex type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAComplex(MlirType type);
+int mlirTypeIsAComplex(MlirType type);
 
 /** Creates a complex type with the given element type in the same context as
  * the element type. The type is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGet(MlirType elementType);
+MlirType mlirComplexTypeGet(MlirType elementType);
 
 /// Returns the element type of the given complex type.
-MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGetElementType(MlirType type);
+MlirType mlirComplexTypeGetElementType(MlirType type);
 
 //===----------------------------------------------------------------------===//
 // Shaped type.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is a Shaped type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAShaped(MlirType type);
+int mlirTypeIsAShaped(MlirType type);
 
 /// Returns the element type of the shaped type.
-MLIR_CAPI_EXPORTED MlirType mlirShapedTypeGetElementType(MlirType type);
+MlirType mlirShapedTypeGetElementType(MlirType type);
 
 /// Checks whether the given shaped type is ranked.
-MLIR_CAPI_EXPORTED int mlirShapedTypeHasRank(MlirType type);
+int mlirShapedTypeHasRank(MlirType type);
 
 /// Returns the rank of the given ranked shaped type.
-MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetRank(MlirType type);
+int64_t mlirShapedTypeGetRank(MlirType type);
 
 /// Checks whether the given shaped type has a static shape.
-MLIR_CAPI_EXPORTED int mlirShapedTypeHasStaticShape(MlirType type);
+int mlirShapedTypeHasStaticShape(MlirType type);
 
 /// Checks wither the dim-th dimension of the given shaped type is dynamic.
-MLIR_CAPI_EXPORTED int mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim);
+int mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim);
 
 /// Returns the dim-th dimension of the given ranked shaped type.
-MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDimSize(MlirType type,
-                                                    intptr_t dim);
+int64_t mlirShapedTypeGetDimSize(MlirType type, intptr_t dim);
 
 /** Checks whether the given value is used as a placeholder for dynamic sizes
  * in shaped types. */
-MLIR_CAPI_EXPORTED int mlirShapedTypeIsDynamicSize(int64_t size);
+int mlirShapedTypeIsDynamicSize(int64_t size);
 
 /** Checks whether the given value is used as a placeholder for dynamic strides
  * and offsets in shaped types. */
-MLIR_CAPI_EXPORTED int mlirShapedTypeIsDynamicStrideOrOffset(int64_t val);
+int mlirShapedTypeIsDynamicStrideOrOffset(int64_t val);
 
 //===----------------------------------------------------------------------===//
 // Vector type.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is a Vector type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAVector(MlirType type);
+int mlirTypeIsAVector(MlirType type);
 
 /** Creates a vector type of the shape identified by its rank and dimensions,
  * with the given element type in the same context as the element type. The type
  * is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank, int64_t *shape,
-                                              MlirType elementType);
+MlirType mlirVectorTypeGet(intptr_t rank, int64_t *shape, MlirType elementType);
 
 /** Same as "mlirVectorTypeGet" but returns a nullptr wrapping MlirType on
  * illegal arguments, emitting appropriate diagnostics. */
-MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetChecked(intptr_t rank,
-                                                     int64_t *shape,
-                                                     MlirType elementType,
-                                                     MlirLocation loc);
+MlirType mlirVectorTypeGetChecked(intptr_t rank, int64_t *shape,
+                                  MlirType elementType, MlirLocation loc);
 
 //===----------------------------------------------------------------------===//
 // Ranked / Unranked Tensor type.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is a Tensor type.
-MLIR_CAPI_EXPORTED int mlirTypeIsATensor(MlirType type);
+int mlirTypeIsATensor(MlirType type);
 
 /// Checks whether the given type is a ranked tensor type.
-MLIR_CAPI_EXPORTED int mlirTypeIsARankedTensor(MlirType type);
+int mlirTypeIsARankedTensor(MlirType type);
 
 /// Checks whether the given type is an unranked tensor type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAUnrankedTensor(MlirType type);
+int mlirTypeIsAUnrankedTensor(MlirType type);
 
 /** Creates a tensor type of a fixed rank with the given shape and element type
  * in the same context as the element type. The type is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGet(intptr_t rank,
-                                                    int64_t *shape,
-                                                    MlirType elementType);
+MlirType mlirRankedTensorTypeGet(intptr_t rank, int64_t *shape,
+                                 MlirType elementType);
 
 /** Same as "mlirRankedTensorTypeGet" but returns a nullptr wrapping MlirType on
  * illegal arguments, emitting appropriate diagnostics. */
-MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGetChecked(intptr_t rank,
-                                                           int64_t *shape,
-                                                           MlirType elementType,
-                                                           MlirLocation loc);
+MlirType mlirRankedTensorTypeGetChecked(intptr_t rank, int64_t *shape,
+                                        MlirType elementType, MlirLocation loc);
 
 /** Creates an unranked tensor type with the given element type in the same
  * context as the element type. The type is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirUnrankedTensorTypeGet(MlirType elementType);
+MlirType mlirUnrankedTensorTypeGet(MlirType elementType);
 
 /** Same as "mlirUnrankedTensorTypeGet" but returns a nullptr wrapping MlirType
  * on illegal arguments, emitting appropriate diagnostics. */
-MLIR_CAPI_EXPORTED MlirType
-mlirUnrankedTensorTypeGetChecked(MlirType elementType, MlirLocation loc);
+MlirType mlirUnrankedTensorTypeGetChecked(MlirType elementType,
+                                          MlirLocation loc);
 
 //===----------------------------------------------------------------------===//
 // Ranked / Unranked MemRef type.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is a MemRef type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAMemRef(MlirType type);
+int mlirTypeIsAMemRef(MlirType type);
 
 /// Checks whether the given type is an UnrankedMemRef type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAUnrankedMemRef(MlirType type);
+int mlirTypeIsAUnrankedMemRef(MlirType type);
 
 /** Creates a MemRef type with the given rank and shape, a potentially empty
  * list of affine layout maps, the given memory space and element type, in the
  * same context as element type. The type is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(MlirType elementType,
-                                              intptr_t rank, int64_t *shape,
-                                              intptr_t numMaps,
-                                              MlirAttribute *affineMaps,
-                                              unsigned memorySpace);
+MlirType mlirMemRefTypeGet(MlirType elementType, intptr_t rank, int64_t *shape,
+                           intptr_t numMaps, MlirAttribute *affineMaps,
+                           unsigned memorySpace);
 
 /** Creates a MemRef type with the given rank, shape, memory space and element
  * type in the same context as the element type. The type has no affine maps,
  * i.e. represents a default row-major contiguous memref. The type is owned by
  * the context. */
-MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGet(MlirType elementType,
-                                                        intptr_t rank,
-                                                        int64_t *shape,
-                                                        unsigned memorySpace);
+MlirType mlirMemRefTypeContiguousGet(MlirType elementType, intptr_t rank,
+                                     int64_t *shape, unsigned memorySpace);
 
 /** Same as "mlirMemRefTypeContiguousGet" but returns a nullptr wrapping
  * MlirType on illegal arguments, emitting appropriate diagnostics. */
-MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGetChecked(
-    MlirType elementType, intptr_t rank, int64_t *shape, unsigned memorySpace,
-    MlirLocation loc);
+MlirType mlirMemRefTypeContiguousGetChecked(MlirType elementType, intptr_t rank,
+                                            int64_t *shape,
+                                            unsigned memorySpace,
+                                            MlirLocation loc);
 
 /** Creates an Unranked MemRef type with the given element type and in the given
  * memory space. The type is owned by the context of element type. */
-MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGet(MlirType elementType,
-                                                      unsigned memorySpace);
+MlirType mlirUnrankedMemRefTypeGet(MlirType elementType, unsigned memorySpace);
 
 /** Same as "mlirUnrankedMemRefTypeGet" but returns a nullptr wrapping
  * MlirType on illegal arguments, emitting appropriate diagnostics. */
-MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGetChecked(
-    MlirType elementType, unsigned memorySpace, MlirLocation loc);
+MlirType mlirUnrankedMemRefTypeGetChecked(MlirType elementType,
+                                          unsigned memorySpace,
+                                          MlirLocation loc);
 
 /// Returns the number of affine layout maps in the given MemRef type.
-MLIR_CAPI_EXPORTED intptr_t mlirMemRefTypeGetNumAffineMaps(MlirType type);
+intptr_t mlirMemRefTypeGetNumAffineMaps(MlirType type);
 
 /// Returns the pos-th affine map of the given MemRef type.
-MLIR_CAPI_EXPORTED MlirAffineMap mlirMemRefTypeGetAffineMap(MlirType type,
-                                                            intptr_t pos);
+MlirAffineMap mlirMemRefTypeGetAffineMap(MlirType type, intptr_t pos);
 
 /// Returns the memory space of the given MemRef type.
-MLIR_CAPI_EXPORTED unsigned mlirMemRefTypeGetMemorySpace(MlirType type);
+unsigned mlirMemRefTypeGetMemorySpace(MlirType type);
 
 /// Returns the memory spcae of the given Unranked MemRef type.
-MLIR_CAPI_EXPORTED unsigned mlirUnrankedMemrefGetMemorySpace(MlirType type);
+unsigned mlirUnrankedMemrefGetMemorySpace(MlirType type);
 
 //===----------------------------------------------------------------------===//
 // Tuple type.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is a tuple type.
-MLIR_CAPI_EXPORTED int mlirTypeIsATuple(MlirType type);
+int mlirTypeIsATuple(MlirType type);
 
 /** Creates a tuple type that consists of the given list of elemental types. The
  * type is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGet(MlirContext ctx,
-                                             intptr_t numElements,
-                                             MlirType *elements);
+MlirType mlirTupleTypeGet(MlirContext ctx, intptr_t numElements,
+                          MlirType *elements);
 
 /// Returns the number of types contained in a tuple.
-MLIR_CAPI_EXPORTED intptr_t mlirTupleTypeGetNumTypes(MlirType type);
+intptr_t mlirTupleTypeGetNumTypes(MlirType type);
 
 /// Returns the pos-th type in the tuple type.
-MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGetType(MlirType type, intptr_t pos);
+MlirType mlirTupleTypeGetType(MlirType type, intptr_t pos);
 
 //===----------------------------------------------------------------------===//
 // Function type.
 //===----------------------------------------------------------------------===//
 
 /// Checks whether the given type is a function type.
-MLIR_CAPI_EXPORTED int mlirTypeIsAFunction(MlirType type);
+int mlirTypeIsAFunction(MlirType type);
 
 /// Creates a function type, mapping a list of input types to result types.
-MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGet(MlirContext ctx,
-                                                intptr_t numInputs,
-                                                MlirType *inputs,
-                                                intptr_t numResults,
-                                                MlirType *results);
+MlirType mlirFunctionTypeGet(MlirContext ctx, intptr_t numInputs,
+                             MlirType *inputs, intptr_t numResults,
+                             MlirType *results);
 
 /// Returns the number of input types.
-MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumInputs(MlirType type);
+intptr_t mlirFunctionTypeGetNumInputs(MlirType type);
 
 /// Returns the number of result types.
-MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumResults(MlirType type);
+intptr_t mlirFunctionTypeGetNumResults(MlirType type);
 
 /// Returns the pos-th input type.
-MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetInput(MlirType type,
-                                                     intptr_t pos);
+MlirType mlirFunctionTypeGetInput(MlirType type, intptr_t pos);
 
 /// Returns the pos-th result type.
-MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGetResult(MlirType type,
-                                                      intptr_t pos);
+MlirType mlirFunctionTypeGetResult(MlirType type, intptr_t pos);
 
 #ifdef __cplusplus
 }

diff  --git a/mlir/include/mlir-c/Support.h b/mlir/include/mlir-c/Support.h
index 717ec41a805d..66323539c6bc 100644
--- a/mlir/include/mlir-c/Support.h
+++ b/mlir/include/mlir-c/Support.h
@@ -18,25 +18,6 @@
 #include <stddef.h>
 #include <stdint.h>
 
-//===----------------------------------------------------------------------===//
-// Visibility annotations.
-// Use MLIR_CAPI_EXPORTED for exported functions.
-//===----------------------------------------------------------------------===//
-
-#if defined(MLIR_CAPI_DISABLE_VISIBILITY_ANNOTATIONS)
-#define MLIR_CAPI_EXPORTED
-#elif defined(_WIN32) || defined(__CYGWIN__)
-// Windows visibility declarations.
-#if MLIR_CAPI_BUILDING_LIBRARY
-#define MLIR_CAPI_EXPORTED __declspec(dllexport)
-#else
-#define MLIR_CAPI_EXPORTED __declspec(dllimport)
-#endif
-#else
-// Non-windows: use visibility attributes.
-#define MLIR_CAPI_EXPORTED __attribute__((visibility("default")))
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -68,8 +49,7 @@ inline static MlirStringRef mlirStringRefCreate(const char *str,
 /** Constructs a string reference from a null-terminated C string. Prefer
  * mlirStringRefCreate if the length of the string is known.
  */
-MLIR_CAPI_EXPORTED MlirStringRef
-mlirStringRefCreateFromCString(const char *str);
+MlirStringRef mlirStringRefCreateFromCString(const char *str);
 
 /** A callback for returning string references.
  *

diff  --git a/mlir/include/mlir-c/Transforms.h b/mlir/include/mlir-c/Transforms.h
index 715de3ee4296..149f12b157c0 100644
--- a/mlir/include/mlir-c/Transforms.h
+++ b/mlir/include/mlir-c/Transforms.h
@@ -15,8 +15,6 @@
 #ifndef MLIR_C_TRANSFORMS_H
 #define MLIR_C_TRANSFORMS_H
 
-#include "mlir-c/Support.h"
-
 #include "mlir/Transforms/Transforms.capi.h.inc"
 
 #endif // MLIR_C_TRANSFORMS_H

diff  --git a/mlir/lib/Bindings/Python/CMakeLists.txt b/mlir/lib/Bindings/Python/CMakeLists.txt
index 9c294fefbf23..04762b46a315 100644
--- a/mlir/lib/Bindings/Python/CMakeLists.txt
+++ b/mlir/lib/Bindings/Python/CMakeLists.txt
@@ -1,3 +1,7 @@
+if(NOT LLVM_BUILD_LLVM_DYLIB)
+  message(FATAL_ERROR "Building the MLIR Python bindings require -DLLVM_BUILD_LLVM_DYLIB=ON")
+endif()
+
 include(AddMLIRPythonExtension)
 add_custom_target(MLIRBindingsPythonExtension)
 ################################################################################

diff  --git a/mlir/lib/CAPI/CMakeLists.txt b/mlir/lib/CAPI/CMakeLists.txt
index 8bbee6a74c08..276d7b721bca 100644
--- a/mlir/lib/CAPI/CMakeLists.txt
+++ b/mlir/lib/CAPI/CMakeLists.txt
@@ -2,40 +2,3 @@ add_subdirectory(IR)
 add_subdirectory(Registration)
 add_subdirectory(Standard)
 add_subdirectory(Transforms)
-
-
-################################################################################
-# libMLIRPublicAPI shared library/DLL.
-################################################################################
-
-get_property(public_api_libs GLOBAL PROPERTY MLIR_PUBLIC_C_API_LIBS)
-
-foreach(lib ${public_api_libs})
-  if(XCODE)
-    # Xcode doesn't support object libraries, so we have to trick it into
-    # linking the static libraries instead.
-    list(APPEND _DEPS "-force_load" ${lib})
-  else()
-    list(APPEND _OBJECTS $<TARGET_OBJECTS:obj.${lib}>)
-  endif()
-  # Accumulate transitive deps of each exported lib into _DEPS.
-  list(APPEND _DEPS  $<TARGET_PROPERTY:${lib},LINK_LIBRARIES>)
-endforeach()
-
-add_mlir_library(MLIRPublicAPI
-  SHARED
-  ${_OBJECTS}
-  EXCLUDE_FROM_LIBMLIR
-  LINK_LIBS
-  # Dependency on the implementation shared library.
-  $<$<BOOL:${LLVM_BUILD_LLVM_DYLIB}>:MLIR>
-  ${_DEPS}
-)
-
-target_link_options(
-  MLIRPublicAPI
-  PRIVATE
-    # On Linux, disable re-export of any static linked libraries that
-    # came through.
-    $<$<PLATFORM_ID:Linux>:LINKER:--exclude-libs,ALL>
-)

diff  --git a/mlir/lib/CAPI/IR/CMakeLists.txt b/mlir/lib/CAPI/IR/CMakeLists.txt
index 4b5883040f06..9be8be9cffe2 100644
--- a/mlir/lib/CAPI/IR/CMakeLists.txt
+++ b/mlir/lib/CAPI/IR/CMakeLists.txt
@@ -1,5 +1,5 @@
-# Main API shared library.
-add_mlir_public_c_api_library(MLIRCAPIIR
+# Main API.
+add_mlir_library(MLIRCAPIIR
   AffineExpr.cpp
   AffineMap.cpp
   Diagnostics.cpp
@@ -9,9 +9,12 @@ add_mlir_public_c_api_library(MLIRCAPIIR
   StandardTypes.cpp
   Support.cpp
 
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir-c
+
   LINK_LIBS PUBLIC
   MLIRIR
   MLIRParser
   MLIRSupport
   MLIRPass
-)
+  )

diff  --git a/mlir/lib/CAPI/Registration/CMakeLists.txt b/mlir/lib/CAPI/Registration/CMakeLists.txt
index 3ac29e2a4128..e506d1f421b7 100644
--- a/mlir/lib/CAPI/Registration/CMakeLists.txt
+++ b/mlir/lib/CAPI/Registration/CMakeLists.txt
@@ -1,9 +1,12 @@
 # Dialect registration.
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
-add_mlir_public_c_api_library(MLIRCAPIRegistration
+add_mlir_library(MLIRCAPIRegistration
   Registration.cpp
 
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir-c
+
   LINK_LIBS PUBLIC
   MLIRCAPIIR
   ${dialect_libs}
-)
+  )

diff  --git a/mlir/lib/CAPI/Standard/CMakeLists.txt b/mlir/lib/CAPI/Standard/CMakeLists.txt
index 197fea4ce4b2..c8411666052e 100644
--- a/mlir/lib/CAPI/Standard/CMakeLists.txt
+++ b/mlir/lib/CAPI/Standard/CMakeLists.txt
@@ -1,7 +1,11 @@
-add_mlir_public_c_api_library(MLIRCAPIStandard
+add_mlir_library(MLIRCAPIStandard
+
   StandardDialect.cpp
 
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir-c
+
   LINK_LIBS PUBLIC
   MLIRCAPIIR
   MLIRStandard
-)
+  )

diff  --git a/mlir/lib/CAPI/Transforms/CMakeLists.txt b/mlir/lib/CAPI/Transforms/CMakeLists.txt
index e5e1677ec70a..5d73be0d5dd0 100644
--- a/mlir/lib/CAPI/Transforms/CMakeLists.txt
+++ b/mlir/lib/CAPI/Transforms/CMakeLists.txt
@@ -1,6 +1,10 @@
-add_mlir_public_c_api_library(MLIRCAPITransforms
+add_mlir_library(MLIRCAPITransforms
+
   Passes.cpp
 
+  ADDITIONAL_HEADER_DIRS
+  ${MLIR_MAIN_INCLUDE_DIR}/mlir-c
+
   LINK_LIBS PUBLIC
   MLIRTransforms
-)
+  )

diff  --git a/mlir/lib/CAPI/Transforms/Passes.cpp b/mlir/lib/CAPI/Transforms/Passes.cpp
index 7452bd996308..9fd00efa4767 100644
--- a/mlir/lib/CAPI/Transforms/Passes.cpp
+++ b/mlir/lib/CAPI/Transforms/Passes.cpp
@@ -1,4 +1,4 @@
-//===- CAPIPasses.cpp - C API for Tranformations Passes -------------------===//
+//===- CAPIPAsses.cpp - C API for Tranformations Passes -------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -10,9 +10,6 @@
 #include "mlir/CAPI/Pass.h"
 #include "mlir/Pass/Pass.h"
 
-// Must include the declarations as they carry important visibility attributes.
-#include "mlir/Transforms/Transforms.capi.h.inc"
-
 using namespace mlir;
 
 #ifdef __cplusplus

diff  --git a/mlir/test/CAPI/CMakeLists.txt b/mlir/test/CAPI/CMakeLists.txt
index ef770050eb34..cf7731405817 100644
--- a/mlir/test/CAPI/CMakeLists.txt
+++ b/mlir/test/CAPI/CMakeLists.txt
@@ -16,8 +16,10 @@ llvm_update_compile_flags(mlir-capi-ir-test)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
 target_link_libraries(mlir-capi-ir-test
   PRIVATE
-  MLIRPublicAPI
-  )
+  MLIRCAPIIR
+  MLIRCAPIRegistration
+  MLIRCAPIStandard
+  ${dialect_libs})
 
 
 add_llvm_executable(mlir-capi-pass-test
@@ -28,5 +30,8 @@ llvm_update_compile_flags(mlir-capi-pass-test)
 get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
 target_link_libraries(mlir-capi-pass-test
   PRIVATE
-  MLIRPublicAPI
-  )
+  MLIRCAPIIR
+  MLIRCAPIRegistration
+  MLIRCAPIStandard
+  MLIRCAPITransforms
+  ${dialect_libs})

diff  --git a/mlir/tools/mlir-tblgen/PassCAPIGen.cpp b/mlir/tools/mlir-tblgen/PassCAPIGen.cpp
index 32d540967f91..d15bcb4632d2 100644
--- a/mlir/tools/mlir-tblgen/PassCAPIGen.cpp
+++ b/mlir/tools/mlir-tblgen/PassCAPIGen.cpp
@@ -32,8 +32,8 @@ static llvm::cl::opt<std::string>
 
 const char *const passDecl = R"(
 /* Create {0} Pass. */
-MLIR_CAPI_EXPORTED MlirPass mlirCreate{0}{1}();
-MLIR_CAPI_EXPORTED void mlirRegister{0}{1}();
+MlirPass mlirCreate{0}{1}();
+void mlirRegister{0}{1}();
 
 )";
 


        


More information about the Mlir-commits mailing list