Home | History | Annotate | Download | only in SystemZ
      1 //===-- SystemZMCTargetDesc.cpp - SystemZ target descriptions -------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 /* Capstone Disassembly Engine */
     11 /* By Nguyen Anh Quynh <aquynh (at) gmail.com>, 2013-2014 */
     12 
     13 #ifdef CAPSTONE_HAS_SYSZ
     14 
     15 #include "SystemZMCTargetDesc.h"
     16 
     17 #define GET_REGINFO_ENUM
     18 #include "SystemZGenRegisterInfo.inc"
     19 
     20 const unsigned SystemZMC_GR32Regs[16] = {
     21 	SystemZ_R0L, SystemZ_R1L, SystemZ_R2L, SystemZ_R3L,
     22 	SystemZ_R4L, SystemZ_R5L, SystemZ_R6L, SystemZ_R7L,
     23 	SystemZ_R8L, SystemZ_R9L, SystemZ_R10L, SystemZ_R11L,
     24 	SystemZ_R12L, SystemZ_R13L, SystemZ_R14L, SystemZ_R15L
     25 };
     26 
     27 const unsigned SystemZMC_GRH32Regs[16] = {
     28 	SystemZ_R0H, SystemZ_R1H, SystemZ_R2H, SystemZ_R3H,
     29 	SystemZ_R4H, SystemZ_R5H, SystemZ_R6H, SystemZ_R7H,
     30 	SystemZ_R8H, SystemZ_R9H, SystemZ_R10H, SystemZ_R11H,
     31 	SystemZ_R12H, SystemZ_R13H, SystemZ_R14H, SystemZ_R15H
     32 };
     33 
     34 const unsigned SystemZMC_GR64Regs[16] = {
     35 	SystemZ_R0D, SystemZ_R1D, SystemZ_R2D, SystemZ_R3D,
     36 	SystemZ_R4D, SystemZ_R5D, SystemZ_R6D, SystemZ_R7D,
     37 	SystemZ_R8D, SystemZ_R9D, SystemZ_R10D, SystemZ_R11D,
     38 	SystemZ_R12D, SystemZ_R13D, SystemZ_R14D, SystemZ_R15D
     39 };
     40 
     41 const unsigned SystemZMC_GR128Regs[16] = {
     42 	SystemZ_R0Q, 0, SystemZ_R2Q, 0,
     43 	SystemZ_R4Q, 0, SystemZ_R6Q, 0,
     44 	SystemZ_R8Q, 0, SystemZ_R10Q, 0,
     45 	SystemZ_R12Q, 0, SystemZ_R14Q, 0
     46 };
     47 
     48 const unsigned SystemZMC_FP32Regs[16] = {
     49 	SystemZ_F0S, SystemZ_F1S, SystemZ_F2S, SystemZ_F3S,
     50 	SystemZ_F4S, SystemZ_F5S, SystemZ_F6S, SystemZ_F7S,
     51 	SystemZ_F8S, SystemZ_F9S, SystemZ_F10S, SystemZ_F11S,
     52 	SystemZ_F12S, SystemZ_F13S, SystemZ_F14S, SystemZ_F15S
     53 };
     54 
     55 const unsigned SystemZMC_FP64Regs[16] = {
     56 	SystemZ_F0D, SystemZ_F1D, SystemZ_F2D, SystemZ_F3D,
     57 	SystemZ_F4D, SystemZ_F5D, SystemZ_F6D, SystemZ_F7D,
     58 	SystemZ_F8D, SystemZ_F9D, SystemZ_F10D, SystemZ_F11D,
     59 	SystemZ_F12D, SystemZ_F13D, SystemZ_F14D, SystemZ_F15D
     60 };
     61 
     62 const unsigned SystemZMC_FP128Regs[16] = {
     63 	SystemZ_F0Q, SystemZ_F1Q, 0, 0,
     64 	SystemZ_F4Q, SystemZ_F5Q, 0, 0,
     65 	SystemZ_F8Q, SystemZ_F9Q, 0, 0,
     66 	SystemZ_F12Q, SystemZ_F13Q, 0, 0
     67 };
     68 
     69 unsigned SystemZMC_getFirstReg(unsigned Reg)
     70 {
     71 	static unsigned Map[SystemZ_NUM_TARGET_REGS];
     72 	static int Initialized = 0;
     73 	unsigned I;
     74 
     75 	if (!Initialized) {
     76 		Initialized = 1;
     77 		for (I = 0; I < 16; ++I) {
     78 			Map[SystemZMC_GR32Regs[I]] = I;
     79 			Map[SystemZMC_GRH32Regs[I]] = I;
     80 			Map[SystemZMC_GR64Regs[I]] = I;
     81 			Map[SystemZMC_GR128Regs[I]] = I;
     82 			Map[SystemZMC_FP32Regs[I]] = I;
     83 			Map[SystemZMC_FP64Regs[I]] = I;
     84 			Map[SystemZMC_FP128Regs[I]] = I;
     85 		}
     86 	}
     87 
     88 	// assert(Reg < SystemZ_NUM_TARGET_REGS);
     89 	return Map[Reg];
     90 }
     91 
     92 #endif
     93