mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
R600: BB operand support for SI
Patch by: Christian König Reviewed-by: Tom Stellard <thomas.stellard@amd.com> Tested-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Christian König <deathsimple@vodafone.de> llvm-svn: 170342
This commit is contained in:
parent
6817104534
commit
861d1ea443
@ -21,11 +21,14 @@
|
|||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
AMDGPUMCInstLower::AMDGPUMCInstLower() { }
|
AMDGPUMCInstLower::AMDGPUMCInstLower(MCContext &ctx):
|
||||||
|
Ctx(ctx)
|
||||||
|
{ }
|
||||||
|
|
||||||
void AMDGPUMCInstLower::lower(const MachineInstr *MI, MCInst &OutMI) const {
|
void AMDGPUMCInstLower::lower(const MachineInstr *MI, MCInst &OutMI) const {
|
||||||
OutMI.setOpcode(MI->getOpcode());
|
OutMI.setOpcode(MI->getOpcode());
|
||||||
@ -50,13 +53,16 @@ void AMDGPUMCInstLower::lower(const MachineInstr *MI, MCInst &OutMI) const {
|
|||||||
case MachineOperand::MO_Register:
|
case MachineOperand::MO_Register:
|
||||||
MCOp = MCOperand::CreateReg(MO.getReg());
|
MCOp = MCOperand::CreateReg(MO.getReg());
|
||||||
break;
|
break;
|
||||||
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
|
MCOp = MCOperand::CreateExpr(MCSymbolRefExpr::Create(
|
||||||
|
MO.getMBB()->getSymbol(), Ctx));
|
||||||
}
|
}
|
||||||
OutMI.addOperand(MCOp);
|
OutMI.addOperand(MCOp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
void AMDGPUAsmPrinter::EmitInstruction(const MachineInstr *MI) {
|
||||||
AMDGPUMCInstLower MCInstLowering;
|
AMDGPUMCInstLower MCInstLowering(OutContext);
|
||||||
|
|
||||||
if (MI->isBundle()) {
|
if (MI->isBundle()) {
|
||||||
const MachineBasicBlock *MBB = MI->getParent();
|
const MachineBasicBlock *MBB = MI->getParent();
|
||||||
|
@ -14,12 +14,15 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class MCInst;
|
class MCInst;
|
||||||
|
class MCContext;
|
||||||
class MachineInstr;
|
class MachineInstr;
|
||||||
|
|
||||||
class AMDGPUMCInstLower {
|
class AMDGPUMCInstLower {
|
||||||
|
|
||||||
|
MCContext &Ctx;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AMDGPUMCInstLower();
|
AMDGPUMCInstLower(MCContext &ctx);
|
||||||
|
|
||||||
/// \brief Lower a MachineInstr to an MCInst
|
/// \brief Lower a MachineInstr to an MCInst
|
||||||
void lower(const MachineInstr *MI, MCInst &OutMI) const;
|
void lower(const MachineInstr *MI, MCInst &OutMI) const;
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
virtual AMDGPUMCObjectWriter *createObjectWriter(raw_ostream &OS) const;
|
virtual AMDGPUMCObjectWriter *createObjectWriter(raw_ostream &OS) const;
|
||||||
virtual unsigned getNumFixupKinds() const { return 0; };
|
virtual unsigned getNumFixupKinds() const { return 0; };
|
||||||
virtual void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
virtual void applyFixup(const MCFixup &Fixup, char *Data, unsigned DataSize,
|
||||||
uint64_t Value) const { assert(!"Not implemented"); }
|
uint64_t Value) const;
|
||||||
virtual bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
|
virtual bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value,
|
||||||
const MCInstFragment *DF,
|
const MCInstFragment *DF,
|
||||||
const MCAsmLayout &Layout) const {
|
const MCAsmLayout &Layout) const {
|
||||||
@ -80,3 +80,11 @@ AMDGPUMCObjectWriter * AMDGPUAsmBackend::createObjectWriter(
|
|||||||
raw_ostream &OS) const {
|
raw_ostream &OS) const {
|
||||||
return new AMDGPUMCObjectWriter(OS);
|
return new AMDGPUMCObjectWriter(OS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AMDGPUAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
|
||||||
|
unsigned DataSize, uint64_t Value) const {
|
||||||
|
|
||||||
|
uint16_t *Dst = (uint16_t*)(Data + Fixup.getOffset());
|
||||||
|
assert(Fixup.getKind() == FK_PCRel_4);
|
||||||
|
*Dst = (Value - 4) / 4;
|
||||||
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "llvm/MC/MCInstrInfo.h"
|
#include "llvm/MC/MCInstrInfo.h"
|
||||||
#include "llvm/MC/MCRegisterInfo.h"
|
#include "llvm/MC/MCRegisterInfo.h"
|
||||||
#include "llvm/MC/MCSubtargetInfo.h"
|
#include "llvm/MC/MCSubtargetInfo.h"
|
||||||
|
#include "llvm/MC/MCFixup.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
|
|
||||||
#define VGPR_BIT(src_idx) (1ULL << (9 * src_idx - 1))
|
#define VGPR_BIT(src_idx) (1ULL << (9 * src_idx - 1))
|
||||||
@ -149,6 +150,11 @@ uint64_t SIMCCodeEmitter::getMachineOpValue(const MCInst &MI,
|
|||||||
} Imm;
|
} Imm;
|
||||||
Imm.F = MO.getFPImm();
|
Imm.F = MO.getFPImm();
|
||||||
return Imm.I;
|
return Imm.I;
|
||||||
|
} else if (MO.isExpr()) {
|
||||||
|
const MCExpr *Expr = MO.getExpr();
|
||||||
|
MCFixupKind Kind = MCFixupKind(FK_PCRel_4);
|
||||||
|
Fixups.push_back(MCFixup::Create(0, Expr, Kind, MI.getLoc()));
|
||||||
|
return 0;
|
||||||
} else{
|
} else{
|
||||||
llvm_unreachable("Encoding of this operand type is not supported yet.");
|
llvm_unreachable("Encoding of this operand type is not supported yet.");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user