llvm.org GIT mirror llvm / f805775
Move the enum attributes defined in Attributes.h to a table-gen file. This is a step towards consolidating some of the information regarding attributes in a single place. This patch moves the enum attributes in Attributes.h to the table-gen file. Additionally, it adds definitions of target independent string attributes that will be used in follow-up commits by the inliner to check attribute compatibility. rdar://problem/19836465 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252796 91177308-0d34-0410-b5e6-96231b3b80d8 Akira Hatanaka 3 years ago
8 changed file(s) with 250 addition(s) and 59 deletion(s). Raw diff Collapse all Expand all
6363 enum AttrKind {
6464 // IR-Level Attributes
6565 None, ///< No attributes have been set
66 Alignment, ///< Alignment of parameter (5 bits)
67 ///< stored as log2 of alignment with +1 bias
68 ///< 0 means unaligned (different from align(1))
69 AlwaysInline, ///< inline=always
70 ArgMemOnly, ///< Funciton can access memory only using pointers
71 ///< based on its arguments.
72 Builtin, ///< Callee is recognized as a builtin, despite
73 ///< nobuiltin attribute on its declaration.
74 ByVal, ///< Pass structure by value
75 Cold, ///< Marks function as being in a cold path.
76 Convergent, ///< Can only be moved to control-equivalent blocks
77 Dereferenceable, ///< Pointer is known to be dereferenceable
78 DereferenceableOrNull, ///< Pointer is either null or dereferenceable
79 InAlloca, ///< Pass structure in an alloca
80 InlineHint, ///< Source said inlining was desirable
81 InReg, ///< Force argument to be passed in register
82 JumpTable, ///< Build jump-instruction tables and replace refs.
83 MinSize, ///< Function must be optimized for size first
84 Naked, ///< Naked function
85 Nest, ///< Nested function static chain
86 NoAlias, ///< Considered to not alias after call
87 NoBuiltin, ///< Callee isn't recognized as a builtin
88 NoCapture, ///< Function creates no aliases of pointer
89 NoDuplicate, ///< Call cannot be duplicated
90 NoImplicitFloat, ///< Disable implicit floating point insts
91 NoInline, ///< inline=never
92 NonLazyBind, ///< Function is called early and/or
93 ///< often, so lazy binding isn't worthwhile
94 NonNull, ///< Pointer is known to be not null
95 NoRecurse, ///< The function does not recurse
96 NoRedZone, ///< Disable redzone
97 NoReturn, ///< Mark the function as not returning
98 NoUnwind, ///< Function doesn't unwind stack
99 OptimizeForSize, ///< opt_size
100 OptimizeNone, ///< Function must not be optimized.
101 ReadNone, ///< Function does not access memory
102 ReadOnly, ///< Function only reads from memory
103 Returned, ///< Return value is always equal to this argument
104 ReturnsTwice, ///< Function can return twice
105 SafeStack, ///< Safe Stack protection.
106 SanitizeAddress, ///< AddressSanitizer is on.
107 SanitizeMemory, ///< MemorySanitizer is on.
108 SanitizeThread, ///< ThreadSanitizer is on.
109 SExt, ///< Sign extended before/after call
110 StackAlignment, ///< Alignment of stack for function (3 bits)
111 ///< stored as log2 of alignment with +1 bias 0
112 ///< means unaligned (different from
113 ///< alignstack=(1))
114 StackProtect, ///< Stack protection.
115 StackProtectReq, ///< Stack protection required.
116 StackProtectStrong, ///< Strong Stack protection.
117 StructRet, ///< Hidden pointer to structure to return
118 UWTable, ///< Function must be in a unwind table
119 ZExt, ///< Zero extended before/after call
120
66 #define GET_ATTR_ENUM
67 #include "llvm/IR/Attributes.inc"
12168 EndAttrKinds ///< Sentinal value useful for loops
12269 };
12370
0 /// Attribute base class.
1 class Attr {
2 // String representation of this attribute in the IR.
3 string AttrString = S;
4 }
5
6 /// Enum attribute.
7 class EnumAttr : Attr;
8
9 /// StringBool attribute.
10 class StrBoolAttr : Attr;
11
12 /// Target-independent enum attributes.
13
14 /// Alignment of parameter (5 bits) stored as log2 of alignment with +1 bias.
15 /// 0 means unaligned (different from align(1)).
16 def Alignment : EnumAttr<"align">;
17
18 /// inline=always.
19 def AlwaysInline : EnumAttr<"alwaysinline">;
20
21 /// Funciton can access memory only using pointers based on its arguments.
22 def ArgMemOnly : EnumAttr<"argmemonly">;
23
24 /// Callee is recognized as a builtin, despite nobuiltin attribute on its
25 /// declaration.
26 def Builtin : EnumAttr<"builtin">;
27
28 /// Pass structure by value.
29 def ByVal : EnumAttr<"byval">;
30
31 /// Marks function as being in a cold path.
32 def Cold : EnumAttr<"cold">;
33
34 /// Can only be moved to control-equivalent blocks.
35 def Convergent : EnumAttr<"convergent">;
36
37 /// Pointer is known to be dereferenceable.
38 def Dereferenceable : EnumAttr<"dereferenceable">;
39
40 /// Pointer is either null or dereferenceable.
41 def DereferenceableOrNull : EnumAttr<"dereferenceable_or_null">;
42
43 /// Pass structure in an alloca.
44 def InAlloca : EnumAttr<"inalloca">;
45
46 /// Source said inlining was desirable.
47 def InlineHint : EnumAttr<"inlinehint">;
48
49 /// Force argument to be passed in register.
50 def InReg : EnumAttr<"inreg">;
51
52 /// Build jump-instruction tables and replace refs.
53 def JumpTable : EnumAttr<"jumptable">;
54
55 /// Function must be optimized for size first.
56 def MinSize : EnumAttr<"minsize">;
57
58 /// Naked function.
59 def Naked : EnumAttr<"naked">;
60
61 /// Nested function static chain.
62 def Nest : EnumAttr<"nest">;
63
64 /// Considered to not alias after call.
65 def NoAlias : EnumAttr<"noalias">;
66
67 /// Callee isn't recognized as a builtin.
68 def NoBuiltin : EnumAttr<"nobuiltin">;
69
70 /// Function creates no aliases of pointer.
71 def NoCapture : EnumAttr<"nocapture">;
72
73 /// Call cannot be duplicated.
74 def NoDuplicate : EnumAttr<"noduplicate">;
75
76 /// Disable implicit floating point insts.
77 def NoImplicitFloat : EnumAttr<"noimplicitfloat">;
78
79 /// inline=never.
80 def NoInline : EnumAttr<"noinline">;
81
82 /// Function is called early and/or often, so lazy binding isn't worthwhile.
83 def NonLazyBind : EnumAttr<"nonlazybind">;
84
85 /// Pointer is known to be not null.
86 def NonNull : EnumAttr<"nonnull">;
87
88 /// The function does not recurse.
89 def NoRecurse : EnumAttr<"norecurse">;
90
91 /// Disable redzone.
92 def NoRedZone : EnumAttr<"noredzone">;
93
94 /// Mark the function as not returning.
95 def NoReturn : EnumAttr<"noreturn">;
96
97 /// Function doesn't unwind stack.
98 def NoUnwind : EnumAttr<"nounwind">;
99
100 /// opt_size.
101 def OptimizeForSize : EnumAttr<"optsize">;
102
103 /// Function must not be optimized.
104 def OptimizeNone : EnumAttr<"optnone">;
105
106 /// Function does not access memory.
107 def ReadNone : EnumAttr<"readnone">;
108
109 /// Function only reads from memory.
110 def ReadOnly : EnumAttr<"readonly">;
111
112 /// Return value is always equal to this argument.
113 def Returned : EnumAttr<"returned">;
114
115 /// Function can return twice.
116 def ReturnsTwice : EnumAttr<"returns_twice">;
117
118 /// Safe Stack protection.
119 def SafeStack : EnumAttr<"safestack">;
120
121 /// Sign extended before/after call.
122 def SExt : EnumAttr<"signext">;
123
124 /// Alignment of stack for function (3 bits) stored as log2 of alignment with
125 /// +1 bias 0 means unaligned (different from alignstack=(1)).
126 def StackAlignment : EnumAttr<"alignstack">;
127
128 /// Stack protection.
129 def StackProtect : EnumAttr<"ssp">;
130
131 /// Stack protection required.
132 def StackProtectReq : EnumAttr<"sspreq">;
133
134 /// Strong Stack protection.
135 def StackProtectStrong : EnumAttr<"sspstrong">;
136
137 /// Hidden pointer to structure to return.
138 def StructRet : EnumAttr<"sret">;
139
140 /// AddressSanitizer is on.
141 def SanitizeAddress : EnumAttr<"sanitize_address">;
142
143 /// ThreadSanitizer is on.
144 def SanitizeThread : EnumAttr<"sanitize_thread">;
145
146 /// MemorySanitizer is on.
147 def SanitizeMemory : EnumAttr<"sanitize_memory">;
148
149 /// Function must be in a unwind table.
150 def UWTable : EnumAttr<"uwtable">;
151
152 /// Zero extended before/after call.
153 def ZExt : EnumAttr<"zeroext">;
154
155 /// Target-independent string attributes.
156 def LessPreciseFPMAD : StrBoolAttr<"less-precise-fpmad">;
157 def NoInfsFPMath : StrBoolAttr<"no-infs-fp-math">;
158 def NoNansFPMath : StrBoolAttr<"no-nans-fp-math">;
159 def UnsafeFPMath : StrBoolAttr<"unsafe-fp-math">;
0 set(LLVM_TARGET_DEFINITIONS Attributes.td)
1 tablegen(LLVM Attributes.inc -gen-attrs)
2
3 set(LLVM_TARGET_DEFINITIONS Intrinsics.td)
1
24 tablegen(LLVM Intrinsics.gen -gen-intrinsic)
3
45 add_public_tablegen_target(intrinsics_gen)
99 LIBRARYNAME = LLVMCore
1010 BUILD_ARCHIVE = 1
1111
12 BUILT_SOURCES = $(PROJ_OBJ_ROOT)/include/llvm/IR/Intrinsics.gen
12 BUILT_SOURCES = $(PROJ_OBJ_ROOT)/include/llvm/IR/Intrinsics.gen \
13 $(PROJ_OBJ_ROOT)/include/llvm/IR/Attributes.inc
1314
1415 include $(LEVEL)/Makefile.common
1516
1617 GENFILE:=$(PROJ_OBJ_ROOT)/include/llvm/IR/Intrinsics.gen
18 ATTRINCFILE:=$(PROJ_OBJ_ROOT)/include/llvm/IR/Attributes.inc
1719
1820 INTRINSICTD := $(PROJ_SRC_ROOT)/include/llvm/IR/Intrinsics.td
1921 INTRINSICTDS := $(wildcard $(PROJ_SRC_ROOT)/include/llvm/IR/Intrinsics*.td)
22 ATTRIBUTESTD := $(PROJ_SRC_ROOT)/include/llvm/IR/Attributes.td
2023
2124 $(ObjDir)/Intrinsics.gen.tmp: $(ObjDir)/.dir $(INTRINSICTDS) $(LLVM_TBLGEN)
2225 $(Echo) Building Intrinsics.gen.tmp from Intrinsics.td
2730 $(EchoCmd) Updated Intrinsics.gen because Intrinsics.gen.tmp \
2831 changed significantly. )
2932
33 $(ObjDir)/Attributes.inc.tmp: $(ObjDir)/.dir $(ATTRIBUTESTD) $(LLVM_TBLGEN)
34 $(Echo) Building Attributes.inc.tmp from $(ATTRIBUTESTD)
35 $(Verb) $(LLVMTableGen) $(call SYSPATH, $(ATTRIBUTESTD)) -o $(call SYSPATH, $@) -gen-attrs
36
37 $(ATTRINCFILE): $(ObjDir)/Attributes.inc.tmp $(PROJ_OBJ_ROOT)/include/llvm/IR/.dir
38 $(Verb) $(CMP) -s $@ $< || ( $(CP) $< $@ && \
39 $(EchoCmd) Updated Attributes.inc because Attributes.inc.tmp \
40 changed significantly. )
41
3042 install-local:: $(GENFILE)
3143 $(Echo) Installing $(DESTDIR)$(PROJ_includedir)/llvm/IR/Intrinsics.gen
3244 $(Verb) $(DataInstall) $(GENFILE) $(DESTDIR)$(PROJ_includedir)/llvm/IR/Intrinsics.gen
45
46 install-local:: $(ATTRINCFILE)
47 $(Echo) Installing $(DESTDIR)$(PROJ_includedir)/llvm/IR/Attributes.inc
48 $(Verb) $(DataInstall) $(ATTRINCFILE) $(DESTDIR)$(PROJ_includedir)/llvm/IR/Attributes.inc
0 //===- Attributes.cpp - Generate attributes -------------------------------===//
1 //
2 // The LLVM Compiler Infrastructure
3 //
4 // This file is distributed under the University of Illinois Open Source
5 // License. See LICENSE.TXT for details.
6 //
7 //===----------------------------------------------------------------------===//
8
9 #include "llvm/Support/SourceMgr.h"
10 #include "llvm/Support/MemoryBuffer.h"
11 #include "llvm/TableGen/Error.h"
12 #include "llvm/TableGen/Record.h"
13 #include
14 #include
15 #include
16 using namespace llvm;
17
18 #define DEBUG_TYPE "attr-enum"
19
20 namespace {
21
22 class Attributes {
23 public:
24 Attributes(RecordKeeper &R) : Records(R) {}
25 void emit(raw_ostream &OS);
26
27 private:
28 void emitTargetIndependentEnums(raw_ostream &OS);
29
30 RecordKeeper &Records;
31 };
32
33 } // End anonymous namespace.
34
35 void Attributes::emitTargetIndependentEnums(raw_ostream &OS) {
36 OS << "#ifdef GET_ATTR_ENUM\n";
37 OS << "#undef GET_ATTR_ENUM\n";
38
39 const std::vector &Attrs =
40 Records.getAllDerivedDefinitions("EnumAttr");
41
42 for (auto A : Attrs)
43 OS << A->getName() << ",\n";
44
45 OS << "#endif\n";
46 }
47
48 void Attributes::emit(raw_ostream &OS) {
49 emitTargetIndependentEnums(OS);
50 }
51
52 namespace llvm {
53
54 void EmitAttributes(RecordKeeper &RK, raw_ostream &OS) {
55 Attributes(RK).emit(OS);
56 }
57
58 } // End llvm namespace.
33 AsmMatcherEmitter.cpp
44 AsmWriterEmitter.cpp
55 AsmWriterInst.cpp
6 Attributes.cpp
67 CallingConvEmitter.cpp
78 CodeEmitterGen.cpp
89 CodeGenDAGPatterns.cpp
4040 PrintEnums,
4141 PrintSets,
4242 GenOptParserDefs,
43 GenCTags
43 GenCTags,
44 GenAttributes
4445 };
4546
4647 namespace {
8485 "Generate option definitions"),
8586 clEnumValN(GenCTags, "gen-ctags",
8687 "Generate ctags-compatible index"),
88 clEnumValN(GenAttributes, "gen-attrs",
89 "Generate attributes"),
8790 clEnumValEnd));
8891
8992 cl::opt
164167 case GenCTags:
165168 EmitCTags(Records, OS);
166169 break;
170 case GenAttributes:
171 EmitAttributes(Records, OS);
172 break;
167173 }
168174
169175 return false;
7777 void EmitMapTable(RecordKeeper &RK, raw_ostream &OS);
7878 void EmitOptParser(RecordKeeper &RK, raw_ostream &OS);
7979 void EmitCTags(RecordKeeper &RK, raw_ostream &OS);
80 void EmitAttributes(RecordKeeper &RK, raw_ostream &OS);
8081
8182 } // End llvm namespace
8283