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