1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
7 #if V8_TARGET_ARCH_MIPS64
9 #include "src/mips64/constants-mips64.h"
15 // -----------------------------------------------------------------------------
19 // These register names are defined in a way to match the native disassembler
20 // formatting. See for example the command "objdump -d <binary file>".
21 const char* Registers::names_[kNumSimuRegisters] = {
25 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
26 "t0", "t1", "t2", "t3",
27 "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
39 // List of alias names which can be used when referring to MIPS registers.
40 const Registers::RegisterAlias Registers::aliases_[] = {
45 {kInvalidRegister, NULL}
49 const char* Registers::Name(int reg) {
51 if ((0 <= reg) && (reg < kNumSimuRegisters)) {
60 int Registers::Number(const char* name) {
61 // Look through the canonical names.
62 for (int i = 0; i < kNumSimuRegisters; i++) {
63 if (strcmp(names_[i], name) == 0) {
68 // Look through the alias names.
70 while (aliases_[i].reg != kInvalidRegister) {
71 if (strcmp(aliases_[i].name, name) == 0) {
72 return aliases_[i].reg;
77 // No register with the reguested name found.
78 return kInvalidRegister;
82 const char* FPURegisters::names_[kNumFPURegisters] = {
83 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11",
84 "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", "f20", "f21",
85 "f22", "f23", "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31"
89 // List of alias names which can be used when referring to MIPS registers.
90 const FPURegisters::RegisterAlias FPURegisters::aliases_[] = {
91 {kInvalidRegister, NULL}
95 const char* FPURegisters::Name(int creg) {
97 if ((0 <= creg) && (creg < kNumFPURegisters)) {
98 result = names_[creg];
106 int FPURegisters::Number(const char* name) {
107 // Look through the canonical names.
108 for (int i = 0; i < kNumFPURegisters; i++) {
109 if (strcmp(names_[i], name) == 0) {
114 // Look through the alias names.
116 while (aliases_[i].creg != kInvalidRegister) {
117 if (strcmp(aliases_[i].name, name) == 0) {
118 return aliases_[i].creg;
123 // No Cregister with the reguested name found.
124 return kInvalidFPURegister;
128 // -----------------------------------------------------------------------------
131 bool Instruction::IsForbiddenInBranchDelay() const {
132 const int op = OpcodeFieldRaw();
146 switch (RtFieldRaw()) {
157 switch (FunctionFieldRaw()) {
171 bool Instruction::IsLinkingInstruction() const {
172 const int op = OpcodeFieldRaw();
177 switch (RtFieldRaw()) {
185 switch (FunctionFieldRaw()) {
197 bool Instruction::IsTrap() const {
198 if (OpcodeFieldRaw() != SPECIAL) {
201 switch (FunctionFieldRaw()) {
217 Instruction::Type Instruction::InstructionType() const {
218 switch (OpcodeFieldRaw()) {
220 switch (FunctionFieldRaw()) {
272 return kRegisterType;
278 switch (FunctionFieldRaw()) {
281 return kRegisterType;
287 switch (FunctionFieldRaw()) {
290 return kRegisterType;
295 case COP1: // Coprocessor instructions.
296 switch (RsFieldRawNoAssert()) {
297 case BC1: // Branch on coprocessor condition.
300 return kImmediateType;
302 return kRegisterType;
306 return kRegisterType;
307 // 16 bits Immediate type instructions. e.g.: addi dest, src, imm16.
348 return kImmediateType;
349 // 26 bits immediate type instructions. e.g.: j imm26.
360 } } // namespace v8::internal
362 #endif // V8_TARGET_ARCH_MIPS64