llvm.org GIT mirror llvm / 8e12985
ARM IAS: improve .eabi_attribute handling Parse tag names as well as expressions. The former is part of the specification, the latter is for improved compatibility with the GNU assembler. Fix attribute value handling to be comformant to the specification. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198662 91177308-0d34-0410-b5e6-96231b3b80d8 Saleem Abdulrasool 6 years ago
11 changed file(s) with 571 addition(s) and 201 deletion(s). Raw diff Collapse all Expand all
9191 virtual void switchVendor(StringRef Vendor) = 0;
9292 virtual void emitAttribute(unsigned Attribute, unsigned Value) = 0;
9393 virtual void emitTextAttribute(unsigned Attribute, StringRef String) = 0;
94 virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
95 StringRef StringValue = "") = 0;
9496 virtual void emitFPU(unsigned FPU) = 0;
9597 virtual void emitArch(unsigned Arch) = 0;
9698 virtual void finishAttributeSection() = 0;
1414 #define DEBUG_TYPE "asm-printer"
1515 #include "ARMAsmPrinter.h"
1616 #include "ARM.h"
17 #include "ARMBuildAttrs.h"
1817 #include "ARMConstantPoolValue.h"
1918 #include "ARMFPUName.h"
2019 #include "ARMMachineFunctionInfo.h"
2221 #include "ARMTargetObjectFile.h"
2322 #include "InstPrinter/ARMInstPrinter.h"
2423 #include "MCTargetDesc/ARMAddressingModes.h"
24 #include "MCTargetDesc/ARMBuildAttrs.h"
2525 #include "MCTargetDesc/ARMMCExpr.h"
2626 #include "llvm/ADT/SetVector.h"
2727 #include "llvm/ADT/SmallString.h"
+0
-170
lib/Target/ARM/ARMBuildAttrs.h less more
None //===-- ARMBuildAttrs.h - ARM Build Attributes ------------------*- C++ -*-===//
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 // This file contains enumerations and support routines for ARM build attributes
10 // as defined in ARM ABI addenda document (ABI release 2.08).
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef __TARGET_ARMBUILDATTRS_H__
15 #define __TARGET_ARMBUILDATTRS_H__
16
17 namespace llvm {
18 namespace ARMBuildAttrs {
19
20 enum SpecialAttr {
21 // This is for the .cpu asm attr. It translates into one or more
22 // AttrType (below) entries in the .ARM.attributes section in the ELF.
23 SEL_CPU
24 };
25
26 enum AttrType {
27 // Rest correspond to ELF/.ARM.attributes
28 File = 1,
29 Section = 2,
30 Symbol = 3,
31 CPU_raw_name = 4,
32 CPU_name = 5,
33 CPU_arch = 6,
34 CPU_arch_profile = 7,
35 ARM_ISA_use = 8,
36 THUMB_ISA_use = 9,
37 FP_arch = 10,
38 WMMX_arch = 11,
39 Advanced_SIMD_arch = 12,
40 PCS_config = 13,
41 ABI_PCS_R9_use = 14,
42 ABI_PCS_RW_data = 15,
43 ABI_PCS_RO_data = 16,
44 ABI_PCS_GOT_use = 17,
45 ABI_PCS_wchar_t = 18,
46 ABI_FP_rounding = 19,
47 ABI_FP_denormal = 20,
48 ABI_FP_exceptions = 21,
49 ABI_FP_user_exceptions = 22,
50 ABI_FP_number_model = 23,
51 ABI_align8_needed = 24,
52 ABI_align8_preserved = 25,
53 ABI_enum_size = 26,
54 ABI_HardFP_use = 27,
55 ABI_VFP_args = 28,
56 ABI_WMMX_args = 29,
57 ABI_optimization_goals = 30,
58 ABI_FP_optimization_goals = 31,
59 compatibility = 32,
60 CPU_unaligned_access = 34,
61 FP_HP_extension = 36,
62 ABI_FP_16bit_format = 38,
63 MPextension_use = 42, // was 70, 2.08 ABI
64 DIV_use = 44,
65 nodefaults = 64,
66 also_compatible_with = 65,
67 T2EE_use = 66,
68 conformance = 67,
69 Virtualization_use = 68,
70 MPextension_use_old = 70
71 };
72
73 // Magic numbers for .ARM.attributes
74 enum AttrMagic {
75 Format_Version = 0x41
76 };
77
78 // Legal Values for CPU_arch, (=6), uleb128
79 enum CPUArch {
80 Pre_v4 = 0,
81 v4 = 1, // e.g. SA110
82 v4T = 2, // e.g. ARM7TDMI
83 v5T = 3, // e.g. ARM9TDMI
84 v5TE = 4, // e.g. ARM946E_S
85 v5TEJ = 5, // e.g. ARM926EJ_S
86 v6 = 6, // e.g. ARM1136J_S
87 v6KZ = 7, // e.g. ARM1176JZ_S
88 v6T2 = 8, // e.g. ARM1156T2F_S
89 v6K = 9, // e.g. ARM1136J_S
90 v7 = 10, // e.g. Cortex A8, Cortex M3
91 v6_M = 11, // e.g. Cortex M1
92 v6S_M = 12, // v6_M with the System extensions
93 v7E_M = 13, // v7_M with DSP extensions
94 v8 = 14 // v8, AArch32
95 };
96
97 enum CPUArchProfile { // (=7), uleb128
98 Not_Applicable = 0, // pre v7, or cross-profile code
99 ApplicationProfile = (0x41), // 'A' (e.g. for Cortex A8)
100 RealTimeProfile = (0x52), // 'R' (e.g. for Cortex R4)
101 MicroControllerProfile = (0x4D), // 'M' (e.g. for Cortex M3)
102 SystemProfile = (0x53) // 'S' Application or real-time profile
103 };
104
105 // The following have a lot of common use cases
106 enum {
107 Not_Allowed = 0,
108 Allowed = 1,
109
110 // Tag_ARM_ISA_use (=8), uleb128
111
112 // Tag_THUMB_ISA_use, (=9), uleb128
113 AllowThumb32 = 2, // 32-bit Thumb (implies 16-bit instructions)
114
115 // Tag_FP_arch (=10), uleb128 (formerly Tag_VFP_arch = 10)
116 AllowFPv2 = 2, // v2 FP ISA permitted (implies use of the v1 FP ISA)
117 AllowFPv3A = 3, // v3 FP ISA permitted (implies use of the v2 FP ISA)
118 AllowFPv3B = 4, // v3 FP ISA permitted, but only D0-D15, S0-S31
119 AllowFPv4A = 5, // v4 FP ISA permitted (implies use of v3 FP ISA)
120 AllowFPv4B = 6, // v4 FP ISA was permitted, but only D0-D15, S0-S31
121 AllowFPARMv8A = 7, // Use of the ARM v8-A FP ISA was permitted
122 AllowFPARMv8B = 8, // Use of the ARM v8-A FP ISA was permitted, but only D0-D15, S0-S31
123
124 // Tag_WMMX_arch, (=11), uleb128
125 AllowWMMXv1 = 1, // The user permitted this entity to use WMMX v1
126 AllowWMMXv2 = 2, // The user permitted this entity to use WMMX v2
127
128 // Tag_Advanced_SIMD_arch, (=12), uleb128
129 AllowNeon = 1, // SIMDv1 was permitted
130 AllowNeon2 = 2, // SIMDv2 was permitted (Half-precision FP, MAC operations)
131 AllowNeonARMv8 = 3, // ARM v8-A SIMD was permitted
132
133 // Tag_ABI_FP_denormal, (=20), uleb128
134 PreserveFPSign = 2, // sign when flushed-to-zero is preserved
135
136 // Tag_ABI_FP_number_model, (=23), uleb128
137 AllowRTABI = 2, // numbers, infinities, and one quiet NaN (see [RTABI])
138 AllowIEE754 = 3, // this code to use all the IEEE 754-defined FP encodings
139
140 // Tag_ABI_HardFP_use, (=27), uleb128
141 HardFPImplied = 0, // FP use should be implied by Tag_FP_arch
142 HardFPSinglePrecision = 1, // Single-precision only
143
144 // Tag_ABI_VFP_args, (=28), uleb128
145 BaseAAPCS = 0,
146 HardFPAAPCS = 1,
147
148 // Tag_FP_HP_extension, (=36), uleb128
149 AllowHPFP = 1, // Allow use of Half Precision FP
150
151 // Tag_MPextension_use, (=42), uleb128
152 AllowMP = 1, // Allow use of MP extensions
153
154 // Tag_DIV_use, (=44), uleb128
155 AllowDIVIfExists = 0, // Allow hardware divide if available in arch, or no info exists.
156 DisallowDIV = 1, // Hardware divide explicitly disallowed
157 AllowDIVExt = 2, // Allow hardware divide as optional architecture extension above
158 // the base arch specified by Tag_CPU_arch and Tag_CPU_arch_profile.
159
160 // Tag_Virtualization_use, (=68), uleb128
161 AllowTZ = 1,
162 AllowVirtualization = 2,
163 AllowTZVirtualization = 3
164 };
165
166 } // namespace ARMBuildAttrs
167 } // namespace llvm
168
169 #endif // __TARGET_ARMBUILDATTRS_H__
66 //
77 //===----------------------------------------------------------------------===//
88
9 #include "ARMBuildAttrs.h"
109 #include "ARMFPUName.h"
1110 #include "ARMFeatures.h"
1211 #include "llvm/MC/MCTargetAsmParser.h"
1312 #include "MCTargetDesc/ARMAddressingModes.h"
13 #include "MCTargetDesc/ARMBuildAttrs.h"
1414 #include "MCTargetDesc/ARMArchName.h"
1515 #include "MCTargetDesc/ARMBaseInfo.h"
1616 #include "MCTargetDesc/ARMMCExpr.h"
81888188 }
81898189
81908190 /// parseDirectiveEabiAttr
8191 /// ::= .eabi_attribute int, int
8191 /// ::= .eabi_attribute int, int [, "str"]
8192 /// ::= .eabi_attribute Tag_name, int [, "str"]
81928193 bool ARMAsmParser::parseDirectiveEabiAttr(SMLoc L) {
8193 if (Parser.getTok().isNot(AsmToken::Integer)) {
8194 Error(L, "integer expected");
8194 int64_t Tag;
8195 SMLoc TagLoc;
8196
8197 TagLoc = Parser.getTok().getLoc();
8198 if (Parser.getTok().is(AsmToken::Identifier)) {
8199 StringRef Name = Parser.getTok().getIdentifier();
8200 Tag = ARMBuildAttrs::AttrTypeFromString(Name);
8201 if (Tag == -1) {
8202 Error(TagLoc, "attribute name not recognised: " + Name);
8203 Parser.eatToEndOfStatement();
8204 return false;
8205 }
8206 Parser.Lex();
8207 } else {
8208 const MCExpr *AttrExpr;
8209
8210 TagLoc = Parser.getTok().getLoc();
8211 if (Parser.parseExpression(AttrExpr)) {
8212 Parser.eatToEndOfStatement();
8213 return false;
8214 }
8215
8216 const MCConstantExpr *CE = dyn_cast(AttrExpr);
8217 if (!CE) {
8218 Error(TagLoc, "expected numeric constant");
8219 Parser.eatToEndOfStatement();
8220 return false;
8221 }
8222
8223 Tag = CE->getValue();
8224 }
8225
8226 if (Parser.getTok().isNot(AsmToken::Comma)) {
8227 Error(Parser.getTok().getLoc(), "comma expected");
8228 Parser.eatToEndOfStatement();
81958229 return false;
81968230 }
8197 int64_t Tag = Parser.getTok().getIntVal();
8198 Parser.Lex(); // eat tag integer
8199
8200 if (Parser.getTok().isNot(AsmToken::Comma)) {
8201 Error(L, "comma expected");
8202 return false;
8203 }
82048231 Parser.Lex(); // skip comma
82058232
8206 L = Parser.getTok().getLoc();
8207 if (Parser.getTok().isNot(AsmToken::Integer)) {
8208 Error(L, "integer expected");
8209 return false;
8210 }
8211 int64_t Value = Parser.getTok().getIntVal();
8212 Parser.Lex(); // eat value integer
8213
8214 getTargetStreamer().emitAttribute(Tag, Value);
8233 StringRef StringValue = "";
8234 bool IsStringValue = false;
8235
8236 int64_t IntegerValue = 0;
8237 bool IsIntegerValue = false;
8238
8239 if (Tag == ARMBuildAttrs::CPU_raw_name || Tag == ARMBuildAttrs::CPU_name)
8240 IsStringValue = true;
8241 else if (Tag == ARMBuildAttrs::compatibility) {
8242 IsStringValue = true;
8243 IsIntegerValue = true;
8244 } else if (Tag == ARMBuildAttrs::nodefaults || Tag < 32 || Tag % 2 == 0)
8245 IsIntegerValue = true;
8246 else if (Tag % 2 == 1)
8247 IsStringValue = true;
8248 else
8249 llvm_unreachable("invalid tag type");
8250
8251 if (IsIntegerValue) {
8252 const MCExpr *ValueExpr;
8253 SMLoc ValueExprLoc = Parser.getTok().getLoc();
8254 if (Parser.parseExpression(ValueExpr)) {
8255 Parser.eatToEndOfStatement();
8256 return false;
8257 }
8258
8259 const MCConstantExpr *CE = dyn_cast(ValueExpr);
8260 if (!CE) {
8261 Error(ValueExprLoc, "expected numeric constant");
8262 Parser.eatToEndOfStatement();
8263 return false;
8264 }
8265
8266 IntegerValue = CE->getValue();
8267 }
8268
8269 if (Tag == ARMBuildAttrs::compatibility) {
8270 if (Parser.getTok().isNot(AsmToken::Comma))
8271 IsStringValue = false;
8272 else
8273 Parser.Lex();
8274 }
8275
8276 if (IsStringValue) {
8277 if (Parser.getTok().isNot(AsmToken::String)) {
8278 Error(Parser.getTok().getLoc(), "bad string constant");
8279 Parser.eatToEndOfStatement();
8280 return false;
8281 }
8282
8283 StringValue = Parser.getTok().getStringContents();
8284 Parser.Lex();
8285 }
8286
8287 if (IsIntegerValue && IsStringValue) {
8288 assert(Tag == ARMBuildAttrs::compatibility);
8289 getTargetStreamer().emitIntTextAttribute(Tag, IntegerValue, StringValue);
8290 } else if (IsIntegerValue)
8291 getTargetStreamer().emitAttribute(Tag, IntegerValue);
8292 else if (IsStringValue)
8293 getTargetStreamer().emitTextAttribute(Tag, StringValue);
82158294 return false;
82168295 }
82178296
0 //===-- ARMBuildAttrs.cpp - ARM Build 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 "ARMBuildAttrs.h"
10 #include "llvm/ADT/StringRef.h"
11 #include "llvm/Support/Debug.h"
12
13 using namespace llvm;
14
15 namespace {
16 const struct {
17 ARMBuildAttrs::AttrType Attr;
18 const char *TagName;
19 } ARMAttributeTags[] = {
20 { ARMBuildAttrs::File, "Tag_File" },
21 { ARMBuildAttrs::Section, "Tag_Section" },
22 { ARMBuildAttrs::Symbol, "Tag_Symbol" },
23 { ARMBuildAttrs::CPU_raw_name, "Tag_CPU_raw_name" },
24 { ARMBuildAttrs::CPU_name, "Tag_CPU_name" },
25 { ARMBuildAttrs::CPU_arch, "Tag_CPU_arch" },
26 { ARMBuildAttrs::CPU_arch_profile, "Tag_CPU_arch_profile" },
27 { ARMBuildAttrs::ARM_ISA_use, "Tag_ARM_ISA_use" },
28 { ARMBuildAttrs::THUMB_ISA_use, "Tag_THUMB_ISA_use" },
29 { ARMBuildAttrs::FP_arch, "Tag_FP_arch" },
30 { ARMBuildAttrs::WMMX_arch, "Tag_WMMX_arch" },
31 { ARMBuildAttrs::Advanced_SIMD_arch, "Tag_Advanced_SIMD_arch" },
32 { ARMBuildAttrs::PCS_config, "Tag_PCS_config" },
33 { ARMBuildAttrs::ABI_PCS_R9_use, "Tag_ABI_PCS_R9_use" },
34 { ARMBuildAttrs::ABI_PCS_RW_data, "Tag_ABI_PCS_RW_data" },
35 { ARMBuildAttrs::ABI_PCS_RO_data, "Tag_ABI_PCS_RO_data" },
36 { ARMBuildAttrs::ABI_PCS_GOT_use, "Tag_ABI_PCS_GOT_use" },
37 { ARMBuildAttrs::ABI_PCS_wchar_t, "Tag_ABI_PCS_wchar_t" },
38 { ARMBuildAttrs::ABI_FP_rounding, "Tag_ABI_FP_rounding" },
39 { ARMBuildAttrs::ABI_FP_denormal, "Tag_ABI_FP_denormal" },
40 { ARMBuildAttrs::ABI_FP_exceptions, "Tag_ABI_FP_exceptions" },
41 { ARMBuildAttrs::ABI_FP_user_exceptions, "Tag_ABI_FP_user_exceptions" },
42 { ARMBuildAttrs::ABI_FP_number_model, "Tag_ABI_FP_number_model" },
43 { ARMBuildAttrs::ABI_align8_needed, "Tag_ABI_align8_needed" },
44 { ARMBuildAttrs::ABI_align8_preserved, "Tag_ABI_align8_preserved" },
45 { ARMBuildAttrs::ABI_enum_size, "Tag_ABI_enum_size" },
46 { ARMBuildAttrs::ABI_HardFP_use, "Tag_ABI_HardFP_use" },
47 { ARMBuildAttrs::ABI_VFP_args, "Tag_ABI_VFP_args" },
48 { ARMBuildAttrs::ABI_WMMX_args, "Tag_ABI_WMMX_args" },
49 { ARMBuildAttrs::ABI_optimization_goals, "Tag_ABI_optimization_goals" },
50 { ARMBuildAttrs::ABI_FP_optimization_goals, "Tag_ABI_FP_optimization_goals" },
51 { ARMBuildAttrs::compatibility, "Tag_compatibility" },
52 { ARMBuildAttrs::CPU_unaligned_access, "Tag_CPU_unaligned_access" },
53 { ARMBuildAttrs::FP_HP_extension, "Tag_FP_HP_extension" },
54 { ARMBuildAttrs::ABI_FP_16bit_format, "Tag_ABI_FP_16bit_format" },
55 { ARMBuildAttrs::MPextension_use, "Tag_MPextension_use" },
56 { ARMBuildAttrs::DIV_use, "Tag_DIV_use" },
57 { ARMBuildAttrs::nodefaults, "Tag_nodefaults" },
58 { ARMBuildAttrs::also_compatible_with, "Tag_also_compatible_with" },
59 { ARMBuildAttrs::T2EE_use, "Tag_T2EE_use" },
60 { ARMBuildAttrs::conformance, "Tag_conformance" },
61 { ARMBuildAttrs::Virtualization_use, "Tag_Virtualization_use" },
62
63 // Legacy Names
64 { ARMBuildAttrs::FP_arch, "Tag_VFP_arch" },
65 { ARMBuildAttrs::ABI_align8_needed, "Tag_ABI_align_needed" },
66 { ARMBuildAttrs::ABI_align8_preserved, "Tag_ABI_align_preserved" },
67 { ARMBuildAttrs::FP_HP_extension, "Tag_VFP_HP_extension" },
68 };
69 }
70
71 namespace llvm {
72 namespace ARMBuildAttrs {
73 StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix) {
74 return AttrTypeAsString(static_cast(Attr), HasTagPrefix);
75 }
76
77 StringRef AttrTypeAsString(AttrType Attr, bool HasTagPrefix) {
78 for (unsigned TI = 0, TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags);
79 TI != TE; ++TI)
80 if (ARMAttributeTags[TI].Attr == Attr)
81 return ARMAttributeTags[TI].TagName + (HasTagPrefix ? 0 : 4);
82 return "";
83 }
84
85 int AttrTypeFromString(StringRef Tag) {
86 bool HasTagPrefix = Tag.startswith("Tag_");
87 for (unsigned TI = 0, TE = sizeof(ARMAttributeTags) / sizeof(*ARMAttributeTags);
88 TI != TE; ++TI)
89 if (StringRef(ARMAttributeTags[TI].TagName + (HasTagPrefix ? 0 : 4)) == Tag)
90 return ARMAttributeTags[TI].Attr;
91 return -1;
92 }
93 }
94 }
95
0 //===-- ARMBuildAttrs.h - ARM Build Attributes ------------------*- C++ -*-===//
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 // This file contains enumerations and support routines for ARM build attributes
10 // as defined in ARM ABI addenda document (ABI release 2.08).
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef __TARGET_ARMBUILDATTRS_H__
15 #define __TARGET_ARMBUILDATTRS_H__
16
17 namespace llvm {
18
19 class StringRef;
20
21 namespace ARMBuildAttrs {
22
23 enum SpecialAttr {
24 // This is for the .cpu asm attr. It translates into one or more
25 // AttrType (below) entries in the .ARM.attributes section in the ELF.
26 SEL_CPU
27 };
28
29 enum AttrType {
30 // Rest correspond to ELF/.ARM.attributes
31 File = 1,
32 Section = 2,
33 Symbol = 3,
34 CPU_raw_name = 4,
35 CPU_name = 5,
36 CPU_arch = 6,
37 CPU_arch_profile = 7,
38 ARM_ISA_use = 8,
39 THUMB_ISA_use = 9,
40 FP_arch = 10,
41 WMMX_arch = 11,
42 Advanced_SIMD_arch = 12,
43 PCS_config = 13,
44 ABI_PCS_R9_use = 14,
45 ABI_PCS_RW_data = 15,
46 ABI_PCS_RO_data = 16,
47 ABI_PCS_GOT_use = 17,
48 ABI_PCS_wchar_t = 18,
49 ABI_FP_rounding = 19,
50 ABI_FP_denormal = 20,
51 ABI_FP_exceptions = 21,
52 ABI_FP_user_exceptions = 22,
53 ABI_FP_number_model = 23,
54 ABI_align8_needed = 24,
55 ABI_align8_preserved = 25,
56 ABI_enum_size = 26,
57 ABI_HardFP_use = 27,
58 ABI_VFP_args = 28,
59 ABI_WMMX_args = 29,
60 ABI_optimization_goals = 30,
61 ABI_FP_optimization_goals = 31,
62 compatibility = 32,
63 CPU_unaligned_access = 34,
64 FP_HP_extension = 36,
65 ABI_FP_16bit_format = 38,
66 MPextension_use = 42, // was 70, 2.08 ABI
67 DIV_use = 44,
68 nodefaults = 64,
69 also_compatible_with = 65,
70 T2EE_use = 66,
71 conformance = 67,
72 Virtualization_use = 68,
73 MPextension_use_old = 70
74 };
75
76 StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix = true);
77 StringRef AttrTypeAsString(AttrType Attr, bool HasTagPrefix = true);
78 int AttrTypeFromString(StringRef Tag);
79
80 // Magic numbers for .ARM.attributes
81 enum AttrMagic {
82 Format_Version = 0x41
83 };
84
85 // Legal Values for CPU_arch, (=6), uleb128
86 enum CPUArch {
87 Pre_v4 = 0,
88 v4 = 1, // e.g. SA110
89 v4T = 2, // e.g. ARM7TDMI
90 v5T = 3, // e.g. ARM9TDMI
91 v5TE = 4, // e.g. ARM946E_S
92 v5TEJ = 5, // e.g. ARM926EJ_S
93 v6 = 6, // e.g. ARM1136J_S
94 v6KZ = 7, // e.g. ARM1176JZ_S
95 v6T2 = 8, // e.g. ARM1156T2F_S
96 v6K = 9, // e.g. ARM1136J_S
97 v7 = 10, // e.g. Cortex A8, Cortex M3
98 v6_M = 11, // e.g. Cortex M1
99 v6S_M = 12, // v6_M with the System extensions
100 v7E_M = 13, // v7_M with DSP extensions
101 v8 = 14 // v8, AArch32
102 };
103
104 enum CPUArchProfile { // (=7), uleb128
105 Not_Applicable = 0, // pre v7, or cross-profile code
106 ApplicationProfile = (0x41), // 'A' (e.g. for Cortex A8)
107 RealTimeProfile = (0x52), // 'R' (e.g. for Cortex R4)
108 MicroControllerProfile = (0x4D), // 'M' (e.g. for Cortex M3)
109 SystemProfile = (0x53) // 'S' Application or real-time profile
110 };
111
112 // The following have a lot of common use cases
113 enum {
114 Not_Allowed = 0,
115 Allowed = 1,
116
117 // Tag_ARM_ISA_use (=8), uleb128
118
119 // Tag_THUMB_ISA_use, (=9), uleb128
120 AllowThumb32 = 2, // 32-bit Thumb (implies 16-bit instructions)
121
122 // Tag_FP_arch (=10), uleb128 (formerly Tag_VFP_arch = 10)
123 AllowFPv2 = 2, // v2 FP ISA permitted (implies use of the v1 FP ISA)
124 AllowFPv3A = 3, // v3 FP ISA permitted (implies use of the v2 FP ISA)
125 AllowFPv3B = 4, // v3 FP ISA permitted, but only D0-D15, S0-S31
126 AllowFPv4A = 5, // v4 FP ISA permitted (implies use of v3 FP ISA)
127 AllowFPv4B = 6, // v4 FP ISA was permitted, but only D0-D15, S0-S31
128 AllowFPARMv8A = 7, // Use of the ARM v8-A FP ISA was permitted
129 AllowFPARMv8B = 8, // Use of the ARM v8-A FP ISA was permitted, but only D0-D15, S0-S31
130
131 // Tag_WMMX_arch, (=11), uleb128
132 AllowWMMXv1 = 1, // The user permitted this entity to use WMMX v1
133 AllowWMMXv2 = 2, // The user permitted this entity to use WMMX v2
134
135 // Tag_Advanced_SIMD_arch, (=12), uleb128
136 AllowNeon = 1, // SIMDv1 was permitted
137 AllowNeon2 = 2, // SIMDv2 was permitted (Half-precision FP, MAC operations)
138 AllowNeonARMv8 = 3, // ARM v8-A SIMD was permitted
139
140 // Tag_ABI_FP_denormal, (=20), uleb128
141 PreserveFPSign = 2, // sign when flushed-to-zero is preserved
142
143 // Tag_ABI_FP_number_model, (=23), uleb128
144 AllowRTABI = 2, // numbers, infinities, and one quiet NaN (see [RTABI])
145 AllowIEE754 = 3, // this code to use all the IEEE 754-defined FP encodings
146
147 // Tag_ABI_HardFP_use, (=27), uleb128
148 HardFPImplied = 0, // FP use should be implied by Tag_FP_arch
149 HardFPSinglePrecision = 1, // Single-precision only
150
151 // Tag_ABI_VFP_args, (=28), uleb128
152 BaseAAPCS = 0,
153 HardFPAAPCS = 1,
154
155 // Tag_FP_HP_extension, (=36), uleb128
156 AllowHPFP = 1, // Allow use of Half Precision FP
157
158 // Tag_MPextension_use, (=42), uleb128
159 AllowMP = 1, // Allow use of MP extensions
160
161 // Tag_DIV_use, (=44), uleb128
162 AllowDIVIfExists = 0, // Allow hardware divide if available in arch, or no info exists.
163 DisallowDIV = 1, // Hardware divide explicitly disallowed
164 AllowDIVExt = 2, // Allow hardware divide as optional architecture extension above
165 // the base arch specified by Tag_CPU_arch and Tag_CPU_arch_profile.
166
167 // Tag_Virtualization_use, (=68), uleb128
168 AllowTZ = 1,
169 AllowVirtualization = 2,
170 AllowTZVirtualization = 3
171 };
172
173 } // namespace ARMBuildAttrs
174 } // namespace llvm
175
176 #endif // __TARGET_ARMBUILDATTRS_H__
124124 virtual void switchVendor(StringRef Vendor);
125125 virtual void emitAttribute(unsigned Attribute, unsigned Value);
126126 virtual void emitTextAttribute(unsigned Attribute, StringRef String);
127 virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
128 StringRef StrinValue);
127129 virtual void emitArch(unsigned Arch);
128130 virtual void emitFPU(unsigned FPU);
129131 virtual void emitInst(uint32_t Inst, char Suffix = '\0');
181183 void ARMTargetAsmStreamer::emitTextAttribute(unsigned Attribute,
182184 StringRef String) {
183185 switch (Attribute) {
184 default: llvm_unreachable("Unsupported Text attribute in ASM Mode");
185186 case ARMBuildAttrs::CPU_name:
186 OS << "\t.cpu\t" << String.lower() << "\n";
187 break;
188 }
187 OS << "\t.cpu\t" << String.lower();
188 break;
189 default:
190 OS << "\t.eabi_attribute\t" << Attribute << ", \"" << String << "\"";
191 break;
192 }
193 OS << "\n";
194 }
195 void ARMTargetAsmStreamer::emitIntTextAttribute(unsigned Attribute,
196 unsigned IntValue,
197 StringRef StringValue) {
198 switch (Attribute) {
199 default: llvm_unreachable("unsupported multi-value attribute in asm mode");
200 case ARMBuildAttrs::compatibility:
201 OS << "\t.eabi_attribute\t" << Attribute << ", " << IntValue;
202 if (!StringValue.empty())
203 OS << ", \"" << StringValue << "\"";
204 break;
205 }
206 OS << "\n";
189207 }
190208 void ARMTargetAsmStreamer::emitArch(unsigned Arch) {
191209 OS << "\t.arch\t" << GetArchName(Arch) << "\n";
212230 enum {
213231 HiddenAttribute = 0,
214232 NumericAttribute,
215 TextAttribute
233 TextAttribute,
234 NumericAndTextAttributes
216235 } Type;
217236 unsigned Tag;
218237 unsigned IntValue;
288307 Contents.push_back(Item);
289308 }
290309
310 void setAttributeItems(unsigned Attribute, unsigned IntValue,
311 StringRef StringValue, bool OverwriteExisting) {
312 // Look for existing attribute item
313 if (AttributeItem *Item = getAttributeItem(Attribute)) {
314 if (!OverwriteExisting)
315 return;
316 Item->IntValue = IntValue;
317 Item->StringValue = StringValue;
318 return;
319 }
320
321 // Create new attribute item
322 AttributeItem Item = {
323 AttributeItem::NumericAndTextAttributes,
324 Attribute,
325 IntValue,
326 StringValue
327 };
328 Contents.push_back(Item);
329 }
330
291331 void emitArchDefaultAttributes();
292332 void emitFPUDefaultAttributes();
293333
306346 virtual void switchVendor(StringRef Vendor);
307347 virtual void emitAttribute(unsigned Attribute, unsigned Value);
308348 virtual void emitTextAttribute(unsigned Attribute, StringRef String);
349 virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
350 StringRef StringValue);
309351 virtual void emitArch(unsigned Arch);
310352 virtual void emitFPU(unsigned FPU);
311353 virtual void emitInst(uint32_t Inst, char Suffix = '\0');
587629 StringRef Value) {
588630 setAttributeItem(Attribute, Value, /* OverwriteExisting= */ true);
589631 }
632 void ARMTargetELFStreamer::emitIntTextAttribute(unsigned Attribute,
633 unsigned IntValue,
634 StringRef StringValue) {
635 setAttributeItems(Attribute, IntValue, StringValue,
636 /* OverwriteExisting= */ true);
637 }
590638 void ARMTargetELFStreamer::emitArch(unsigned Value) {
591639 Arch = Value;
592640 }
770818 Result += getULEBSize(item.Tag);
771819 Result += item.StringValue.size() + 1; // string + '\0'
772820 break;
821 case AttributeItem::NumericAndTextAttributes:
822 Result += getULEBSize(item.Tag);
823 Result += getULEBSize(item.IntValue);
824 Result += item.StringValue.size() + 1; // string + '\0';
825 break;
773826 }
774827 }
775828 return Result;
837890 Streamer.EmitULEB128IntValue(item.IntValue);
838891 break;
839892 case AttributeItem::TextAttribute:
893 Streamer.EmitBytes(item.StringValue.upper());
894 Streamer.EmitIntValue(0, 1); // '\0'
895 break;
896 case AttributeItem::NumericAndTextAttributes:
897 Streamer.EmitULEB128IntValue(item.IntValue);
840898 Streamer.EmitBytes(item.StringValue.upper());
841899 Streamer.EmitIntValue(0, 1); // '\0'
842900 break;
0 add_llvm_library(LLVMARMDesc
11 ARMAsmBackend.cpp
2 ARMBuildAttrs.cpp
23 ARMELFObjectWriter.cpp
34 ARMELFStreamer.cpp
45 ARMMCAsmInfo.cpp
33 // RUN: | llvm-readobj -s -sd | FileCheck %s
44
55 // Tag_CPU_name (=5)
6 .cpu Cortex-A8
6 .cpu cortex-a8
77
88 // Tag_CPU_arch (=6)
99 .eabi_attribute 6, 10
6060 .eabi_attribute 110, 160
6161
6262 // Check that tags > 128 are encoded properly
63 .eabi_attribute 129, 1
63 .eabi_attribute 129, "1"
6464 .eabi_attribute 250, 1
6565
6666 // CHECK: Section {
7070 // CHECK-NEXT: ]
7171 // CHECK-NEXT: Address: 0x0
7272 // CHECK-NEXT: Offset: 0x34
73 // CHECK-NEXT: Size: 70
73 // CHECK-NEXT: Size: 71
7474 // CHECK-NEXT: Link: 0
7575 // CHECK-NEXT: Info: 0
7676 // CHECK-NEXT: AddressAlignment: 1
7777 // CHECK-NEXT: EntrySize: 0
7878 // CHECK-NEXT: SectionData (
79 // CHECK-NEXT: 0000: 41450000 00616561 62690001 3B000000
79 // CHECK-NEXT: 0000: 41460000 00616561 62690001 3C000000
8080 // CHECK-NEXT: 0010: 05434F52 5445582D 41380006 0A074108
8181 // CHECK-NEXT: 0020: 0109020A 030C0214 01150117 01180119
8282 // CHECK-NEXT: 0030: 011B001C 0124012A 012C0244 036EA001
83 // CHECK-NEXT: 0040: 810101FA 0101
83 // CHECK-NEXT: 0040: 81013100 FA0101
8484 // CHECK-NEXT: )
0 @ RUN: llvm-mc -triple armv7-elf -filetype asm -o - %s | FileCheck %s
1
2 .syntax unified
3 .thumb
4
5 .eabi_attribute Tag_CPU_raw_name, "Cortex-A9"
6 @ CHECK: .eabi_attribute 4, "Cortex-A9"
7 .eabi_attribute Tag_CPU_name, "cortex-a9"
8 @ CHECK: .cpu cortex-a9
9 .eabi_attribute Tag_CPU_arch, 10
10 @ CHECK: .eabi_attribute 6, 10
11 .eabi_attribute Tag_CPU_arch_profile, 'A'
12 @ CHECK: .eabi_attribute 7, 65
13 .eabi_attribute Tag_ARM_ISA_use, 0
14 @ CHECK: .eabi_attribute 8, 0
15 .eabi_attribute Tag_THUMB_ISA_use, 2
16 @ CHECK: .eabi_attribute 9, 2
17 .eabi_attribute Tag_FP_arch, 3
18 @ CHECK: .eabi_attribute 10, 3
19 .eabi_attribute Tag_WMMX_arch, 0
20 @ CHECK: .eabi_attribute 11, 0
21 .eabi_attribute Tag_Advanced_SIMD_arch, 1
22 @ CHECK: .eabi_attribute 12, 1
23 .eabi_attribute Tag_PCS_config, 2
24 @ CHECK: .eabi_attribute 13, 2
25 .eabi_attribute Tag_ABI_PCS_R9_use, 0
26 @ CHECK: .eabi_attribute 14, 0
27 .eabi_attribute Tag_ABI_PCS_RW_data, 0
28 @ CHECK: .eabi_attribute 15, 0
29 .eabi_attribute Tag_ABI_PCS_RO_data, 0
30 @ CHECK: .eabi_attribute 16, 0
31 .eabi_attribute Tag_ABI_PCS_GOT_use, 0
32 @ CHECK: .eabi_attribute 17, 0
33 .eabi_attribute Tag_ABI_PCS_wchar_t, 4
34 @ CHECK: .eabi_attribute 18, 4
35 .eabi_attribute Tag_ABI_FP_rounding, 1
36 @ CHECK: .eabi_attribute 19, 1
37 .eabi_attribute Tag_ABI_FP_denormal, 2
38 @ CHECK: .eabi_attribute 20, 2
39 .eabi_attribute Tag_ABI_FP_exceptions, 1
40 @ CHECK: .eabi_attribute 21, 1
41 .eabi_attribute Tag_ABI_FP_user_exceptions, 1
42 @ CHECK: .eabi_attribute 22, 1
43 .eabi_attribute Tag_ABI_FP_number_model, 3
44 @ CHECK: .eabi_attribute 23, 3
45 .eabi_attribute Tag_ABI_align8_needed, 1
46 @ CHECK: .eabi_attribute 24, 1
47 .eabi_attribute Tag_ABI_align8_preserved, 2
48 @ CHECK: .eabi_attribute 25, 2
49 .eabi_attribute Tag_ABI_enum_size, 3
50 @ CHECK: .eabi_attribute 26, 3
51 .eabi_attribute Tag_ABI_HardFP_use, 0
52 @ CHECK: .eabi_attribute 27, 0
53 .eabi_attribute Tag_ABI_VFP_args, 1
54 @ CHECK: .eabi_attribute 28, 1
55 .eabi_attribute Tag_ABI_WMMX_args, 0
56 @ CHECK: .eabi_attribute 29, 0
57 .eabi_attribute Tag_ABI_FP_optimization_goals, 1
58 @ CHECK: .eabi_attribute 31, 1
59 .eabi_attribute Tag_compatibility, 1
60 @ CHECK: .eabi_attribute 32, 1
61 .eabi_attribute Tag_compatibility, 1, "aeabi"
62 @ CHECK: .eabi_attribute 32, 1, "aeabi"
63 .eabi_attribute Tag_CPU_unaligned_access, 0
64 @ CHECK: .eabi_attribute 34, 0
65 .eabi_attribute Tag_FP_HP_extension, 0
66 @ CHECK: .eabi_attribute 36, 0
67 .eabi_attribute Tag_ABI_FP_16bit_format, 0
68 @ CHECK: .eabi_attribute 38, 0
69 .eabi_attribute Tag_MPextension_use, 0
70 @ CHECK: .eabi_attribute 42, 0
71 .eabi_attribute Tag_DIV_use, 0
72 @ CHECK: .eabi_attribute 44, 0
73 .eabi_attribute Tag_nodefaults, 0
74 @ CHECK: .eabi_attribute 64, 0
75 .eabi_attribute Tag_also_compatible_with, "gnu"
76 @ CHECK: .eabi_attribute 65, "gnu"
77 .eabi_attribute Tag_T2EE_use, 0
78 @ CHECK: .eabi_attribute 66, 0
79 .eabi_attribute Tag_conformance, "2.09"
80 @ CHECK: .eabi_attribute 67, "2.09"
81 .eabi_attribute Tag_Virtualization_use, 0
82 @ CHECK: .eabi_attribute 68, 0
83
84 @ ===--- GNU AS Compatibility Checks ---===
85
86 .eabi_attribute 2 * 2 + 1, "cortex-a9"
87 @ CHECK: .cpu cortex-a9
88 .eabi_attribute 2 * 2 + 2, 5 * 2
89 @ CHECK: .eabi_attribute 6, 10
90
0 @ RUN: not llvm-mc -triple armv7-elf -filetype asm -o /dev/null %s 2>&1 \
1 @ RUN: | FileCheck %s
2
3 .syntax unified
4 .thumb
5
6 .eabi_attribute Tag_unknown_name, 0
7 @ CHECK: error: attribute name not recognised: Tag_unknown_name
8 @ CHECK: .eabi_attribute Tag_unknown_name
9 @ CHECK: ^
10
11 .eabi_attribute [non_constant_expression], 0
12 @ CHECK: error: expected numeric constant
13 @ CHECK: .eabi_attribute [non_constant_expression], 0
14 @ CHECK: ^
15
16 .eabi_attribute 42, "forty two"
17 @ CHECK: error: expected numeric constant
18 @ CHECK: .eabi_attribute 42, "forty two"
19 @ CHECK: ^
20
21 .eabi_attribute 43, 43
22 @ CHECK: error: bad string constant
23 @ CHECK: .eabi_attribute 43, 43
24 @ CHECK: ^
25
26 .eabi_attribute 0
27 @ CHECK: error: comma expected
28 @ CHECK: .eabi_attribute 0
29 @ CHECK: ^
30
31 .eabi_attribute Tag_MPextension_use_old, 0
32 @ CHECK: error: attribute name not recognised: Tag_MPextension_use_old
33 @ CHECK: .eabi_attribute Tag_MPextension_use_old, 0
34 @ CHECK: ^
35