summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PowerPC/PPCMCCodeEmitter.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-15 05:19:25 +0000
committerChris Lattner <sabre@nondot.org>2010-11-15 05:19:25 +0000
commitd6a07ccd10191c7060ebc04e53371bb383dc5863 (patch)
tree27fe43e8dc863e5de96d470293e84a1f6ee9724d /llvm/lib/Target/PowerPC/PPCMCCodeEmitter.cpp
parent63274cbc5d6bb988ede7eafedddc00ec860cdd89 (diff)
downloadbcm5719-llvm-d6a07ccd10191c7060ebc04e53371bb383dc5863.tar.gz
bcm5719-llvm-d6a07ccd10191c7060ebc04e53371bb383dc5863.zip
add proper encoding for MTCRF instead of using a hack.
llvm-svn: 119121
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCMCCodeEmitter.cpp')
-rw-r--r--llvm/lib/Target/PowerPC/PPCMCCodeEmitter.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCMCCodeEmitter.cpp b/llvm/lib/Target/PowerPC/PPCMCCodeEmitter.cpp
index fd98f4dfb13..bbadcb07918 100644
--- a/llvm/lib/Target/PowerPC/PPCMCCodeEmitter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCMCCodeEmitter.cpp
@@ -56,12 +56,14 @@ public:
"Invalid kind!");
return Infos[Kind - FirstTargetFixupKind];
}
-
+
+ unsigned get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
+ SmallVectorImpl<MCFixup> &Fixups) const;
+
/// getMachineOpValue - Return binary encoding of operand. If the machine
/// operand requires relocation, record the relocation and return zero.
unsigned getMachineOpValue(const MCInst &MI,const MCOperand &MO,
SmallVectorImpl<MCFixup> &Fixups) const;
-
// getBinaryCodeForInstr - TableGen'erated function for getting the
// binary encoding for an instruction.
@@ -90,10 +92,22 @@ MCCodeEmitter *llvm::createPPCMCCodeEmitter(const Target &, TargetMachine &TM,
}
unsigned PPCMCCodeEmitter::
+get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
+ SmallVectorImpl<MCFixup> &Fixups) const {
+ const MCOperand &MO = MI.getOperand(OpNo);
+ assert((MI.getOpcode() == PPC::MTCRF || MI.getOpcode() == PPC::MFOCRF) &&
+ (MO.getReg() >= PPC::CR0 && MO.getReg() <= PPC::CR7));
+ return 0x80 >> PPCRegisterInfo::getRegisterNumbering(MO.getReg());
+}
+
+
+unsigned PPCMCCodeEmitter::
getMachineOpValue(const MCInst &MI, const MCOperand &MO,
SmallVectorImpl<MCFixup> &Fixups) const {
- if (MO.isReg())
+ if (MO.isReg()) {
+ assert(MI.getOpcode() != PPC::MTCRF && MI.getOpcode() != PPC::MFOCRF);
return PPCRegisterInfo::getRegisterNumbering(MO.getReg());
+ }
if (MO.isImm())
return MO.getImm();
OpenPOWER on IntegriCloud