summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt8
-rw-r--r--mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h35
-rw-r--r--mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h48
-rw-r--r--mlir/include/mlir/Dialect/SPIRV/TargetAndABI.td (renamed from mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td)0
-rw-r--r--mlir/lib/Dialect/SPIRV/CMakeLists.txt5
-rw-r--r--mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp41
-rw-r--r--mlir/lib/Dialect/SPIRV/TargetAndABI.cpp47
-rw-r--r--mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp2
8 files changed, 113 insertions, 73 deletions
diff --git a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt b/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt
index 52464789439..cb32fc5fedb 100644
--- a/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt
+++ b/mlir/include/mlir/Dialect/SPIRV/CMakeLists.txt
@@ -19,7 +19,7 @@ set(LLVM_TARGET_DEFINITIONS SPIRVBase.td)
mlir_tablegen(SPIRVOpUtils.inc -gen-spirv-op-utils)
add_public_tablegen_target(MLIRSPIRVOpUtilsGen)
-set(LLVM_TARGET_DEFINITIONS SPIRVLowering.td)
-mlir_tablegen(SPIRVLowering.h.inc -gen-struct-attr-decls)
-mlir_tablegen(SPIRVLowering.cpp.inc -gen-struct-attr-defs)
-add_public_tablegen_target(MLIRSPIRVLoweringStructGen)
+set(LLVM_TARGET_DEFINITIONS TargetAndABI.td)
+mlir_tablegen(TargetAndABI.h.inc -gen-struct-attr-decls)
+mlir_tablegen(TargetAndABI.cpp.inc -gen-struct-attr-defs)
+add_public_tablegen_target(MLIRSPIRVTargetAndABIIncGen)
diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
index 0f481f5956d..ea13bc0dbb3 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
+++ b/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.h
@@ -13,11 +13,8 @@
#ifndef MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
#define MLIR_DIALECT_SPIRV_SPIRVLOWERING_H
-#include "mlir/Dialect/SPIRV/SPIRVOps.h"
-#include "mlir/IR/Attributes.h"
-#include "mlir/Support/StringExtras.h"
+#include "mlir/Dialect/SPIRV/TargetAndABI.h"
#include "mlir/Transforms/DialectConversion.h"
-#include "llvm/ADT/SetVector.h"
namespace mlir {
@@ -50,36 +47,18 @@ protected:
SPIRVTypeConverter &typeConverter;
};
-#include "mlir/Dialect/SPIRV/SPIRVLowering.h.inc"
-
namespace spirv {
+enum class BuiltIn : uint32_t;
+
/// Returns a value that represents a builtin variable value within the SPIR-V
/// module.
-Value getBuiltinVariableValue(Operation *op, spirv::BuiltIn builtin,
+Value getBuiltinVariableValue(Operation *op, BuiltIn builtin,
OpBuilder &builder);
-/// Attribute name for specifying argument ABI information.
-StringRef getInterfaceVarABIAttrName();
-
-/// Get the InterfaceVarABIAttr given its fields.
-InterfaceVarABIAttr getInterfaceVarABIAttr(unsigned descriptorSet,
- unsigned binding,
- spirv::StorageClass storageClass,
- MLIRContext *context);
-
-/// Attribute name for specifying entry point information.
-StringRef getEntryPointABIAttrName();
-
-/// Get the EntryPointABIAttr given its fields.
-EntryPointABIAttr getEntryPointABIAttr(ArrayRef<int32_t> localSize,
- MLIRContext *context);
-
/// Sets the InterfaceVarABIAttr and EntryPointABIAttr for a function and its
-/// arguments
-LogicalResult setABIAttrs(FuncOp funcOp,
- spirv::EntryPointABIAttr entryPointInfo,
- ArrayRef<spirv::InterfaceVarABIAttr> argABIInfo);
-
+/// arguments.
+LogicalResult setABIAttrs(FuncOp funcOp, EntryPointABIAttr entryPointInfo,
+ ArrayRef<InterfaceVarABIAttr> argABIInfo);
} // namespace spirv
} // namespace mlir
diff --git a/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h b/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
new file mode 100644
index 00000000000..9ac5c69b24a
--- /dev/null
+++ b/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.h
@@ -0,0 +1,48 @@
+//===- TargetAndABI.h - SPIR-V target and ABI utilities --------*- C++ -*-===//
+//
+// Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file declares utilities for SPIR-V target and shader interface ABI.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MLIR_DIALECT_SPIRV_TARGETANDABI_H
+#define MLIR_DIALECT_SPIRV_TARGETANDABI_H
+
+#include "mlir/IR/Attributes.h"
+#include "mlir/Support/LLVM.h"
+
+namespace mlir {
+class OpBuilder;
+class Operation;
+class Value;
+
+// Pull in SPIR-V attribute definitions.
+#include "mlir/Dialect/SPIRV/TargetAndABI.h.inc"
+
+namespace spirv {
+enum class StorageClass : uint32_t;
+
+/// Attribute name for specifying argument ABI information.
+StringRef getInterfaceVarABIAttrName();
+
+/// Get the InterfaceVarABIAttr given its fields.
+InterfaceVarABIAttr getInterfaceVarABIAttr(unsigned descriptorSet,
+ unsigned binding,
+ StorageClass storageClass,
+ MLIRContext *context);
+
+/// Attribute name for specifying entry point information.
+StringRef getEntryPointABIAttrName();
+
+/// Get the EntryPointABIAttr given its fields.
+EntryPointABIAttr getEntryPointABIAttr(ArrayRef<int32_t> localSize,
+ MLIRContext *context);
+} // namespace spirv
+} // namespace mlir
+
+#endif // MLIR_DIALECT_SPIRV_TARGETANDABI_H
diff --git a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td b/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.td
index 91a8ff68bbf..91a8ff68bbf 100644
--- a/mlir/include/mlir/Dialect/SPIRV/SPIRVLowering.td
+++ b/mlir/include/mlir/Dialect/SPIRV/TargetAndABI.td
diff --git a/mlir/lib/Dialect/SPIRV/CMakeLists.txt b/mlir/lib/Dialect/SPIRV/CMakeLists.txt
index d3af53e3aaa..ee57121da43 100644
--- a/mlir/lib/Dialect/SPIRV/CMakeLists.txt
+++ b/mlir/lib/Dialect/SPIRV/CMakeLists.txt
@@ -9,6 +9,7 @@ add_llvm_library(MLIRSPIRV
SPIRVOps.cpp
SPIRVLowering.cpp
SPIRVTypes.cpp
+ TargetAndABI.cpp
ADDITIONAL_HEADER_DIRS
${MLIR_MAIN_INCLUDE_DIR}/mlir/SPIRV
@@ -18,9 +19,9 @@ add_dependencies(MLIRSPIRV
MLIRSPIRVAvailabilityIncGen
MLIRSPIRVCanonicalizationIncGen
MLIRSPIRVEnumsIncGen
- MLIRSPIRVLoweringStructGen
MLIRSPIRVOpsIncGen
- MLIRSPIRVOpUtilsGen)
+ MLIRSPIRVOpUtilsGen
+ MLIRSPIRVTargetAndABIIncGen)
target_link_libraries(MLIRSPIRV
MLIRIR
diff --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
index 0d2348c2626..2a635351485 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp
@@ -9,53 +9,16 @@
// This file implements utilities used to lower to SPIR-V dialect.
//
//===----------------------------------------------------------------------===//
+
#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
#include "mlir/Dialect/SPIRV/LayoutUtils.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
+#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "llvm/ADT/Sequence.h"
using namespace mlir;
//===----------------------------------------------------------------------===//
-// Attributes for ABI
-//===----------------------------------------------------------------------===//
-
-// Pull in the attributes needed for lowering.
-namespace mlir {
-#include "mlir/Dialect/SPIRV/SPIRVLowering.cpp.inc"
-}
-
-StringRef mlir::spirv::getInterfaceVarABIAttrName() {
- return "spirv.interface_var_abi";
-}
-
-mlir::spirv::InterfaceVarABIAttr
-mlir::spirv::getInterfaceVarABIAttr(unsigned descriptorSet, unsigned binding,
- spirv::StorageClass storageClass,
- MLIRContext *context) {
- Type i32Type = IntegerType::get(32, context);
- return mlir::spirv::InterfaceVarABIAttr::get(
- IntegerAttr::get(i32Type, descriptorSet),
- IntegerAttr::get(i32Type, binding),
- IntegerAttr::get(i32Type, static_cast<int64_t>(storageClass)), context);
-}
-
-StringRef mlir::spirv::getEntryPointABIAttrName() {
- return "spirv.entry_point_abi";
-}
-
-mlir::spirv::EntryPointABIAttr
-mlir::spirv::getEntryPointABIAttr(ArrayRef<int32_t> localSize,
- MLIRContext *context) {
- assert(localSize.size() == 3);
- return mlir::spirv::EntryPointABIAttr::get(
- DenseElementsAttr::get<int32_t>(
- VectorType::get(3, IntegerType::get(32, context)), localSize)
- .cast<DenseIntElementsAttr>(),
- context);
-}
-
-//===----------------------------------------------------------------------===//
// Type Conversion
//===----------------------------------------------------------------------===//
diff --git a/mlir/lib/Dialect/SPIRV/TargetAndABI.cpp b/mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
new file mode 100644
index 00000000000..696b8b55391
--- /dev/null
+++ b/mlir/lib/Dialect/SPIRV/TargetAndABI.cpp
@@ -0,0 +1,47 @@
+//===- SPIRVLowering.cpp - Standard to SPIR-V dialect conversion--===//
+//
+// Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/SPIRV/TargetAndABI.h"
+#include "mlir/Dialect/SPIRV/SPIRVTypes.h"
+#include "mlir/IR/Operation.h"
+
+using namespace mlir;
+
+namespace mlir {
+#include "mlir/Dialect/SPIRV/TargetAndABI.cpp.inc"
+}
+
+StringRef mlir::spirv::getInterfaceVarABIAttrName() {
+ return "spirv.interface_var_abi";
+}
+
+mlir::spirv::InterfaceVarABIAttr
+mlir::spirv::getInterfaceVarABIAttr(unsigned descriptorSet, unsigned binding,
+ spirv::StorageClass storageClass,
+ MLIRContext *context) {
+ Type i32Type = IntegerType::get(32, context);
+ return mlir::spirv::InterfaceVarABIAttr::get(
+ IntegerAttr::get(i32Type, descriptorSet),
+ IntegerAttr::get(i32Type, binding),
+ IntegerAttr::get(i32Type, static_cast<int64_t>(storageClass)), context);
+}
+
+StringRef mlir::spirv::getEntryPointABIAttrName() {
+ return "spirv.entry_point_abi";
+}
+
+mlir::spirv::EntryPointABIAttr
+mlir::spirv::getEntryPointABIAttr(ArrayRef<int32_t> localSize,
+ MLIRContext *context) {
+ assert(localSize.size() == 3);
+ return mlir::spirv::EntryPointABIAttr::get(
+ DenseElementsAttr::get<int32_t>(
+ VectorType::get(3, IntegerType::get(32, context)), localSize)
+ .cast<DenseIntElementsAttr>(),
+ context);
+}
diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
index d7194da0778..1892a6de3bd 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp
@@ -15,8 +15,10 @@
#include "mlir/Dialect/SPIRV/Passes.h"
#include "mlir/Dialect/SPIRV/SPIRVDialect.h"
#include "mlir/Dialect/SPIRV/SPIRVLowering.h"
+#include "mlir/Dialect/SPIRV/SPIRVOps.h"
#include "mlir/Dialect/StandardOps/Ops.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "llvm/ADT/SetVector.h"
using namespace mlir;
OpenPOWER on IntegriCloud