[flang] sync latest changes to these files

Original-commit: flang-compiler/f18@97becf30fa
Reviewed-on: https://github.com/flang-compiler/f18/pull/696
This commit is contained in:
Eric Schweitz 2019-09-26 13:08:27 -07:00
parent cca3c31176
commit 5c8c0716b4
7 changed files with 474 additions and 462 deletions

View File

@ -1,4 +1,9 @@
//===- IteratedDominanceFrontier.h - Calculate IDF --------------*- C++ -*-===//
//
// Part of the LLVM 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
//
//===----------------------------------------------------------------------===//
/// \file
/// Compute iterated dominance frontiers using a linear time algorithm.
@ -25,7 +30,7 @@
namespace mlir {
class Block;
class DominanceInfo;
}
} // namespace mlir
namespace fir {
@ -42,8 +47,7 @@ namespace fir {
template <class NodeTy, bool IsPostDom>
class IDFCalculator {
public:
IDFCalculator(mlir::DominanceInfo &DT)
: DT(DT), useLiveIn(false) {}
IDFCalculator(mlir::DominanceInfo &DT) : DT(DT), useLiveIn(false) {}
/// Give the IDF calculator the set of blocks in which the value is
/// defined. This is equivalent to the set of starting blocks it should be

View File

@ -27,7 +27,7 @@ struct TypeAttributeStorage;
enum AttributeKind {
FIR_ATTR = mlir::Attribute::FIRST_FIR_ATTR,
FIR_EXACTTYPE, // instance_of, precise type relation
FIR_EXACTTYPE, // instance_of, precise type relation
FIR_SUBCLASS, // subsumed_by, is-a (subclass) relation
FIR_POINT,
FIR_CLOSEDCLOSED_INTERVAL,
@ -35,8 +35,9 @@ enum AttributeKind {
FIR_CLOSEDOPEN_INTERVAL,
};
class ExactTypeAttr : public mlir::Attribute::AttrBase<ExactTypeAttr,
mlir::Attribute, detail::TypeAttributeStorage> {
class ExactTypeAttr
: public mlir::Attribute::AttrBase<ExactTypeAttr, mlir::Attribute,
detail::TypeAttributeStorage> {
public:
using Base::Base;
using ValueType = mlir::Type;
@ -50,8 +51,9 @@ public:
constexpr static unsigned getId() { return AttributeKind::FIR_EXACTTYPE; }
};
class SubclassAttr : public mlir::Attribute::AttrBase<SubclassAttr,
mlir::Attribute, detail::TypeAttributeStorage> {
class SubclassAttr
: public mlir::Attribute::AttrBase<SubclassAttr, mlir::Attribute,
detail::TypeAttributeStorage> {
public:
using Base::Base;
using ValueType = mlir::Type;
@ -66,7 +68,7 @@ public:
};
class ClosedIntervalAttr
: public mlir::Attribute::AttrBase<ClosedIntervalAttr> {
: public mlir::Attribute::AttrBase<ClosedIntervalAttr> {
public:
using Base::Base;
@ -113,8 +115,9 @@ public:
};
mlir::Attribute parseFirAttribute(FIROpsDialect *dialect,
llvm::StringRef rawText, mlir::Type type, mlir::Location loc);
llvm::StringRef rawText, mlir::Type type,
mlir::Location loc);
} // fir
} // namespace fir
#endif // FIR_ATTRIBUTE_H
#endif // FIR_ATTRIBUTE_H

View File

@ -20,14 +20,14 @@
namespace llvm {
class raw_ostream;
class StringRef;
}
} // namespace llvm
namespace mlir {
class Attribute;
class Location;
class MLIRContext;
class Type;
}
} // namespace mlir
namespace fir {
@ -39,16 +39,16 @@ public:
static llvm::StringRef getDialectNamespace() { return "fir"; }
mlir::Type parseType(
llvm::StringRef rawData, mlir::Location loc) const override;
mlir::Type parseType(llvm::StringRef rawData,
mlir::Location loc) const override;
void printType(mlir::Type ty, llvm::raw_ostream &os) const override;
mlir::Attribute parseAttribute(llvm::StringRef rawText, mlir::Type type,
mlir::Location loc) const override;
void printAttribute(
mlir::Attribute attr, llvm::raw_ostream &os) const override;
mlir::Location loc) const override;
void printAttribute(mlir::Attribute attr,
llvm::raw_ostream &os) const override;
};
} // fir
} // namespace fir
#endif // FIR_DIALECT_H
#endif // FIR_DIALECT_H

View File

@ -15,10 +15,10 @@
#ifndef FIR_FIROPS_H
#define FIR_FIROPS_H
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/OpImplementation.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
using namespace mlir;
using llvm::ArrayRef;
@ -30,9 +30,10 @@ class FirEndOp;
/// `fir.global` is a typed symbol with an optional list of initializers.
class GlobalOp
: public mlir::Op<GlobalOp, mlir::OpTrait::ZeroOperands,
mlir::OpTrait::ZeroResult, mlir::OpTrait::IsIsolatedFromAbove,
mlir::OpTrait::SingleBlockImplicitTerminator<FirEndOp>::Impl> {
: public mlir::Op<
GlobalOp, mlir::OpTrait::ZeroOperands, mlir::OpTrait::ZeroResult,
mlir::OpTrait::IsIsolatedFromAbove,
mlir::OpTrait::SingleBlockImplicitTerminator<FirEndOp>::Impl> {
public:
using Op::Op;
using Op::print;
@ -41,13 +42,13 @@ public:
static llvm::StringRef getTypeAttrName() { return "type"; }
static void build(mlir::Builder *builder, mlir::OperationState *result,
llvm::StringRef name, mlir::Type type,
llvm::ArrayRef<mlir::NamedAttribute> attrs);
llvm::StringRef name, mlir::Type type,
llvm::ArrayRef<mlir::NamedAttribute> attrs);
/// Operation hooks.
static mlir::ParseResult parse(
mlir::OpAsmParser *parser, mlir::OperationState *result);
void print(mlir::OpAsmPrinter *p);
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState &result);
void print(mlir::OpAsmPrinter &p);
mlir::LogicalResult verify();
mlir::Type getType() {
@ -63,22 +64,23 @@ private:
/// `fir.dispatch_table` is an untyped symbol that is a list of associations
/// between method identifiers and a FuncOp symbol.
class DispatchTableOp
: public mlir::Op<DispatchTableOp, mlir::OpTrait::ZeroOperands,
mlir::OpTrait::ZeroResult, mlir::OpTrait::IsIsolatedFromAbove,
mlir::OpTrait::SingleBlockImplicitTerminator<FirEndOp>::Impl> {
: public mlir::Op<
DispatchTableOp, mlir::OpTrait::ZeroOperands,
mlir::OpTrait::ZeroResult, mlir::OpTrait::IsIsolatedFromAbove,
mlir::OpTrait::SingleBlockImplicitTerminator<FirEndOp>::Impl> {
public:
using Op::Op;
static llvm::StringRef getOperationName() { return "fir.dispatch_table"; }
static void build(mlir::Builder *builder, mlir::OperationState *result,
llvm::StringRef name, mlir::Type type,
llvm::ArrayRef<mlir::NamedAttribute> attrs);
llvm::StringRef name, mlir::Type type,
llvm::ArrayRef<mlir::NamedAttribute> attrs);
/// Operation hooks.
static mlir::ParseResult parse(
mlir::OpAsmParser *parser, mlir::OperationState *result);
void print(mlir::OpAsmPrinter *p);
static mlir::ParseResult parse(mlir::OpAsmParser &parser,
mlir::OperationState &result);
void print(mlir::OpAsmPrinter &p);
mlir::LogicalResult verify();
void appendTableEntry(mlir::Operation *op);
@ -88,17 +90,18 @@ private:
};
mlir::ParseResult isValidCaseAttr(mlir::Attribute attr);
unsigned getCaseArgumentOffset(
llvm::ArrayRef<mlir::Attribute> cases, unsigned dest);
unsigned getCaseArgumentOffset(llvm::ArrayRef<mlir::Attribute> cases,
unsigned dest);
mlir::ParseResult parseSelector(mlir::OpAsmParser *parser,
mlir::OperationState *result, mlir::OpAsmParser::OperandType &selector,
mlir::Type &type);
mlir::OperationState *result,
mlir::OpAsmParser::OperandType &selector,
mlir::Type &type);
#define GET_OP_CLASSES
#include "fir/FIROps.h.inc"
LoopOp getForInductionVarOwner(mlir::Value *val);
} // namespace fir
} // namespace fir
#endif // FIR_FIROPS_H
#endif // FIR_FIROPS_H

File diff suppressed because it is too large Load Diff

View File

@ -23,16 +23,17 @@
#include <memory>
namespace mlir {
template<typename> class OpPassBase;
template <typename>
class OpPassBase;
class FuncOp;
using FunctionPassBase = OpPassBase<FuncOp>;
}
} // namespace mlir
namespace fir {
/// Creates a pass to convert FIR into a reg SSA form
std::unique_ptr<mlir::FunctionPassBase> createMemToRegPass();
} // fir
} // namespace fir
#endif // FIR_TRANSFORMS_MEMTOREG_H
#endif // FIR_TRANSFORMS_MEMTOREG_H

View File

@ -19,9 +19,10 @@
namespace llvm {
class StringRef;
template<typename> class ArrayRef;
template <typename>
class ArrayRef;
class hash_code;
}
} // namespace llvm
namespace fir {
@ -46,7 +47,7 @@ struct RecordTypeStorage;
struct ReferenceTypeStorage;
struct SequenceTypeStorage;
struct TypeDescTypeStorage;
}
} // namespace detail
enum TypeKind {
// The enum starts at the range reserved for this dialect.
@ -54,16 +55,16 @@ enum TypeKind {
FIR_BOX,
FIR_BOXCHAR,
FIR_BOXPROC,
FIR_CHARACTER, // intrinsic
FIR_COMPLEX, // intrinsic
FIR_DERIVED, // derived
FIR_CHARACTER, // intrinsic
FIR_COMPLEX, // intrinsic
FIR_DERIVED, // derived
FIR_DIMS,
FIR_FIELD,
FIR_HEAP,
FIR_INT, // intrinsic
FIR_LOGICAL, // intrinsic
FIR_INT, // intrinsic
FIR_LOGICAL, // intrinsic
FIR_POINTER,
FIR_REAL, // intrinsic
FIR_REAL, // intrinsic
FIR_REFERENCE,
FIR_SEQUENCE,
FIR_TYPEDESC,
@ -73,15 +74,16 @@ bool isa_fir_type(mlir::Type);
bool isa_std_type(mlir::Type t);
bool isa_fir_or_std_type(mlir::Type t);
template<typename A, unsigned Id> struct IntrinsicTypeMixin {
template <typename A, unsigned Id>
struct IntrinsicTypeMixin {
constexpr static bool kindof(unsigned kind) { return kind == getId(); }
constexpr static unsigned getId() { return Id; }
};
class CharacterType
: public mlir::Type::TypeBase<CharacterType, mlir::Type,
detail::CharacterTypeStorage>,
public IntrinsicTypeMixin<CharacterType, TypeKind::FIR_CHARACTER> {
: public mlir::Type::TypeBase<CharacterType, mlir::Type,
detail::CharacterTypeStorage>,
public IntrinsicTypeMixin<CharacterType, TypeKind::FIR_CHARACTER> {
public:
using Base::Base;
static CharacterType get(mlir::MLIRContext *ctxt, KindTy kind);
@ -90,8 +92,8 @@ public:
};
class IntType
: public mlir::Type::TypeBase<IntType, mlir::Type, detail::IntTypeStorage>,
public IntrinsicTypeMixin<IntType, TypeKind::FIR_INT> {
: public mlir::Type::TypeBase<IntType, mlir::Type, detail::IntTypeStorage>,
public IntrinsicTypeMixin<IntType, TypeKind::FIR_INT> {
public:
using Base::Base;
static IntType get(mlir::MLIRContext *ctxt, KindTy kind);
@ -100,9 +102,9 @@ public:
};
class LogicalType
: public mlir::Type::TypeBase<LogicalType, mlir::Type,
detail::LogicalTypeStorage>,
public IntrinsicTypeMixin<LogicalType, TypeKind::FIR_LOGICAL> {
: public mlir::Type::TypeBase<LogicalType, mlir::Type,
detail::LogicalTypeStorage>,
public IntrinsicTypeMixin<LogicalType, TypeKind::FIR_LOGICAL> {
public:
using Base::Base;
static LogicalType get(mlir::MLIRContext *ctxt, KindTy kind);
@ -110,9 +112,9 @@ public:
KindTy getFKind() const { return getSizeInBits() / 8; }
};
class RealType
: public mlir::Type::TypeBase<RealType, mlir::Type, detail::RealTypeStorage>,
public IntrinsicTypeMixin<RealType, TypeKind::FIR_REAL> {
class RealType : public mlir::Type::TypeBase<RealType, mlir::Type,
detail::RealTypeStorage>,
public IntrinsicTypeMixin<RealType, TypeKind::FIR_REAL> {
public:
using Base::Base;
static RealType get(mlir::MLIRContext *ctxt, KindTy kind);
@ -120,9 +122,9 @@ public:
KindTy getFKind() const { return getSizeInBits() / 8; }
};
class CplxType
: public mlir::Type::TypeBase<CplxType, mlir::Type, detail::CplxTypeStorage>,
public IntrinsicTypeMixin<CplxType, TypeKind::FIR_COMPLEX> {
class CplxType : public mlir::Type::TypeBase<CplxType, mlir::Type,
detail::CplxTypeStorage>,
public IntrinsicTypeMixin<CplxType, TypeKind::FIR_COMPLEX> {
public:
using Base::Base;
static CplxType get(mlir::MLIRContext *ctxt, KindTy kind);
@ -133,7 +135,7 @@ public:
// FIR support types
class BoxType
: public mlir::Type::TypeBase<BoxType, mlir::Type, detail::BoxTypeStorage> {
: public mlir::Type::TypeBase<BoxType, mlir::Type, detail::BoxTypeStorage> {
public:
using Base::Base;
static BoxType get(mlir::Type eleTy);
@ -142,7 +144,7 @@ public:
};
class BoxCharType : public mlir::Type::TypeBase<BoxCharType, mlir::Type,
detail::BoxCharTypeStorage> {
detail::BoxCharTypeStorage> {
public:
using Base::Base;
static BoxCharType get(mlir::MLIRContext *ctxt, KindTy kind);
@ -151,7 +153,7 @@ public:
};
class BoxProcType : public mlir::Type::TypeBase<BoxProcType, mlir::Type,
detail::BoxProcTypeStorage> {
detail::BoxProcTypeStorage> {
public:
using Base::Base;
static BoxProcType get(mlir::Type eleTy);
@ -159,8 +161,8 @@ public:
mlir::Type getEleTy() const;
};
class DimsType
: public mlir::Type::TypeBase<DimsType, mlir::Type, detail::DimsTypeStorage> {
class DimsType : public mlir::Type::TypeBase<DimsType, mlir::Type,
detail::DimsTypeStorage> {
public:
using Base::Base;
static DimsType get(mlir::MLIRContext *ctx, unsigned rank);
@ -171,15 +173,15 @@ public:
};
class FieldType : public mlir::Type::TypeBase<FieldType, mlir::Type,
detail::FieldTypeStorage> {
detail::FieldTypeStorage> {
public:
using Base::Base;
static FieldType get(mlir::MLIRContext *ctxt, KindTy _ = 0);
static bool kindof(unsigned kind) { return kind == TypeKind::FIR_FIELD; }
};
class HeapType
: public mlir::Type::TypeBase<HeapType, mlir::Type, detail::HeapTypeStorage> {
class HeapType : public mlir::Type::TypeBase<HeapType, mlir::Type,
detail::HeapTypeStorage> {
public:
using Base::Base;
static HeapType get(mlir::Type elementType);
@ -189,7 +191,7 @@ public:
};
class PointerType : public mlir::Type::TypeBase<PointerType, mlir::Type,
detail::PointerTypeStorage> {
detail::PointerTypeStorage> {
public:
using Base::Base;
static PointerType get(mlir::Type elementType);
@ -198,8 +200,9 @@ public:
mlir::Type getEleTy() const;
};
class ReferenceType : public mlir::Type::TypeBase<ReferenceType, mlir::Type,
detail::ReferenceTypeStorage> {
class ReferenceType
: public mlir::Type::TypeBase<ReferenceType, mlir::Type,
detail::ReferenceTypeStorage> {
public:
using Base::Base;
static ReferenceType get(mlir::Type elementType);
@ -209,7 +212,7 @@ public:
};
class SequenceType : public mlir::Type::TypeBase<SequenceType, mlir::Type,
detail::SequenceTypeStorage> {
detail::SequenceTypeStorage> {
public:
using Base::Base;
using BoundInfo = int64_t;
@ -238,7 +241,7 @@ llvm::hash_code hash_value(const SequenceType::Extent &);
llvm::hash_code hash_value(const SequenceType::Shape &);
class TypeDescType : public mlir::Type::TypeBase<TypeDescType, mlir::Type,
detail::TypeDescTypeStorage> {
detail::TypeDescTypeStorage> {
public:
using Base::Base;
static TypeDescType get(mlir::Type ofType);
@ -249,7 +252,7 @@ public:
// Derived types
class RecordType : public mlir::Type::TypeBase<RecordType, mlir::Type,
detail::RecordTypeStorage> {
detail::RecordTypeStorage> {
public:
using Base::Base;
using TypePair = std::pair<std::string, mlir::Type>;
@ -260,15 +263,15 @@ public:
TypeList getLenParamList();
static RecordType get(mlir::MLIRContext *ctxt, llvm::StringRef name,
llvm::ArrayRef<TypePair> lenPList = {},
llvm::ArrayRef<TypePair> typeList = {});
llvm::ArrayRef<TypePair> lenPList = {},
llvm::ArrayRef<TypePair> typeList = {});
constexpr static bool kindof(unsigned kind) { return kind == getId(); }
constexpr static unsigned getId() { return TypeKind::FIR_DERIVED; }
};
mlir::Type parseFirType(
FIROpsDialect *dialect, llvm::StringRef rawData, mlir::Location loc);
mlir::Type parseFirType(FIROpsDialect *dialect, llvm::StringRef rawData,
mlir::Location loc);
} // fir
} // namespace fir
#endif // FIR_TYPE_H
#endif // FIR_TYPE_H