summaryrefslogtreecommitdiff
path: root/mlir/include
diff options
context:
space:
mode:
authorTobias Gysi <tobias.gysi@nextsilicon.com>2023-05-11 12:45:31 +0000
committerTobias Gysi <tobias.gysi@nextsilicon.com>2023-05-11 12:45:45 +0000
commitf7cd55f56e9413f37474c8c12fc0a6231bf5fca5 (patch)
treef7f5c68099db65bf336c3a90a275719303520385 /mlir/include
parentdc47813eb042f77e9950d7225f9bdbb4a85f78d2 (diff)
downloadllvm-f7cd55f56e9413f37474c8c12fc0a6231bf5fca5.tar.gz
[mlir][llvm] Improve LLVM IR constant import.
Improve the constant import to handle zeroinitializer as well as additional float types such as quad floats. The logic got restructured to avoid creating intermediate dense element attributes when constructing multi-dimensional arrays. Additionally, we also leverage the fact that we do not need to iterate all elements of splat constants. Reviewed By: Dinistro Differential Revision: https://reviews.llvm.org/D150274
Diffstat (limited to 'mlir/include')
-rw-r--r--mlir/include/mlir/Target/LLVMIR/ModuleImport.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/mlir/include/mlir/Target/LLVMIR/ModuleImport.h b/mlir/include/mlir/Target/LLVMIR/ModuleImport.h
index 61413c5ced20..47af0756a21e 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleImport.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleImport.h
@@ -255,11 +255,14 @@ private:
/// DictionaryAttr for the LLVM dialect.
DictionaryAttr convertParameterAttribute(llvm::AttributeSet llvmParamAttrs,
OpBuilder &builder);
- /// Returns the builtin type equivalent to be used in attributes for the given
- /// LLVM IR dialect type.
- Type getStdTypeForAttr(Type type);
- /// Returns `value` as an attribute to attach to a GlobalOp.
- Attribute getConstantAsAttr(llvm::Constant *value);
+ /// Returns the builtin type equivalent to the given LLVM dialect type or
+ /// nullptr if there is no equivalent. The returned type can be used to create
+ /// an attribute for a GlobalOp or a ConstantOp.
+ Type getBuiltinTypeForAttr(Type type);
+ /// Returns `constant` as an attribute to attach to a GlobalOp or ConstantOp
+ /// or nullptr if the constant is not convertible. It supports scalar integer
+ /// and float constants as well as shaped types thereof including strings.
+ Attribute getConstantAsAttr(llvm::Constant *constant);
/// Returns the topologically sorted set of transitive dependencies needed to
/// convert the given constant.
SetVector<llvm::Constant *> getConstantsToConvert(llvm::Constant *constant);