Skip to content

Commit

Permalink
mlir/LogicalResult: move into llvm (llvm#97309)
Browse files Browse the repository at this point in the history
This patch is part of a project to move the Presburger library into
LLVM.
  • Loading branch information
artagnon committed Jul 2, 2024
1 parent 01134e6 commit db791b2
Show file tree
Hide file tree
Showing 315 changed files with 737 additions and 894 deletions.
12 changes: 6 additions & 6 deletions flang/include/flang/Optimizer/CodeGen/FIROpPatterns.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,10 @@ class FIROpConversion : public ConvertFIRToLLVMPattern {
rewrite(mlir::cast<SourceOp>(op),
OpAdaptor(operands, mlir::cast<SourceOp>(op)), rewriter);
}
mlir::LogicalResult match(mlir::Operation *op) const final {
llvm::LogicalResult match(mlir::Operation *op) const final {
return match(mlir::cast<SourceOp>(op));
}
mlir::LogicalResult
llvm::LogicalResult
matchAndRewrite(mlir::Operation *op, mlir::ArrayRef<mlir::Value> operands,
mlir::ConversionPatternRewriter &rewriter) const final {
return matchAndRewrite(mlir::cast<SourceOp>(op),
Expand All @@ -218,14 +218,14 @@ class FIROpConversion : public ConvertFIRToLLVMPattern {

/// Rewrite and Match methods that operate on the SourceOp type. These must be
/// overridden by the derived pattern class.
virtual mlir::LogicalResult match(SourceOp op) const {
virtual llvm::LogicalResult match(SourceOp op) const {
llvm_unreachable("must override match or matchAndRewrite");
}
virtual void rewrite(SourceOp op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const {
llvm_unreachable("must override rewrite or matchAndRewrite");
}
virtual mlir::LogicalResult
virtual llvm::LogicalResult
matchAndRewrite(SourceOp op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const {
if (mlir::failed(match(op)))
Expand All @@ -246,14 +246,14 @@ class FIROpAndTypeConversion : public FIROpConversion<FromOp> {
using FIROpConversion<FromOp>::FIROpConversion;
using OpAdaptor = typename FromOp::Adaptor;

mlir::LogicalResult
llvm::LogicalResult
matchAndRewrite(FromOp op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const final {
mlir::Type ty = this->convertType(op.getType());
return doRewrite(op, ty, adaptor, rewriter);
}

virtual mlir::LogicalResult
virtual llvm::LogicalResult
doRewrite(FromOp addr, mlir::Type ty, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const = 0;
};
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Optimizer/CodeGen/TypeConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class LLVMTypeConverter : public mlir::LLVMTypeConverter {
mlir::Type indexType() const;

// fir.type<name(p : TY'...){f : TY...}> --> llvm<"%name = { ty... }">
std::optional<mlir::LogicalResult>
std::optional<llvm::LogicalResult>
convertRecordType(fir::RecordType derived,
llvm::SmallVectorImpl<mlir::Type> &results);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

#include "mlir/IR/OpDefinition.h"
#include "mlir/IR/Operation.h"
#include "mlir/Support/LogicalResult.h"
#include "llvm/Support/LogicalResult.h"

namespace fir::detail {
mlir::LogicalResult verifyFirAliasTagOpInterface(mlir::Operation *op);
llvm::LogicalResult verifyFirAliasTagOpInterface(mlir::Operation *op);
} // namespace fir::detail

#include "flang/Optimizer/Dialect/FirAliasTagOpInterface.h.inc"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def fir_FortranVariableOpInterface : OpInterface<"FortranVariableOpInterface"> {
}

/// Interface verifier imlementation for declare operations.
mlir::LogicalResult verifyDeclareLikeOpImpl(mlir::Value memRef);
llvm::LogicalResult verifyDeclareLikeOpImpl(mlir::Value memRef);

}];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class KindMapping {
private:
MatchResult badMapString(const llvm::Twine &ptr);
MatchResult parse(llvm::StringRef kindMap);
mlir::LogicalResult setDefaultKinds(llvm::ArrayRef<KindTy> defs);
llvm::LogicalResult setDefaultKinds(llvm::ArrayRef<KindTy> defs);

mlir::MLIRContext *context;
llvm::DenseMap<std::pair<char, KindTy>, Bitsize> intMap;
Expand Down
8 changes: 4 additions & 4 deletions flang/include/flang/Optimizer/HLFIR/HLFIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ def hlfir_AssociateOp : hlfir_Op<"associate", [AttrSizedOperandSegments,
CArg<"mlir::Value", "{}">:$shape, CArg<"mlir::ValueRange", "{}">:$typeparams,
CArg<"fir::FortranVariableFlagsAttr", "{}">:$fortran_attrs)>,
OpBuilder<(ins "mlir::Value":$memref, CArg<"mlir::Value", "{}">:$shape,
CArg<"mlir::ValueRange", "{}">:$typeparams,
CArg<"mlir::ValueRange", "{}">:$typeparams,
CArg<"fir::FortranVariableFlagsAttr", "{}">:$fortran_attrs,
CArg<"llvm::ArrayRef<mlir::NamedAttribute>", "{}">:$attributes)>];

Expand Down Expand Up @@ -1258,7 +1258,7 @@ def hlfir_OrderedAssignmentTreeOpInterface : OpInterface<"OrderedAssignmentTreeO

let extraClassDeclaration = [{
/// Interface verifier imlementation.
mlir::LogicalResult verifyImpl();
llvm::LogicalResult verifyImpl();

mlir::Block* getSubTreeBlock() {
mlir::Region* region = getSubTreeRegion();
Expand Down Expand Up @@ -1733,8 +1733,8 @@ def hlfir_CharExtremumOp : hlfir_Op<"char_extremum",
[DeclareOpInterfaceMethods<MemoryEffectsOpInterface>]> {
let summary = "Find max/min from given character strings";
let description = [{
Find the lexicographical minimum or maximum of two or more character
strings of the same character kind and return the string with the lexicographical
Find the lexicographical minimum or maximum of two or more character
strings of the same character kind and return the string with the lexicographical
minimum or maximum number of characters. Example:

%0 = hlfir.char_extremum min, %arg0, %arg1 : (!fir.ref<!fir.char<1,10>>, !fir.ref<!fir.char<1,20>>) -> !hlfir.expr<!fir.char<1,10>>
Expand Down
Loading

0 comments on commit db791b2

Please sign in to comment.