clang  10.0.0git
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  LongDoubleWidth = 128;
39  LongDoubleAlign = 128;
40  LongDoubleFormat = &llvm::APFloat::IEEEquad();
41  SuitableAlign = 128;
44  }
45 
46  StringRef getABI() const override { return ABI; }
47  void getTargetDefines(const LangOptions &Opts,
48  MacroBuilder &Builder) const override;
49 
50  ArrayRef<Builtin::Info> getTargetBuiltins() const override { return None; }
51 
54  }
55 
56  const char *getClobbers() const override { return ""; }
57 
58  ArrayRef<const char *> getGCCRegNames() const override;
59 
60  int getEHDataRegisterNumber(unsigned RegNo) const override {
61  if (RegNo == 0)
62  return 10;
63  else if (RegNo == 1)
64  return 11;
65  else
66  return -1;
67  }
68 
70 
71  bool validateAsmConstraint(const char *&Name,
72  TargetInfo::ConstraintInfo &Info) const override;
73 
74  bool hasFeature(StringRef Feature) const override;
75 
76  bool handleTargetFeatures(std::vector<std::string> &Features,
77  DiagnosticsEngine &Diags) override;
78 };
79 class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo {
80 public:
81  RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
82  : RISCVTargetInfo(Triple, Opts) {
86  resetDataLayout("e-m:e-p:32:32-i64:64-n32-S128");
87  }
88 
89  bool setABI(const std::string &Name) override {
90  if (Name == "ilp32" || Name == "ilp32f" || Name == "ilp32d") {
91  ABI = Name;
92  return true;
93  }
94  return false;
95  }
96 
97  void setMaxAtomicWidth() override {
99 
100  if (HasA)
102  }
103 };
104 class LLVM_LIBRARY_VISIBILITY RISCV64TargetInfo : public RISCVTargetInfo {
105 public:
106  RISCV64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
107  : RISCVTargetInfo(Triple, Opts) {
110  resetDataLayout("e-m:e-p:64:64-i64:64-i128:128-n64-S128");
111  }
112 
113  bool setABI(const std::string &Name) override {
114  if (Name == "lp64" || Name == "lp64f" || Name == "lp64d") {
115  ABI = Name;
116  return true;
117  }
118  return false;
119  }
120 
121  void setMaxAtomicWidth() override {
122  MaxAtomicPromoteWidth = 128;
123 
124  if (HasA)
126  }
127 };
128 } // namespace targets
129 } // namespace clang
130 
131 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_RISCV_H
int getEHDataRegisterNumber(unsigned RegNo) const override
Return the register number that __builtin_eh_return_regno would return with the specified argument...
Definition: RISCV.h:60
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:106
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:53
unsigned char MaxAtomicPromoteWidth
Definition: TargetInfo.h:180
bool validateAsmConstraint(const char *&Name, TargetInfo::ConstraintInfo &Info) const override
Definition: RISCV.cpp:57
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:146
bool setABI(const std::string &Name) override
Use the specified ABI.
Definition: RISCV.h:113
BuiltinVaListKind getBuiltinVaListKind() const override
Returns the kind of __builtin_va_list type that should be used with this target.
Definition: RISCV.h:52
RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
Definition: RISCV.h:81
StringRef getABI() const override
Get the ABI currently in use.
Definition: RISCV.h:46
typedef void* __builtin_va_list;
Definition: TargetInfo.h:231
Exposes information about the current target.
Definition: TargetInfo.h:164
ArrayRef< const char * > getGCCRegNames() const override
Definition: RISCV.cpp:20
const llvm::fltSemantics * LongDoubleFormat
Definition: TargetInfo.h:103
bool hasFeature(StringRef Feature) const override
Return true if has this feature, need to sync with handleTargetFeatures.
Definition: RISCV.cpp:131
#define false
Definition: stdbool.h:17
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:50
void setMaxAtomicWidth() override
Set the maximum inline or promote width lock-free atomic operation for the given target.
Definition: RISCV.h:97
Dataflow Directional Tag Classes.
bool setABI(const std::string &Name) override
Use the specified ABI.
Definition: RISCV.h:89
BuiltinVaListKind
The different kinds of __builtin_va_list types defined by the target implementation.
Definition: TargetInfo.h:226
const char * getClobbers() const override
Returns a string of target-specific clobbers, in LLVM format.
Definition: RISCV.h:56
Defines the clang::TargetInfo interface.
void getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const override
===-— Other target property query methods --------------------——===//
Definition: RISCV.cpp:85
unsigned char MaxAtomicInlineWidth
Definition: TargetInfo.h:180
ArrayRef< TargetInfo::GCCRegAlias > getGCCRegAliases() const override
Definition: RISCV.cpp:36
void resetDataLayout(StringRef DL)
Definition: TargetInfo.cpp:140
void setMaxAtomicWidth() override
Set the maximum inline or promote width lock-free atomic operation for the given target.
Definition: RISCV.h:121