1 //===-- RISCVBaseInfo.h - Top level definitions for RISCV MC ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains small standalone enum definitions for the RISCV target
11 // useful for the compiler back-end and the MC libraries.
13 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVBASEINFO_H
15 #define LLVM_LIB_TARGET_RISCV_MCTARGETDESC_RISCVBASEINFO_H
17 #include "RISCVMCTargetDesc.h"
18 #include "llvm/ADT/StringRef.h"
19 #include "llvm/ADT/StringSwitch.h"
23 // RISCVII - This namespace holds all of the target specific flags that
24 // instruction info tracks. All definitions must match RISCVInstrFormats.td.
54 } // namespace RISCVII
56 // Describes the predecessor/successor bits used in the FENCE instruction.
57 namespace RISCVFenceField {
66 // Describes the supported floating point rounding mode encodings.
67 namespace RISCVFPRndMode {
78 inline static StringRef roundingModeToString(RoundingMode RndMode) {
81 llvm_unreachable("Unknown floating point rounding mode");
82 case RISCVFPRndMode::RNE:
84 case RISCVFPRndMode::RTZ:
86 case RISCVFPRndMode::RDN:
88 case RISCVFPRndMode::RUP:
90 case RISCVFPRndMode::RMM:
92 case RISCVFPRndMode::DYN:
97 inline static RoundingMode stringToRoundingMode(StringRef Str) {
98 return StringSwitch<RoundingMode>(Str)
99 .Case("rne", RISCVFPRndMode::RNE)
100 .Case("rtz", RISCVFPRndMode::RTZ)
101 .Case("rdn", RISCVFPRndMode::RDN)
102 .Case("rup", RISCVFPRndMode::RUP)
103 .Case("rmm", RISCVFPRndMode::RMM)
104 .Case("dyn", RISCVFPRndMode::DYN)
105 .Default(RISCVFPRndMode::Invalid);
107 } // namespace RISCVFPRndMode