TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
//===-- TargetParser - Parser for target features ---------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements a target parser to recognise hardware features such as
|
|
|
|
// FPU/CPU/ARCH names as well as specific support such as HDIV, etc.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Support/ARMBuildAttributes.h"
|
|
|
|
#include "llvm/Support/TargetParser.h"
|
|
|
|
#include "llvm/ADT/StringExtras.h"
|
|
|
|
#include "llvm/ADT/StringSwitch.h"
|
2015-11-19 00:32:12 +08:00
|
|
|
#include "llvm/ADT/Twine.h"
|
2015-05-23 04:43:30 +08:00
|
|
|
#include <cctype>
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
2015-08-30 13:27:31 +08:00
|
|
|
using namespace ARM;
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2015-06-05 21:29:24 +08:00
|
|
|
// List of canonical FPU names (use getFPUSynonym) and which architectural
|
|
|
|
// features they correspond to (use getFPUFeatures).
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
// FIXME: TableGen this.
|
2015-06-29 17:32:29 +08:00
|
|
|
// The entries must appear in the order listed in ARM::FPUKind for correct indexing
|
2015-11-16 20:08:05 +08:00
|
|
|
static const struct {
|
2015-08-30 15:51:04 +08:00
|
|
|
const char *NameCStr;
|
|
|
|
size_t NameLength;
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
ARM::FPUKind ID;
|
2015-06-29 17:32:29 +08:00
|
|
|
ARM::FPUVersion FPUVersion;
|
2015-06-05 21:29:24 +08:00
|
|
|
ARM::NeonSupportLevel NeonSupport;
|
|
|
|
ARM::FPURestriction Restriction;
|
2015-08-30 15:51:04 +08:00
|
|
|
|
|
|
|
StringRef getName() const { return StringRef(NameCStr, NameLength); }
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
} FPUNames[] = {
|
2015-08-30 13:27:31 +08:00
|
|
|
#define ARM_FPU(NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION) \
|
2015-08-30 15:51:04 +08:00
|
|
|
{ NAME, sizeof(NAME) - 1, KIND, VERSION, NEON_SUPPORT, RESTRICTION },
|
2015-08-30 13:27:31 +08:00
|
|
|
#include "llvm/Support/ARMTargetParser.def"
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
};
|
2015-06-05 21:29:24 +08:00
|
|
|
|
2015-05-28 02:15:37 +08:00
|
|
|
// List of canonical arch names (use getArchSynonym).
|
|
|
|
// This table also provides the build attribute fields for CPU arch
|
|
|
|
// and Arch ID, according to the Addenda to the ARM ABI, chapters
|
|
|
|
// 2.4 and 2.3.5.2 respectively.
|
2015-05-28 23:05:18 +08:00
|
|
|
// FIXME: SubArch values were simplified to fit into the expectations
|
|
|
|
// of the triples and are not conforming with their official names.
|
|
|
|
// Check to see if the expectation should be changed.
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
// FIXME: TableGen this.
|
2015-11-16 20:08:05 +08:00
|
|
|
static const struct {
|
2015-08-30 15:51:04 +08:00
|
|
|
const char *NameCStr;
|
|
|
|
size_t NameLength;
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
ARM::ArchKind ID;
|
2015-08-30 15:51:04 +08:00
|
|
|
const char *CPUAttrCStr;
|
|
|
|
size_t CPUAttrLength;
|
|
|
|
const char *SubArchCStr;
|
|
|
|
size_t SubArchLength;
|
2015-05-28 02:15:37 +08:00
|
|
|
ARMBuildAttrs::CPUArch ArchAttr; // Arch ID in build attributes.
|
2015-11-16 19:15:22 +08:00
|
|
|
unsigned DefaultFPU;
|
2015-09-06 01:05:33 +08:00
|
|
|
unsigned ArchBaseExtensions;
|
2015-08-30 15:51:04 +08:00
|
|
|
|
|
|
|
StringRef getName() const { return StringRef(NameCStr, NameLength); }
|
|
|
|
|
|
|
|
// CPU class in build attributes.
|
|
|
|
StringRef getCPUAttr() const { return StringRef(CPUAttrCStr, CPUAttrLength); }
|
|
|
|
|
|
|
|
// Sub-Arch name.
|
|
|
|
StringRef getSubArch() const { return StringRef(SubArchCStr, SubArchLength); }
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
} ARCHNames[] = {
|
2015-11-16 19:15:22 +08:00
|
|
|
#define ARM_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) \
|
2015-08-30 15:51:04 +08:00
|
|
|
{NAME, sizeof(NAME) - 1, ID, CPU_ATTR, sizeof(CPU_ATTR) - 1, SUB_ARCH, \
|
2015-11-16 19:15:22 +08:00
|
|
|
sizeof(SUB_ARCH) - 1, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT},
|
2015-08-30 13:27:31 +08:00
|
|
|
#include "llvm/Support/ARMTargetParser.def"
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
};
|
2015-08-30 15:51:04 +08:00
|
|
|
|
2015-05-28 16:59:03 +08:00
|
|
|
// List of Arch Extension names.
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
// FIXME: TableGen this.
|
2015-11-16 20:08:05 +08:00
|
|
|
static const struct {
|
2015-08-30 15:51:04 +08:00
|
|
|
const char *NameCStr;
|
|
|
|
size_t NameLength;
|
2015-07-28 06:26:59 +08:00
|
|
|
unsigned ID;
|
2015-11-19 00:32:12 +08:00
|
|
|
const char *Feature;
|
|
|
|
const char *NegFeature;
|
2015-08-30 15:51:04 +08:00
|
|
|
|
|
|
|
StringRef getName() const { return StringRef(NameCStr, NameLength); }
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
} ARCHExtNames[] = {
|
2015-11-19 00:32:12 +08:00
|
|
|
#define ARM_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE) \
|
|
|
|
{ NAME, sizeof(NAME) - 1, ID, FEATURE, NEGFEATURE },
|
2015-08-30 13:27:31 +08:00
|
|
|
#include "llvm/Support/ARMTargetParser.def"
|
2015-07-28 06:26:59 +08:00
|
|
|
};
|
2015-08-30 15:51:04 +08:00
|
|
|
|
2015-07-28 06:26:59 +08:00
|
|
|
// List of HWDiv names (use getHWDivSynonym) and which architectural
|
|
|
|
// features they correspond to (use getHWDivFeatures).
|
|
|
|
// FIXME: TableGen this.
|
2015-11-16 20:08:05 +08:00
|
|
|
static const struct {
|
2015-08-30 15:51:04 +08:00
|
|
|
const char *NameCStr;
|
|
|
|
size_t NameLength;
|
2015-07-28 06:26:59 +08:00
|
|
|
unsigned ID;
|
2015-08-30 15:51:04 +08:00
|
|
|
|
|
|
|
StringRef getName() const { return StringRef(NameCStr, NameLength); }
|
2015-07-28 06:26:59 +08:00
|
|
|
} HWDivNames[] = {
|
2015-08-30 15:51:04 +08:00
|
|
|
#define ARM_HW_DIV_NAME(NAME, ID) { NAME, sizeof(NAME) - 1, ID },
|
2015-08-30 13:27:31 +08:00
|
|
|
#include "llvm/Support/ARMTargetParser.def"
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
};
|
2015-08-30 15:51:04 +08:00
|
|
|
|
2015-05-20 23:05:07 +08:00
|
|
|
// List of CPU names and their arches.
|
|
|
|
// The same CPU can have multiple arches and can be default on multiple arches.
|
|
|
|
// When finding the Arch for a CPU, first-found prevails. Sort them accordingly.
|
2015-05-28 20:10:37 +08:00
|
|
|
// When this becomes table-generated, we'd probably need two tables.
|
2015-05-20 23:05:07 +08:00
|
|
|
// FIXME: TableGen this.
|
2015-11-16 20:08:05 +08:00
|
|
|
static const struct {
|
2015-08-30 15:51:04 +08:00
|
|
|
const char *NameCStr;
|
|
|
|
size_t NameLength;
|
2015-05-20 23:05:07 +08:00
|
|
|
ARM::ArchKind ArchID;
|
2015-07-15 18:46:21 +08:00
|
|
|
bool Default; // is $Name the default CPU for $ArchID ?
|
2015-09-06 01:05:33 +08:00
|
|
|
unsigned DefaultExtensions;
|
2015-08-30 15:51:04 +08:00
|
|
|
|
|
|
|
StringRef getName() const { return StringRef(NameCStr, NameLength); }
|
2015-05-20 23:05:07 +08:00
|
|
|
} CPUNames[] = {
|
2015-09-06 01:05:33 +08:00
|
|
|
#define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
|
|
|
|
{ NAME, sizeof(NAME) - 1, ID, IS_DEFAULT, DEFAULT_EXT },
|
2015-08-30 13:27:31 +08:00
|
|
|
#include "llvm/Support/ARMTargetParser.def"
|
2015-05-20 23:05:07 +08:00
|
|
|
};
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
// ======================================================= //
|
|
|
|
// Information by ID
|
|
|
|
// ======================================================= //
|
|
|
|
|
2015-08-30 15:51:04 +08:00
|
|
|
StringRef llvm::ARM::getFPUName(unsigned FPUKind) {
|
2015-05-20 23:05:07 +08:00
|
|
|
if (FPUKind >= ARM::FK_LAST)
|
2015-08-30 15:51:04 +08:00
|
|
|
return StringRef();
|
|
|
|
return FPUNames[FPUKind].getName();
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::getFPUVersion(unsigned FPUKind) {
|
2015-06-05 21:29:24 +08:00
|
|
|
if (FPUKind >= ARM::FK_LAST)
|
|
|
|
return 0;
|
|
|
|
return FPUNames[FPUKind].FPUVersion;
|
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::getFPUNeonSupportLevel(unsigned FPUKind) {
|
2015-06-05 21:29:24 +08:00
|
|
|
if (FPUKind >= ARM::FK_LAST)
|
|
|
|
return 0;
|
|
|
|
return FPUNames[FPUKind].NeonSupport;
|
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::getFPURestriction(unsigned FPUKind) {
|
2015-06-05 21:29:24 +08:00
|
|
|
if (FPUKind >= ARM::FK_LAST)
|
|
|
|
return 0;
|
|
|
|
return FPUNames[FPUKind].Restriction;
|
|
|
|
}
|
|
|
|
|
2015-11-16 19:15:22 +08:00
|
|
|
unsigned llvm::ARM::getDefaultFPU(StringRef CPU, unsigned ArchKind) {
|
|
|
|
if (CPU == "generic")
|
|
|
|
return ARCHNames[ArchKind].DefaultFPU;
|
|
|
|
|
2015-08-30 17:01:38 +08:00
|
|
|
return StringSwitch<unsigned>(CPU)
|
2015-09-06 01:05:33 +08:00
|
|
|
#define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
|
2015-08-30 17:01:38 +08:00
|
|
|
.Case(NAME, DEFAULT_FPU)
|
|
|
|
#include "llvm/Support/ARMTargetParser.def"
|
|
|
|
.Default(ARM::FK_INVALID);
|
2015-07-15 18:46:21 +08:00
|
|
|
}
|
|
|
|
|
2015-11-16 20:08:05 +08:00
|
|
|
unsigned llvm::ARM::getDefaultExtensions(StringRef CPU, unsigned ArchKind) {
|
|
|
|
if (CPU == "generic")
|
|
|
|
return ARCHNames[ArchKind].ArchBaseExtensions;
|
|
|
|
|
|
|
|
return StringSwitch<unsigned>(CPU)
|
|
|
|
#define ARM_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT) \
|
|
|
|
.Case(NAME, ARCHNames[ID].ArchBaseExtensions | DEFAULT_EXT)
|
|
|
|
#include "llvm/Support/ARMTargetParser.def"
|
|
|
|
.Default(ARM::AEK_INVALID);
|
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
bool llvm::ARM::getHWDivFeatures(unsigned HWDivKind,
|
2015-08-30 10:17:15 +08:00
|
|
|
std::vector<const char *> &Features) {
|
2015-07-28 06:26:59 +08:00
|
|
|
|
|
|
|
if (HWDivKind == ARM::AEK_INVALID)
|
|
|
|
return false;
|
|
|
|
|
2015-08-30 10:17:15 +08:00
|
|
|
if (HWDivKind & ARM::AEK_HWDIVARM)
|
2015-07-28 06:26:59 +08:00
|
|
|
Features.push_back("+hwdiv-arm");
|
|
|
|
else
|
|
|
|
Features.push_back("-hwdiv-arm");
|
|
|
|
|
|
|
|
if (HWDivKind & ARM::AEK_HWDIV)
|
|
|
|
Features.push_back("+hwdiv");
|
|
|
|
else
|
|
|
|
Features.push_back("-hwdiv");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-09-06 01:05:33 +08:00
|
|
|
bool llvm::ARM::getExtensionFeatures(unsigned Extensions,
|
|
|
|
std::vector<const char *> &Features) {
|
|
|
|
|
|
|
|
if (Extensions == ARM::AEK_INVALID)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (Extensions & ARM::AEK_CRC)
|
|
|
|
Features.push_back("+crc");
|
|
|
|
else
|
|
|
|
Features.push_back("-crc");
|
|
|
|
|
2015-09-25 01:31:16 +08:00
|
|
|
if (Extensions & ARM::AEK_DSP)
|
2015-10-24 01:19:19 +08:00
|
|
|
Features.push_back("+dsp");
|
2015-09-25 01:31:16 +08:00
|
|
|
else
|
2015-10-24 01:19:19 +08:00
|
|
|
Features.push_back("-dsp");
|
2015-09-25 01:31:16 +08:00
|
|
|
|
2015-09-06 01:05:33 +08:00
|
|
|
return getHWDivFeatures(Extensions, Features);
|
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
bool llvm::ARM::getFPUFeatures(unsigned FPUKind,
|
2015-08-30 10:17:15 +08:00
|
|
|
std::vector<const char *> &Features) {
|
2015-06-05 21:29:24 +08:00
|
|
|
|
|
|
|
if (FPUKind >= ARM::FK_LAST || FPUKind == ARM::FK_INVALID)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// fp-only-sp and d16 subtarget features are independent of each other, so we
|
|
|
|
// must enable/disable both.
|
|
|
|
switch (FPUNames[FPUKind].Restriction) {
|
|
|
|
case ARM::FR_SP_D16:
|
|
|
|
Features.push_back("+fp-only-sp");
|
|
|
|
Features.push_back("+d16");
|
|
|
|
break;
|
|
|
|
case ARM::FR_D16:
|
|
|
|
Features.push_back("-fp-only-sp");
|
|
|
|
Features.push_back("+d16");
|
|
|
|
break;
|
|
|
|
case ARM::FR_None:
|
|
|
|
Features.push_back("-fp-only-sp");
|
|
|
|
Features.push_back("-d16");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FPU version subtarget features are inclusive of lower-numbered ones, so
|
|
|
|
// enable the one corresponding to this version and disable all that are
|
2015-06-12 17:38:51 +08:00
|
|
|
// higher. We also have to make sure to disable fp16 when vfp4 is disabled,
|
|
|
|
// as +vfp4 implies +fp16 but -vfp4 does not imply -fp16.
|
2015-06-05 21:29:24 +08:00
|
|
|
switch (FPUNames[FPUKind].FPUVersion) {
|
2015-06-29 17:32:29 +08:00
|
|
|
case ARM::FV_VFPV5:
|
2015-06-05 21:29:24 +08:00
|
|
|
Features.push_back("+fp-armv8");
|
|
|
|
break;
|
2015-06-29 17:32:29 +08:00
|
|
|
case ARM::FV_VFPV4:
|
2015-06-05 21:29:24 +08:00
|
|
|
Features.push_back("+vfp4");
|
|
|
|
Features.push_back("-fp-armv8");
|
|
|
|
break;
|
2015-06-29 17:32:29 +08:00
|
|
|
case ARM::FV_VFPV3_FP16:
|
|
|
|
Features.push_back("+vfp3");
|
|
|
|
Features.push_back("+fp16");
|
|
|
|
Features.push_back("-vfp4");
|
|
|
|
Features.push_back("-fp-armv8");
|
|
|
|
break;
|
|
|
|
case ARM::FV_VFPV3:
|
2015-06-05 21:29:24 +08:00
|
|
|
Features.push_back("+vfp3");
|
2015-06-12 17:38:51 +08:00
|
|
|
Features.push_back("-fp16");
|
2015-06-05 21:29:24 +08:00
|
|
|
Features.push_back("-vfp4");
|
|
|
|
Features.push_back("-fp-armv8");
|
|
|
|
break;
|
2015-06-29 17:32:29 +08:00
|
|
|
case ARM::FV_VFPV2:
|
2015-06-05 21:29:24 +08:00
|
|
|
Features.push_back("+vfp2");
|
|
|
|
Features.push_back("-vfp3");
|
2015-06-12 17:38:51 +08:00
|
|
|
Features.push_back("-fp16");
|
2015-06-05 21:29:24 +08:00
|
|
|
Features.push_back("-vfp4");
|
|
|
|
Features.push_back("-fp-armv8");
|
|
|
|
break;
|
2015-06-29 17:32:29 +08:00
|
|
|
case ARM::FV_NONE:
|
2015-06-05 21:29:24 +08:00
|
|
|
Features.push_back("-vfp2");
|
|
|
|
Features.push_back("-vfp3");
|
2015-06-12 17:38:51 +08:00
|
|
|
Features.push_back("-fp16");
|
2015-06-05 21:29:24 +08:00
|
|
|
Features.push_back("-vfp4");
|
|
|
|
Features.push_back("-fp-armv8");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// crypto includes neon, so we handle this similarly to FPU version.
|
|
|
|
switch (FPUNames[FPUKind].NeonSupport) {
|
|
|
|
case ARM::NS_Crypto:
|
2015-09-06 01:05:33 +08:00
|
|
|
Features.push_back("+neon");
|
2015-06-05 21:29:24 +08:00
|
|
|
Features.push_back("+crypto");
|
|
|
|
break;
|
|
|
|
case ARM::NS_Neon:
|
|
|
|
Features.push_back("+neon");
|
|
|
|
Features.push_back("-crypto");
|
|
|
|
break;
|
|
|
|
case ARM::NS_None:
|
|
|
|
Features.push_back("-neon");
|
|
|
|
Features.push_back("-crypto");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-08-30 15:51:04 +08:00
|
|
|
StringRef llvm::ARM::getArchName(unsigned ArchKind) {
|
2015-05-20 23:05:07 +08:00
|
|
|
if (ArchKind >= ARM::AK_LAST)
|
2015-08-30 15:51:04 +08:00
|
|
|
return StringRef();
|
|
|
|
return ARCHNames[ArchKind].getName();
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
}
|
|
|
|
|
2015-08-30 15:51:04 +08:00
|
|
|
StringRef llvm::ARM::getCPUAttr(unsigned ArchKind) {
|
2015-05-20 23:05:07 +08:00
|
|
|
if (ArchKind >= ARM::AK_LAST)
|
2015-08-30 15:51:04 +08:00
|
|
|
return StringRef();
|
|
|
|
return ARCHNames[ArchKind].getCPUAttr();
|
2015-05-20 23:05:07 +08:00
|
|
|
}
|
|
|
|
|
2015-08-30 15:51:04 +08:00
|
|
|
StringRef llvm::ARM::getSubArch(unsigned ArchKind) {
|
2015-05-28 23:05:18 +08:00
|
|
|
if (ArchKind >= ARM::AK_LAST)
|
2015-08-30 15:51:04 +08:00
|
|
|
return StringRef();
|
|
|
|
return ARCHNames[ArchKind].getSubArch();
|
2015-05-28 23:05:18 +08:00
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::getArchAttr(unsigned ArchKind) {
|
2015-05-20 23:05:07 +08:00
|
|
|
if (ArchKind >= ARM::AK_LAST)
|
|
|
|
return ARMBuildAttrs::CPUArch::Pre_v4;
|
2015-05-28 02:15:37 +08:00
|
|
|
return ARCHNames[ArchKind].ArchAttr;
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
}
|
|
|
|
|
2015-08-30 15:51:04 +08:00
|
|
|
StringRef llvm::ARM::getArchExtName(unsigned ArchExtKind) {
|
2015-07-28 06:26:59 +08:00
|
|
|
for (const auto AE : ARCHExtNames) {
|
|
|
|
if (ArchExtKind == AE.ID)
|
2015-08-30 15:51:04 +08:00
|
|
|
return AE.getName();
|
2015-07-28 06:26:59 +08:00
|
|
|
}
|
2015-08-30 15:51:04 +08:00
|
|
|
return StringRef();
|
2015-07-28 06:26:59 +08:00
|
|
|
}
|
|
|
|
|
2015-11-19 00:32:12 +08:00
|
|
|
const char *llvm::ARM::getArchExtFeature(StringRef ArchExt) {
|
2015-11-19 23:42:52 +08:00
|
|
|
if (ArchExt.startswith("no")) {
|
2015-11-19 23:03:11 +08:00
|
|
|
StringRef ArchExtBase(ArchExt.substr(2));
|
|
|
|
for (const auto AE : ARCHExtNames) {
|
|
|
|
if (AE.NegFeature && ArchExtBase == AE.getName())
|
|
|
|
return AE.NegFeature;
|
|
|
|
}
|
|
|
|
}
|
2015-11-19 00:32:12 +08:00
|
|
|
for (const auto AE : ARCHExtNames) {
|
|
|
|
if (AE.Feature && ArchExt == AE.getName())
|
|
|
|
return AE.Feature;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2015-08-30 15:51:04 +08:00
|
|
|
StringRef llvm::ARM::getHWDivName(unsigned HWDivKind) {
|
2015-07-28 06:26:59 +08:00
|
|
|
for (const auto D : HWDivNames) {
|
|
|
|
if (HWDivKind == D.ID)
|
2015-08-30 15:51:04 +08:00
|
|
|
return D.getName();
|
2015-07-28 06:26:59 +08:00
|
|
|
}
|
2015-08-30 15:51:04 +08:00
|
|
|
return StringRef();
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
}
|
|
|
|
|
2015-08-30 15:51:04 +08:00
|
|
|
StringRef llvm::ARM::getDefaultCPU(StringRef Arch) {
|
2015-05-20 23:05:07 +08:00
|
|
|
unsigned AK = parseArch(Arch);
|
|
|
|
if (AK == ARM::AK_INVALID)
|
2015-08-30 15:51:04 +08:00
|
|
|
return StringRef();
|
2015-05-20 23:05:07 +08:00
|
|
|
|
|
|
|
// Look for multiple AKs to find the default for pair AK+Name.
|
|
|
|
for (const auto CPU : CPUNames) {
|
|
|
|
if (CPU.ArchID == AK && CPU.Default)
|
2015-08-30 15:51:04 +08:00
|
|
|
return CPU.getName();
|
2015-05-20 23:05:07 +08:00
|
|
|
}
|
2015-11-16 19:15:22 +08:00
|
|
|
|
|
|
|
// If we can't find a default then target the architecture instead
|
|
|
|
return "generic";
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// ======================================================= //
|
|
|
|
// Parsers
|
|
|
|
// ======================================================= //
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
static StringRef getHWDivSynonym(StringRef HWDiv) {
|
2015-07-28 06:26:59 +08:00
|
|
|
return StringSwitch<StringRef>(HWDiv)
|
2015-08-30 10:17:15 +08:00
|
|
|
.Case("thumb,arm", "arm,thumb")
|
|
|
|
.Default(HWDiv);
|
2015-07-28 06:26:59 +08:00
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
static StringRef getFPUSynonym(StringRef FPU) {
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
return StringSwitch<StringRef>(FPU)
|
2015-08-30 10:17:15 +08:00
|
|
|
.Cases("fpa", "fpe2", "fpe3", "maverick", "invalid") // Unsupported
|
|
|
|
.Case("vfp2", "vfpv2")
|
|
|
|
.Case("vfp3", "vfpv3")
|
|
|
|
.Case("vfp4", "vfpv4")
|
|
|
|
.Case("vfp3-d16", "vfpv3-d16")
|
|
|
|
.Case("vfp4-d16", "vfpv4-d16")
|
|
|
|
.Cases("fp4-sp-d16", "vfpv4-sp-d16", "fpv4-sp-d16")
|
|
|
|
.Cases("fp4-dp-d16", "fpv4-dp-d16", "vfpv4-d16")
|
|
|
|
.Case("fp5-sp-d16", "fpv5-sp-d16")
|
|
|
|
.Cases("fp5-dp-d16", "fpv5-dp-d16", "fpv5-d16")
|
|
|
|
// FIXME: Clang uses it, but it's bogus, since neon defaults to vfpv3.
|
|
|
|
.Case("neon-vfpv3", "neon")
|
|
|
|
.Default(FPU);
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
static StringRef getArchSynonym(StringRef Arch) {
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
return StringSwitch<StringRef>(Arch)
|
Cull non-standard variants of ARM architectures (NFC)
Summary:
This patch changes ARMV5, ARMV5E, ARMV6SM, ARMV6HL, ARMV7, ARMV7L,
ARMV7HL, ARMV7EM to be treated as aliases for the corresponding
standard architectures, instead of as actual architectures.
Reviewers: rengolin
Subscribers: aemerson, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D14577
llvm-svn: 252903
2015-11-12 23:51:41 +08:00
|
|
|
.Case("v5", "v5t")
|
|
|
|
.Case("v5e", "v5te")
|
Handle ARMv6-J as an alias, instead of fake architecture
Summary:
This follows D14577 to treat ARMv6-J as an alias for ARMv6,
instead of an architecture in its own right.
The functional change is that the default CPU when targeting ARMv6-J
changes from arm1136j-s to arm1136jf-s, which is currently used as
the default CPU for ARMv6; both are, in fact, ARMv6-J CPUs.
The J-bit (Jazelle support) is irrelevant to LLVM, and it doesn't
affect code generation, attributes, optimizations, or anything else,
apart from selecting the default CPU.
Reviewers: rengolin, logan, compnerd
Subscribers: aemerson, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D14755
llvm-svn: 253675
2015-11-21 00:46:09 +08:00
|
|
|
.Case("v6j", "v6")
|
Cull non-standard variants of ARM architectures (NFC)
Summary:
This patch changes ARMV5, ARMV5E, ARMV6SM, ARMV6HL, ARMV7, ARMV7L,
ARMV7HL, ARMV7EM to be treated as aliases for the corresponding
standard architectures, instead of as actual architectures.
Reviewers: rengolin
Subscribers: aemerson, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D14577
llvm-svn: 252903
2015-11-12 23:51:41 +08:00
|
|
|
.Case("v6hl", "v6k")
|
|
|
|
.Cases("v6m", "v6sm", "v6s-m", "v6-m")
|
2015-11-16 22:05:32 +08:00
|
|
|
.Cases("v6z", "v6zk", "v6kz")
|
Cull non-standard variants of ARM architectures (NFC)
Summary:
This patch changes ARMV5, ARMV5E, ARMV6SM, ARMV6HL, ARMV7, ARMV7L,
ARMV7HL, ARMV7EM to be treated as aliases for the corresponding
standard architectures, instead of as actual architectures.
Reviewers: rengolin
Subscribers: aemerson, llvm-commits, rengolin
Differential Revision: http://reviews.llvm.org/D14577
llvm-svn: 252903
2015-11-12 23:51:41 +08:00
|
|
|
.Cases("v7", "v7a", "v7hl", "v7l", "v7-a")
|
2015-08-30 10:17:15 +08:00
|
|
|
.Case("v7r", "v7-r")
|
|
|
|
.Case("v7m", "v7-m")
|
|
|
|
.Case("v7em", "v7e-m")
|
|
|
|
.Cases("v8", "v8a", "aarch64", "arm64", "v8-a")
|
|
|
|
.Case("v8.1a", "v8.1-a")
|
2015-12-01 18:33:56 +08:00
|
|
|
.Case("v8.2a", "v8.2-a")
|
2015-08-30 10:17:15 +08:00
|
|
|
.Default(Arch);
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
}
|
|
|
|
|
2015-05-20 23:05:07 +08:00
|
|
|
// MArch is expected to be of the form (arm|thumb)?(eb)?(v.+)?(eb)?, but
|
|
|
|
// (iwmmxt|xscale)(eb)? is also permitted. If the former, return
|
2015-05-23 04:43:30 +08:00
|
|
|
// "v.+", if the latter, return unmodified string, minus 'eb'.
|
|
|
|
// If invalid, return empty string.
|
2015-08-30 10:09:48 +08:00
|
|
|
StringRef llvm::ARM::getCanonicalArchName(StringRef Arch) {
|
2015-05-20 23:05:07 +08:00
|
|
|
size_t offset = StringRef::npos;
|
|
|
|
StringRef A = Arch;
|
2015-05-21 21:52:20 +08:00
|
|
|
StringRef Error = "";
|
2015-05-20 23:05:07 +08:00
|
|
|
|
|
|
|
// Begins with "arm" / "thumb", move past it.
|
2015-05-23 04:43:30 +08:00
|
|
|
if (A.startswith("arm64"))
|
|
|
|
offset = 5;
|
|
|
|
else if (A.startswith("arm"))
|
2015-05-20 23:05:07 +08:00
|
|
|
offset = 3;
|
|
|
|
else if (A.startswith("thumb"))
|
|
|
|
offset = 5;
|
2015-05-21 21:52:20 +08:00
|
|
|
else if (A.startswith("aarch64")) {
|
|
|
|
offset = 7;
|
|
|
|
// AArch64 uses "_be", not "eb" suffix.
|
|
|
|
if (A.find("eb") != StringRef::npos)
|
|
|
|
return Error;
|
2015-08-30 10:17:15 +08:00
|
|
|
if (A.substr(offset, 3) == "_be")
|
2015-05-21 21:52:20 +08:00
|
|
|
offset += 3;
|
|
|
|
}
|
|
|
|
|
2015-05-20 23:05:07 +08:00
|
|
|
// Ex. "armebv7", move past the "eb".
|
|
|
|
if (offset != StringRef::npos && A.substr(offset, 2) == "eb")
|
|
|
|
offset += 2;
|
|
|
|
// Or, if it ends with eb ("armv7eb"), chop it off.
|
|
|
|
else if (A.endswith("eb"))
|
|
|
|
A = A.substr(0, A.size() - 2);
|
2015-05-23 04:43:30 +08:00
|
|
|
// Trim the head
|
|
|
|
if (offset != StringRef::npos)
|
2015-05-20 23:05:07 +08:00
|
|
|
A = A.substr(offset);
|
|
|
|
|
2015-05-23 04:43:30 +08:00
|
|
|
// Empty string means offset reached the end, which means it's valid.
|
2015-05-20 23:05:07 +08:00
|
|
|
if (A.empty())
|
|
|
|
return Arch;
|
|
|
|
|
2015-05-23 04:43:30 +08:00
|
|
|
// Only match non-marketing names
|
|
|
|
if (offset != StringRef::npos) {
|
2015-08-30 10:17:15 +08:00
|
|
|
// Must start with 'vN'.
|
2015-05-23 04:43:30 +08:00
|
|
|
if (A[0] != 'v' || !std::isdigit(A[1]))
|
|
|
|
return Error;
|
|
|
|
// Can't have an extra 'eb'.
|
|
|
|
if (A.find("eb") != StringRef::npos)
|
|
|
|
return Error;
|
|
|
|
}
|
2015-05-20 23:05:07 +08:00
|
|
|
|
2015-05-23 04:43:30 +08:00
|
|
|
// Arch will either be a 'v' name (v7a) or a marketing name (xscale).
|
2015-05-20 23:05:07 +08:00
|
|
|
return A;
|
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::parseHWDiv(StringRef HWDiv) {
|
2015-07-28 06:26:59 +08:00
|
|
|
StringRef Syn = getHWDivSynonym(HWDiv);
|
|
|
|
for (const auto D : HWDivNames) {
|
2015-08-30 15:51:04 +08:00
|
|
|
if (Syn == D.getName())
|
2015-07-28 06:26:59 +08:00
|
|
|
return D.ID;
|
|
|
|
}
|
|
|
|
return ARM::AEK_INVALID;
|
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::parseFPU(StringRef FPU) {
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
StringRef Syn = getFPUSynonym(FPU);
|
|
|
|
for (const auto F : FPUNames) {
|
2015-08-30 15:51:04 +08:00
|
|
|
if (Syn == F.getName())
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
return F.ID;
|
|
|
|
}
|
2015-05-12 18:33:58 +08:00
|
|
|
return ARM::FK_INVALID;
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
}
|
|
|
|
|
2015-05-20 23:05:07 +08:00
|
|
|
// Allows partial match, ex. "v7a" matches "armv7a".
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::parseArch(StringRef Arch) {
|
2015-06-05 05:26:58 +08:00
|
|
|
Arch = getCanonicalArchName(Arch);
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
StringRef Syn = getArchSynonym(Arch);
|
|
|
|
for (const auto A : ARCHNames) {
|
2015-08-30 15:51:04 +08:00
|
|
|
if (A.getName().endswith(Syn))
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
return A.ID;
|
|
|
|
}
|
2015-05-12 18:33:58 +08:00
|
|
|
return ARM::AK_INVALID;
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::parseArchExt(StringRef ArchExt) {
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
for (const auto A : ARCHExtNames) {
|
2015-08-30 15:51:04 +08:00
|
|
|
if (ArchExt == A.getName())
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
return A.ID;
|
|
|
|
}
|
2015-05-12 18:33:58 +08:00
|
|
|
return ARM::AEK_INVALID;
|
TargetParser: FPU/ARCH/EXT parsing refactory - NFC
This new class in a global context contain arch-specific knowledge in order
to provide LLVM libraries, tools and projects with the ability to understand
the architectures. For now, only FPU, ARCH and ARCH extensions on ARM are
supported.
Current behaviour it to parse from free-text to enum values and back, so that
all users can share the same parser and codes. This simplifies a lot both the
ASM/Obj streamers in the back-end (where this came from), and the front-end
parsers for command line arguments (where this is going to be used next).
The previous implementation, using .def/.h includes is deprecated due to its
inflexibility to be built without the backend support and for being too
cumbersome. As more architectures join this scheme, and as more features of
such architectures are added (such as hardware features, type sizes, etc) into
a full blown TargetDescription class, having a set of classes is the most
sane implementation.
The ultimate goal of this refactor both LLVM's and Clang's target description
classes into one unique interface, so that we can de-duplicate and standardise
the descriptions, as well as make it available for other front-ends, tools,
etc.
The FPU parsing for command line options in Clang has been converted to use
this new library and a number of aliases were added for compatibility:
* A bogus neon-vfpv3 alias (neon defaults to vfp3)
* armv5/v6
* {fp4/fp5}-{sp/dp}-d16
Next steps:
* Port Clang's ARCH/EXT parsing to use this library.
* Create a TableGen back-end to generate this information.
* Run this TableGen process regardless of which back-ends are built.
* Expose more information and rename it to TargetDescription.
* Continue re-factoring Clang to use as much of it as possible.
llvm-svn: 236900
2015-05-09 05:04:27 +08:00
|
|
|
}
|
|
|
|
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::parseCPUArch(StringRef CPU) {
|
2015-05-20 23:05:07 +08:00
|
|
|
for (const auto C : CPUNames) {
|
2015-08-30 15:51:04 +08:00
|
|
|
if (CPU == C.getName())
|
2015-05-20 23:05:07 +08:00
|
|
|
return C.ArchID;
|
|
|
|
}
|
|
|
|
return ARM::AK_INVALID;
|
|
|
|
}
|
|
|
|
|
2015-05-21 21:52:20 +08:00
|
|
|
// ARM, Thumb, AArch64
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::parseArchISA(StringRef Arch) {
|
2015-05-21 21:52:20 +08:00
|
|
|
return StringSwitch<unsigned>(Arch)
|
|
|
|
.StartsWith("aarch64", ARM::IK_AARCH64)
|
2015-08-30 10:17:15 +08:00
|
|
|
.StartsWith("arm64", ARM::IK_AARCH64)
|
|
|
|
.StartsWith("thumb", ARM::IK_THUMB)
|
|
|
|
.StartsWith("arm", ARM::IK_ARM)
|
2015-05-21 21:52:20 +08:00
|
|
|
.Default(ARM::EK_INVALID);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Little/Big endian
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::parseArchEndian(StringRef Arch) {
|
2015-08-30 10:17:15 +08:00
|
|
|
if (Arch.startswith("armeb") || Arch.startswith("thumbeb") ||
|
2015-05-21 21:52:20 +08:00
|
|
|
Arch.startswith("aarch64_be"))
|
|
|
|
return ARM::EK_BIG;
|
|
|
|
|
|
|
|
if (Arch.startswith("arm") || Arch.startswith("thumb")) {
|
|
|
|
if (Arch.endswith("eb"))
|
|
|
|
return ARM::EK_BIG;
|
|
|
|
else
|
|
|
|
return ARM::EK_LITTLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Arch.startswith("aarch64"))
|
|
|
|
return ARM::EK_LITTLE;
|
|
|
|
|
|
|
|
return ARM::EK_INVALID;
|
|
|
|
}
|
|
|
|
|
2015-05-23 02:17:55 +08:00
|
|
|
// Profile A/R/M
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::parseArchProfile(StringRef Arch) {
|
2015-05-23 02:17:55 +08:00
|
|
|
Arch = getCanonicalArchName(Arch);
|
2015-08-30 10:17:15 +08:00
|
|
|
switch (parseArch(Arch)) {
|
2015-05-23 02:17:55 +08:00
|
|
|
case ARM::AK_ARMV6M:
|
|
|
|
case ARM::AK_ARMV7M:
|
|
|
|
case ARM::AK_ARMV7EM:
|
|
|
|
return ARM::PK_M;
|
|
|
|
case ARM::AK_ARMV7R:
|
|
|
|
return ARM::PK_R;
|
|
|
|
case ARM::AK_ARMV7A:
|
2015-10-29 06:36:05 +08:00
|
|
|
case ARM::AK_ARMV7K:
|
2015-05-23 02:17:55 +08:00
|
|
|
case ARM::AK_ARMV8A:
|
|
|
|
case ARM::AK_ARMV8_1A:
|
2015-12-01 18:33:56 +08:00
|
|
|
case ARM::AK_ARMV8_2A:
|
2015-05-23 02:17:55 +08:00
|
|
|
return ARM::PK_A;
|
|
|
|
}
|
|
|
|
return ARM::PK_INVALID;
|
|
|
|
}
|
|
|
|
|
2015-05-23 04:43:30 +08:00
|
|
|
// Version number (ex. v7 = 7).
|
2015-08-30 10:09:48 +08:00
|
|
|
unsigned llvm::ARM::parseArchVersion(StringRef Arch) {
|
2015-05-23 02:17:55 +08:00
|
|
|
Arch = getCanonicalArchName(Arch);
|
2015-08-30 10:17:15 +08:00
|
|
|
switch (parseArch(Arch)) {
|
2015-05-23 02:17:55 +08:00
|
|
|
case ARM::AK_ARMV2:
|
|
|
|
case ARM::AK_ARMV2A:
|
|
|
|
return 2;
|
|
|
|
case ARM::AK_ARMV3:
|
|
|
|
case ARM::AK_ARMV3M:
|
|
|
|
return 3;
|
|
|
|
case ARM::AK_ARMV4:
|
|
|
|
case ARM::AK_ARMV4T:
|
|
|
|
return 4;
|
|
|
|
case ARM::AK_ARMV5T:
|
|
|
|
case ARM::AK_ARMV5TE:
|
|
|
|
case ARM::AK_IWMMXT:
|
|
|
|
case ARM::AK_IWMMXT2:
|
|
|
|
case ARM::AK_XSCALE:
|
|
|
|
case ARM::AK_ARMV5TEJ:
|
|
|
|
return 5;
|
|
|
|
case ARM::AK_ARMV6:
|
|
|
|
case ARM::AK_ARMV6K:
|
|
|
|
case ARM::AK_ARMV6T2:
|
2015-11-16 22:05:32 +08:00
|
|
|
case ARM::AK_ARMV6KZ:
|
2015-05-23 02:17:55 +08:00
|
|
|
case ARM::AK_ARMV6M:
|
|
|
|
return 6;
|
|
|
|
case ARM::AK_ARMV7A:
|
|
|
|
case ARM::AK_ARMV7R:
|
|
|
|
case ARM::AK_ARMV7M:
|
|
|
|
case ARM::AK_ARMV7S:
|
|
|
|
case ARM::AK_ARMV7EM:
|
2015-08-22 05:52:48 +08:00
|
|
|
case ARM::AK_ARMV7K:
|
2015-05-23 02:17:55 +08:00
|
|
|
return 7;
|
|
|
|
case ARM::AK_ARMV8A:
|
|
|
|
case ARM::AK_ARMV8_1A:
|
2015-12-01 18:33:56 +08:00
|
|
|
case ARM::AK_ARMV8_2A:
|
2015-05-23 02:17:55 +08:00
|
|
|
return 8;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|