5#ifndef V8_CODEGEN_RISCV_BASE_CONSTANTS_RISCV_H_
6#define V8_CODEGEN_RISCV_BASE_CONSTANTS_RISCV_H_
14#define UNIMPLEMENTED_RISCV() \
15 v8::internal::PrintF("%s, \tline %d: \tfunction %s not implemented. \n", \
16 __FILE__, __LINE__, __func__);
18#define UNIMPLEMENTED_RISCV()
21#define UNSUPPORTED_RISCV() \
22 v8::internal::PrintF("Unsupported instruction %d.\n", __LINE__); \
27#if defined(V8_TARGET_LITTLE_ENDIAN)
29#elif defined(V8_TARGET_BIG_ENDIAN)
32#error Unknown endianness
35#if defined(V8_TARGET_LITTLE_ENDIAN)
36const uint32_t kLeastSignificantByteInInt32Offset = 0;
37const uint32_t kLessSignificantWordInDoublewordOffset = 0;
38#elif defined(V8_TARGET_BIG_ENDIAN)
39const uint32_t kLeastSignificantByteInInt32Offset = 3;
40const uint32_t kLessSignificantWordInDoublewordOffset = 4;
42#error Unknown endianness
45#ifndef __STDC_FORMAT_MACROS
46#define __STDC_FORMAT_MACROS
75#define DEFINE_FLAG(name) name,
87#define DEFINE_FLAG(name) name,
179 static const char*
Name(
int reg);
182 static int Number(
const char* name);
198using Instr = int32_t;
331const uint32_t
kRvcBImm8Mask = (((1 << 5) - 1) << 2) | (((1 << 3) - 1) << 10);
340 "RVV extension only supports 128bit wide VLEN at current RISC-V backend.");
725 uint16_t FirstHalfWord = *
reinterpret_cast<const uint16_t*
>(
this);
726 return FirstHalfWord == 0;
732 return (
v8_flags.riscv_c_extension && this->IsShortInstruction())
739 if (
v8_flags.riscv_c_extension && this->IsShortInstruction()) {
740 return 0x0000FFFF & (*
reinterpret_cast<const ShortInstr*
>(
this));
742 return *
reinterpret_cast<const Instr*
>(
this);
747 *
reinterpret_cast<Instr*
>(
this) = value;
823 DCHECK(this->IsShortInstruction());
947 return Value << 20 >> 20;
959 uint32_t Bits = this->InstructionBits();
960 int16_t imm13 = ((Bits & 0xf00) >> 7) | ((Bits & 0x7e000000) >> 20) |
961 ((Bits & 0x80) << 4) | ((Bits & 0x80000000) >> 19);
962 return imm13 << 19 >> 19;
969 uint32_t Bits = this->InstructionBits();
970 int16_t imm12 = ((Bits & 0xf80) >> 7) | ((Bits & 0xfe000000) >> 20);
971 return imm12 << 20 >> 20;
978 int32_t Bits = this->InstructionBits();
986 uint32_t Bits = this->InstructionBits();
987 int32_t imm20 = ((Bits & 0x7fe00000) >> 20) | ((Bits & 0x100000) >> 9) |
988 (Bits & 0xff000) | ((Bits & 0x80000000) >> 11);
989 return imm20 << 11 >> 11;
997 return this->InstructionBits() & 0x40000000;
1012#ifdef V8_TARGET_ARCH_RISCV32
1026 DCHECK(this->IsShortInstruction());
1029 uint32_t Bits = this->InstructionBits();
1030 int32_t imm6 = ((Bits & 0x1000) >> 7) | ((Bits & 0x7c) >> 2);
1031 return imm6 << 26 >> 26;
1035 DCHECK(this->IsShortInstruction());
1038 uint32_t Bits = this->InstructionBits();
1039 int32_t imm10 = ((Bits & 0x1000) >> 3) | ((Bits & 0x40) >> 2) |
1040 ((Bits & 0x20) << 1) | ((Bits & 0x18) << 4) |
1041 ((Bits & 0x4) << 3);
1043 return imm10 << 22 >> 22;
1047 DCHECK(this->IsShortInstruction());
1050 uint32_t Bits = this->InstructionBits();
1051 int32_t uimm10 = ((Bits & 0x20) >> 2) | ((Bits & 0x40) >> 4) |
1052 ((Bits & 0x780) >> 1) | ((Bits & 0x1800) >> 7);
1058 DCHECK(this->IsShortInstruction());
1066 DCHECK(this->IsShortInstruction());
1069 uint32_t Bits = this->InstructionBits();
1071 ((Bits & 0x1000) >> 7) | ((Bits & 0x70) >> 2) | ((Bits & 0xc) << 4);
1076 DCHECK(this->IsShortInstruction());
1079 uint32_t Bits = this->InstructionBits();
1081 ((Bits & 0x1000) >> 7) | ((Bits & 0x60) >> 2) | ((Bits & 0x1c) << 4);
1086 DCHECK(this->IsShortInstruction());
1089 uint32_t Bits = this->InstructionBits();
1090 int32_t imm8 = ((Bits & 0x1e00) >> 7) | ((Bits & 0x180) >> 1);
1095 DCHECK(this->IsShortInstruction());
1098 uint32_t Bits = this->InstructionBits();
1099 int32_t imm9 = ((Bits & 0x1c00) >> 7) | ((Bits & 0x380) >> 1);
1104 DCHECK(this->IsShortInstruction());
1107 uint32_t Bits = this->InstructionBits();
1109 ((Bits & 0x1c00) >> 7) | ((Bits & 0x40) >> 4) | ((Bits & 0x20) << 1);
1114 DCHECK(this->IsShortInstruction());
1117 uint32_t Bits = this->InstructionBits();
1118 int32_t imm8 = ((Bits & 0x1c00) >> 7) | ((Bits & 0x60) << 1);
1123 DCHECK(this->IsShortInstruction());
1126 uint32_t Bits = this->InstructionBits();
1127 int32_t imm12 = ((Bits & 0x4) << 3) | ((Bits & 0x38) >> 2) |
1128 ((Bits & 0x40) << 1) | ((Bits & 0x80) >> 1) |
1129 ((Bits & 0x100) << 2) | ((Bits & 0x600) >> 1) |
1130 ((Bits & 0x800) >> 7) | ((Bits & 0x1000) >> 1);
1131 return imm12 << 20 >> 20;
1135 DCHECK(this->IsShortInstruction());
1138 uint32_t Bits = this->InstructionBits();
1139 int32_t imm9 = ((Bits & 0x4) << 3) | ((Bits & 0x18) >> 2) |
1140 ((Bits & 0x60) << 1) | ((Bits & 0xc00) >> 7) |
1141 ((Bits & 0x1000) >> 4);
1142 return imm9 << 23 >> 23;
1187 uint32_t zimm = this->
Rvvzimm();
1188 uint32_t vsew = (zimm >> 3) & 0x7;
1193 uint32_t zimm = this->
Rvvzimm();
1194 uint32_t vlmul = zimm & 0x7;
1206 uint32_t vsew = this->
RvvVsew();
1208#define CAST_VSEW(name) \
1221#define CAST_VLMUL(name) \
1231#define sext(x, len) (((int32_t)(x) << (32 - len)) >> (32 - len))
1232#define zext(x, len) (((uint32_t)(x) << (32 - len)) >> (32 - len))
1259class Instruction :
public InstructionGetters<InstructionBase> {
#define DEFINE_FLAG(name)
static const char * Name(int reg)
static int Number(const char *name)
static const RegisterAlias aliases_[]
static const char * names_[kNumFPURegisters]
int Funct6FieldRaw() const
int Funct7FieldRaw() const
BaseOpcode BaseOpcodeFieldRaw() const
Type InstructionType() const
bool IsIllegalInstruction() const
bool IsShortInstruction() const
int Bits(int hi, int lo) const
int32_t ITypeBits() const
int Funct3FieldRaw() const
uint8_t InstructionSize() const
int Rs3FieldRawNoAssert() const
Instr InstructionBits() const
int Rs1FieldRawNoAssert() const
int Rs2FieldRawNoAssert() const
void SetInstructionBits(Instr value)
int32_t InstructionOpcodeType() const
BaseOpcode BaseOpcodeValue() const
int RvcFunct2Value() const
int RvcImm8BValue() const
int RvcImm6Addi16spValue() const
bool IsArithShift() const
uint32_t OperandFunct3() const
int RvcImm6LdspValue() const
uint32_t RvvVlmul() const
int RvcImm11CJValue() const
int RvcImm5WValue() const
const char * RvvLMUL() const
int32_t Imm12Value() const
int RvcImm5DValue() const
int RvcImm6SdspValue() const
const char * RvvSEW() const
int RvcImm8Addi4spnValue() const
int RvcFunct2BValue() const
int32_t Imm12SExtValue() const
int MemoryOrder(bool is_pred) const
int RvcImm6SwspValue() const
int RvcFunct6Value() const
int RvcFunct3Value() const
uint32_t RvvUimm5() const
int RvcImm6LwspValue() const
int RvcFunct4Value() const
static Instruction * At(uint8_t *pc)
DISALLOW_IMPLICIT_CONSTRUCTORS(Instruction)
static const char * Name(int reg)
static int Number(const char *name)
static const RegisterAlias aliases_[]
static const char * names_[kNumRegisters]
static const char * Name(int reg)
static const char * names_[kNumVRegisters]
static const RegisterAlias aliases_[]
const uint32_t kCSTypeMask
const uint32_t kBImm12Mask
Hint NegateHint(Hint ignored)
const uint32_t kRvvMewMask
const uint32_t kRvcFunct2BMask
const uint32_t kRATypeMask
const int32_t kPrefHintLoadStreamed
const int kRvcFunct3Shift
const uint32_t kRvvNfMask
const uint32_t kITypeMask
constexpr int kPCRegister
const uint32_t kRvcFunct4Mask
const unsigned kDebuggerTracingDirectivesMask
const uint32_t kRs3FieldMask
const uint32_t kExceptionIsSwitchStackLimit
@ kUnsignedGreaterThanEqual
CheckForInexactConversion
@ kCheckForInexactConversion
@ kDontCheckForInexactConversion
const int32_t kPrefHintStore
const uint32_t kFunct3Mask
const int32_t kPrefHintStoreRetained
const uint32_t kSTypeMask
const int kFloat64MantissaBits
const Instr rtCallRedirInstr
const int32_t kPrefHintLoad
constexpr uint32_t kMaxStopCode
const uint32_t kMaxWatchpointCode
const int32_t kPrefHintLoadRetained
constexpr DataProcessing3SourceOp MSUB
const int kInvalidStackOffset
const int kPredOrderShift
const uint32_t kRvvMopMask
static const int kNegOffset
const int kRvcFunct4Shift
const int kFloat64ExponentBias
const uint32_t kRFPTypeMask
const uint32_t kMaxTracepointCode
const int kFloat32ExponentBias
const uint32_t kRvcBImm8Mask
const int32_t kPrefHintWritebackInvalidate
const uint32_t kFunct7Mask
const uint32_t kCRTypeMask
const int kNumFPURegisters
const uint32_t kBTypeMask
const int kInvalidFPURegister
Union< Smi, HeapNumber > Number
const uint32_t kRvcFunct6Mask
const uint32_t kImm11Mask
constexpr uint8_t kInstrSizeLog2
const uint32_t kRvvZimmMask
const int kNumSimuRegisters
const uint32_t kShamtMask
const int kSuccOrderShift
const int kInvalidRegister
const int kInvalidVRegister
const uint32_t kR4TypeMask
const int kBaseOpcodeShift
const uint32_t kRvvVs1Mask
const uint32_t kRvvWidthMask
const uint32_t kRvcFunct2Mask
Condition NegateCondition(Condition cond)
const uint32_t kUTypeMask
const uint32_t kRvcFunct3Mask
const uint32_t kFunct6Mask
constexpr size_t kMaxPCRelativeCodeRangeInMB
constexpr uint8_t kShortInstrSize
const int32_t kPrefHintPrepareForStore
const uint32_t kRvcOpcodeMask
const int kRvcFunct2BShift
const int kCArgsSlotsSize
const uint32_t kImm19_0Mask
const int kRvcFunct2Shift
const int kFloat32ExponentBits
const uint32_t kRvvVmMask
const uint32_t kRvvFunct6Mask
V8_EXPORT_PRIVATE FlagValues v8_flags
@ kPositiveSubnormalNumber
@ kNegativeSubnormalNumber
const uint32_t kRvvImm5Mask
const int kRvvFunct6Shift
const uint32_t kRTypeMask
const uint32_t kRvvRs1Mask
const uint32_t kRs1FieldMask
const uint32_t kRs2FieldMask
const int kFloat32MantissaBits
const int kBranchReturnOffset
const uint32_t kRvvRs2Mask
const uint32_t kImm31_12Mask
const uint32_t kRvvVs2Mask
const uint32_t kFunct2Mask
constexpr uint8_t kInstrSize
const uint32_t kFunct5Mask
const int kFloat64ExponentBits
constexpr DataProcessing3SourceOp MADD
const uint32_t kCATypeMask
const int kRvcFunct6Shift
constexpr int kRootRegisterBias
const uint32_t kRvvUimmMask
const uint32_t kJTypeMask
Condition NegateFpuCondition(Condition cc)
const uint32_t kBaseOpcodeMask
const uint32_t kRvvVdMask
const uint32_t kRvvRdMask
const uint32_t kImm20Mask
const Instr kIllegalInstr
const int kBaseOpcodeBits
const int kArithShiftShift
const uint32_t kVTypeMask
constexpr int kNumRegisters
const int32_t kPrefHintStoreStreamed
#define DCHECK_NE(v1, v2)
#define DCHECK(condition)