mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-19 17:33:29 +00:00
edaa58ee66
When targeting the Darwin assembler, we need to generate markers ha16() and lo16() to designate the high and low parts of a (symbolic) immediate. This is necessary not just for plain symbols, but also for certain symbolic expression, typically along the lines of ha16(A - B). The latter doesn't work when simply using VariantKind flags on the symbol reference. This is why the current back-end uses hacks (explicitly called out as such via multiple FIXMEs) in the symbolLo/symbolHi print methods. This patch uses target-defined MCExpr codes to represent the Darwin ha16/lo16 constructs, following along the lines of the equivalent solution used by the ARM back end to handle their :upper16: / :lower16: markers. This allows us to get rid of special handling both in the symbolLo/symbolHi print method and in the common code MCExpr::print routine. Instead, the ha16 / lo16 markers are printed simply in a custom print routine for the target MCExpr types. (As a result, the symbolLo/symbolHi print methods can now replaced by a single printS16ImmOperand routine that also handles symbolic operands.) The patch also provides a EvaluateAsRelocatableImpl routine to handle ha16/lo16 constructs. This is not actually used at the moment by any in-tree code, but is provided as it makes merging into David Fang's out-of-tree Mach-O object writer simpler. Since there is no longer any need to treat VK_PPC_GAS_HA16 and VK_PPC_DARWIN_HA16 differently, they are merged into a single VK_PPC_ADDR16_HA (and likewise for the _LO16 types). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182616 91177308-0d34-0410-b5e6-96231b3b80d8
64 lines
2.2 KiB
C++
64 lines
2.2 KiB
C++
//===- PPCInstPrinter.h - Convert PPC MCInst to assembly syntax -*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This class prints an PPC MCInst to a .s file.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef PPCINSTPRINTER_H
|
|
#define PPCINSTPRINTER_H
|
|
|
|
#include "llvm/MC/MCInstPrinter.h"
|
|
|
|
namespace llvm {
|
|
|
|
class MCOperand;
|
|
|
|
class PPCInstPrinter : public MCInstPrinter {
|
|
// 0 -> AIX, 1 -> Darwin.
|
|
unsigned SyntaxVariant;
|
|
public:
|
|
PPCInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
|
|
const MCRegisterInfo &MRI, unsigned syntaxVariant)
|
|
: MCInstPrinter(MAI, MII, MRI), SyntaxVariant(syntaxVariant) {}
|
|
|
|
bool isDarwinSyntax() const {
|
|
return SyntaxVariant == 1;
|
|
}
|
|
|
|
virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
|
|
virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
|
|
|
|
// Autogenerated by tblgen.
|
|
void printInstruction(const MCInst *MI, raw_ostream &O);
|
|
static const char *getRegisterName(unsigned RegNo);
|
|
|
|
|
|
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
void printPredicateOperand(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O, const char *Modifier = 0);
|
|
|
|
|
|
void printS5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
void printU5ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
void printU6ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
void printS16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
void printU16ImmOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
void printBranchOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
void printAbsAddrOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
|
|
void printcrbitm(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
|
|
void printMemRegImm(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
void printMemRegReg(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
|
};
|
|
} // end namespace llvm
|
|
|
|
#endif
|