diff options
Diffstat (limited to 'lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp')
| -rw-r--r-- | lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp b/lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp index 3c1142dd664b..5e8e6ceb7ca2 100644 --- a/lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp +++ b/lib/Target/AMDGPU/MCTargetDesc/R600MCCodeEmitter.cpp @@ -15,6 +15,7 @@ //===----------------------------------------------------------------------===// #include "R600Defines.h" +#include "MCTargetDesc/AMDGPUFixupKinds.h" #include "MCTargetDesc/AMDGPUMCCodeEmitter.h" #include "MCTargetDesc/AMDGPUMCTargetDesc.h" #include "llvm/MC/MCCodeEmitter.h" @@ -51,12 +52,9 @@ public: const MCSubtargetInfo &STI) const override; private: - void EmitByte(unsigned int byte, raw_ostream &OS) const; - void Emit(uint32_t value, raw_ostream &OS) const; void Emit(uint64_t value, raw_ostream &OS) const; - unsigned getHWRegChan(unsigned reg) const; unsigned getHWReg(unsigned regNo) const; }; @@ -142,10 +140,6 @@ void R600MCCodeEmitter::encodeInstruction(const MCInst &MI, raw_ostream &OS, } } -void R600MCCodeEmitter::EmitByte(unsigned int Byte, raw_ostream &OS) const { - OS.write((uint8_t) Byte & 0xff); -} - void R600MCCodeEmitter::Emit(uint32_t Value, raw_ostream &OS) const { support::endian::Writer<support::little>(OS).write(Value); } @@ -154,17 +148,13 @@ void R600MCCodeEmitter::Emit(uint64_t Value, raw_ostream &OS) const { support::endian::Writer<support::little>(OS).write(Value); } -unsigned R600MCCodeEmitter::getHWRegChan(unsigned reg) const { - return MRI.getEncodingValue(reg) >> HW_CHAN_SHIFT; -} - unsigned R600MCCodeEmitter::getHWReg(unsigned RegNo) const { return MRI.getEncodingValue(RegNo) & HW_REG_MASK; } uint64_t R600MCCodeEmitter::getMachineOpValue(const MCInst &MI, const MCOperand &MO, - SmallVectorImpl<MCFixup> &Fixup, + SmallVectorImpl<MCFixup> &Fixups, const MCSubtargetInfo &STI) const { if (MO.isReg()) { if (HAS_NATIVE_OPERANDS(MCII.get(MI.getOpcode()).TSFlags)) @@ -172,6 +162,18 @@ uint64_t R600MCCodeEmitter::getMachineOpValue(const MCInst &MI, return getHWReg(MO.getReg()); } + if (MO.isExpr()) { + // We put rodata at the end of code section, then map the entire + // code secetion as vtx buf. Thus the section relative address is the + // correct one. + // Each R600 literal instruction has two operands + // We can't easily get the order of the current one, so compare against + // the first one and adjust offset. + const unsigned offset = (&MO == &MI.getOperand(0)) ? 0 : 4; + Fixups.push_back(MCFixup::create(offset, MO.getExpr(), FK_SecRel_4, MI.getLoc())); + return 0; + } + assert(MO.isImm()); return MO.getImm(); } |
