-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SystemZ] Split SystemZInstPrinter to two classes based on Asm dialect (
#112975) In preparation for future work on separating the output of the GNU/HLASM ASM dialects, we first separate the SystemZInstPrinter classes to two versions, one for each ASM dialect. The common code remains in a SystemZInstPrinterCommon class instead. --------- Co-authored-by: Tony Tao <[email protected]>
- Loading branch information
Showing
13 changed files
with
455 additions
and
297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZGNUInstPrinter.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//===- SystemZGNUInstPrinter.cpp - Convert SystemZ MCInst to GNU assembly -===// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "SystemZGNUInstPrinter.h" | ||
#include "llvm/MC/MCInst.h" | ||
#include "llvm/MC/MCRegister.h" | ||
#include "llvm/Support/raw_ostream.h" | ||
|
||
using namespace llvm; | ||
|
||
#define DEBUG_TYPE "asm-printer" | ||
|
||
#include "SystemZGenGNUAsmWriter.inc" | ||
|
||
void SystemZGNUInstPrinter::printFormattedRegName(const MCAsmInfo *MAI, | ||
MCRegister Reg, | ||
raw_ostream &O) const { | ||
const char *RegName = getRegisterName(Reg); | ||
markup(O, Markup::Register) << '%' << RegName; | ||
} | ||
|
||
void SystemZGNUInstPrinter::printInst(const MCInst *MI, uint64_t Address, | ||
StringRef Annot, | ||
const MCSubtargetInfo &STI, | ||
raw_ostream &O) { | ||
printInstruction(MI, Address, O); | ||
printAnnotation(O, Annot); | ||
} |
46 changes: 46 additions & 0 deletions
46
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZGNUInstPrinter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//=- SystemZGNUInstPrinter.h - Convert SystemZ MCInst to assembly -*- 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 class prints a SystemZ MCInst to a .s file in GNU assembly format. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZGNUINSTPRINTER_H | ||
#define LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZGNUINSTPRINTER_H | ||
|
||
#include "SystemZInstPrinterCommon.h" | ||
#include "llvm/MC/MCInstPrinter.h" | ||
#include <cstdint> | ||
|
||
namespace llvm { | ||
|
||
class MCOperand; | ||
|
||
class SystemZGNUInstPrinter : public SystemZInstPrinterCommon { | ||
public: | ||
SystemZGNUInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, | ||
const MCRegisterInfo &MRI) | ||
: SystemZInstPrinterCommon(MAI, MII, MRI) {} | ||
|
||
// Automatically generated by tblgen. | ||
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override; | ||
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); | ||
static const char *getRegisterName(MCRegister Reg); | ||
|
||
// Override MCInstPrinter. | ||
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, | ||
const MCSubtargetInfo &STI, raw_ostream &O) override; | ||
|
||
private: | ||
void printFormattedRegName(const MCAsmInfo *MAI, MCRegister Reg, | ||
raw_ostream &O) const override; | ||
}; | ||
|
||
} // end namespace llvm | ||
|
||
#endif // LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZGNUINSTPRINTER_H |
35 changes: 35 additions & 0 deletions
35
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMInstPrinter.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//=- SystemZHLASMInstPrinter.cpp - Convert SystemZ MCInst to HLASM assembly -=// | ||
// | ||
// 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 | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "SystemZHLASMInstPrinter.h" | ||
#include "llvm/MC/MCInst.h" | ||
#include "llvm/MC/MCRegister.h" | ||
#include "llvm/Support/raw_ostream.h" | ||
|
||
using namespace llvm; | ||
|
||
#define DEBUG_TYPE "asm-printer" | ||
|
||
#include "SystemZGenHLASMAsmWriter.inc" | ||
|
||
void SystemZHLASMInstPrinter::printFormattedRegName(const MCAsmInfo *MAI, | ||
MCRegister Reg, | ||
raw_ostream &O) const { | ||
const char *RegName = getRegisterName(Reg); | ||
// Skip register prefix so that only register number is left | ||
assert(isalpha(RegName[0]) && isdigit(RegName[1])); | ||
markup(O, Markup::Register) << (RegName + 1); | ||
} | ||
|
||
void SystemZHLASMInstPrinter::printInst(const MCInst *MI, uint64_t Address, | ||
StringRef Annot, | ||
const MCSubtargetInfo &STI, | ||
raw_ostream &O) { | ||
printInstruction(MI, Address, O); | ||
printAnnotation(O, Annot); | ||
} |
45 changes: 45 additions & 0 deletions
45
llvm/lib/Target/SystemZ/MCTargetDesc/SystemZHLASMInstPrinter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//- SystemZHLASMInstPrinter.h - Convert SystemZ MCInst to assembly -*- 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 class prints a SystemZ MCInst to a .s file in HLASM assembly format. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZHLASMINSTPRINTER_H | ||
#define LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZHLASMINSTPRINTER_H | ||
|
||
#include "SystemZInstPrinterCommon.h" | ||
#include "llvm/MC/MCInstPrinter.h" | ||
#include <cstdint> | ||
|
||
namespace llvm { | ||
|
||
class MCOperand; | ||
|
||
class SystemZHLASMInstPrinter : public SystemZInstPrinterCommon { | ||
public: | ||
SystemZHLASMInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII, | ||
const MCRegisterInfo &MRI) | ||
: SystemZInstPrinterCommon(MAI, MII, MRI) {} | ||
|
||
// Automatically generated by tblgen. | ||
std::pair<const char *, uint64_t> getMnemonic(const MCInst *MI) override; | ||
void printInstruction(const MCInst *MI, uint64_t Address, raw_ostream &O); | ||
static const char *getRegisterName(MCRegister Reg); | ||
|
||
void printInst(const MCInst *MI, uint64_t Address, StringRef Annot, | ||
const MCSubtargetInfo &STI, raw_ostream &O) override; | ||
|
||
private: | ||
void printFormattedRegName(const MCAsmInfo *MAI, MCRegister Reg, | ||
raw_ostream &O) const override; | ||
}; | ||
|
||
} // end namespace llvm | ||
|
||
#endif // LLVM_LIB_TARGET_SYSTEMZ_MCTARGETDESC_SYSTEMZHLASMINSTPRINTER_H |
Oops, something went wrong.