diff options
Diffstat (limited to 'llvm/lib/Target/VE/MCTargetDesc')
| -rw-r--r-- | llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.cpp | 40 | ||||
| -rw-r--r-- | llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.h | 31 | ||||
| -rw-r--r-- | llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp | 106 | ||||
| -rw-r--r-- | llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.h | 53 | ||||
| -rw-r--r-- | llvm/lib/Target/VE/MCTargetDesc/VETargetStreamer.cpp | 44 | ||||
| -rw-r--r-- | llvm/lib/Target/VE/MCTargetDesc/VETargetStreamer.h | 47 |
6 files changed, 321 insertions, 0 deletions
diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.cpp new file mode 100644 index 0000000000000..9f29fc092c697 --- /dev/null +++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.cpp @@ -0,0 +1,40 @@ +//===- VEMCAsmInfo.cpp - VE asm properties --------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains the declarations of the VEMCAsmInfo properties. +// +//===----------------------------------------------------------------------===// + +#include "VEMCAsmInfo.h" +#include "llvm/ADT/Triple.h" +#include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCStreamer.h" +#include "llvm/MC/MCTargetOptions.h" + +using namespace llvm; + +void VEELFMCAsmInfo::anchor() {} + +VEELFMCAsmInfo::VEELFMCAsmInfo(const Triple &TheTriple) { + + CodePointerSize = CalleeSaveStackSlotSize = 8; + MaxInstLength = MinInstAlignment = 8; + + // VE uses ".*byte" directive for unaligned data. + Data8bitsDirective = "\t.byte\t"; + Data16bitsDirective = "\t.2byte\t"; + Data32bitsDirective = "\t.4byte\t"; + Data64bitsDirective = "\t.8byte\t"; + + // Uses '.section' before '.bss' directive. VE requires this although + // assembler manual says sinple '.bss' is supported. + UsesELFSectionDirectiveForBSS = true; + + SupportsDebugInformation = true; +} diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.h b/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.h new file mode 100644 index 0000000000000..6557d68b383cd --- /dev/null +++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCAsmInfo.h @@ -0,0 +1,31 @@ +//===- VEMCAsmInfo.h - VE asm properties -----------------------*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file contains the declaration of the VEMCAsmInfo class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_TARGET_VE_MCTARGETDESC_VEMCASMINFO_H +#define LLVM_LIB_TARGET_VE_MCTARGETDESC_VEMCASMINFO_H + +#include "llvm/MC/MCAsmInfoELF.h" + +namespace llvm { + +class Triple; + +class VEELFMCAsmInfo : public MCAsmInfoELF { + void anchor() override; + +public: + explicit VEELFMCAsmInfo(const Triple &TheTriple); +}; + +} // namespace llvm + +#endif // LLVM_LIB_TARGET_VE_MCTARGETDESC_VEMCASMINFO_H diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp b/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp new file mode 100644 index 0000000000000..b228617058a6a --- /dev/null +++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.cpp @@ -0,0 +1,106 @@ +//===-- VEMCTargetDesc.cpp - VE Target Descriptions -----------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file provides VE specific target descriptions. +// +//===----------------------------------------------------------------------===// + +#include "VEMCTargetDesc.h" +#include "InstPrinter/VEInstPrinter.h" +#include "VEMCAsmInfo.h" +#include "VETargetStreamer.h" +#include "llvm/MC/MCInstrInfo.h" +#include "llvm/MC/MCRegisterInfo.h" +#include "llvm/MC/MCSubtargetInfo.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/TargetRegistry.h" + +using namespace llvm; + +#define GET_INSTRINFO_MC_DESC +#include "VEGenInstrInfo.inc" + +#define GET_SUBTARGETINFO_MC_DESC +#include "VEGenSubtargetInfo.inc" + +#define GET_REGINFO_MC_DESC +#include "VEGenRegisterInfo.inc" + +static MCAsmInfo *createVEMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT, + const MCTargetOptions &Options) { + MCAsmInfo *MAI = new VEELFMCAsmInfo(TT); + unsigned Reg = MRI.getDwarfRegNum(VE::SX11, true); + MCCFIInstruction Inst = MCCFIInstruction::createDefCfa(nullptr, Reg, 0); + MAI->addInitialFrameState(Inst); + return MAI; +} + +static MCInstrInfo *createVEMCInstrInfo() { + MCInstrInfo *X = new MCInstrInfo(); + InitVEMCInstrInfo(X); + return X; +} + +static MCRegisterInfo *createVEMCRegisterInfo(const Triple &TT) { + MCRegisterInfo *X = new MCRegisterInfo(); + InitVEMCRegisterInfo(X, VE::SX10); + return X; +} + +static MCSubtargetInfo *createVEMCSubtargetInfo(const Triple &TT, StringRef CPU, + StringRef FS) { + if (CPU.empty()) + CPU = "ve"; + return createVEMCSubtargetInfoImpl(TT, CPU, FS); +} + +static MCTargetStreamer * +createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) { + return new VETargetELFStreamer(S); +} + +static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S, + formatted_raw_ostream &OS, + MCInstPrinter *InstPrint, + bool isVerboseAsm) { + return new VETargetAsmStreamer(S, OS); +} + +static MCInstPrinter *createVEMCInstPrinter(const Triple &T, + unsigned SyntaxVariant, + const MCAsmInfo &MAI, + const MCInstrInfo &MII, + const MCRegisterInfo &MRI) { + return new VEInstPrinter(MAI, MII, MRI); +} + +extern "C" void LLVMInitializeVETargetMC() { + // Register the MC asm info. + RegisterMCAsmInfoFn X(getTheVETarget(), createVEMCAsmInfo); + + for (Target *T : {&getTheVETarget()}) { + // Register the MC instruction info. + TargetRegistry::RegisterMCInstrInfo(*T, createVEMCInstrInfo); + + // Register the MC register info. + TargetRegistry::RegisterMCRegInfo(*T, createVEMCRegisterInfo); + + // Register the MC subtarget info. + TargetRegistry::RegisterMCSubtargetInfo(*T, createVEMCSubtargetInfo); + + // Register the object target streamer. + TargetRegistry::RegisterObjectTargetStreamer(*T, + createObjectTargetStreamer); + + // Register the asm streamer. + TargetRegistry::RegisterAsmTargetStreamer(*T, createTargetAsmStreamer); + + // Register the MCInstPrinter + TargetRegistry::RegisterMCInstPrinter(*T, createVEMCInstPrinter); + } +} diff --git a/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.h b/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.h new file mode 100644 index 0000000000000..24a5c8209be27 --- /dev/null +++ b/llvm/lib/Target/VE/MCTargetDesc/VEMCTargetDesc.h @@ -0,0 +1,53 @@ +//===-- VEMCTargetDesc.h - VE Target Descriptions ---------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file provides VE specific target descriptions. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_TARGET_VE_MCTARGETDESC_VEMCTARGETDESC_H +#define LLVM_LIB_TARGET_VE_MCTARGETDESC_VEMCTARGETDESC_H + +#include "llvm/Support/DataTypes.h" + +#include <memory> + +namespace llvm { +class MCAsmBackend; +class MCCodeEmitter; +class MCContext; +class MCInstrInfo; +class MCObjectWriter; +class MCRegisterInfo; +class MCSubtargetInfo; +class MCTargetOptions; +class Target; +class Triple; +class StringRef; +class raw_pwrite_stream; +class raw_ostream; + +Target &getTheVETarget(); + +} // namespace llvm + +// Defines symbolic names for VE registers. This defines a mapping from +// register name to register number. +// +#define GET_REGINFO_ENUM +#include "VEGenRegisterInfo.inc" + +// Defines symbolic names for the VE instructions. +// +#define GET_INSTRINFO_ENUM +#include "VEGenInstrInfo.inc" + +#define GET_SUBTARGETINFO_ENUM +#include "VEGenSubtargetInfo.inc" + +#endif diff --git a/llvm/lib/Target/VE/MCTargetDesc/VETargetStreamer.cpp b/llvm/lib/Target/VE/MCTargetDesc/VETargetStreamer.cpp new file mode 100644 index 0000000000000..dfe94bbaaa4bf --- /dev/null +++ b/llvm/lib/Target/VE/MCTargetDesc/VETargetStreamer.cpp @@ -0,0 +1,44 @@ +//===-- VETargetStreamer.cpp - VE Target Streamer Methods -----------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file provides VE specific target streamer methods. +// +//===----------------------------------------------------------------------===// + +#include "VETargetStreamer.h" +#include "InstPrinter/VEInstPrinter.h" +#include "llvm/Support/FormattedStream.h" + +using namespace llvm; + +// pin vtable to this file +VETargetStreamer::VETargetStreamer(MCStreamer &S) : MCTargetStreamer(S) {} + +void VETargetStreamer::anchor() {} + +VETargetAsmStreamer::VETargetAsmStreamer(MCStreamer &S, + formatted_raw_ostream &OS) + : VETargetStreamer(S), OS(OS) {} + +void VETargetAsmStreamer::emitVERegisterIgnore(unsigned reg) { + OS << "\t.register " + << "%" << StringRef(VEInstPrinter::getRegisterName(reg)).lower() + << ", #ignore\n"; +} + +void VETargetAsmStreamer::emitVERegisterScratch(unsigned reg) { + OS << "\t.register " + << "%" << StringRef(VEInstPrinter::getRegisterName(reg)).lower() + << ", #scratch\n"; +} + +VETargetELFStreamer::VETargetELFStreamer(MCStreamer &S) : VETargetStreamer(S) {} + +MCELFStreamer &VETargetELFStreamer::getStreamer() { + return static_cast<MCELFStreamer &>(Streamer); +} diff --git a/llvm/lib/Target/VE/MCTargetDesc/VETargetStreamer.h b/llvm/lib/Target/VE/MCTargetDesc/VETargetStreamer.h new file mode 100644 index 0000000000000..6f6a0d4b02d79 --- /dev/null +++ b/llvm/lib/Target/VE/MCTargetDesc/VETargetStreamer.h @@ -0,0 +1,47 @@ +//===-- VETargetStreamer.h - VE Target Streamer ----------------*- C++ -*--===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_LIB_TARGET_VE_VETARGETSTREAMER_H +#define LLVM_LIB_TARGET_VE_VETARGETSTREAMER_H + +#include "llvm/MC/MCELFStreamer.h" +#include "llvm/MC/MCStreamer.h" + +namespace llvm { +class VETargetStreamer : public MCTargetStreamer { + virtual void anchor(); + +public: + VETargetStreamer(MCStreamer &S); + /// Emit ".register <reg>, #ignore". + virtual void emitVERegisterIgnore(unsigned reg) = 0; + /// Emit ".register <reg>, #scratch". + virtual void emitVERegisterScratch(unsigned reg) = 0; +}; + +// This part is for ascii assembly output +class VETargetAsmStreamer : public VETargetStreamer { + formatted_raw_ostream &OS; + +public: + VETargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS); + void emitVERegisterIgnore(unsigned reg) override; + void emitVERegisterScratch(unsigned reg) override; +}; + +// This part is for ELF object output +class VETargetELFStreamer : public VETargetStreamer { +public: + VETargetELFStreamer(MCStreamer &S); + MCELFStreamer &getStreamer(); + void emitVERegisterIgnore(unsigned reg) override {} + void emitVERegisterScratch(unsigned reg) override {} +}; +} // namespace llvm + +#endif |
