mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-21 00:32:23 +00:00
d04a8d4b33
Sooooo many of these had incorrect or strange main module includes. I have manually inspected all of these, and fixed the main module include to be the nearest plausible thing I could find. If you own or care about any of these source files, I encourage you to take some time and check that these edits were sensible. I can't have broken anything (I strictly added headers, and reordered them, never removed), but they may not be the headers you'd really like to identify as containing the API being implemented. Many forward declarations and missing includes were added to a header files to allow them to parse cleanly when included first. The main module rule does in fact have its merits. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169131 91177308-0d34-0410-b5e6-96231b3b80d8
72 lines
2.2 KiB
C++
72 lines
2.2 KiB
C++
//===-- MBlazeInstPrinter.cpp - Convert MBlaze MCInst to assembly syntax --===//
|
|
//
|
|
// 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 MBlaze MCInst to a .s file.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#define DEBUG_TYPE "asm-printer"
|
|
#include "MBlazeInstPrinter.h"
|
|
#include "MBlaze.h"
|
|
#include "llvm/MC/MCAsmInfo.h"
|
|
#include "llvm/MC/MCExpr.h"
|
|
#include "llvm/MC/MCInst.h"
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
#include "llvm/Support/FormattedStream.h"
|
|
using namespace llvm;
|
|
|
|
|
|
// Include the auto-generated portion of the assembly writer.
|
|
#include "MBlazeGenAsmWriter.inc"
|
|
|
|
void MBlazeInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
|
|
StringRef Annot) {
|
|
printInstruction(MI, O);
|
|
printAnnotation(O, Annot);
|
|
}
|
|
|
|
void MBlazeInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O, const char *Modifier) {
|
|
assert((Modifier == 0 || Modifier[0] == 0) && "No modifiers supported");
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
if (Op.isReg()) {
|
|
O << getRegisterName(Op.getReg());
|
|
} else if (Op.isImm()) {
|
|
O << (int32_t)Op.getImm();
|
|
} else {
|
|
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
|
O << *Op.getExpr();
|
|
}
|
|
}
|
|
|
|
void MBlazeInstPrinter::printFSLImm(const MCInst *MI, int OpNo,
|
|
raw_ostream &O) {
|
|
const MCOperand &MO = MI->getOperand(OpNo);
|
|
if (MO.isImm())
|
|
O << "rfsl" << MO.getImm();
|
|
else
|
|
printOperand(MI, OpNo, O, NULL);
|
|
}
|
|
|
|
void MBlazeInstPrinter::printUnsignedImm(const MCInst *MI, int OpNo,
|
|
raw_ostream &O) {
|
|
const MCOperand &MO = MI->getOperand(OpNo);
|
|
if (MO.isImm())
|
|
O << (uint32_t)MO.getImm();
|
|
else
|
|
printOperand(MI, OpNo, O, NULL);
|
|
}
|
|
|
|
void MBlazeInstPrinter::printMemOperand(const MCInst *MI, int OpNo,
|
|
raw_ostream &O, const char *Modifier) {
|
|
printOperand(MI, OpNo, O, NULL);
|
|
O << ", ";
|
|
printOperand(MI, OpNo+1, O, NULL);
|
|
}
|