mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 00:17:01 +00:00
R600/SI: Print more immediates in hex format
Print in decimal for inline immediates, and hex otherwise. Use hex always for offsets in addressing offsets. This approximately matches what the shader compiler does. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206335 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -12,6 +12,8 @@
|
||||
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
@@ -23,6 +25,21 @@ void AMDGPUInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
|
||||
printAnnotation(OS, Annot);
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printU8ImmOperand(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
O << formatHex(MI->getOperand(OpNo).getImm() & 0xff);
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printU16ImmOperand(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
O << formatHex(MI->getOperand(OpNo).getImm() & 0xffff);
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printU32ImmOperand(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
O << formatHex(MI->getOperand(OpNo).getImm() & 0xffffffff);
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printRegOperand(unsigned reg, raw_ostream &O) {
|
||||
switch (reg) {
|
||||
case AMDGPU::VCC:
|
||||
@@ -93,6 +110,28 @@ void AMDGPUInstPrinter::printRegOperand(unsigned reg, raw_ostream &O) {
|
||||
O << Type << '[' << RegIdx << ':' << (RegIdx + NumRegs - 1) << ']';
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printImmediate(uint32_t Imm, raw_ostream &O) {
|
||||
int32_t SImm = static_cast<int32_t>(Imm);
|
||||
if (SImm >= -16 && SImm <= 64) {
|
||||
O << SImm;
|
||||
return;
|
||||
}
|
||||
|
||||
if (Imm == FloatToBits(1.0f) ||
|
||||
Imm == FloatToBits(-1.0f) ||
|
||||
Imm == FloatToBits(0.5f) ||
|
||||
Imm == FloatToBits(-0.5f) ||
|
||||
Imm == FloatToBits(2.0f) ||
|
||||
Imm == FloatToBits(-2.0f) ||
|
||||
Imm == FloatToBits(4.0f) ||
|
||||
Imm == FloatToBits(-4.0f)) {
|
||||
O << BitsToFloat(Imm);
|
||||
return;
|
||||
}
|
||||
|
||||
O << formatHex(static_cast<uint64_t>(Imm));
|
||||
}
|
||||
|
||||
void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||
raw_ostream &O) {
|
||||
|
||||
@@ -108,7 +147,7 @@ void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||
break;
|
||||
}
|
||||
} else if (Op.isImm()) {
|
||||
O << Op.getImm();
|
||||
printImmediate(Op.getImm(), O);
|
||||
} else if (Op.isFPImm()) {
|
||||
O << Op.getFPImm();
|
||||
} else if (Op.isExpr()) {
|
||||
|
||||
Reference in New Issue
Block a user