mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-04 16:01:46 +00:00
c0b0c677a1
Only implemented for R600 so far. SI is missing implementations of a few callbacks used by the Indirect Addressing pass and needs code to handle frame indices. At the moment R600 only supports array sizes of 16 dwords or less. Register packing of vector types is currently disabled, which means that a vec4 is stored in T0_X, T1_X, T2_X, T3_X, rather than T0_XYZW. In order to correctly pack registers in all cases, we will need to implement an analysis pass for R600 that determines the correct vector width for each array. v2: - Add support for i8 zext load from stack. - Coding style fixes v3: - Don't reserve registers for indirect addressing when it isn't being used. - Fix bug caused by LLVM limiting the number of SubRegIndex declarations. v4: - Fix 64-bit defines git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174525 91177308-0d34-0410-b5e6-96231b3b80d8
154 lines
4.0 KiB
C++
154 lines
4.0 KiB
C++
//===-- AMDGPUInstPrinter.cpp - AMDGPU MC Inst -> ASM ---------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
// \file
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "AMDGPUInstPrinter.h"
|
|
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
|
#include "llvm/MC/MCInst.h"
|
|
|
|
using namespace llvm;
|
|
|
|
void AMDGPUInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
|
|
StringRef Annot) {
|
|
printInstruction(MI, OS);
|
|
|
|
printAnnotation(OS, Annot);
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
if (Op.isReg()) {
|
|
switch (Op.getReg()) {
|
|
// This is the default predicate state, so we don't need to print it.
|
|
case AMDGPU::PRED_SEL_OFF: break;
|
|
default: O << getRegisterName(Op.getReg()); break;
|
|
}
|
|
} else if (Op.isImm()) {
|
|
O << Op.getImm();
|
|
} else if (Op.isFPImm()) {
|
|
O << Op.getFPImm();
|
|
} else {
|
|
assert(!"unknown operand type in printOperand");
|
|
}
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printMemOperand(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
printOperand(MI, OpNo, O);
|
|
O << ", ";
|
|
printOperand(MI, OpNo + 1, O);
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printIfSet(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O, StringRef Asm) {
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
assert(Op.isImm());
|
|
if (Op.getImm() == 1) {
|
|
O << Asm;
|
|
}
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printAbs(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
printIfSet(MI, OpNo, O, "|");
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printClamp(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
printIfSet(MI, OpNo, O, "_SAT");
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printLiteral(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
union Literal {
|
|
float f;
|
|
int32_t i;
|
|
} L;
|
|
|
|
L.i = MI->getOperand(OpNo).getImm();
|
|
O << L.i << "(" << L.f << ")";
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printLast(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
printIfSet(MI, OpNo, O, " *");
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printNeg(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
printIfSet(MI, OpNo, O, "-");
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printOMOD(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
switch (MI->getOperand(OpNo).getImm()) {
|
|
default: break;
|
|
case 1:
|
|
O << " * 2.0";
|
|
break;
|
|
case 2:
|
|
O << " * 4.0";
|
|
break;
|
|
case 3:
|
|
O << " / 2.0";
|
|
break;
|
|
}
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printRel(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
printIfSet(MI, OpNo, O, "+");
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printUpdateExecMask(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
printIfSet(MI, OpNo, O, "ExecMask,");
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printUpdatePred(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
printIfSet(MI, OpNo, O, "Pred,");
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printWrite(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
const MCOperand &Op = MI->getOperand(OpNo);
|
|
if (Op.getImm() == 0) {
|
|
O << " (MASKED)";
|
|
}
|
|
}
|
|
|
|
void AMDGPUInstPrinter::printSel(const MCInst *MI, unsigned OpNo,
|
|
raw_ostream &O) {
|
|
const char * chans = "XYZW";
|
|
int sel = MI->getOperand(OpNo).getImm();
|
|
|
|
int chan = sel & 3;
|
|
sel >>= 2;
|
|
|
|
if (sel >= 512) {
|
|
sel -= 512;
|
|
int cb = sel >> 12;
|
|
sel &= 4095;
|
|
O << cb << "[" << sel << "]";
|
|
} else if (sel >= 448) {
|
|
sel -= 448;
|
|
O << sel;
|
|
} else if (sel >= 0){
|
|
O << sel;
|
|
}
|
|
|
|
if (sel >= 0)
|
|
O << "." << chans[chan];
|
|
}
|
|
|
|
#include "AMDGPUGenAsmWriter.inc"
|