mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
Replace the old algorithm that emitted the "print the alias for an instruction"
with the newer, cleaner model. It uses the IAPrinter class to hold the information that is needed to match an instruction with its alias. This also takes into account the available features of the platform. There is one bit of ugliness. The way the logic determines if a pattern is unique is O(N**2), which is gross. But in reality, the number of items it's checking against isn't large. So while it's N**2, it shouldn't be a massive time sink. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129110 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#define DEBUG_TYPE "asm-printer"
|
||||
#include "X86ATTInstPrinter.h"
|
||||
#include "X86InstComments.h"
|
||||
#include "X86Subtarget.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
@@ -22,11 +23,23 @@
|
||||
#include "llvm/Support/Format.h"
|
||||
#include "llvm/Support/FormattedStream.h"
|
||||
#include "X86GenInstrNames.inc"
|
||||
#include <map>
|
||||
using namespace llvm;
|
||||
|
||||
// Include the auto-generated portion of the assembly writer.
|
||||
#define GET_INSTRUCTION_NAME
|
||||
#define PRINT_ALIAS_INSTR
|
||||
#include "X86GenRegisterNames.inc"
|
||||
#include "X86GenAsmWriter.inc"
|
||||
#undef PRINT_ALIAS_INSTR
|
||||
#undef GET_INSTRUCTION_NAME
|
||||
|
||||
X86ATTInstPrinter::X86ATTInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
|
||||
: MCInstPrinter(MAI) {
|
||||
// Initialize the set of available features.
|
||||
setAvailableFeatures(ComputeAvailableFeatures(
|
||||
&TM.getSubtarget<X86Subtarget>()));
|
||||
}
|
||||
|
||||
void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) {
|
||||
printInstruction(MI, OS);
|
||||
@@ -35,11 +48,11 @@ void X86ATTInstPrinter::printInst(const MCInst *MI, raw_ostream &OS) {
|
||||
if (CommentStream)
|
||||
EmitAnyX86InstComments(MI, *CommentStream, getRegisterName);
|
||||
}
|
||||
|
||||
StringRef X86ATTInstPrinter::getOpcodeName(unsigned Opcode) const {
|
||||
return getInstructionName(Opcode);
|
||||
}
|
||||
|
||||
|
||||
void X86ATTInstPrinter::printSSECC(const MCInst *MI, unsigned Op,
|
||||
raw_ostream &O) {
|
||||
switch (MI->getOperand(Op).getImm()) {
|
||||
|
@@ -19,16 +19,20 @@
|
||||
namespace llvm {
|
||||
|
||||
class MCOperand;
|
||||
class X86Subtarget;
|
||||
class TargetMachine;
|
||||
|
||||
class X86ATTInstPrinter : public MCInstPrinter {
|
||||
public:
|
||||
X86ATTInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
|
||||
: MCInstPrinter(MAI) {}
|
||||
X86ATTInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI);
|
||||
|
||||
virtual void printInst(const MCInst *MI, raw_ostream &OS);
|
||||
virtual StringRef getOpcodeName(unsigned Opcode) const;
|
||||
|
||||
// Methods used to print the alias of an instruction.
|
||||
unsigned ComputeAvailableFeatures(const X86Subtarget *Subtarget) const;
|
||||
bool printAliasInstr(const MCInst *MI, raw_ostream &OS);
|
||||
|
||||
// Autogenerated by tblgen.
|
||||
void printInstruction(const MCInst *MI, raw_ostream &OS);
|
||||
static const char *getRegisterName(unsigned RegNo);
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#define DEBUG_TYPE "asm-printer"
|
||||
#include "X86IntelInstPrinter.h"
|
||||
#include "X86InstComments.h"
|
||||
#include "X86Subtarget.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
|
@@ -26,7 +26,7 @@ class X86IntelInstPrinter : public MCInstPrinter {
|
||||
public:
|
||||
X86IntelInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
|
||||
: MCInstPrinter(MAI) {}
|
||||
|
||||
|
||||
virtual void printInst(const MCInst *MI, raw_ostream &OS);
|
||||
virtual StringRef getOpcodeName(unsigned Opcode) const;
|
||||
|
||||
@@ -35,7 +35,6 @@ public:
|
||||
static const char *getRegisterName(unsigned RegNo);
|
||||
static const char *getInstructionName(unsigned Opcode);
|
||||
|
||||
|
||||
void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O);
|
||||
void printMemReference(const MCInst *MI, unsigned Op, raw_ostream &O);
|
||||
void printSSECC(const MCInst *MI, unsigned Op, raw_ostream &O);
|
||||
|
Reference in New Issue
Block a user