Home | History | Annotate | Download | only in s390
      1 // Copyright 2014 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.
      4 
      5 // A Disassembler object is used to disassemble a block of code instruction by
      6 // instruction. The default implementation of the NameConverter object can be
      7 // overriden to modify register names or to do symbol lookup on addresses.
      8 //
      9 // The example below will disassemble a block of code and print it to stdout.
     10 //
     11 //   NameConverter converter;
     12 //   Disassembler d(converter);
     13 //   for (byte* pc = begin; pc < end;) {
     14 //     v8::internal::EmbeddedVector<char, 256> buffer;
     15 //     byte* prev_pc = pc;
     16 //     pc += d.InstructionDecode(buffer, pc);
     17 //     printf("%p    %08x      %s\n",
     18 //            prev_pc, *reinterpret_cast<int32_t*>(prev_pc), buffer);
     19 //   }
     20 //
     21 // The Disassembler class also has a convenience method to disassemble a block
     22 // of code into a FILE*, meaning that the above functionality could also be
     23 // achieved by just calling Disassembler::Disassemble(stdout, begin, end);
     24 
     25 #include <assert.h>
     26 #include <stdarg.h>
     27 #include <stdio.h>
     28 #include <string.h>
     29 
     30 #if V8_TARGET_ARCH_S390
     31 
     32 #include "src/base/platform/platform.h"
     33 #include "src/disasm.h"
     34 #include "src/macro-assembler.h"
     35 #include "src/s390/constants-s390.h"
     36 
     37 namespace v8 {
     38 namespace internal {
     39 
     40 const auto GetRegConfig = RegisterConfiguration::Crankshaft;
     41 
     42 //------------------------------------------------------------------------------
     43 
     44 // Decoder decodes and disassembles instructions into an output buffer.
     45 // It uses the converter to convert register names and call destinations into
     46 // more informative description.
     47 class Decoder {
     48  public:
     49   Decoder(const disasm::NameConverter& converter, Vector<char> out_buffer)
     50       : converter_(converter), out_buffer_(out_buffer), out_buffer_pos_(0) {
     51     out_buffer_[out_buffer_pos_] = '\0';
     52   }
     53 
     54   ~Decoder() {}
     55 
     56   // Writes one disassembled instruction into 'buffer' (0-terminated).
     57   // Returns the length of the disassembled machine instruction in bytes.
     58   int InstructionDecode(byte* instruction);
     59 
     60  private:
     61   // Bottleneck functions to print into the out_buffer.
     62   void PrintChar(const char ch);
     63   void Print(const char* str);
     64 
     65   // Printing of common values.
     66   void PrintRegister(int reg);
     67   void PrintDRegister(int reg);
     68   void PrintSoftwareInterrupt(SoftwareInterruptCodes svc);
     69 
     70   // Handle formatting of instructions and their options.
     71   int FormatRegister(Instruction* instr, const char* option);
     72   int FormatFloatingRegister(Instruction* instr, const char* option);
     73   int FormatMask(Instruction* instr, const char* option);
     74   int FormatDisplacement(Instruction* instr, const char* option);
     75   int FormatImmediate(Instruction* instr, const char* option);
     76   int FormatOption(Instruction* instr, const char* option);
     77   void Format(Instruction* instr, const char* format);
     78   void Unknown(Instruction* instr);
     79   void UnknownFormat(Instruction* instr, const char* opcname);
     80 
     81   bool DecodeTwoByte(Instruction* instr);
     82   bool DecodeFourByte(Instruction* instr);
     83   bool DecodeSixByte(Instruction* instr);
     84 
     85   const disasm::NameConverter& converter_;
     86   Vector<char> out_buffer_;
     87   int out_buffer_pos_;
     88 
     89   DISALLOW_COPY_AND_ASSIGN(Decoder);
     90 };
     91 
     92 // Support for assertions in the Decoder formatting functions.
     93 #define STRING_STARTS_WITH(string, compare_string) \
     94   (strncmp(string, compare_string, strlen(compare_string)) == 0)
     95 
     96 // Append the ch to the output buffer.
     97 void Decoder::PrintChar(const char ch) { out_buffer_[out_buffer_pos_++] = ch; }
     98 
     99 // Append the str to the output buffer.
    100 void Decoder::Print(const char* str) {
    101   char cur = *str++;
    102   while (cur != '\0' && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
    103     PrintChar(cur);
    104     cur = *str++;
    105   }
    106   out_buffer_[out_buffer_pos_] = 0;
    107 }
    108 
    109 // Print the register name according to the active name converter.
    110 void Decoder::PrintRegister(int reg) {
    111   Print(converter_.NameOfCPURegister(reg));
    112 }
    113 
    114 // Print the double FP register name according to the active name converter.
    115 void Decoder::PrintDRegister(int reg) {
    116   Print(GetRegConfig()->GetDoubleRegisterName(reg));
    117 }
    118 
    119 // Print SoftwareInterrupt codes. Factoring this out reduces the complexity of
    120 // the FormatOption method.
    121 void Decoder::PrintSoftwareInterrupt(SoftwareInterruptCodes svc) {
    122   switch (svc) {
    123     case kCallRtRedirected:
    124       Print("call rt redirected");
    125       return;
    126     case kBreakpoint:
    127       Print("breakpoint");
    128       return;
    129     default:
    130       if (svc >= kStopCode) {
    131         out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d - 0x%x",
    132                                     svc & kStopCodeMask, svc & kStopCodeMask);
    133       } else {
    134         out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", svc);
    135       }
    136       return;
    137   }
    138 }
    139 
    140 // Handle all register based formatting in this function to reduce the
    141 // complexity of FormatOption.
    142 int Decoder::FormatRegister(Instruction* instr, const char* format) {
    143   DCHECK(format[0] == 'r');
    144 
    145   if (format[1] == '1') {  // 'r1: register resides in bit 8-11
    146     RRInstruction* rrinstr = reinterpret_cast<RRInstruction*>(instr);
    147     int reg = rrinstr->R1Value();
    148     PrintRegister(reg);
    149     return 2;
    150   } else if (format[1] == '2') {  // 'r2: register resides in bit 12-15
    151     RRInstruction* rrinstr = reinterpret_cast<RRInstruction*>(instr);
    152     int reg = rrinstr->R2Value();
    153     // indicating it is a r0 for displacement, in which case the offset
    154     // should be 0.
    155     if (format[2] == 'd') {
    156       if (reg == 0) return 4;
    157       PrintRegister(reg);
    158       return 3;
    159     } else {
    160       PrintRegister(reg);
    161       return 2;
    162     }
    163   } else if (format[1] == '3') {  // 'r3: register resides in bit 16-19
    164     RSInstruction* rsinstr = reinterpret_cast<RSInstruction*>(instr);
    165     int reg = rsinstr->B2Value();
    166     PrintRegister(reg);
    167     return 2;
    168   } else if (format[1] == '4') {  // 'r4: register resides in bit 20-23
    169     RSInstruction* rsinstr = reinterpret_cast<RSInstruction*>(instr);
    170     int reg = rsinstr->B2Value();
    171     PrintRegister(reg);
    172     return 2;
    173   } else if (format[1] == '5') {  // 'r5: register resides in bit 24-28
    174     RREInstruction* rreinstr = reinterpret_cast<RREInstruction*>(instr);
    175     int reg = rreinstr->R1Value();
    176     PrintRegister(reg);
    177     return 2;
    178   } else if (format[1] == '6') {  // 'r6: register resides in bit 29-32
    179     RREInstruction* rreinstr = reinterpret_cast<RREInstruction*>(instr);
    180     int reg = rreinstr->R2Value();
    181     PrintRegister(reg);
    182     return 2;
    183   } else if (format[1] == '7') {  // 'r6: register resides in bit 32-35
    184     SSInstruction* ssinstr = reinterpret_cast<SSInstruction*>(instr);
    185     int reg = ssinstr->B2Value();
    186     PrintRegister(reg);
    187     return 2;
    188   }
    189 
    190   UNREACHABLE();
    191   return -1;
    192 }
    193 
    194 int Decoder::FormatFloatingRegister(Instruction* instr, const char* format) {
    195   DCHECK(format[0] == 'f');
    196 
    197   // reuse 1, 5 and 6 because it is coresponding
    198   if (format[1] == '1') {  // 'r1: register resides in bit 8-11
    199     RRInstruction* rrinstr = reinterpret_cast<RRInstruction*>(instr);
    200     int reg = rrinstr->R1Value();
    201     PrintDRegister(reg);
    202     return 2;
    203   } else if (format[1] == '2') {  // 'f2: register resides in bit 12-15
    204     RRInstruction* rrinstr = reinterpret_cast<RRInstruction*>(instr);
    205     int reg = rrinstr->R2Value();
    206     PrintDRegister(reg);
    207     return 2;
    208   } else if (format[1] == '3') {  // 'f3: register resides in bit 16-19
    209     RRDInstruction* rrdinstr = reinterpret_cast<RRDInstruction*>(instr);
    210     int reg = rrdinstr->R1Value();
    211     PrintDRegister(reg);
    212     return 2;
    213   } else if (format[1] == '5') {  // 'f5: register resides in bit 24-28
    214     RREInstruction* rreinstr = reinterpret_cast<RREInstruction*>(instr);
    215     int reg = rreinstr->R1Value();
    216     PrintDRegister(reg);
    217     return 2;
    218   } else if (format[1] == '6') {  // 'f6: register resides in bit 29-32
    219     RREInstruction* rreinstr = reinterpret_cast<RREInstruction*>(instr);
    220     int reg = rreinstr->R2Value();
    221     PrintDRegister(reg);
    222     return 2;
    223   }
    224   UNREACHABLE();
    225   return -1;
    226 }
    227 
    228 // FormatOption takes a formatting string and interprets it based on
    229 // the current instructions. The format string points to the first
    230 // character of the option string (the option escape has already been
    231 // consumed by the caller.)  FormatOption returns the number of
    232 // characters that were consumed from the formatting string.
    233 int Decoder::FormatOption(Instruction* instr, const char* format) {
    234   switch (format[0]) {
    235     case 'o': {
    236       if (instr->Bit(10) == 1) {
    237         Print("o");
    238       }
    239       return 1;
    240     }
    241     case '.': {
    242       if (instr->Bit(0) == 1) {
    243         Print(".");
    244       } else {
    245         Print(" ");  // ensure consistent spacing
    246       }
    247       return 1;
    248     }
    249     case 'r': {
    250       return FormatRegister(instr, format);
    251     }
    252     case 'f': {
    253       return FormatFloatingRegister(instr, format);
    254     }
    255     case 'i': {  // int16
    256       return FormatImmediate(instr, format);
    257     }
    258     case 'u': {  // uint16
    259       int32_t value = instr->Bits(15, 0);
    260       out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    261       return 6;
    262     }
    263     case 'l': {
    264       // Link (LK) Bit 0
    265       if (instr->Bit(0) == 1) {
    266         Print("l");
    267       }
    268       return 1;
    269     }
    270     case 'a': {
    271       // Absolute Address Bit 1
    272       if (instr->Bit(1) == 1) {
    273         Print("a");
    274       }
    275       return 1;
    276     }
    277     case 't': {  // 'target: target of branch instructions
    278       // target26 or target16
    279       DCHECK(STRING_STARTS_WITH(format, "target"));
    280       if ((format[6] == '2') && (format[7] == '6')) {
    281         int off = ((instr->Bits(25, 2)) << 8) >> 6;
    282         out_buffer_pos_ += SNPrintF(
    283             out_buffer_ + out_buffer_pos_, "%+d -> %s", off,
    284             converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + off));
    285         return 8;
    286       } else if ((format[6] == '1') && (format[7] == '6')) {
    287         int off = ((instr->Bits(15, 2)) << 18) >> 16;
    288         out_buffer_pos_ += SNPrintF(
    289             out_buffer_ + out_buffer_pos_, "%+d -> %s", off,
    290             converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + off));
    291         return 8;
    292       }
    293       case 'm': {
    294         return FormatMask(instr, format);
    295       }
    296     }
    297     case 'd': {  // ds value for offset
    298       return FormatDisplacement(instr, format);
    299     }
    300     default: {
    301       UNREACHABLE();
    302       break;
    303     }
    304   }
    305 
    306   UNREACHABLE();
    307   return -1;
    308 }
    309 
    310 int Decoder::FormatMask(Instruction* instr, const char* format) {
    311   DCHECK(format[0] == 'm');
    312   int32_t value = 0;
    313   if ((format[1] == '1')) {  // prints the mask format in bits 8-12
    314     value = reinterpret_cast<RRInstruction*>(instr)->R1Value();
    315     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", value);
    316     return 2;
    317   } else if (format[1] == '2') {  // mask format in bits 16-19
    318     value = reinterpret_cast<RXInstruction*>(instr)->B2Value();
    319     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", value);
    320     return 2;
    321   } else if (format[1] == '3') {  // mask format in bits 20-23
    322     value = reinterpret_cast<RRFInstruction*>(instr)->M4Value();
    323     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "0x%x", value);
    324     return 2;
    325   }
    326 
    327   out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    328   return 2;
    329 }
    330 
    331 int Decoder::FormatDisplacement(Instruction* instr, const char* format) {
    332   DCHECK(format[0] == 'd');
    333 
    334   if (format[1] == '1') {  // displacement in 20-31
    335     RSInstruction* rsinstr = reinterpret_cast<RSInstruction*>(instr);
    336     uint16_t value = rsinstr->D2Value();
    337     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    338 
    339     return 2;
    340   } else if (format[1] == '2') {  // displacement in 20-39
    341     RXYInstruction* rxyinstr = reinterpret_cast<RXYInstruction*>(instr);
    342     int32_t value = rxyinstr->D2Value();
    343     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    344     return 2;
    345   } else if (format[1] == '4') {  // SS displacement 2 36-47
    346     SSInstruction* ssInstr = reinterpret_cast<SSInstruction*>(instr);
    347     uint16_t value = ssInstr->D2Value();
    348     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    349     return 2;
    350   } else if (format[1] == '3') {  // SS displacement 1 20 - 32
    351     SSInstruction* ssInstr = reinterpret_cast<SSInstruction*>(instr);
    352     uint16_t value = ssInstr->D1Value();
    353     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    354     return 2;
    355   } else {  // s390 specific
    356     int32_t value = SIGN_EXT_IMM16(instr->Bits(15, 0) & ~3);
    357     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    358     return 1;
    359   }
    360 }
    361 
    362 int Decoder::FormatImmediate(Instruction* instr, const char* format) {
    363   DCHECK(format[0] == 'i');
    364 
    365   if (format[1] == '1') {  // immediate in 16-31
    366     RIInstruction* riinstr = reinterpret_cast<RIInstruction*>(instr);
    367     int16_t value = riinstr->I2Value();
    368     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    369     return 2;
    370   } else if (format[1] == '2') {  // immediate in 16-48
    371     RILInstruction* rilinstr = reinterpret_cast<RILInstruction*>(instr);
    372     int32_t value = rilinstr->I2Value();
    373     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    374     return 2;
    375   } else if (format[1] == '3') {  // immediate in I format
    376     IInstruction* iinstr = reinterpret_cast<IInstruction*>(instr);
    377     int8_t value = iinstr->IValue();
    378     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    379     return 2;
    380   } else if (format[1] == '4') {  // immediate in 16-31, but outputs as offset
    381     RIInstruction* riinstr = reinterpret_cast<RIInstruction*>(instr);
    382     int16_t value = riinstr->I2Value() * 2;
    383     if (value >= 0)
    384       out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "*+");
    385     else
    386       out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "*");
    387 
    388     out_buffer_pos_ += SNPrintF(
    389         out_buffer_ + out_buffer_pos_, "%d -> %s", value,
    390         converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + value));
    391     return 2;
    392   } else if (format[1] == '5') {  // immediate in 16-31, but outputs as offset
    393     RILInstruction* rilinstr = reinterpret_cast<RILInstruction*>(instr);
    394     int32_t value = rilinstr->I2Value() * 2;
    395     if (value >= 0)
    396       out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "*+");
    397     else
    398       out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "*");
    399 
    400     out_buffer_pos_ += SNPrintF(
    401         out_buffer_ + out_buffer_pos_, "%d -> %s", value,
    402         converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + value));
    403     return 2;
    404   } else if (format[1] == '6') {  // unsigned immediate in 16-31
    405     RIInstruction* riinstr = reinterpret_cast<RIInstruction*>(instr);
    406     uint16_t value = riinstr->I2UnsignedValue();
    407     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    408     return 2;
    409   } else if (format[1] == '7') {  // unsigned immediate in 16-47
    410     RILInstruction* rilinstr = reinterpret_cast<RILInstruction*>(instr);
    411     uint32_t value = rilinstr->I2UnsignedValue();
    412     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    413     return 2;
    414   } else if (format[1] == '8') {  // unsigned immediate in 8-15
    415     SSInstruction* ssinstr = reinterpret_cast<SSInstruction*>(instr);
    416     uint8_t value = ssinstr->Length();
    417     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    418     return 2;
    419   } else if (format[1] == '9') {  // unsigned immediate in 16-23
    420     RIEInstruction* rie_instr = reinterpret_cast<RIEInstruction*>(instr);
    421     uint8_t value = rie_instr->I3Value();
    422     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    423     return 2;
    424   } else if (format[1] == 'a') {  // unsigned immediate in 24-31
    425     RIEInstruction* rie_instr = reinterpret_cast<RIEInstruction*>(instr);
    426     uint8_t value = rie_instr->I4Value();
    427     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    428     return 2;
    429   } else if (format[1] == 'b') {  // unsigned immediate in 32-39
    430     RIEInstruction* rie_instr = reinterpret_cast<RIEInstruction*>(instr);
    431     uint8_t value = rie_instr->I5Value();
    432     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    433     return 2;
    434   } else if (format[1] == 'c') {  // signed immediate in 8-15
    435     SSInstruction* ssinstr = reinterpret_cast<SSInstruction*>(instr);
    436     int8_t value = ssinstr->Length();
    437     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    438     return 2;
    439   } else if (format[1] == 'd') {  // signed immediate in 32-47
    440     SILInstruction* silinstr = reinterpret_cast<SILInstruction*>(instr);
    441     int16_t value = silinstr->I2Value();
    442     out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%d", value);
    443     return 2;
    444   } else if (format[1] == 'e') {  // immediate in 16-47, but outputs as offset
    445     RILInstruction* rilinstr = reinterpret_cast<RILInstruction*>(instr);
    446     int32_t value = rilinstr->I2Value() * 2;
    447     if (value >= 0)
    448       out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "*+");
    449     else
    450       out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "*");
    451 
    452     out_buffer_pos_ += SNPrintF(
    453         out_buffer_ + out_buffer_pos_, "%d -> %s", value,
    454         converter_.NameOfAddress(reinterpret_cast<byte*>(instr) + value));
    455     return 2;
    456   }
    457 
    458   UNREACHABLE();
    459   return -1;
    460 }
    461 
    462 // Format takes a formatting string for a whole instruction and prints it into
    463 // the output buffer. All escaped options are handed to FormatOption to be
    464 // parsed further.
    465 void Decoder::Format(Instruction* instr, const char* format) {
    466   char cur = *format++;
    467   while ((cur != 0) && (out_buffer_pos_ < (out_buffer_.length() - 1))) {
    468     if (cur == '\'') {  // Single quote is used as the formatting escape.
    469       format += FormatOption(instr, format);
    470     } else {
    471       out_buffer_[out_buffer_pos_++] = cur;
    472     }
    473     cur = *format++;
    474   }
    475   out_buffer_[out_buffer_pos_] = '\0';
    476 }
    477 
    478 // The disassembler may end up decoding data inlined in the code. We do not want
    479 // it to crash if the data does not ressemble any known instruction.
    480 #define VERIFY(condition) \
    481   if (!(condition)) {     \
    482     Unknown(instr);       \
    483     return;               \
    484   }
    485 
    486 // For currently unimplemented decodings the disassembler calls Unknown(instr)
    487 // which will just print "unknown" of the instruction bits.
    488 void Decoder::Unknown(Instruction* instr) { Format(instr, "unknown"); }
    489 
    490 // For currently unimplemented decodings the disassembler calls
    491 // UnknownFormat(instr) which will just print opcode name of the
    492 // instruction bits.
    493 void Decoder::UnknownFormat(Instruction* instr, const char* name) {
    494   char buffer[100];
    495   snprintf(buffer, sizeof(buffer), "%s (unknown-format)", name);
    496   Format(instr, buffer);
    497 }
    498 
    499 // Disassembles Two Byte S390 Instructions
    500 // @return true if successfully decoded
    501 bool Decoder::DecodeTwoByte(Instruction* instr) {
    502   // Print the Instruction bits.
    503   out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%04x           ",
    504                               instr->InstructionBits<TwoByteInstr>());
    505 
    506   Opcode opcode = instr->S390OpcodeValue();
    507   switch (opcode) {
    508     case AR:
    509       Format(instr, "ar\t'r1,'r2");
    510       break;
    511     case SR:
    512       Format(instr, "sr\t'r1,'r2");
    513       break;
    514     case MR:
    515       Format(instr, "mr\t'r1,'r2");
    516       break;
    517     case DR:
    518       Format(instr, "dr\t'r1,'r2");
    519       break;
    520     case OR:
    521       Format(instr, "or\t'r1,'r2");
    522       break;
    523     case NR:
    524       Format(instr, "nr\t'r1,'r2");
    525       break;
    526     case XR:
    527       Format(instr, "xr\t'r1,'r2");
    528       break;
    529     case LR:
    530       Format(instr, "lr\t'r1,'r2");
    531       break;
    532     case CR:
    533       Format(instr, "cr\t'r1,'r2");
    534       break;
    535     case CLR:
    536       Format(instr, "clr\t'r1,'r2");
    537       break;
    538     case BCR:
    539       Format(instr, "bcr\t'm1,'r2");
    540       break;
    541     case LTR:
    542       Format(instr, "ltr\t'r1,'r2");
    543       break;
    544     case ALR:
    545       Format(instr, "alr\t'r1,'r2");
    546       break;
    547     case SLR:
    548       Format(instr, "slr\t'r1,'r2");
    549       break;
    550     case LNR:
    551       Format(instr, "lnr\t'r1,'r2");
    552       break;
    553     case LCR:
    554       Format(instr, "lcr\t'r1,'r2");
    555       break;
    556     case BASR:
    557       Format(instr, "basr\t'r1,'r2");
    558       break;
    559     case LDR:
    560       Format(instr, "ldr\t'f1,'f2");
    561       break;
    562     case BKPT:
    563       Format(instr, "bkpt");
    564       break;
    565     case LPR:
    566       Format(instr, "lpr\t'r1, 'r2");
    567       break;
    568     default:
    569       return false;
    570   }
    571   return true;
    572 }
    573 
    574 // Disassembles Four Byte S390 Instructions
    575 // @return true if successfully decoded
    576 bool Decoder::DecodeFourByte(Instruction* instr) {
    577   // Print the Instruction bits.
    578   out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_, "%08x       ",
    579                               instr->InstructionBits<FourByteInstr>());
    580 
    581   Opcode opcode = instr->S390OpcodeValue();
    582   switch (opcode) {
    583     case AHI:
    584       Format(instr, "ahi\t'r1,'i1");
    585       break;
    586     case AGHI:
    587       Format(instr, "aghi\t'r1,'i1");
    588       break;
    589     case LHI:
    590       Format(instr, "lhi\t'r1,'i1");
    591       break;
    592     case LGHI:
    593       Format(instr, "lghi\t'r1,'i1");
    594       break;
    595     case MHI:
    596       Format(instr, "mhi\t'r1,'i1");
    597       break;
    598     case MGHI:
    599       Format(instr, "mghi\t'r1,'i1");
    600       break;
    601     case CHI:
    602       Format(instr, "chi\t'r1,'i1");
    603       break;
    604     case CGHI:
    605       Format(instr, "cghi\t'r1,'i1");
    606       break;
    607     case BRAS:
    608       Format(instr, "bras\t'r1,'i1");
    609       break;
    610     case BRC:
    611       Format(instr, "brc\t'm1,'i4");
    612       break;
    613     case BRCT:
    614       Format(instr, "brct\t'r1,'i4");
    615       break;
    616     case BRCTG:
    617       Format(instr, "brctg\t'r1,'i4");
    618       break;
    619     case IIHH:
    620       Format(instr, "iihh\t'r1,'i1");
    621       break;
    622     case IIHL:
    623       Format(instr, "iihl\t'r1,'i1");
    624       break;
    625     case IILH:
    626       Format(instr, "iilh\t'r1,'i1");
    627       break;
    628     case IILL:
    629       Format(instr, "iill\t'r1,'i1");
    630       break;
    631     case OILL:
    632       Format(instr, "oill\t'r1,'i1");
    633       break;
    634     case TMLL:
    635       Format(instr, "tmll\t'r1,'i1");
    636       break;
    637     case STM:
    638       Format(instr, "stm\t'r1,'r2,'d1('r3)");
    639       break;
    640     case LM:
    641       Format(instr, "lm\t'r1,'r2,'d1('r3)");
    642       break;
    643     case SLL:
    644       Format(instr, "sll\t'r1,'d1('r3)");
    645       break;
    646     case SRL:
    647       Format(instr, "srl\t'r1,'d1('r3)");
    648       break;
    649     case SLA:
    650       Format(instr, "sla\t'r1,'d1('r3)");
    651       break;
    652     case SRA:
    653       Format(instr, "sra\t'r1,'d1('r3)");
    654       break;
    655     case SLDL:
    656       Format(instr, "sldl\t'r1,'d1('r3)");
    657       break;
    658     case AGR:
    659       Format(instr, "agr\t'r5,'r6");
    660       break;
    661     case AGFR:
    662       Format(instr, "agfr\t'r5,'r6");
    663       break;
    664     case ARK:
    665       Format(instr, "ark\t'r5,'r6,'r3");
    666       break;
    667     case AGRK:
    668       Format(instr, "agrk\t'r5,'r6,'r3");
    669       break;
    670     case SGR:
    671       Format(instr, "sgr\t'r5,'r6");
    672       break;
    673     case SGFR:
    674       Format(instr, "sgfr\t'r5,'r6");
    675       break;
    676     case SRK:
    677       Format(instr, "srk\t'r5,'r6,'r3");
    678       break;
    679     case SGRK:
    680       Format(instr, "sgrk\t'r5,'r6,'r3");
    681       break;
    682     case NGR:
    683       Format(instr, "ngr\t'r5,'r6");
    684       break;
    685     case NRK:
    686       Format(instr, "nrk\t'r5,'r6,'r3");
    687       break;
    688     case NGRK:
    689       Format(instr, "ngrk\t'r5,'r6,'r3");
    690       break;
    691     case NILL:
    692       Format(instr, "nill\t'r1,'i1");
    693       break;
    694     case NILH:
    695       Format(instr, "nilh\t'r1,'i1");
    696       break;
    697     case OGR:
    698       Format(instr, "ogr\t'r5,'r6");
    699       break;
    700     case ORK:
    701       Format(instr, "ork\t'r5,'r6,'r3");
    702       break;
    703     case OGRK:
    704       Format(instr, "ogrk\t'r5,'r6,'r3");
    705       break;
    706     case XGR:
    707       Format(instr, "xgr\t'r5,'r6");
    708       break;
    709     case XRK:
    710       Format(instr, "xrk\t'r5,'r6,'r3");
    711       break;
    712     case XGRK:
    713       Format(instr, "xgrk\t'r5,'r6,'r3");
    714       break;
    715     case CGFR:
    716       Format(instr, "cgfr\t'r5,'r6");
    717       break;
    718     case CGR:
    719       Format(instr, "cgr\t'r5,'r6");
    720       break;
    721     case CLGR:
    722       Format(instr, "clgr\t'r5,'r6");
    723       break;
    724     case LLGFR:
    725       Format(instr, "llgfr\t'r5,'r6");
    726       break;
    727     case POPCNT_Z:
    728       Format(instr, "popcnt\t'r5,'r6");
    729       break;
    730     case LLGCR:
    731       Format(instr, "llgcr\t'r5,'r6");
    732       break;
    733     case LLCR:
    734       Format(instr, "llcr\t'r5,'r6");
    735       break;
    736     case LBR:
    737       Format(instr, "lbr\t'r5,'r6");
    738       break;
    739     case LEDBR:
    740       Format(instr, "ledbr\t'f5,'f6");
    741       break;
    742     case LDEBR:
    743       Format(instr, "ldebr\t'f5,'f6");
    744       break;
    745     case LTGR:
    746       Format(instr, "ltgr\t'r5,'r6");
    747       break;
    748     case LTDBR:
    749       Format(instr, "ltdbr\t'f5,'f6");
    750       break;
    751     case LTEBR:
    752       Format(instr, "ltebr\t'f5,'f6");
    753       break;
    754     case LRVR:
    755       Format(instr, "lrvr\t'r5,'r6");
    756       break;
    757     case LRVGR:
    758       Format(instr, "lrvgr\t'r5,'r6");
    759       break;
    760     case LGR:
    761       Format(instr, "lgr\t'r5,'r6");
    762       break;
    763     case LGDR:
    764       Format(instr, "lgdr\t'r5,'f6");
    765       break;
    766     case LGFR:
    767       Format(instr, "lgfr\t'r5,'r6");
    768       break;
    769     case LTGFR:
    770       Format(instr, "ltgfr\t'r5,'r6");
    771       break;
    772     case LCGR:
    773       Format(instr, "lcgr\t'r5,'r6");
    774       break;
    775     case MSR:
    776       Format(instr, "msr\t'r5,'r6");
    777       break;
    778     case MSRKC:
    779       Format(instr, "msrkc\t'r5,'r6,'r3");
    780       break;
    781     case LGBR:
    782       Format(instr, "lgbr\t'r5,'r6");
    783       break;
    784     case LGHR:
    785       Format(instr, "lghr\t'r5,'r6");
    786       break;
    787     case MSGR:
    788       Format(instr, "msgr\t'r5,'r6");
    789       break;
    790     case MSGRKC:
    791       Format(instr, "msgrkc\t'r5,'r6,'r3");
    792       break;
    793     case DSGR:
    794       Format(instr, "dsgr\t'r5,'r6");
    795       break;
    796     case DSGFR:
    797       Format(instr, "dsgfr\t'r5,'r6");
    798       break;
    799     case MSGFR:
    800       Format(instr, "msgfr\t'r5,'r6");
    801       break;
    802     case LZDR:
    803       Format(instr, "lzdr\t'f5");
    804       break;
    805     case MLR:
    806       Format(instr, "mlr\t'r5,'r6");
    807       break;
    808     case MLGR:
    809       Format(instr, "mlgr\t'r5,'r6");
    810       break;
    811     case ALCR:
    812       Format(instr, "alcr\t'r5,'r6");
    813       break;
    814     case ALGR:
    815       Format(instr, "algr\t'r5,'r6");
    816       break;
    817     case ALRK:
    818       Format(instr, "alrk\t'r5,'r6,'r3");
    819       break;
    820     case ALGRK:
    821       Format(instr, "algrk\t'r5,'r6,'r3");
    822       break;
    823     case SLGR:
    824       Format(instr, "slgr\t'r5,'r6");
    825       break;
    826     case SLBR:
    827       Format(instr, "slbr\t'r5,'r6");
    828       break;
    829     case DLR:
    830       Format(instr, "dlr\t'r5,'r6");
    831       break;
    832     case DLGR:
    833       Format(instr, "dlgr\t'r5,'r6");
    834       break;
    835     case SLRK:
    836       Format(instr, "slrk\t'r5,'r6,'r3");
    837       break;
    838     case SLGRK:
    839       Format(instr, "slgrk\t'r5,'r6,'r3");
    840       break;
    841     case LHR:
    842       Format(instr, "lhr\t'r5,'r6");
    843       break;
    844     case LLHR:
    845       Format(instr, "llhr\t'r5,'r6");
    846       break;
    847     case LLGHR:
    848       Format(instr, "llghr\t'r5,'r6");
    849       break;
    850     case LOCR:
    851       Format(instr, "locr\t'm1,'r5,'r6");
    852       break;
    853     case LOCGR:
    854       Format(instr, "locgr\t'm1,'r5,'r6");
    855       break;
    856     case LNGR:
    857       Format(instr, "lngr\t'r5,'r6");
    858       break;
    859     case A:
    860       Format(instr, "a\t'r1,'d1('r2d,'r3)");
    861       break;
    862     case S:
    863       Format(instr, "s\t'r1,'d1('r2d,'r3)");
    864       break;
    865     case M:
    866       Format(instr, "m\t'r1,'d1('r2d,'r3)");
    867       break;
    868     case D:
    869       Format(instr, "d\t'r1,'d1('r2d,'r3)");
    870       break;
    871     case O:
    872       Format(instr, "o\t'r1,'d1('r2d,'r3)");
    873       break;
    874     case N:
    875       Format(instr, "n\t'r1,'d1('r2d,'r3)");
    876       break;
    877     case L:
    878       Format(instr, "l\t'r1,'d1('r2d,'r3)");
    879       break;
    880     case C:
    881       Format(instr, "c\t'r1,'d1('r2d,'r3)");
    882       break;
    883     case AH:
    884       Format(instr, "ah\t'r1,'d1('r2d,'r3)");
    885       break;
    886     case SH:
    887       Format(instr, "sh\t'r1,'d1('r2d,'r3)");
    888       break;
    889     case MH:
    890       Format(instr, "mh\t'r1,'d1('r2d,'r3)");
    891       break;
    892     case AL:
    893       Format(instr, "al\t'r1,'d1('r2d,'r3)");
    894       break;
    895     case SL:
    896       Format(instr, "sl\t'r1,'d1('r2d,'r3)");
    897       break;
    898     case LA:
    899       Format(instr, "la\t'r1,'d1('r2d,'r3)");
    900       break;
    901     case CH:
    902       Format(instr, "ch\t'r1,'d1('r2d,'r3)");
    903       break;
    904     case CL:
    905       Format(instr, "cl\t'r1,'d1('r2d,'r3)");
    906       break;
    907     case CLI:
    908       Format(instr, "cli\t'd1('r3),'i8");
    909       break;
    910     case TM:
    911       Format(instr, "tm\t'd1('r3),'i8");
    912       break;
    913     case BC:
    914       Format(instr, "bc\t'm1,'d1('r2d,'r3)");
    915       break;
    916     case BCT:
    917       Format(instr, "bct\t'r1,'d1('r2d,'r3)");
    918       break;
    919     case ST:
    920       Format(instr, "st\t'r1,'d1('r2d,'r3)");
    921       break;
    922     case STC:
    923       Format(instr, "stc\t'r1,'d1('r2d,'r3)");
    924       break;
    925     case IC_z:
    926       Format(instr, "ic\t'r1,'d1('r2d,'r3)");
    927       break;
    928     case LD:
    929       Format(instr, "ld\t'f1,'d1('r2d,'r3)");
    930       break;
    931     case LE:
    932       Format(instr, "le\t'f1,'d1('r2d,'r3)");
    933       break;
    934     case LDGR:
    935       Format(instr, "ldgr\t'f5,'r6");
    936       break;
    937     case MS:
    938       Format(instr, "ms\t'r1,'d1('r2d,'r3)");
    939       break;
    940     case STE:
    941       Format(instr, "ste\t'f1,'d1('r2d,'r3)");
    942       break;
    943     case STD:
    944       Format(instr, "std\t'f1,'d1('r2d,'r3)");
    945       break;
    946     case CFDBR:
    947       Format(instr, "cfdbr\t'r5,'m2,'f6");
    948       break;
    949     case CDFBR:
    950       Format(instr, "cdfbr\t'f5,'m2,'r6");
    951       break;
    952     case CFEBR:
    953       Format(instr, "cfebr\t'r5,'m2,'f6");
    954       break;
    955     case CEFBR:
    956       Format(instr, "cefbr\t'f5,'m2,'r6");
    957       break;
    958     case CELFBR:
    959       Format(instr, "celfbr\t'f5,'m2,'r6");
    960       break;
    961     case CGEBR:
    962       Format(instr, "cgebr\t'r5,'m2,'f6");
    963       break;
    964     case CGDBR:
    965       Format(instr, "cgdbr\t'r5,'m2,'f6");
    966       break;
    967     case CEGBR:
    968       Format(instr, "cegbr\t'f5,'m2,'r6");
    969       break;
    970     case CDGBR:
    971       Format(instr, "cdgbr\t'f5,'m2,'r6");
    972       break;
    973     case CDLFBR:
    974       Format(instr, "cdlfbr\t'f5,'m2,'r6");
    975       break;
    976     case CDLGBR:
    977       Format(instr, "cdlgbr\t'f5,'m2,'r6");
    978       break;
    979     case CELGBR:
    980       Format(instr, "celgbr\t'f5,'m2,'r6");
    981       break;
    982     case CLFDBR:
    983       Format(instr, "clfdbr\t'r5,'m2,'f6");
    984       break;
    985     case CLFEBR:
    986       Format(instr, "clfebr\t'r5,'m2,'f6");
    987       break;
    988     case CLGEBR:
    989       Format(instr, "clgebr\t'r5,'m2,'f6");
    990       break;
    991     case CLGDBR:
    992       Format(instr, "clgdbr\t'r5,'m2,'f6");
    993       break;
    994     case AEBR:
    995       Format(instr, "aebr\t'f5,'f6");
    996       break;
    997     case SEBR:
    998       Format(instr, "sebr\t'f5,'f6");
    999       break;
   1000     case MEEBR:
   1001       Format(instr, "meebr\t'f5,'f6");
   1002       break;
   1003     case DEBR:
   1004       Format(instr, "debr\t'f5,'f6");
   1005       break;
   1006     case ADBR:
   1007       Format(instr, "adbr\t'f5,'f6");
   1008       break;
   1009     case SDBR:
   1010       Format(instr, "sdbr\t'f5,'f6");
   1011       break;
   1012     case MDBR:
   1013       Format(instr, "mdbr\t'f5,'f6");
   1014       break;
   1015     case DDBR:
   1016       Format(instr, "ddbr\t'f5,'f6");
   1017       break;
   1018     case CDBR:
   1019       Format(instr, "cdbr\t'f5,'f6");
   1020       break;
   1021     case CEBR:
   1022       Format(instr, "cebr\t'f5,'f6");
   1023       break;
   1024     case SQDBR:
   1025       Format(instr, "sqdbr\t'f5,'f6");
   1026       break;
   1027     case SQEBR:
   1028       Format(instr, "sqebr\t'f5,'f6");
   1029       break;
   1030     case LCDBR:
   1031       Format(instr, "lcdbr\t'f5,'f6");
   1032       break;
   1033     case LCEBR:
   1034       Format(instr, "lcebr\t'f5,'f6");
   1035       break;
   1036     case STH:
   1037       Format(instr, "sth\t'r1,'d1('r2d,'r3)");
   1038       break;
   1039     case SRDA:
   1040       Format(instr, "srda\t'r1,'d1('r3)");
   1041       break;
   1042     case SRDL:
   1043       Format(instr, "srdl\t'r1,'d1('r3)");
   1044       break;
   1045     case MADBR:
   1046       Format(instr, "madbr\t'f3,'f5,'f6");
   1047       break;
   1048     case MSDBR:
   1049       Format(instr, "msdbr\t'f3,'f5,'f6");
   1050       break;
   1051     case FLOGR:
   1052       Format(instr, "flogr\t'r5,'r6");
   1053       break;
   1054     case FIEBRA:
   1055       Format(instr, "fiebra\t'f5,'m2,'f6,'m3");
   1056       break;
   1057     case FIDBRA:
   1058       Format(instr, "fidbra\t'f5,'m2,'f6,'m3");
   1059       break;
   1060     // TRAP4 is used in calling to native function. it will not be generated
   1061     // in native code.
   1062     case TRAP4: {
   1063       Format(instr, "trap4");
   1064       break;
   1065     }
   1066     case LPGR:
   1067       Format(instr, "lpgr\t'r1, 'r2");
   1068       break;
   1069     case LPGFR:
   1070       Format(instr, "lpgfr\t'r1,'r2");
   1071       break;
   1072     default:
   1073       return false;
   1074   }
   1075   return true;
   1076 }
   1077 
   1078 // Disassembles Six Byte S390 Instructions
   1079 // @return true if successfully decoded
   1080 bool Decoder::DecodeSixByte(Instruction* instr) {
   1081   // Print the Instruction bits.
   1082   out_buffer_pos_ +=
   1083       SNPrintF(out_buffer_ + out_buffer_pos_, "%012" PRIx64 "   ",
   1084                instr->InstructionBits<SixByteInstr>());
   1085 
   1086   Opcode opcode = instr->S390OpcodeValue();
   1087   switch (opcode) {
   1088     case DUMY:
   1089       Format(instr, "dumy\t'r1, 'd2 ( 'r2d, 'r3 )");
   1090       break;
   1091 #define DECODE_VRR_C_INSTRUCTIONS(name, opcode_name, opcode_value) \
   1092   case opcode_name:                                                \
   1093     Format(instr, #name "\t'f1,'f2,'f3");                          \
   1094     break;
   1095       S390_VRR_C_OPCODE_LIST(DECODE_VRR_C_INSTRUCTIONS)
   1096 #undef DECODE_VRR_C_INSTRUCTIONS
   1097     case LLILF:
   1098       Format(instr, "llilf\t'r1,'i7");
   1099       break;
   1100     case LLIHF:
   1101       Format(instr, "llihf\t'r1,'i7");
   1102       break;
   1103     case AFI:
   1104       Format(instr, "afi\t'r1,'i7");
   1105       break;
   1106     case AIH:
   1107       Format(instr, "aih\t'r1,'i7");
   1108       break;
   1109     case ASI:
   1110       Format(instr, "asi\t'd2('r3),'ic");
   1111       break;
   1112     case AGSI:
   1113       Format(instr, "agsi\t'd2('r3),'ic");
   1114       break;
   1115     case ALFI:
   1116       Format(instr, "alfi\t'r1,'i7");
   1117       break;
   1118     case AHIK:
   1119       Format(instr, "ahik\t'r1,'r2,'i1");
   1120       break;
   1121     case AGHIK:
   1122       Format(instr, "aghik\t'r1,'r2,'i1");
   1123       break;
   1124     case CLGFI:
   1125       Format(instr, "clgfi\t'r1,'i7");
   1126       break;
   1127     case CLFI:
   1128       Format(instr, "clfi\t'r1,'i7");
   1129       break;
   1130     case CLIH:
   1131       Format(instr, "clih\t'r1,'i7");
   1132       break;
   1133     case CIH:
   1134       Format(instr, "cih\t'r1,'i2");
   1135       break;
   1136     case CFI:
   1137       Format(instr, "cfi\t'r1,'i2");
   1138       break;
   1139     case CGFI:
   1140       Format(instr, "cgfi\t'r1,'i2");
   1141       break;
   1142     case BRASL:
   1143       Format(instr, "brasl\t'r1,'ie");
   1144       break;
   1145     case BRCL:
   1146       Format(instr, "brcl\t'm1,'i5");
   1147       break;
   1148     case IIHF:
   1149       Format(instr, "iihf\t'r1,'i7");
   1150       break;
   1151     case LGFI:
   1152       Format(instr, "lgfi\t'r1,'i7");
   1153       break;
   1154     case IILF:
   1155       Format(instr, "iilf\t'r1,'i7");
   1156       break;
   1157     case XIHF:
   1158       Format(instr, "xihf\t'r1,'i7");
   1159       break;
   1160     case XILF:
   1161       Format(instr, "xilf\t'r1,'i7");
   1162       break;
   1163     case SLLK:
   1164       Format(instr, "sllk\t'r1,'r2,'d2('r3)");
   1165       break;
   1166     case SLLG:
   1167       Format(instr, "sllg\t'r1,'r2,'d2('r3)");
   1168       break;
   1169     case RLL:
   1170       Format(instr, "rll\t'r1,'r2,'d2('r3)");
   1171       break;
   1172     case RLLG:
   1173       Format(instr, "rllg\t'r1,'r2,'d2('r3)");
   1174       break;
   1175     case SRLK:
   1176       Format(instr, "srlk\t'r1,'r2,'d2('r3)");
   1177       break;
   1178     case SRLG:
   1179       Format(instr, "srlg\t'r1,'r2,'d2('r3)");
   1180       break;
   1181     case SLAK:
   1182       Format(instr, "slak\t'r1,'r2,'d2('r3)");
   1183       break;
   1184     case SLAG:
   1185       Format(instr, "slag\t'r1,'r2,'d2('r3)");
   1186       break;
   1187     case SRAK:
   1188       Format(instr, "srak\t'r1,'r2,'d2('r3)");
   1189       break;
   1190     case SRAG:
   1191       Format(instr, "srag\t'r1,'r2,'d2('r3)");
   1192       break;
   1193     case RISBG:
   1194       Format(instr, "risbg\t'r1,'r2,'i9,'ia,'ib");
   1195       break;
   1196     case RISBGN:
   1197       Format(instr, "risbgn\t'r1,'r2,'i9,'ia,'ib");
   1198       break;
   1199     case LOCG:
   1200       Format(instr, "locg\t'm2,'r1,'d2('r3)");
   1201       break;
   1202     case LOC:
   1203       Format(instr, "loc\t'm2,'r1,'d2('r3)");
   1204       break;
   1205     case LMY:
   1206       Format(instr, "lmy\t'r1,'r2,'d2('r3)");
   1207       break;
   1208     case LMG:
   1209       Format(instr, "lmg\t'r1,'r2,'d2('r3)");
   1210       break;
   1211     case STMY:
   1212       Format(instr, "stmy\t'r1,'r2,'d2('r3)");
   1213       break;
   1214     case STMG:
   1215       Format(instr, "stmg\t'r1,'r2,'d2('r3)");
   1216       break;
   1217     case LT:
   1218       Format(instr, "lt\t'r1,'d2('r2d,'r3)");
   1219       break;
   1220     case LTG:
   1221       Format(instr, "ltg\t'r1,'d2('r2d,'r3)");
   1222       break;
   1223     case ML:
   1224       Format(instr, "ml\t'r1,'d2('r2d,'r3)");
   1225       break;
   1226     case AY:
   1227       Format(instr, "ay\t'r1,'d2('r2d,'r3)");
   1228       break;
   1229     case SY:
   1230       Format(instr, "sy\t'r1,'d2('r2d,'r3)");
   1231       break;
   1232     case NY:
   1233       Format(instr, "ny\t'r1,'d2('r2d,'r3)");
   1234       break;
   1235     case OY:
   1236       Format(instr, "oy\t'r1,'d2('r2d,'r3)");
   1237       break;
   1238     case XY:
   1239       Format(instr, "xy\t'r1,'d2('r2d,'r3)");
   1240       break;
   1241     case CY:
   1242       Format(instr, "cy\t'r1,'d2('r2d,'r3)");
   1243       break;
   1244     case AHY:
   1245       Format(instr, "ahy\t'r1,'d2('r2d,'r3)");
   1246       break;
   1247     case SHY:
   1248       Format(instr, "shy\t'r1,'d2('r2d,'r3)");
   1249       break;
   1250     case LGH:
   1251       Format(instr, "lgh\t'r1,'d2('r2d,'r3)");
   1252       break;
   1253     case AG:
   1254       Format(instr, "ag\t'r1,'d2('r2d,'r3)");
   1255       break;
   1256     case AGF:
   1257       Format(instr, "agf\t'r1,'d2('r2d,'r3)");
   1258       break;
   1259     case SG:
   1260       Format(instr, "sg\t'r1,'d2('r2d,'r3)");
   1261       break;
   1262     case NG:
   1263       Format(instr, "ng\t'r1,'d2('r2d,'r3)");
   1264       break;
   1265     case OG:
   1266       Format(instr, "og\t'r1,'d2('r2d,'r3)");
   1267       break;
   1268     case XG:
   1269       Format(instr, "xg\t'r1,'d2('r2d,'r3)");
   1270       break;
   1271     case CG:
   1272       Format(instr, "cg\t'r1,'d2('r2d,'r3)");
   1273       break;
   1274     case LB:
   1275       Format(instr, "lb\t'r1,'d2('r2d,'r3)");
   1276       break;
   1277     case LRVH:
   1278       Format(instr, "lrvh\t'r1,'d2('r2d,'r3)");
   1279       break;
   1280     case LRV:
   1281       Format(instr, "lrv\t'r1,'d2('r2d,'r3)");
   1282       break;
   1283     case LRVG:
   1284       Format(instr, "lrvg\t'r1,'d2('r2d,'r3)");
   1285       break;
   1286     case LG:
   1287       Format(instr, "lg\t'r1,'d2('r2d,'r3)");
   1288       break;
   1289     case LGF:
   1290       Format(instr, "lgf\t'r1,'d2('r2d,'r3)");
   1291       break;
   1292     case LLGF:
   1293       Format(instr, "llgf\t'r1,'d2('r2d,'r3)");
   1294       break;
   1295     case LY:
   1296       Format(instr, "ly\t'r1,'d2('r2d,'r3)");
   1297       break;
   1298     case ALY:
   1299       Format(instr, "aly\t'r1,'d2('r2d,'r3)");
   1300       break;
   1301     case ALG:
   1302       Format(instr, "alg\t'r1,'d2('r2d,'r3)");
   1303       break;
   1304     case SLG:
   1305       Format(instr, "slg\t'r1,'d2('r2d,'r3)");
   1306       break;
   1307     case SGF:
   1308       Format(instr, "sgf\t'r1,'d2('r2d,'r3)");
   1309       break;
   1310     case SLY:
   1311       Format(instr, "sly\t'r1,'d2('r2d,'r3)");
   1312       break;
   1313     case LLH:
   1314       Format(instr, "llh\t'r1,'d2('r2d,'r3)");
   1315       break;
   1316     case LLGH:
   1317       Format(instr, "llgh\t'r1,'d2('r2d,'r3)");
   1318       break;
   1319     case LLC:
   1320       Format(instr, "llc\t'r1,'d2('r2d,'r3)");
   1321       break;
   1322     case LLGC:
   1323       Format(instr, "llgc\t'r1,'d2('r2d,'r3)");
   1324       break;
   1325     case LDEB:
   1326       Format(instr, "ldeb\t'f1,'d2('r2d,'r3)");
   1327       break;
   1328     case LAY:
   1329       Format(instr, "lay\t'r1,'d2('r2d,'r3)");
   1330       break;
   1331     case LARL:
   1332       Format(instr, "larl\t'r1,'i5");
   1333       break;
   1334     case LGB:
   1335       Format(instr, "lgb\t'r1,'d2('r2d,'r3)");
   1336       break;
   1337     case CHY:
   1338       Format(instr, "chy\t'r1,'d2('r2d,'r3)");
   1339       break;
   1340     case CLY:
   1341       Format(instr, "cly\t'r1,'d2('r2d,'r3)");
   1342       break;
   1343     case CLIY:
   1344       Format(instr, "cliy\t'd2('r3),'i8");
   1345       break;
   1346     case TMY:
   1347       Format(instr, "tmy\t'd2('r3),'i8");
   1348       break;
   1349     case CLG:
   1350       Format(instr, "clg\t'r1,'d2('r2d,'r3)");
   1351       break;
   1352     case BCTG:
   1353       Format(instr, "bctg\t'r1,'d2('r2d,'r3)");
   1354       break;
   1355     case STY:
   1356       Format(instr, "sty\t'r1,'d2('r2d,'r3)");
   1357       break;
   1358     case STRVH:
   1359       Format(instr, "strvh\t'r1,'d2('r2d,'r3)");
   1360       break;
   1361     case STRV:
   1362       Format(instr, "strv\t'r1,'d2('r2d,'r3)");
   1363       break;
   1364     case STRVG:
   1365       Format(instr, "strvg\t'r1,'d2('r2d,'r3)");
   1366       break;
   1367     case STG:
   1368       Format(instr, "stg\t'r1,'d2('r2d,'r3)");
   1369       break;
   1370     case ICY:
   1371       Format(instr, "icy\t'r1,'d2('r2d,'r3)");
   1372       break;
   1373     case MVC:
   1374       Format(instr, "mvc\t'd3('i8,'r3),'d4('r7)");
   1375       break;
   1376     case MVHI:
   1377       Format(instr, "mvhi\t'd3('r3),'id");
   1378       break;
   1379     case MVGHI:
   1380       Format(instr, "mvghi\t'd3('r3),'id");
   1381       break;
   1382     case ALGFI:
   1383       Format(instr, "algfi\t'r1,'i7");
   1384       break;
   1385     case SLGFI:
   1386       Format(instr, "slgfi\t'r1,'i7");
   1387       break;
   1388     case SLFI:
   1389       Format(instr, "slfi\t'r1,'i7");
   1390       break;
   1391     case NIHF:
   1392       Format(instr, "nihf\t'r1,'i7");
   1393       break;
   1394     case NILF:
   1395       Format(instr, "nilf\t'r1,'i7");
   1396       break;
   1397     case OIHF:
   1398       Format(instr, "oihf\t'r1,'i7");
   1399       break;
   1400     case OILF:
   1401       Format(instr, "oilf\t'r1,'i7");
   1402       break;
   1403     case MSFI:
   1404       Format(instr, "msfi\t'r1,'i7");
   1405       break;
   1406     case MSGFI:
   1407       Format(instr, "msgfi\t'r1,'i7");
   1408       break;
   1409     case LDY:
   1410       Format(instr, "ldy\t'f1,'d2('r2d,'r3)");
   1411       break;
   1412     case LEY:
   1413       Format(instr, "ley\t'f1,'d2('r2d,'r3)");
   1414       break;
   1415     case MSG:
   1416       Format(instr, "msg\t'r1,'d2('r2d,'r3)");
   1417       break;
   1418     case DSG:
   1419       Format(instr, "dsg\t'r1,'d2('r2d,'r3)");
   1420       break;
   1421     case DSGF:
   1422       Format(instr, "dsgf\t'r1,'d2('r2d,'r3)");
   1423       break;
   1424     case MSGF:
   1425       Format(instr, "msgf\t'r1,'d2('r2d,'r3)");
   1426       break;
   1427     case MSY:
   1428       Format(instr, "msy\t'r1,'d2('r2d,'r3)");
   1429       break;
   1430     case STEY:
   1431       Format(instr, "stey\t'f1,'d2('r2d,'r3)");
   1432       break;
   1433     case STDY:
   1434       Format(instr, "stdy\t'f1,'d2('r2d,'r3)");
   1435       break;
   1436     case ADB:
   1437       Format(instr, "adb\t'f1,'d1('r2d, 'r3)");
   1438       break;
   1439     case CDB:
   1440       Format(instr, "cdb\t'f1,'d1('r2d, 'r3)");
   1441       break;
   1442     case CEB:
   1443       Format(instr, "ceb\t'f1,'d1('r2d, 'r3)");
   1444       break;
   1445     case SDB:
   1446       Format(instr, "sdb\t'r1,'d1('r2d, 'r3)");
   1447       break;
   1448     case MDB:
   1449       Format(instr, "mdb\t'r1,'d1('r2d, 'r3)");
   1450       break;
   1451     case DDB:
   1452       Format(instr, "ddb\t'r1,'d1('r2d, 'r3)");
   1453       break;
   1454     case SQDB:
   1455       Format(instr, "sqdb\t'r1,'d1('r2d, 'r3)");
   1456       break;
   1457     case PFD:
   1458       Format(instr, "pfd\t'm1,'d2('r2d,'r3)");
   1459       break;
   1460     default:
   1461       return false;
   1462   }
   1463   return true;
   1464 }
   1465 
   1466 #undef VERIFIY
   1467 
   1468 // Disassemble the instruction at *instr_ptr into the output buffer.
   1469 int Decoder::InstructionDecode(byte* instr_ptr) {
   1470   Instruction* instr = Instruction::At(instr_ptr);
   1471   int instrLength = instr->InstructionLength();
   1472 
   1473   if (2 == instrLength)
   1474     DecodeTwoByte(instr);
   1475   else if (4 == instrLength)
   1476     DecodeFourByte(instr);
   1477   else
   1478     DecodeSixByte(instr);
   1479 
   1480   return instrLength;
   1481 }
   1482 
   1483 }  // namespace internal
   1484 }  // namespace v8
   1485 
   1486 //------------------------------------------------------------------------------
   1487 
   1488 namespace disasm {
   1489 
   1490 const char* NameConverter::NameOfAddress(byte* addr) const {
   1491   v8::internal::SNPrintF(tmp_buffer_, "%p", static_cast<void*>(addr));
   1492   return tmp_buffer_.start();
   1493 }
   1494 
   1495 const char* NameConverter::NameOfConstant(byte* addr) const {
   1496   return NameOfAddress(addr);
   1497 }
   1498 
   1499 const char* NameConverter::NameOfCPURegister(int reg) const {
   1500   return v8::internal::GetRegConfig()->GetGeneralRegisterName(reg);
   1501 }
   1502 
   1503 const char* NameConverter::NameOfByteCPURegister(int reg) const {
   1504   UNREACHABLE();  // S390 does not have the concept of a byte register
   1505   return "nobytereg";
   1506 }
   1507 
   1508 const char* NameConverter::NameOfXMMRegister(int reg) const {
   1509   // S390 does not have XMM register
   1510   // TODO(joransiu): Consider update this for Vector Regs
   1511   UNREACHABLE();
   1512   return "noxmmreg";
   1513 }
   1514 
   1515 const char* NameConverter::NameInCode(byte* addr) const {
   1516   // The default name converter is called for unknown code. So we will not try
   1517   // to access any memory.
   1518   return "";
   1519 }
   1520 
   1521 //------------------------------------------------------------------------------
   1522 
   1523 Disassembler::Disassembler(const NameConverter& converter)
   1524     : converter_(converter) {}
   1525 
   1526 Disassembler::~Disassembler() {}
   1527 
   1528 int Disassembler::InstructionDecode(v8::internal::Vector<char> buffer,
   1529                                     byte* instruction) {
   1530   v8::internal::Decoder d(converter_, buffer);
   1531   return d.InstructionDecode(instruction);
   1532 }
   1533 
   1534 // The S390 assembler does not currently use constant pools.
   1535 int Disassembler::ConstantPoolSizeAt(byte* instruction) { return -1; }
   1536 
   1537 void Disassembler::Disassemble(FILE* f, byte* begin, byte* end) {
   1538   NameConverter converter;
   1539   Disassembler d(converter);
   1540   for (byte* pc = begin; pc < end;) {
   1541     v8::internal::EmbeddedVector<char, 128> buffer;
   1542     buffer[0] = '\0';
   1543     byte* prev_pc = pc;
   1544     pc += d.InstructionDecode(buffer, pc);
   1545     v8::internal::PrintF(f, "%p    %08x      %s\n", static_cast<void*>(prev_pc),
   1546                          *reinterpret_cast<int32_t*>(prev_pc), buffer.start());
   1547   }
   1548 }
   1549 
   1550 }  // namespace disasm
   1551 
   1552 #endif  // V8_TARGET_ARCH_S390
   1553