Skip to content

Commit 278a9f4

Browse files
committed
Move ARM build attributes into Support
This moves the ARM build attributes definitions and support routines into the Support library. The support routines simply permit the conversion of the value to and from a string representation. The movement is prompted in order to permit access to the constants and string representations from readobj in order to facilitate decoding of the attributes section. llvm-svn: 199575
1 parent 9dedf64 commit 278a9f4

File tree

8 files changed

+189
-184
lines changed

8 files changed

+189
-184
lines changed
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
//===-- ARMBuildAttributes.h - ARM Build Attributes -------------*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
//
10+
// This file contains enumerations and support routines for ARM build attributes
11+
// as defined in ARM ABI addenda document (ABI release 2.08).
12+
//
13+
// ELF for the ARM Architecture r2.09 - November 30, 2012
14+
//
15+
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0044e/IHI0044E_aaelf.pdf
16+
//
17+
//===----------------------------------------------------------------------===//
18+
19+
#ifndef LLVM_SUPPORT_ARM_BUILD_ATTRIBUTES_H
20+
#define LLVM_SUPPORT_ARM_BUILD_ATTRIBUTES_H
21+
22+
namespace llvm {
23+
class StringRef;
24+
25+
namespace ARMBuildAttrs {
26+
27+
enum SpecialAttr {
28+
// This is for the .cpu asm attr. It translates into one or more
29+
// AttrType (below) entries in the .ARM.attributes section in the ELF.
30+
SEL_CPU
31+
};
32+
33+
enum AttrType {
34+
// Rest correspond to ELF/.ARM.attributes
35+
File = 1,
36+
Section = 2,
37+
Symbol = 3,
38+
CPU_raw_name = 4,
39+
CPU_name = 5,
40+
CPU_arch = 6,
41+
CPU_arch_profile = 7,
42+
ARM_ISA_use = 8,
43+
THUMB_ISA_use = 9,
44+
FP_arch = 10,
45+
WMMX_arch = 11,
46+
Advanced_SIMD_arch = 12,
47+
PCS_config = 13,
48+
ABI_PCS_R9_use = 14,
49+
ABI_PCS_RW_data = 15,
50+
ABI_PCS_RO_data = 16,
51+
ABI_PCS_GOT_use = 17,
52+
ABI_PCS_wchar_t = 18,
53+
ABI_FP_rounding = 19,
54+
ABI_FP_denormal = 20,
55+
ABI_FP_exceptions = 21,
56+
ABI_FP_user_exceptions = 22,
57+
ABI_FP_number_model = 23,
58+
ABI_align8_needed = 24,
59+
ABI_align8_preserved = 25,
60+
ABI_enum_size = 26,
61+
ABI_HardFP_use = 27,
62+
ABI_VFP_args = 28,
63+
ABI_WMMX_args = 29,
64+
ABI_optimization_goals = 30,
65+
ABI_FP_optimization_goals = 31,
66+
compatibility = 32,
67+
CPU_unaligned_access = 34,
68+
FP_HP_extension = 36,
69+
ABI_FP_16bit_format = 38,
70+
MPextension_use = 42, // was 70, 2.08 ABI
71+
DIV_use = 44,
72+
nodefaults = 64,
73+
also_compatible_with = 65,
74+
T2EE_use = 66,
75+
conformance = 67,
76+
Virtualization_use = 68,
77+
MPextension_use_old = 70
78+
};
79+
80+
StringRef AttrTypeAsString(unsigned Attr, bool HasTagPrefix = true);
81+
StringRef AttrTypeAsString(AttrType Attr, bool HasTagPrefix = true);
82+
int AttrTypeFromString(StringRef Tag);
83+
84+
// Magic numbers for .ARM.attributes
85+
enum AttrMagic {
86+
Format_Version = 0x41
87+
};
88+
89+
// Legal Values for CPU_arch, (=6), uleb128
90+
enum CPUArch {
91+
Pre_v4 = 0,
92+
v4 = 1, // e.g. SA110
93+
v4T = 2, // e.g. ARM7TDMI
94+
v5T = 3, // e.g. ARM9TDMI
95+
v5TE = 4, // e.g. ARM946E_S
96+
v5TEJ = 5, // e.g. ARM926EJ_S
97+
v6 = 6, // e.g. ARM1136J_S
98+
v6KZ = 7, // e.g. ARM1176JZ_S
99+
v6T2 = 8, // e.g. ARM1156T2F_S
100+
v6K = 9, // e.g. ARM1136J_S
101+
v7 = 10, // e.g. Cortex A8, Cortex M3
102+
v6_M = 11, // e.g. Cortex M1
103+
v6S_M = 12, // v6_M with the System extensions
104+
v7E_M = 13, // v7_M with DSP extensions
105+
v8 = 14 // v8, AArch32
106+
};
107+
108+
enum CPUArchProfile { // (=7), uleb128
109+
Not_Applicable = 0, // pre v7, or cross-profile code
110+
ApplicationProfile = (0x41), // 'A' (e.g. for Cortex A8)
111+
RealTimeProfile = (0x52), // 'R' (e.g. for Cortex R4)
112+
MicroControllerProfile = (0x4D), // 'M' (e.g. for Cortex M3)
113+
SystemProfile = (0x53) // 'S' Application or real-time profile
114+
};
115+
116+
// The following have a lot of common use cases
117+
enum {
118+
Not_Allowed = 0,
119+
Allowed = 1,
120+
121+
// Tag_ARM_ISA_use (=8), uleb128
122+
123+
// Tag_THUMB_ISA_use, (=9), uleb128
124+
AllowThumb32 = 2, // 32-bit Thumb (implies 16-bit instructions)
125+
126+
// Tag_FP_arch (=10), uleb128 (formerly Tag_VFP_arch = 10)
127+
AllowFPv2 = 2, // v2 FP ISA permitted (implies use of the v1 FP ISA)
128+
AllowFPv3A = 3, // v3 FP ISA permitted (implies use of the v2 FP ISA)
129+
AllowFPv3B = 4, // v3 FP ISA permitted, but only D0-D15, S0-S31
130+
AllowFPv4A = 5, // v4 FP ISA permitted (implies use of v3 FP ISA)
131+
AllowFPv4B = 6, // v4 FP ISA was permitted, but only D0-D15, S0-S31
132+
AllowFPARMv8A = 7, // Use of the ARM v8-A FP ISA was permitted
133+
AllowFPARMv8B = 8, // Use of the ARM v8-A FP ISA was permitted, but only
134+
// D0-D15, S0-S31
135+
136+
// Tag_WMMX_arch, (=11), uleb128
137+
AllowWMMXv1 = 1, // The user permitted this entity to use WMMX v1
138+
AllowWMMXv2 = 2, // The user permitted this entity to use WMMX v2
139+
140+
// Tag_Advanced_SIMD_arch, (=12), uleb128
141+
AllowNeon = 1, // SIMDv1 was permitted
142+
AllowNeon2 = 2, // SIMDv2 was permitted (Half-precision FP, MAC operations)
143+
AllowNeonARMv8 = 3, // ARM v8-A SIMD was permitted
144+
145+
// Tag_ABI_FP_denormal, (=20), uleb128
146+
PreserveFPSign = 2, // sign when flushed-to-zero is preserved
147+
148+
// Tag_ABI_FP_number_model, (=23), uleb128
149+
AllowRTABI = 2, // numbers, infinities, and one quiet NaN (see [RTABI])
150+
AllowIEE754 = 3, // this code to use all the IEEE 754-defined FP encodings
151+
152+
// Tag_ABI_HardFP_use, (=27), uleb128
153+
HardFPImplied = 0, // FP use should be implied by Tag_FP_arch
154+
HardFPSinglePrecision = 1, // Single-precision only
155+
156+
// Tag_ABI_VFP_args, (=28), uleb128
157+
BaseAAPCS = 0,
158+
HardFPAAPCS = 1,
159+
160+
// Tag_FP_HP_extension, (=36), uleb128
161+
AllowHPFP = 1, // Allow use of Half Precision FP
162+
163+
// Tag_MPextension_use, (=42), uleb128
164+
AllowMP = 1, // Allow use of MP extensions
165+
166+
// Tag_DIV_use, (=44), uleb128
167+
AllowDIVIfExists = 0, // Allow hardware divide if available in arch, or no
168+
// info exists.
169+
DisallowDIV = 1, // Hardware divide explicitly disallowed
170+
AllowDIVExt = 2, // Allow hardware divide as optional architecture
171+
// extension above the base arch specified by
172+
// Tag_CPU_arch and Tag_CPU_arch_profile.
173+
174+
// Tag_Virtualization_use, (=68), uleb128
175+
AllowTZ = 1,
176+
AllowVirtualization = 2,
177+
AllowTZVirtualization = 3
178+
};
179+
180+
} // namespace ARMBuildAttrs
181+
} // namespace llvm
182+
183+
#endif // LLVM_SUPPORT_ARM_BUILD_ATTRIBUTES_H

llvm/lib/Target/ARM/MCTargetDesc/ARMBuildAttrs.cpp renamed to llvm/lib/Support/ARMBuildAttrs.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#include "ARMBuildAttrs.h"
10+
#include "llvm/Support/ARMBuildAttributes.h"
1111
#include "llvm/ADT/StringRef.h"
12-
#include "llvm/Support/Debug.h"
1312

1413
using namespace llvm;
1514

llvm/lib/Support/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ add_llvm_library(LLVMSupport
22
APFloat.cpp
33
APInt.cpp
44
APSInt.cpp
5+
ARMBuildAttrs.cpp
56
Allocator.cpp
67
BlockFrequency.cpp
78
BranchProbability.cpp

llvm/lib/Target/ARM/ARMAsmPrinter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include "ARMTargetObjectFile.h"
2323
#include "InstPrinter/ARMInstPrinter.h"
2424
#include "MCTargetDesc/ARMAddressingModes.h"
25-
#include "MCTargetDesc/ARMBuildAttrs.h"
2625
#include "MCTargetDesc/ARMMCExpr.h"
2726
#include "llvm/ADT/SetVector.h"
2827
#include "llvm/ADT/SmallString.h"
@@ -45,6 +44,7 @@
4544
#include "llvm/MC/MCSectionMachO.h"
4645
#include "llvm/MC/MCStreamer.h"
4746
#include "llvm/MC/MCSymbol.h"
47+
#include "llvm/Support/ARMBuildAttributes.h"
4848
#include "llvm/Support/CommandLine.h"
4949
#include "llvm/Support/Debug.h"
5050
#include "llvm/Support/ELF.h"
@@ -697,7 +697,7 @@ void ARMAsmPrinter::emitAttributes() {
697697
ATS.emitAttribute(ARMBuildAttrs::ABI_FP_number_model,
698698
ARMBuildAttrs::AllowIEE754);
699699

700-
// FIXME: add more flags to ARMBuildAttrs.h
700+
// FIXME: add more flags to ARMBuildAttributes.h
701701
// 8-bytes alignment stuff.
702702
ATS.emitAttribute(ARMBuildAttrs::ABI_align8_needed, 1);
703703
ATS.emitAttribute(ARMBuildAttrs::ABI_align8_preserved, 1);

llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "MCTargetDesc/ARMAddressingModes.h"
1313
#include "MCTargetDesc/ARMArchName.h"
1414
#include "MCTargetDesc/ARMBaseInfo.h"
15-
#include "MCTargetDesc/ARMBuildAttrs.h"
1615
#include "MCTargetDesc/ARMMCExpr.h"
1716
#include "llvm/ADT/BitVector.h"
1817
#include "llvm/ADT/MapVector.h"
@@ -40,6 +39,7 @@
4039
#include "llvm/MC/MCSubtargetInfo.h"
4140
#include "llvm/MC/MCSymbol.h"
4241
#include "llvm/MC/MCTargetAsmParser.h"
42+
#include "llvm/Support/ARMBuildAttributes.h"
4343
#include "llvm/Support/Debug.h"
4444
#include "llvm/Support/ELF.h"
4545
#include "llvm/Support/MathExtras.h"

0 commit comments

Comments
 (0)