[Workflow] Roll back some settings since they caused more issues
[llvm-project.git] / mlir / lib / Dialect / LLVMIR / IR / LLVMAttrs.cpp
blob3d45ab8fac4d70559890311ae26b83011aa9c9e8
1 //===- LLVMAttrs.cpp - LLVM Attributes registration -----------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the attribute details for the LLVM IR dialect in MLIR.
11 //===----------------------------------------------------------------------===//
13 #include "mlir/Dialect/LLVMIR/LLVMAttrs.h"
14 #include "mlir/Dialect/LLVMIR/LLVMDialect.h"
15 #include "mlir/IR/Builders.h"
16 #include "mlir/IR/DialectImplementation.h"
17 #include "llvm/ADT/StringExtras.h"
18 #include "llvm/ADT/TypeSwitch.h"
19 #include "llvm/BinaryFormat/Dwarf.h"
20 #include <optional>
22 using namespace mlir;
23 using namespace mlir::LLVM;
25 #include "mlir/Dialect/LLVMIR/LLVMOpsEnums.cpp.inc"
26 #define GET_ATTRDEF_CLASSES
27 #include "mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.cpp.inc"
29 //===----------------------------------------------------------------------===//
30 // LLVMDialect registration
31 //===----------------------------------------------------------------------===//
33 void LLVMDialect::registerAttributes() {
34 addAttributes<
35 #define GET_ATTRDEF_LIST
36 #include "mlir/Dialect/LLVMIR/LLVMOpsAttrDefs.cpp.inc"
37 >();
40 //===----------------------------------------------------------------------===//
41 // DINodeAttr
42 //===----------------------------------------------------------------------===//
44 bool DINodeAttr::classof(Attribute attr) {
45 return llvm::isa<DIBasicTypeAttr, DICompileUnitAttr, DICompositeTypeAttr,
46 DIDerivedTypeAttr, DIFileAttr, DILabelAttr,
47 DILexicalBlockAttr, DILexicalBlockFileAttr,
48 DILocalVariableAttr, DIModuleAttr, DINamespaceAttr,
49 DINullTypeAttr, DISubprogramAttr, DISubrangeAttr,
50 DISubroutineTypeAttr>(attr);
53 //===----------------------------------------------------------------------===//
54 // DIScopeAttr
55 //===----------------------------------------------------------------------===//
57 bool DIScopeAttr::classof(Attribute attr) {
58 return llvm::isa<DICompileUnitAttr, DICompositeTypeAttr, DIFileAttr,
59 DILocalScopeAttr, DIModuleAttr, DINamespaceAttr>(attr);
62 //===----------------------------------------------------------------------===//
63 // DILocalScopeAttr
64 //===----------------------------------------------------------------------===//
66 bool DILocalScopeAttr::classof(Attribute attr) {
67 return llvm::isa<DILexicalBlockAttr, DILexicalBlockFileAttr,
68 DISubprogramAttr>(attr);
71 //===----------------------------------------------------------------------===//
72 // DITypeAttr
73 //===----------------------------------------------------------------------===//
75 bool DITypeAttr::classof(Attribute attr) {
76 return llvm::isa<DINullTypeAttr, DIBasicTypeAttr, DICompositeTypeAttr,
77 DIDerivedTypeAttr, DISubroutineTypeAttr>(attr);
80 //===----------------------------------------------------------------------===//
81 // TBAANodeAttr
82 //===----------------------------------------------------------------------===//
84 bool TBAANodeAttr::classof(Attribute attr) {
85 return llvm::isa<TBAATypeDescriptorAttr, TBAARootAttr>(attr);
88 //===----------------------------------------------------------------------===//
89 // MemoryEffectsAttr
90 //===----------------------------------------------------------------------===//
92 MemoryEffectsAttr MemoryEffectsAttr::get(MLIRContext *context,
93 ArrayRef<ModRefInfo> memInfoArgs) {
94 if (memInfoArgs.empty())
95 return MemoryEffectsAttr::get(context, ModRefInfo::ModRef,
96 ModRefInfo::ModRef, ModRefInfo::ModRef);
97 if (memInfoArgs.size() == 3)
98 return MemoryEffectsAttr::get(context, memInfoArgs[0], memInfoArgs[1],
99 memInfoArgs[2]);
100 return {};
103 bool MemoryEffectsAttr::isReadWrite() {
104 if (this->getArgMem() != ModRefInfo::ModRef)
105 return false;
106 if (this->getInaccessibleMem() != ModRefInfo::ModRef)
107 return false;
108 if (this->getOther() != ModRefInfo::ModRef)
109 return false;
110 return true;