170de1e442d30eceea6d71ef5403f06323eda7e55Craig Topper//===-- HexagonMCTargetDesc.cpp - Hexagon Target Descriptions -------------===// 2d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum// 3d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum// The LLVM Compiler Infrastructure 4d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum// 5d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum// This file is distributed under the University of Illinois Open Source 6d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum// License. See LICENSE.TXT for details. 7d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum// 8d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum//===----------------------------------------------------------------------===// 9d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum// 108aea2dd964752c4bc222244a696f101f1d35591bCraig Topper// This file provides Hexagon specific target descriptions. 11d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum// 12d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum//===----------------------------------------------------------------------===// 13d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 14d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#include "HexagonMCTargetDesc.h" 15d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#include "HexagonMCAsmInfo.h" 16d6c98ae63824854ea2175b362a10985cac7cfb32Jyotsna Verma#include "InstPrinter/HexagonInstPrinter.h" 17d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#include "llvm/MC/MCCodeGenInfo.h" 18d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#include "llvm/MC/MCInstrInfo.h" 19d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#include "llvm/MC/MCRegisterInfo.h" 20d6c98ae63824854ea2175b362a10985cac7cfb32Jyotsna Verma#include "llvm/MC/MCStreamer.h" 21d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#include "llvm/MC/MCSubtargetInfo.h" 2236b56886974eae4f9c5ebc96befd3e7bfe5de338Stephen Hines#include "llvm/MC/MachineLocation.h" 23655b8de7b2ab773a977e0c524307e71354d8af29Craig Topper#include "llvm/Support/ErrorHandling.h" 24d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#include "llvm/Support/TargetRegistry.h" 25d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 26dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hinesusing namespace llvm; 27dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines 28d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#define GET_INSTRINFO_MC_DESC 29d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#include "HexagonGenInstrInfo.inc" 30d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 31d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#define GET_SUBTARGETINFO_MC_DESC 32d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#include "HexagonGenSubtargetInfo.inc" 33d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 34d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#define GET_REGINFO_MC_DESC 35d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum#include "HexagonGenRegisterInfo.inc" 36d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 37d239ff67f210094c205be7e57332948caecf6a24Tony Linthicumstatic MCInstrInfo *createHexagonMCInstrInfo() { 38d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum MCInstrInfo *X = new MCInstrInfo(); 39d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum InitHexagonMCInstrInfo(X); 40d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum return X; 41d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum} 42d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 43d239ff67f210094c205be7e57332948caecf6a24Tony Linthicumstatic MCRegisterInfo *createHexagonMCRegisterInfo(StringRef TT) { 44d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum MCRegisterInfo *X = new MCRegisterInfo(); 45d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum InitHexagonMCRegisterInfo(X, Hexagon::R0); 46d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum return X; 47d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum} 48d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 49d239ff67f210094c205be7e57332948caecf6a24Tony Linthicumstatic MCSubtargetInfo *createHexagonMCSubtargetInfo(StringRef TT, 50d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum StringRef CPU, 51d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum StringRef FS) { 52d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum MCSubtargetInfo *X = new MCSubtargetInfo(); 53d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum InitHexagonMCSubtargetInfo(X, TT, CPU, FS); 54d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum return X; 55d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum} 56d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 574a971705bc6030dc2e4338b3cd5cffa2e0f88b7bRafael Espindolastatic MCAsmInfo *createHexagonMCAsmInfo(const MCRegisterInfo &MRI, 584a971705bc6030dc2e4338b3cd5cffa2e0f88b7bRafael Espindola StringRef TT) { 596e53180db120b30f600ac31611a9dd47ef7f4921Rafael Espindola MCAsmInfo *MAI = new HexagonMCAsmInfo(TT); 60d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 61d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum // VirtualFP = (R30 + #0). 624a971705bc6030dc2e4338b3cd5cffa2e0f88b7bRafael Espindola MCCFIInstruction Inst = MCCFIInstruction::createDefCfa( 63dce4a407a24b04eebc6a376f8e62b41aaa7b071fStephen Hines nullptr, Hexagon::R30, 0); 644a971705bc6030dc2e4338b3cd5cffa2e0f88b7bRafael Espindola MAI->addInitialFrameState(Inst); 65d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 66d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum return MAI; 67d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum} 68d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 69d239ff67f210094c205be7e57332948caecf6a24Tony Linthicumstatic MCCodeGenInfo *createHexagonMCCodeGenInfo(StringRef TT, Reloc::Model RM, 70d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum CodeModel::Model CM, 71d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum CodeGenOpt::Level OL) { 72d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum MCCodeGenInfo *X = new MCCodeGenInfo(); 73d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum // For the time being, use static relocations, since there's really no 74d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum // support for PIC yet. 75d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum X->InitMCCodeGenInfo(Reloc::Static, CM, OL); 76d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum return X; 77d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum} 78d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 79d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum// Force static initialization. 80d239ff67f210094c205be7e57332948caecf6a24Tony Linthicumextern "C" void LLVMInitializeHexagonTargetMC() { 81d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum // Register the MC asm info. 82d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum RegisterMCAsmInfoFn X(TheHexagonTarget, createHexagonMCAsmInfo); 83d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 84d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum // Register the MC codegen info. 85d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum TargetRegistry::RegisterMCCodeGenInfo(TheHexagonTarget, 86d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum createHexagonMCCodeGenInfo); 87d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 88d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum // Register the MC instruction info. 89d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum TargetRegistry::RegisterMCInstrInfo(TheHexagonTarget, createHexagonMCInstrInfo); 90d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 91d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum // Register the MC register info. 92d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum TargetRegistry::RegisterMCRegInfo(TheHexagonTarget, 93d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum createHexagonMCRegisterInfo); 94d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum 95d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum // Register the MC subtarget info. 96d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum TargetRegistry::RegisterMCSubtargetInfo(TheHexagonTarget, 97d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum createHexagonMCSubtargetInfo); 98d239ff67f210094c205be7e57332948caecf6a24Tony Linthicum} 99