//===- LLVMAttrs.cpp - LLVM Attributes registration -----------------------===// // // 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 // //===----------------------------------------------------------------------===// // // This file defines the attribute details for the LLVM IR dialect in MLIR. // //===----------------------------------------------------------------------===// #include "mlir/Dialect/LLVMIR/LLVMAttrs.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/IR/Builders.h" #include "mlir/IR/DialectImplementation.h" #include "mlir/Interfaces/FunctionInterfaces.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/TypeSwitch.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/IR/DebugInfoMetadata.h" #include <optional> usingnamespacemlir; usingnamespacemlir::LLVM; /// Parses DWARF expression arguments with respect to the DWARF operation /// opcode. Some DWARF expression operations have a specific number of operands /// and may appear in a textual form. static LogicalResult parseExpressionArg(AsmParser &parser, uint64_t opcode, SmallVector<uint64_t> &args); /// Prints DWARF expression arguments with respect to the specific DWARF /// operation. Some operands are printed in their textual form. static void printExpressionArg(AsmPrinter &printer, uint64_t opcode, ArrayRef<uint64_t> args); #include "mlir/Dialect/LLVMIR/LLVMAttrInterfaces.cpp.inc" #include "mlir/Dialect/LLVMIR/LLVMOpsEnums.cpp.inc" #define GET_ATTRDEF_CLASSES #include "mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.cpp.inc" //===----------------------------------------------------------------------===// // LLVMDialect registration //===----------------------------------------------------------------------===// void LLVMDialect::registerAttributes() { … } //===----------------------------------------------------------------------===// // DINodeAttr //===----------------------------------------------------------------------===// bool DINodeAttr::classof(Attribute attr) { … } //===----------------------------------------------------------------------===// // DIScopeAttr //===----------------------------------------------------------------------===// bool DIScopeAttr::classof(Attribute attr) { … } //===----------------------------------------------------------------------===// // DILocalScopeAttr //===----------------------------------------------------------------------===// bool DILocalScopeAttr::classof(Attribute attr) { … } //===----------------------------------------------------------------------===// // DIVariableAttr //===----------------------------------------------------------------------===// bool DIVariableAttr::classof(Attribute attr) { … } //===----------------------------------------------------------------------===// // DITypeAttr //===----------------------------------------------------------------------===// bool DITypeAttr::classof(Attribute attr) { … } //===----------------------------------------------------------------------===// // TBAANodeAttr //===----------------------------------------------------------------------===// bool TBAANodeAttr::classof(Attribute attr) { … } //===----------------------------------------------------------------------===// // MemoryEffectsAttr //===----------------------------------------------------------------------===// MemoryEffectsAttr MemoryEffectsAttr::get(MLIRContext *context, ArrayRef<ModRefInfo> memInfoArgs) { … } bool MemoryEffectsAttr::isReadWrite() { … } //===----------------------------------------------------------------------===// // DIExpression //===----------------------------------------------------------------------===// DIExpressionAttr DIExpressionAttr::get(MLIRContext *context) { … } LogicalResult parseExpressionArg(AsmParser &parser, uint64_t opcode, SmallVector<uint64_t> &args) { … } void printExpressionArg(AsmPrinter &printer, uint64_t opcode, ArrayRef<uint64_t> args) { … } //===----------------------------------------------------------------------===// // DICompositeTypeAttr //===----------------------------------------------------------------------===// DIRecursiveTypeAttrInterface DICompositeTypeAttr::withRecId(DistinctAttr recId) { … } DIRecursiveTypeAttrInterface DICompositeTypeAttr::getRecSelf(DistinctAttr recId) { … } //===----------------------------------------------------------------------===// // DISubprogramAttr //===----------------------------------------------------------------------===// DIRecursiveTypeAttrInterface DISubprogramAttr::withRecId(DistinctAttr recId) { … } DIRecursiveTypeAttrInterface DISubprogramAttr::getRecSelf(DistinctAttr recId) { … } //===----------------------------------------------------------------------===// // ConstantRangeAttr //===----------------------------------------------------------------------===// Attribute ConstantRangeAttr::parse(AsmParser &parser, Type odsType) { … } void ConstantRangeAttr::print(AsmPrinter &printer) const { … } LogicalResult ConstantRangeAttr::verify(llvm::function_ref<InFlightDiagnostic()> emitError, APInt lower, APInt upper) { … } //===----------------------------------------------------------------------===// // TargetFeaturesAttr //===----------------------------------------------------------------------===// TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context, llvm::ArrayRef<StringRef> features) { … } TargetFeaturesAttr TargetFeaturesAttr::get(MLIRContext *context, StringRef targetFeatures) { … } LogicalResult TargetFeaturesAttr::verify(function_ref<InFlightDiagnostic()> emitError, llvm::ArrayRef<StringAttr> features) { … } bool TargetFeaturesAttr::contains(StringAttr feature) const { … } bool TargetFeaturesAttr::contains(StringRef feature) const { … } std::string TargetFeaturesAttr::getFeaturesString() const { … } TargetFeaturesAttr TargetFeaturesAttr::featuresAt(Operation *op) { … }