LLVM  8.0.0svn
RISCVBaseInfo.h
Go to the documentation of this file.
1 //===-- RISCVBaseInfo.h - Top level definitions for RISCV MC ----*- 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 contains small standalone enum definitions for the RISCV target
11 // useful for the compiler back-end and the MC libraries.
12 //
13 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVBASEINFO_H
15 #define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVBASEINFO_H
16 
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/ADT/StringSwitch.h"
21 
22 namespace llvm {
23 
24 // RISCVII - This namespace holds all of the target specific flags that
25 // instruction info tracks. All definitions must match RISCVInstrFormats.td.
26 namespace RISCVII {
27 enum {
45 
47 };
48 
49 enum {
54 };
55 } // namespace RISCVII
56 
57 // Describes the predecessor/successor bits used in the FENCE instruction.
58 namespace RISCVFenceField {
59 enum FenceField {
60  I = 8,
61  O = 4,
62  R = 2,
63  W = 1
64 };
65 }
66 
67 // Describes the supported floating point rounding mode encodings.
68 namespace RISCVFPRndMode {
70  RNE = 0,
71  RTZ = 1,
72  RDN = 2,
73  RUP = 3,
74  RMM = 4,
75  DYN = 7,
76  Invalid
77 };
78 
80  switch (RndMode) {
81  default:
82  llvm_unreachable("Unknown floating point rounding mode");
84  return "rne";
86  return "rtz";
88  return "rdn";
90  return "rup";
92  return "rmm";
94  return "dyn";
95  }
96 }
97 
99  return StringSwitch<RoundingMode>(Str)
100  .Case("rne", RISCVFPRndMode::RNE)
101  .Case("rtz", RISCVFPRndMode::RTZ)
102  .Case("rdn", RISCVFPRndMode::RDN)
103  .Case("rup", RISCVFPRndMode::RUP)
104  .Case("rmm", RISCVFPRndMode::RMM)
105  .Case("dyn", RISCVFPRndMode::DYN)
107 }
108 
109 inline static bool isValidRoundingMode(unsigned Mode) {
110  switch (Mode) {
111  default:
112  return false;
113  case RISCVFPRndMode::RNE:
114  case RISCVFPRndMode::RTZ:
115  case RISCVFPRndMode::RDN:
116  case RISCVFPRndMode::RUP:
117  case RISCVFPRndMode::RMM:
118  case RISCVFPRndMode::DYN:
119  return true;
120  }
121 }
122 } // namespace RISCVFPRndMode
123 
124 namespace RISCVSysReg {
125 struct SysReg {
126  const char *Name;
127  unsigned Encoding;
128  // FIXME: add these additional fields when needed.
129  // Privilege Access: Read, Write, Read-Only.
130  // unsigned ReadWrite;
131  // Privilege Mode: User, System or Machine.
132  // unsigned Mode;
133  // Check field name.
134  // unsigned Extra;
135  // Register number without the privilege bits.
136  // unsigned Number;
139 
140  bool haveRequiredFeatures(FeatureBitset ActiveFeatures) const {
141  // Not in 32-bit mode.
142  if (isRV32Only && ActiveFeatures[RISCV::Feature64Bit])
143  return false;
144  // No required feature associated with the system register.
145  if (FeaturesRequired.none())
146  return true;
147  return (FeaturesRequired & ActiveFeatures) == FeaturesRequired;
148  }
149 };
150 
151 #define GET_SysRegsList_DECL
152 #include "RISCVGenSystemOperands.inc"
153 } // end namespace RISCVSysReg
154 
155 } // namespace llvm
156 
157 #endif
static bool isValidRoundingMode(unsigned Mode)
SI Whole Quad Mode
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
static RoundingMode stringToRoundingMode(StringRef Str)
Definition: RISCVBaseInfo.h:98
bool haveRequiredFeatures(FeatureBitset ActiveFeatures) const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE R Default(T Value)
Definition: StringSwitch.h:203
FeatureBitset FeaturesRequired
A switch()-like statement whose cases are string literals.
Definition: StringSwitch.h:43
Container class for subtarget features.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
LLVM_ATTRIBUTE_ALWAYS_INLINE StringSwitch & Case(StringLiteral S, T Value)
Definition: StringSwitch.h:70
#define I(x, y, z)
Definition: MD5.cpp:58
static StringRef roundingModeToString(RoundingMode RndMode)
Definition: RISCVBaseInfo.h:79
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49