clang  6.0.0svn
Lanai.cpp
Go to the documentation of this file.
1 //===--- Lanai.cpp - Implement Lanai target feature support ---------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements Lanai TargetInfo objects.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "Lanai.h"
16 #include "llvm/ADT/StringSwitch.h"
17 
18 using namespace clang;
19 using namespace clang::targets;
20 
21 const char *const LanaiTargetInfo::GCCRegNames[] = {
22  "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
23  "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", "r21",
24  "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31"
25 };
26 
28  return llvm::makeArrayRef(GCCRegNames);
29 }
30 
31 const TargetInfo::GCCRegAlias LanaiTargetInfo::GCCRegAliases[] = {
32  {{"pc"}, "r2"}, {{"sp"}, "r4"}, {{"fp"}, "r5"}, {{"rv"}, "r8"},
33  {{"rr1"}, "r10"}, {{"rr2"}, "r11"}, {{"rca"}, "r15"},
34 };
35 
37  return llvm::makeArrayRef(GCCRegAliases);
38 }
39 
40 bool LanaiTargetInfo::isValidCPUName(StringRef Name) const {
41  return llvm::StringSwitch<bool>(Name).Case("v11", true).Default(false);
42 }
43 
44 bool LanaiTargetInfo::setCPU(const std::string &Name) {
45  CPU = llvm::StringSwitch<CPUKind>(Name).Case("v11", CK_V11).Default(CK_NONE);
46 
47  return CPU != CK_NONE;
48 }
49 
50 bool LanaiTargetInfo::hasFeature(StringRef Feature) const {
51  return llvm::StringSwitch<bool>(Feature).Case("lanai", true).Default(false);
52 }
53 
55  MacroBuilder &Builder) const {
56  // Define __lanai__ when building for target lanai.
57  Builder.defineMacro("__lanai__");
58 
59  // Set define for the CPU specified.
60  switch (CPU) {
61  case CK_V11:
62  Builder.defineMacro("__LANAI_V11__");
63  break;
64  case CK_NONE:
65  llvm_unreachable("Unhandled target CPU");
66  }
67 }
Defines the clang::MacroBuilder utility class.
bool hasFeature(StringRef Feature) const override
Determine whether the given target has the given feature.
Definition: Lanai.cpp:50
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:48
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
Definition: Lanai.cpp:54
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: Lanai.cpp:36
bool isValidCPUName(StringRef Name) const override
brief Determine whether this TargetInfo supports the given CPU name.
Definition: Lanai.cpp:40
bool setCPU(const std::string &Name) override
Target the specified CPU.
Definition: Lanai.cpp:44
Dataflow Directional Tag Classes.
ArrayRef< const char * > getGCCRegNames() const override
Definition: Lanai.cpp:27
void defineMacro(const Twine &Name, const Twine &Value="1")
Append a #define line for macro of the form "\#define Name Value\n".
Definition: MacroBuilder.h:30