10b57cec5SDimitry Andric //===-- SystemZMCTargetDesc.h - SystemZ target descriptions -----*- C++ -*-===// 20b57cec5SDimitry Andric // 30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric // 70b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric 90b57cec5SDimitry Andric #ifndef LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZMCTARGETDESC_H 100b57cec5SDimitry Andric #define LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZMCTARGETDESC_H 110b57cec5SDimitry Andric 120b57cec5SDimitry Andric #include "llvm/Support/DataTypes.h" 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric #include <memory> 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric namespace llvm { 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric class MCAsmBackend; 190b57cec5SDimitry Andric class MCCodeEmitter; 200b57cec5SDimitry Andric class MCContext; 210b57cec5SDimitry Andric class MCInstrInfo; 220b57cec5SDimitry Andric class MCObjectTargetWriter; 230b57cec5SDimitry Andric class MCRegisterInfo; 240b57cec5SDimitry Andric class MCSubtargetInfo; 250b57cec5SDimitry Andric class MCTargetOptions; 260b57cec5SDimitry Andric class Target; 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric namespace SystemZMC { 290b57cec5SDimitry Andric // How many bytes are in the ABI-defined, caller-allocated part of 300b57cec5SDimitry Andric // a stack frame. 31fe6060f1SDimitry Andric const int64_t ELFCallFrameSize = 160; 320b57cec5SDimitry Andric 330b57cec5SDimitry Andric // The offset of the DWARF CFA from the incoming stack pointer. 34fe6060f1SDimitry Andric const int64_t ELFCFAOffsetFromInitialSP = ELFCallFrameSize; 350b57cec5SDimitry Andric 360b57cec5SDimitry Andric // Maps of asm register numbers to LLVM register numbers, with 0 indicating 370b57cec5SDimitry Andric // an invalid register. In principle we could use 32-bit and 64-bit register 380b57cec5SDimitry Andric // classes directly, provided that we relegated the GPR allocation order 390b57cec5SDimitry Andric // in SystemZRegisterInfo.td to an AltOrder and left the default order 400b57cec5SDimitry Andric // as %r0-%r15. It seems better to provide the same interface for 410b57cec5SDimitry Andric // all classes though. 420b57cec5SDimitry Andric extern const unsigned GR32Regs[16]; 430b57cec5SDimitry Andric extern const unsigned GRH32Regs[16]; 440b57cec5SDimitry Andric extern const unsigned GR64Regs[16]; 450b57cec5SDimitry Andric extern const unsigned GR128Regs[16]; 460b57cec5SDimitry Andric extern const unsigned FP32Regs[16]; 470b57cec5SDimitry Andric extern const unsigned FP64Regs[16]; 480b57cec5SDimitry Andric extern const unsigned FP128Regs[16]; 490b57cec5SDimitry Andric extern const unsigned VR32Regs[32]; 500b57cec5SDimitry Andric extern const unsigned VR64Regs[32]; 510b57cec5SDimitry Andric extern const unsigned VR128Regs[32]; 520b57cec5SDimitry Andric extern const unsigned AR32Regs[16]; 530b57cec5SDimitry Andric extern const unsigned CR64Regs[16]; 540b57cec5SDimitry Andric 550b57cec5SDimitry Andric // Return the 0-based number of the first architectural register that 560b57cec5SDimitry Andric // contains the given LLVM register. E.g. R1D -> 1. 570b57cec5SDimitry Andric unsigned getFirstReg(unsigned Reg); 580b57cec5SDimitry Andric 590b57cec5SDimitry Andric // Return the given register as a GR64. 600b57cec5SDimitry Andric inline unsigned getRegAsGR64(unsigned Reg) { 610b57cec5SDimitry Andric return GR64Regs[getFirstReg(Reg)]; 620b57cec5SDimitry Andric } 630b57cec5SDimitry Andric 640b57cec5SDimitry Andric // Return the given register as a low GR32. 650b57cec5SDimitry Andric inline unsigned getRegAsGR32(unsigned Reg) { 660b57cec5SDimitry Andric return GR32Regs[getFirstReg(Reg)]; 670b57cec5SDimitry Andric } 680b57cec5SDimitry Andric 690b57cec5SDimitry Andric // Return the given register as a high GR32. 700b57cec5SDimitry Andric inline unsigned getRegAsGRH32(unsigned Reg) { 710b57cec5SDimitry Andric return GRH32Regs[getFirstReg(Reg)]; 720b57cec5SDimitry Andric } 730b57cec5SDimitry Andric 740b57cec5SDimitry Andric // Return the given register as a VR128. 750b57cec5SDimitry Andric inline unsigned getRegAsVR128(unsigned Reg) { 760b57cec5SDimitry Andric return VR128Regs[getFirstReg(Reg)]; 770b57cec5SDimitry Andric } 780b57cec5SDimitry Andric } // end namespace SystemZMC 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric MCCodeEmitter *createSystemZMCCodeEmitter(const MCInstrInfo &MCII, 810b57cec5SDimitry Andric MCContext &Ctx); 820b57cec5SDimitry Andric 830b57cec5SDimitry Andric MCAsmBackend *createSystemZMCAsmBackend(const Target &T, 840b57cec5SDimitry Andric const MCSubtargetInfo &STI, 850b57cec5SDimitry Andric const MCRegisterInfo &MRI, 860b57cec5SDimitry Andric const MCTargetOptions &Options); 870b57cec5SDimitry Andric 88*5f757f3fSDimitry Andric std::unique_ptr<MCObjectTargetWriter> 89*5f757f3fSDimitry Andric createSystemZELFObjectWriter(uint8_t OSABI); 90*5f757f3fSDimitry Andric std::unique_ptr<MCObjectTargetWriter> createSystemZGOFFObjectWriter(); 910b57cec5SDimitry Andric } // end namespace llvm 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric // Defines symbolic names for SystemZ registers. 940b57cec5SDimitry Andric // This defines a mapping from register name to register number. 950b57cec5SDimitry Andric #define GET_REGINFO_ENUM 960b57cec5SDimitry Andric #include "SystemZGenRegisterInfo.inc" 970b57cec5SDimitry Andric 980b57cec5SDimitry Andric // Defines symbolic names for the SystemZ instructions. 990b57cec5SDimitry Andric #define GET_INSTRINFO_ENUM 100753f127fSDimitry Andric #define GET_INSTRINFO_MC_HELPER_DECLS 1010b57cec5SDimitry Andric #include "SystemZGenInstrInfo.inc" 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andric #define GET_SUBTARGETINFO_ENUM 1040b57cec5SDimitry Andric #include "SystemZGenSubtargetInfo.inc" 1050b57cec5SDimitry Andric 1060b57cec5SDimitry Andric #endif 107