Files
llvm-6502/include/llvm/Support/TargetParser.h
Renato Golin a54f2b87f7 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236900 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-08 21:04:27 +00:00

114 lines
2.5 KiB
C++

//===-- 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.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_TARGETPARSER_H
#define LLVM_SUPPORT_TARGETPARSER_H
namespace llvm {
class StringRef;
// Target specific information into their own namespaces. These should be
// generated from TableGen because the information is already there, and there
// is where new information about targets will be added.
// FIXME: To TableGen this we need to make some table generated files available
// even if the back-end is not compiled with LLVM, plus we need to create a new
// back-end to TableGen to create these clean tables.
namespace ARM {
// FPU names.
enum FPUKind {
INVALID_FPU = 0,
VFP,
VFPV2,
VFPV3,
VFPV3_D16,
VFPV4,
VFPV4_D16,
FPV5_D16,
FP_ARMV8,
NEON,
NEON_VFPV4,
NEON_FP_ARMV8,
CRYPTO_NEON_FP_ARMV8,
SOFTVFP,
LAST_FPU
};
// Arch names.
enum ArchKind {
INVALID_ARCH = 0,
ARMV2,
ARMV2A,
ARMV3,
ARMV3M,
ARMV4,
ARMV4T,
ARMV5,
ARMV5T,
ARMV5TE,
ARMV6,
ARMV6J,
ARMV6K,
ARMV6T2,
ARMV6Z,
ARMV6ZK,
ARMV6M,
ARMV7,
ARMV7A,
ARMV7R,
ARMV7M,
ARMV8A,
ARMV8_1A,
IWMMXT,
IWMMXT2,
LAST_ARCH
};
// Arch extension modifiers for CPUs.
enum ArchExtKind {
INVALID_ARCHEXT = 0,
CRC,
CRYPTO,
FP,
HWDIV,
MP,
SEC,
VIRT,
LAST_ARCHEXT
};
} // namespace ARM
// Target Parsers, one per architecture.
class ARMTargetParser {
static StringRef getFPUSynonym(StringRef FPU);
static StringRef getArchSynonym(StringRef Arch);
public:
// Information by ID
static const char * getFPUName(unsigned ID);
static const char * getArchName(unsigned ID);
static unsigned getArchDefaultCPUArch(unsigned ID);
static const char * getArchDefaultCPUName(unsigned ID);
static const char * getArchExtName(unsigned ID);
// Parser
static unsigned parseFPU(StringRef FPU);
static unsigned parseArch(StringRef Arch);
static unsigned parseArchExt(StringRef ArchExt);
};
} // namespace llvm
#endif