clang  6.0.0svn
Nios2.cpp
Go to the documentation of this file.
1 //===--- Nios2.cpp - Implement Nios2 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 Nios2 TargetInfo objects.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "Nios2.h"
15 #include "Targets.h"
18 #include "llvm/ADT/StringSwitch.h"
19 
20 using namespace clang;
21 using namespace clang::targets;
22 
23 const Builtin::Info Nios2TargetInfo::BuiltinInfo[] = {
24 #define BUILTIN(ID, TYPE, ATTRS) \
25  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
26 #define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) \
27  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
28 #include "clang/Basic/BuiltinsNios2.def"
29 };
30 
32  StringRef CPU) const {
33  const bool isR2 = CPU == "nios2r2";
34  return llvm::StringSwitch<bool>(Feature)
35  .Case("nios2r2mandatory", isR2)
36  .Case("nios2r2bmx", isR2)
37  .Case("nios2r2mpx", isR2)
38  .Case("nios2r2cdx", isR2)
39  .Default(false);
40 }
41 
43  MacroBuilder &Builder) const {
44  DefineStd(Builder, "nios2", Opts);
45  DefineStd(Builder, "NIOS2", Opts);
46 
47  Builder.defineMacro("__nios2");
48  Builder.defineMacro("__NIOS2");
49  Builder.defineMacro("__nios2__");
50  Builder.defineMacro("__NIOS2__");
51 }
52 
54  return llvm::makeArrayRef(BuiltinInfo, clang::Nios2::LastTSBuiltin -
56 }
void DefineStd(MacroBuilder &Builder, StringRef MacroName, const LangOptions &Opts)
DefineStd - Define a macro name and standard variants.
Definition: Targets.cpp:53
Defines the clang::MacroBuilder utility class.
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: Nios2.cpp:42
bool isFeatureSupportedByCPU(StringRef Feature, StringRef CPU) const
Definition: Nios2.cpp:31
Enumerates target-specific builtins in their own namespaces within namespace clang.
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Definition: Nios2.cpp:53
Dataflow Directional Tag Classes.
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