2014-05-24 20:50:23 +08:00
|
|
|
//===-- AArch64InstPrinter.h - Convert AArch64 MCInst to assembly syntax --===//
|
2014-03-29 18:18:08 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2014-05-24 20:50:23 +08:00
|
|
|
// This class prints an AArch64 MCInst to a .s file.
|
2014-03-29 18:18:08 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_AARCH64_INSTPRINTER_AARCH64INSTPRINTER_H
|
|
|
|
#define LLVM_LIB_TARGET_AARCH64_INSTPRINTER_AARCH64INSTPRINTER_H
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2014-05-24 20:50:23 +08:00
|
|
|
#include "MCTargetDesc/AArch64MCTargetDesc.h"
|
2017-02-04 05:49:13 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2014-03-29 18:18:08 +08:00
|
|
|
#include "llvm/MC/MCInstPrinter.h"
|
2018-01-22 18:46:00 +08:00
|
|
|
#include "../Utils/AArch64BaseInfo.h"
|
2014-03-29 18:18:08 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2014-05-24 20:50:23 +08:00
|
|
|
class AArch64InstPrinter : public MCInstPrinter {
|
2014-03-29 18:18:08 +08:00
|
|
|
public:
|
2014-05-24 20:50:23 +08:00
|
|
|
AArch64InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
|
2015-03-31 05:52:26 +08:00
|
|
|
const MCRegisterInfo &MRI);
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2015-03-28 04:36:02 +08:00
|
|
|
void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
|
|
|
|
const MCSubtargetInfo &STI) override;
|
2014-04-29 15:58:25 +08:00
|
|
|
void printRegName(raw_ostream &OS, unsigned RegNo) const override;
|
2014-03-29 18:18:08 +08:00
|
|
|
|
|
|
|
// Autogenerated by tblgen.
|
2015-03-28 04:36:02 +08:00
|
|
|
virtual void printInstruction(const MCInst *MI, const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O);
|
|
|
|
virtual bool printAliasInstr(const MCInst *MI, const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O);
|
2014-05-13 02:04:06 +08:00
|
|
|
virtual void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
|
2015-03-28 04:36:02 +08:00
|
|
|
unsigned PrintMethodIdx,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O);
|
2017-02-04 05:49:13 +08:00
|
|
|
|
2014-03-29 18:18:08 +08:00
|
|
|
virtual StringRef getRegName(unsigned RegNo) const {
|
|
|
|
return getRegisterName(RegNo);
|
|
|
|
}
|
2017-02-04 05:49:13 +08:00
|
|
|
|
2014-03-29 18:18:08 +08:00
|
|
|
static const char *getRegisterName(unsigned RegNo,
|
2014-05-24 20:50:23 +08:00
|
|
|
unsigned AltIdx = AArch64::NoRegAltName);
|
2014-03-29 18:18:08 +08:00
|
|
|
|
|
|
|
protected:
|
2015-11-26 23:28:47 +08:00
|
|
|
bool printSysAlias(const MCInst *MI, const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O);
|
2014-03-29 18:18:08 +08:00
|
|
|
// Operand printers
|
2015-03-28 04:36:02 +08:00
|
|
|
void printOperand(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O);
|
2016-05-14 02:00:09 +08:00
|
|
|
void printImm(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O);
|
|
|
|
void printImmHex(const MCInst *MI, unsigned OpNo, const MCSubtargetInfo &STI,
|
2015-03-28 04:36:02 +08:00
|
|
|
raw_ostream &O);
|
2018-05-25 17:47:52 +08:00
|
|
|
template <typename T> void printImmSVE(T Value, raw_ostream &O);
|
2014-03-29 18:18:08 +08:00
|
|
|
void printPostIncOperand(const MCInst *MI, unsigned OpNo, unsigned Imm,
|
|
|
|
raw_ostream &O);
|
2015-03-28 04:36:02 +08:00
|
|
|
template <int Amount>
|
|
|
|
void printPostIncOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2014-04-30 19:43:36 +08:00
|
|
|
printPostIncOperand(MI, OpNo, Amount, O);
|
|
|
|
}
|
|
|
|
|
2015-03-28 04:36:02 +08:00
|
|
|
void printVRegOperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printSysCROperand(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printAddSubImm(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
[AArch64][AsmParser] NFC: Generalize LogicalImm[Not](32|64) code
Summary:
All variants of isLogicalImm[Not](32|64) can be combined into a single templated function, same for printLogicalImm(32|64).
By making it use a template instead, further SVE patches can use it for other data types as well (e.g. 8, 16 bits).
Reviewers: fhahn, rengolin, aadg, echristo, kristof.beyls, samparker
Reviewed By: samparker
Subscribers: aemerson, javed.absar, llvm-commits
Differential Revision: https://reviews.llvm.org/D42294
llvm-svn: 323646
2018-01-29 21:05:38 +08:00
|
|
|
template <typename T>
|
|
|
|
void printLogicalImm(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2015-03-28 04:36:02 +08:00
|
|
|
void printShifter(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printShiftedRegister(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printExtendedRegister(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printArithExtend(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2014-05-22 19:56:09 +08:00
|
|
|
|
|
|
|
void printMemExtend(const MCInst *MI, unsigned OpNum, raw_ostream &O,
|
|
|
|
char SrcRegKind, unsigned Width);
|
|
|
|
template <char SrcRegKind, unsigned Width>
|
2015-03-28 04:36:02 +08:00
|
|
|
void printMemExtend(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2014-05-22 19:56:09 +08:00
|
|
|
printMemExtend(MI, OpNum, O, SrcRegKind, Width);
|
|
|
|
}
|
[AArch64][SVE] Asm: Add AsmOperand classes for SVE gather/scatter addressing modes.
This patch adds parsing support for 'vector + shift/extend' and
corresponding asm operand classes, needed for implementing SVE's
gather/scatter addressing modes.
The added combinations of vector (ZPR) and Shift/Extend are:
Unscaled:
ZPR64ExtLSL8: signed 64-bit offsets (z0.d)
ZPR32ExtUXTW8: unsigned 32-bit offsets (z0.s, uxtw)
ZPR32ExtSXTW8: signed 32-bit offsets (z0.s, sxtw)
Unpacked and unscaled:
ZPR64ExtUXTW8: unsigned 32-bit offsets (z0.d, uxtw)
ZPR64ExtSXTW8: signed 32-bit offsets (z0.d, sxtw)
Unpacked and scaled:
ZPR64ExtUXTW<scale>: unsigned 32-bit offsets (z0.d, uxtw #<shift>)
ZPR64ExtSXTW<scale>: signed 32-bit offsets (z0.d, sxtw #<shift>)
Scaled:
ZPR32ExtUXTW<scale>: unsigned 32-bit offsets (z0.s, uxtw #<shift>)
ZPR32ExtSXTW<scale>: signed 32-bit offsets (z0.s, sxtw #<shift>)
ZPR64ExtLSL<scale>: unsigned 64-bit offsets (z0.d, lsl #<shift>)
ZPR64ExtLSL<scale>: signed 64-bit offsets (z0.d, lsl #<shift>)
Patch [1/3] in series to add support for SVE's gather load instructions
that use scalar+vector addressing modes:
- Patch [1/3]: https://reviews.llvm.org/D45951
- Patch [2/3]: https://reviews.llvm.org/D46023
- Patch [3/3]: https://reviews.llvm.org/D45958
Reviewers: fhahn, rengolin, samparker, SjoerdMeijer, t.p.northover, echristo, evandro, javed.absar
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D45951
llvm-svn: 330805
2018-04-25 17:26:47 +08:00
|
|
|
template <bool SignedExtend, int ExtWidth, char SrcRegKind, char Suffix>
|
2018-04-20 16:54:49 +08:00
|
|
|
void printRegWithShiftExtend(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2015-03-28 04:36:02 +08:00
|
|
|
void printCondCode(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printInverseCondCode(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printAlignedLabel(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2014-05-22 19:56:09 +08:00
|
|
|
void printUImm12Offset(const MCInst *MI, unsigned OpNum, unsigned Scale,
|
|
|
|
raw_ostream &O);
|
2014-04-09 22:44:31 +08:00
|
|
|
void printAMIndexedWB(const MCInst *MI, unsigned OpNum, unsigned Scale,
|
|
|
|
raw_ostream &O);
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2015-03-28 04:36:02 +08:00
|
|
|
template <int Scale>
|
|
|
|
void printUImm12Offset(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2014-05-22 19:56:09 +08:00
|
|
|
printUImm12Offset(MI, OpNum, Scale, O);
|
2014-04-09 22:44:31 +08:00
|
|
|
}
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2015-03-28 04:36:02 +08:00
|
|
|
template <int BitWidth>
|
|
|
|
void printAMIndexedWB(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O) {
|
2014-04-30 19:43:36 +08:00
|
|
|
printAMIndexedWB(MI, OpNum, BitWidth / 8, O);
|
2014-04-09 22:44:31 +08:00
|
|
|
}
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2015-03-28 04:36:02 +08:00
|
|
|
void printAMNoIndex(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2014-04-30 19:43:36 +08:00
|
|
|
|
2015-03-28 04:36:02 +08:00
|
|
|
template <int Scale>
|
|
|
|
void printImmScale(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2014-04-30 19:43:36 +08:00
|
|
|
|
2018-05-14 19:54:41 +08:00
|
|
|
template <bool IsSVEPrefetch = false>
|
2015-03-28 04:36:02 +08:00
|
|
|
void printPrefetchOp(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2015-12-01 18:48:51 +08:00
|
|
|
|
|
|
|
void printPSBHintOp(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2014-04-30 19:43:36 +08:00
|
|
|
|
2018-09-27 22:54:33 +08:00
|
|
|
void printBTIHintOp(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
|
2015-03-28 04:36:02 +08:00
|
|
|
void printFPImmOperand(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2015-03-28 04:36:02 +08:00
|
|
|
void printVectorList(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O,
|
2014-03-29 18:18:08 +08:00
|
|
|
StringRef LayoutSuffix);
|
|
|
|
|
|
|
|
/// Print a list of vector registers where the type suffix is implicit
|
|
|
|
/// (i.e. attached to the instruction rather than the registers).
|
|
|
|
void printImplicitlyTypedVectorList(const MCInst *MI, unsigned OpNum,
|
2015-03-28 04:36:02 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2014-03-29 18:18:08 +08:00
|
|
|
raw_ostream &O);
|
|
|
|
|
|
|
|
template <unsigned NumLanes, char LaneKind>
|
2015-03-28 04:36:02 +08:00
|
|
|
void printTypedVectorList(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
|
|
|
|
void printVectorIndex(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printAdrpLabel(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printBarrierOption(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printMSRSystemRegister(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printMRSSystemRegister(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printSystemPStateField(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
|
|
|
void printSIMDType10Operand(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2017-08-31 17:27:04 +08:00
|
|
|
template<int64_t Angle, int64_t Remainder>
|
|
|
|
void printComplexRotationOp(const MCInst *MI, unsigned OpNo,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2015-06-02 18:58:41 +08:00
|
|
|
template<unsigned size>
|
|
|
|
void printGPRSeqPairsClassOperand(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O);
|
2018-05-25 17:47:52 +08:00
|
|
|
template <typename T>
|
|
|
|
void printImm8OptLsl(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2018-06-01 15:25:46 +08:00
|
|
|
template <typename T>
|
|
|
|
void printSVELogicalImm(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2018-01-22 18:46:00 +08:00
|
|
|
void printSVEPattern(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2017-11-08 00:45:48 +08:00
|
|
|
template <char = 0>
|
|
|
|
void printSVERegOp(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2018-07-02 15:34:52 +08:00
|
|
|
void printGPR64as32(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2018-06-04 15:07:35 +08:00
|
|
|
template <int Width>
|
|
|
|
void printZPRasFPR(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2018-06-15 21:11:49 +08:00
|
|
|
template <unsigned ImmIs0, unsigned ImmIs1>
|
|
|
|
void printExactFPImm(const MCInst *MI, unsigned OpNum,
|
|
|
|
const MCSubtargetInfo &STI, raw_ostream &O);
|
2014-03-29 18:18:08 +08:00
|
|
|
};
|
|
|
|
|
2014-05-24 20:50:23 +08:00
|
|
|
class AArch64AppleInstPrinter : public AArch64InstPrinter {
|
2014-03-29 18:18:08 +08:00
|
|
|
public:
|
2014-05-24 20:50:23 +08:00
|
|
|
AArch64AppleInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
|
2015-03-31 05:52:26 +08:00
|
|
|
const MCRegisterInfo &MRI);
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2015-03-28 04:36:02 +08:00
|
|
|
void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot,
|
|
|
|
const MCSubtargetInfo &STI) override;
|
2014-03-29 18:18:08 +08:00
|
|
|
|
2015-03-28 04:36:02 +08:00
|
|
|
void printInstruction(const MCInst *MI, const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) override;
|
|
|
|
bool printAliasInstr(const MCInst *MI, const MCSubtargetInfo &STI,
|
|
|
|
raw_ostream &O) override;
|
2014-09-03 19:41:21 +08:00
|
|
|
void printCustomAliasOperand(const MCInst *MI, unsigned OpIdx,
|
|
|
|
unsigned PrintMethodIdx,
|
2015-03-28 04:36:02 +08:00
|
|
|
const MCSubtargetInfo &STI,
|
2014-09-03 19:41:21 +08:00
|
|
|
raw_ostream &O) override;
|
2017-02-04 05:49:13 +08:00
|
|
|
|
2014-04-29 15:58:25 +08:00
|
|
|
StringRef getRegName(unsigned RegNo) const override {
|
2014-03-29 18:18:08 +08:00
|
|
|
return getRegisterName(RegNo);
|
|
|
|
}
|
2017-02-04 05:49:13 +08:00
|
|
|
|
2014-03-29 18:18:08 +08:00
|
|
|
static const char *getRegisterName(unsigned RegNo,
|
2014-05-24 20:50:23 +08:00
|
|
|
unsigned AltIdx = AArch64::NoRegAltName);
|
2014-03-29 18:18:08 +08:00
|
|
|
};
|
|
|
|
|
2017-02-04 05:49:13 +08:00
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif // LLVM_LIB_TARGET_AARCH64_INSTPRINTER_AARCH64INSTPRINTER_H
|