Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 7c0f2ab

Browse files
author
Sumanth Gundapaneni
committed
Use ".arch_extension" ARM directive to specify the additional CPU features
This patch is in response to r223147 where the avaiable features are computed based on ".cpu" directive. This will work clean for the standard variants like cortex-a9. For custom variants which rely on standard cpu names for assembly, the additional features of a CPU should be propagated. This can be done via ".arch_extension" as long as the assembler supports it. The implementation for krait along with unit test will be submitted in next patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230650 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent e382bb9 commit 7c0f2ab

File tree

5 files changed

+76
-0
lines changed

5 files changed

+76
-0
lines changed

include/llvm/MC/MCStreamer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ class ARMTargetStreamer : public MCTargetStreamer {
139139
StringRef StringValue = "");
140140
virtual void emitFPU(unsigned FPU);
141141
virtual void emitArch(unsigned Arch);
142+
virtual void emitArchExtension(unsigned ArchExt);
142143
virtual void emitObjectArch(unsigned Arch);
143144
virtual void finishAttributeSection();
144145
virtual void emitInst(uint32_t Inst, char Suffix = '\0');

lib/Target/ARM/ARMArchExtName.def

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//===-- ARMArchExtName.def - List of the ARM Extension names ----*- 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 the list of the supported ARM Architecture Extension
11+
// names. These can be used to enable the extension through .arch_extension
12+
// attribute
13+
//
14+
//===----------------------------------------------------------------------===//
15+
16+
// NOTE: NO INCLUDE GUARD DESIRED!
17+
18+
#ifndef ARM_ARCHEXT_NAME
19+
#error "You must define ARM_ARCHEXT_NAME(NAME, ID) before including ARMArchExtName.h"
20+
#endif
21+
22+
ARM_ARCHEXT_NAME("crc", CRC)
23+
ARM_ARCHEXT_NAME("crypto", CRYPTO)
24+
ARM_ARCHEXT_NAME("fp", FP)
25+
ARM_ARCHEXT_NAME("idiv", HWDIV)
26+
ARM_ARCHEXT_NAME("mp", MP)
27+
ARM_ARCHEXT_NAME("sec", SEC)
28+
ARM_ARCHEXT_NAME("virt", VIRT)
29+
30+
#undef ARM_ARCHEXT_NAME

lib/Target/ARM/ARMArchExtName.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===-- ARMArchExtName.h - List of the ARM Extension names ------*- 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+
#ifndef LLVM_LIB_TARGET_ARM_ARMARCHEXTNAME_H
11+
#define LLVM_LIB_TARGET_ARM_ARMARCHEXTNAME_H
12+
13+
namespace llvm {
14+
namespace ARM {
15+
16+
enum ArchExtKind {
17+
INVALID_ARCHEXT = 0
18+
19+
#define ARM_ARCHEXT_NAME(NAME, ID) , ID
20+
#include "ARMArchExtName.def"
21+
};
22+
23+
} // namespace ARM
24+
} // namespace llvm
25+
26+
#endif

lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "ARMArchName.h"
1717
#include "ARMFPUName.h"
18+
#include "ARMArchExtName.h"
1819
#include "ARMRegisterInfo.h"
1920
#include "ARMUnwindOpAsm.h"
2021
#include "llvm/ADT/StringExtras.h"
@@ -105,6 +106,19 @@ static unsigned GetArchDefaultCPUArch(unsigned ID) {
105106
return 0;
106107
}
107108

109+
static const char *GetArchExtName(unsigned ID) {
110+
switch (ID) {
111+
default:
112+
llvm_unreachable("Unknown ARCH Extension kind");
113+
break;
114+
#define ARM_ARCHEXT_NAME(NAME, ID) \
115+
case ARM::ID: \
116+
return NAME;
117+
#include "ARMArchExtName.def"
118+
}
119+
return nullptr;
120+
}
121+
108122
namespace {
109123

110124
class ARMELFStreamer;
@@ -134,6 +148,7 @@ class ARMTargetAsmStreamer : public ARMTargetStreamer {
134148
void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
135149
StringRef StrinValue) override;
136150
void emitArch(unsigned Arch) override;
151+
void emitArchExtension(unsigned ArchExt) override;
137152
void emitObjectArch(unsigned Arch) override;
138153
void emitFPU(unsigned FPU) override;
139154
void emitInst(uint32_t Inst, char Suffix = '\0') override;
@@ -249,6 +264,9 @@ void ARMTargetAsmStreamer::emitIntTextAttribute(unsigned Attribute,
249264
void ARMTargetAsmStreamer::emitArch(unsigned Arch) {
250265
OS << "\t.arch\t" << GetArchName(Arch) << "\n";
251266
}
267+
void ARMTargetAsmStreamer::emitArchExtension(unsigned ArchExt) {
268+
OS << "\t.arch_extension\t" << GetArchExtName(ArchExt) << "\n";
269+
}
252270
void ARMTargetAsmStreamer::emitObjectArch(unsigned Arch) {
253271
OS << "\t.object_arch\t" << GetArchName(Arch) << '\n';
254272
}

lib/Target/ARM/MCTargetDesc/ARMTargetStreamer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ void ARMTargetStreamer::emitIntTextAttribute(unsigned Attribute,
6363
unsigned IntValue,
6464
StringRef StringValue) {}
6565
void ARMTargetStreamer::emitArch(unsigned Arch) {}
66+
void ARMTargetStreamer::emitArchExtension(unsigned ArchExt) {}
6667
void ARMTargetStreamer::emitObjectArch(unsigned Arch) {}
6768
void ARMTargetStreamer::emitFPU(unsigned FPU) {}
6869
void ARMTargetStreamer::finishAttributeSection() {}

0 commit comments

Comments
 (0)