clang  7.0.0svn
RISCV.h
Go to the documentation of this file.
1 //===--- RISCV.h - Declare RISCV target feature support ---------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares RISCV TargetInfo objects.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H
15 #define LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H
16 
17 #include "clang/Basic/TargetInfo.h"
19 #include "llvm/ADT/Triple.h"
20 #include "llvm/Support/Compiler.h"
21 
22 namespace clang {
23 namespace targets {
24 
25 // RISC-V Target
26 class RISCVTargetInfo : public TargetInfo {
27 protected:
28  std::string ABI;
29  bool HasM;
30  bool HasA;
31  bool HasF;
32  bool HasD;
33  bool HasC;
34 
35 public:
36  RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
37  : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
38  HasD(false), HasC(false) {
39  TLSSupported = false;
40  LongDoubleWidth = 128;
41  LongDoubleAlign = 128;
42  LongDoubleFormat = &llvm::APFloat::IEEEquad();
43  SuitableAlign = 128;
46  }
47 
48  StringRef getABI() const override { return ABI; }
49  void getTargetDefines(const LangOptions &Opts,
50  MacroBuilder &Builder) const override;
51 
52  ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
53 
56  }
57 
58  const char *getClobbers() const override { return ""; }
59 
60  ArrayRef<const char *> getGCCRegNames() const override;
61 
63 
64  bool validateAsmConstraint(const char *&Name,
65  TargetInfo::ConstraintInfo &Info) const override {
66  return false;
67  }
68 
69  bool hasFeature(StringRef Feature) const override;
70 
71  bool handleTargetFeatures(std::vector<std::string> &Features,
72  DiagnosticsEngine &Diags) override;
73 };
74 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
75 public:
76  RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
77  : RISCVTargetInfo(Triple, Opts) {
81  resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
82  }
83 
84  bool setABI(const std::string &Name) override {
85  // TODO: support ilp32f and ilp32d ABIs.
86  if (Name == "ilp32") {
87  ABI = Name;
88  return true;
89  }
90  return false;
91  }
92 };
93 class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public RISCVTargetInfo {
94 public:
95  RISCV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
96  : RISCVTargetInfo(Triple, Opts) {
99  resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
100  }
101 
102  bool setABI(const std::string &Name) override {
103  // TODO: support lp64f and lp64d ABIs.
104  if (Name == "lp64") {
105  ABI = Name;
106  return true;
107  }
108  return false;
109  }
110 };
111 } // namespace targets
112 } // namespace clang
113 
114 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H
IntType IntPtrType
Definition: TargetInfo.h:200
unsigned char LongDoubleAlign
Definition: TargetInfo.h:73
Options for controlling the target.
Definition: TargetOptions.h:26
RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
Definition: RISCV.h:36
unsigned char LongDoubleWidth
Definition: TargetInfo.h:73
RISCV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: RISCV.h:95
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:50
unsigned char PointerWidth
Definition: TargetInfo.h:67
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
bool handleTargetFeatures(std::vector< std::string > &Features, DiagnosticsEngine &Diags) override
Perform initialization based on the user configured set of features.
Definition: RISCV.cpp:88
unsigned char LongWidth
Definition: TargetInfo.h:75
bool setABI(const std::string &Name) override
Use the specified ABI.
Definition: RISCV.h:102
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: RISCV.h:54
RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: RISCV.h:76
StringRef getABI() const override
Get the ABI currently in use.
Definition: RISCV.h:48
typedef void* __builtin_va_list;
Definition: TargetInfo.h:165
Exposes information about the current target.
Definition: TargetInfo.h:54
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
Definition: RISCV.h:64
ArrayRef< const char * > getGCCRegNames() const override
Definition: RISCV.cpp:21
void resetDataLayout(StringRef DL)
Definition: TargetInfo.h:113
bool hasFeature(StringRef Feature) const override
Return true if has this feature, need to sync with handleTargetFeatures.
Definition: RISCV.cpp:73
IntType PtrDiffType
Definition: TargetInfo.h:200
#define false
Definition: stdbool.h:33
Defines the clang::TargetOptions class.
unsigned char PointerAlign
Definition: TargetInfo.h:67
ArrayRef< Builtin::Info > getTargetBuiltins() const override
Return information about target-specific builtins for the current primary target, and info about whic...
Definition: RISCV.h:52
unsigned char SuitableAlign
Definition: TargetInfo.h:83
Dataflow Directional Tag Classes.
unsigned char LongAlign
Definition: TargetInfo.h:75
bool setABI(const std::string &Name) override
Use the specified ABI.
Definition: RISCV.h:84
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:160
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: RISCV.h:58
Defines the clang::TargetInfo interface.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
Definition: RISCV.cpp:43
const llvm::fltSemantics * LongDoubleFormat
Definition: TargetInfo.h:93
IntType IntMaxType
Definition: TargetInfo.h:200
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: RISCV.cpp:30