13#ifndef FORTRAN_OPTMIZER_CODEGEN_TARGET_H
14#define FORTRAN_OPTMIZER_CODEGEN_TARGET_H
16#include "flang/Optimizer/Dialect/FIRType.h"
17#include "flang/Optimizer/Dialect/Support/KindMapping.h"
18#include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
19#include "mlir/IR/BuiltinTypes.h"
20#include "llvm/TargetParser/Triple.h"
38 enum class IntegerExtension { None, Zero, Sign };
40 Attributes(
unsigned short alignment = 0,
bool byval =
false,
41 bool sret =
false,
bool append =
false,
42 IntegerExtension intExt = IntegerExtension::None)
43 : alignment{alignment}, byval{byval}, sret{sret}, append{append},
46 unsigned getAlignment()
const {
return alignment; }
47 bool hasAlignment()
const {
return alignment != 0; }
48 bool isByVal()
const {
return byval; }
49 bool isSRet()
const {
return sret; }
50 bool isAppend()
const {
return append; }
51 bool isZeroExt()
const {
return intExt == IntegerExtension::Zero; }
52 bool isSignExt()
const {
return intExt == IntegerExtension::Sign; }
53 llvm::StringRef getIntExtensionAttrName()
const;
56 unsigned short alignment{};
60 IntegerExtension intExt;
71 using TypeAndAttr = std::tuple<mlir::Type, Attributes>;
72 using Marshalling = std::vector<TypeAndAttr>;
74 static std::unique_ptr<CodeGenSpecifics>
75 get(mlir::MLIRContext *ctx, llvm::Triple &&trp,
KindMapping &&kindMap,
76 llvm::StringRef targetCPU, mlir::LLVM::TargetFeaturesAttr targetFeatures,
77 const mlir::DataLayout &dl);
79 static std::unique_ptr<CodeGenSpecifics>
80 get(mlir::MLIRContext *ctx, llvm::Triple &&trp,
KindMapping &&kindMap,
81 llvm::StringRef targetCPU, mlir::LLVM::TargetFeaturesAttr targetFeatures,
82 const mlir::DataLayout &dl, llvm::StringRef tuneCPU);
84 static TypeAndAttr getTypeAndAttr(mlir::Type t) {
return TypeAndAttr{t, {}}; }
88 mlir::LLVM::TargetFeaturesAttr targetFeatures,
89 const mlir::DataLayout &dl)
90 : context{*ctx}, triple{std::move(trp)}, kindMap{std::move(kindMap)},
91 targetCPU{targetCPU}, targetFeatures{targetFeatures}, dataLayout{&dl},
96 mlir::LLVM::TargetFeaturesAttr targetFeatures,
97 const mlir::DataLayout &dl, llvm::StringRef tuneCPU)
98 : context{*ctx}, triple{std::move(trp)}, kindMap{std::move(kindMap)},
99 targetCPU{targetCPU}, targetFeatures{targetFeatures}, dataLayout{&dl},
112 mlir::Type eleTy)
const = 0;
117 mlir::Type eleTy)
const = 0;
127 const Marshalling &previousArguments)
const = 0;
132 fir::RecordType eleTy)
const = 0;
168 virtual Marshalling integerArgumentType(mlir::Location loc,
169 mlir::IntegerType argTy)
const = 0;
173 virtual Marshalling integerReturnType(mlir::Location loc,
174 mlir::IntegerType argTy)
const = 0;
177 virtual unsigned char getCIntTypeWidth()
const = 0;
179 llvm::StringRef getTargetCPU()
const {
return targetCPU; }
180 llvm::StringRef getTuneCPU()
const {
return tuneCPU; }
182 mlir::LLVM::TargetFeaturesAttr getTargetFeatures()
const {
183 return targetFeatures;
186 const mlir::DataLayout &getDataLayout()
const {
187 assert(dataLayout &&
"dataLayout must be set");
192 mlir::MLIRContext &context;
195 llvm::StringRef targetCPU;
196 mlir::LLVM::TargetFeaturesAttr targetFeatures;
197 const mlir::DataLayout *dataLayout =
nullptr;
198 llvm::StringRef tuneCPU;
virtual Marshalling complexArgumentType(mlir::Location loc, mlir::Type eleTy) const =0
virtual mlir::Type complexMemoryType(mlir::Type eleTy) const =0
Type presentation of a complex<ele> type value in memory.
virtual mlir::Type boxcharMemoryType(mlir::Type eleTy) const =0
Type presentation of a boxchar<n> type value in memory.
virtual Marshalling structArgumentType(mlir::Location loc, fir::RecordType recTy, const Marshalling &previousArguments) const =0
virtual Marshalling boxcharArgumentType(mlir::Type eleTy) const =0
virtual Marshalling structReturnType(mlir::Location loc, fir::RecordType eleTy) const =0
virtual Marshalling complexReturnType(mlir::Location loc, mlir::Type eleTy) const =0
Definition: KindMapping.h:48
Definition: AbstractConverter.h:31
Definition: AbstractConverter.h:27