aboutsummaryrefslogtreecommitdiffstats
path: root/capstone/arch/RISCV/RISCVBaseInfo.h
blob: e6ae1fcb571dd21af1748424188d8375d45bf965 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//===-- RISCVBaseInfo.h - Top level definitions for RISCV MC ----*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains small standalone enum definitions for the RISCV target
// useful for the compiler back-end and the MC libraries.
//
//===----------------------------------------------------------------------===//
#ifndef CS_RISCVBASEINFO_H
#define CS_RISCVBASEINFO_H
#include "../../cs_priv.h"

//#include "RISCVMCTargetDesc.h"

// RISCVII - This namespace holds all of the target specific flags that
// instruction info tracks. All definitions must match RISCVInstrFormats.td.
enum {
	IRISCVII_InstFormatPseudo = 0,
  	IRISCVII_InstFormatR = 1,
  	IRISCVII_InstFormatR4 = 2,
  	IRISCVII_InstFormatI = 3,
  	IRISCVII_InstFormatS = 4,
  	IRISCVII_InstFormatB = 5,
  	IRISCVII_InstFormatU = 6,
  	IRISCVII_InstFormatJ = 7,
  	IRISCVII_InstFormatCR = 8,
  	IRISCVII_InstFormatCI = 9,
  	IRISCVII_InstFormatCSS = 10,
  	IRISCVII_InstFormatCIW = 11,
 	IRISCVII_InstFormatCL = 12,
  	IRISCVII_InstFormatCS = 13,
  	IRISCVII_InstFormatCA = 14,
  	IRISCVII_InstFormatCB = 15,
  	IRISCVII_InstFormatCJ = 16,
  	IRISCVII_InstFormatOther = 17,

  	IRISCVII_InstFormatMask = 31	
};

enum {
	RISCVII_MO_None,
	RISCVII_MO_LO,
	RISCVII_MO_HI,
	RISCVII_MO_PCREL_HI,
};

// Describes the predecessor/successor bits used in the FENCE instruction.
enum FenceField {
  	RISCVFenceField_I = 8,
  	RISCVFenceField_O = 4,
 	RISCVFenceField_R = 2,
  	RISCVFenceField_W = 1
};

// Describes the supported floating point rounding mode encodings.
enum RoundingMode {
  	RISCVFPRndMode_RNE = 0,
  	RISCVFPRndMode_RTZ = 1,
  	RISCVFPRndMode_RDN = 2,
  	RISCVFPRndMode_RUP = 3,
  	RISCVFPRndMode_RMM = 4,
  	RISCVFPRndMode_DYN = 7,
  	RISCVFPRndMode_Invalid
};

inline static const char *roundingModeToString(enum RoundingMode RndMode) 
{
  	switch (RndMode) {
  	default:
    		CS_ASSERT(0 && "Unknown floating point rounding mode");
  	case RISCVFPRndMode_RNE:
    		return "rne";
  	case RISCVFPRndMode_RTZ:
    		return "rtz";
  	case RISCVFPRndMode_RDN:
    		return "rdn";
  	case RISCVFPRndMode_RUP:
    		return "rup";
  	case RISCVFPRndMode_RMM:
    		return "rmm";
  	case RISCVFPRndMode_DYN:
    		return "dyn";
  	}
}

inline static bool RISCVFPRndMode_isValidRoundingMode(unsigned Mode) 
{
  	switch (Mode) {
  	default:
    		return false;
  	case RISCVFPRndMode_RNE:
  	case RISCVFPRndMode_RTZ:
  	case RISCVFPRndMode_RDN:
  	case RISCVFPRndMode_RUP:
  	case RISCVFPRndMode_RMM:
  	case RISCVFPRndMode_DYN:
    		return true;
  	}
}

#endif