blob: b259c5dab46252d3dec6622555ff2a392198dc6b [file] [log] [blame]
Chris Lattner9ec375c2010-11-15 04:16:32 +00001//===-- PPCMCCodeEmitter.cpp - Convert PPC code to machine code -----------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the PPCMCCodeEmitter class.
11//
12//===----------------------------------------------------------------------===//
13
14#define DEBUG_TYPE "mccodeemitter"
Chandler Carruthed0881b2012-12-03 16:50:05 +000015#include "MCTargetDesc/PPCMCTargetDesc.h"
Evan Cheng61d4a202011-07-25 19:53:23 +000016#include "MCTargetDesc/PPCFixupKinds.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000017#include "llvm/ADT/Statistic.h"
Chris Lattner9ec375c2010-11-15 04:16:32 +000018#include "llvm/MC/MCCodeEmitter.h"
Hal Finkelfeea6532013-03-26 20:08:20 +000019#include "llvm/MC/MCContext.h"
Bill Schmidtc56f1d32012-12-11 20:30:11 +000020#include "llvm/MC/MCExpr.h"
Chris Lattner9ec375c2010-11-15 04:16:32 +000021#include "llvm/MC/MCInst.h"
Adhemerval Zanellaf2aceda2012-10-25 12:27:42 +000022#include "llvm/MC/MCInstrInfo.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000023#include "llvm/MC/MCSubtargetInfo.h"
Chris Lattner9ec375c2010-11-15 04:16:32 +000024#include "llvm/Support/ErrorHandling.h"
Chandler Carruthed0881b2012-12-03 16:50:05 +000025#include "llvm/Support/raw_ostream.h"
Bill Schmidtc763c222013-09-16 17:25:12 +000026#include "llvm/Target/TargetOpcodes.h"
Chris Lattner9ec375c2010-11-15 04:16:32 +000027using namespace llvm;
28
29STATISTIC(MCNumEmitted, "Number of MC instructions emitted");
30
31namespace {
32class PPCMCCodeEmitter : public MCCodeEmitter {
Craig Toppera60c0f12012-09-15 17:09:36 +000033 PPCMCCodeEmitter(const PPCMCCodeEmitter &) LLVM_DELETED_FUNCTION;
34 void operator=(const PPCMCCodeEmitter &) LLVM_DELETED_FUNCTION;
35
Hal Finkela7bbaf62014-02-02 06:12:27 +000036 const MCInstrInfo &MCII;
Hal Finkelfeea6532013-03-26 20:08:20 +000037 const MCContext &CTX;
Ulrich Weigandcae3a172014-03-24 18:16:09 +000038 bool IsLittleEndian;
Adhemerval Zanellaf2aceda2012-10-25 12:27:42 +000039
Chris Lattner9ec375c2010-11-15 04:16:32 +000040public:
Ulrich Weigandcae3a172014-03-24 18:16:09 +000041 PPCMCCodeEmitter(const MCInstrInfo &mcii, MCContext &ctx, bool isLittle)
42 : MCII(mcii), CTX(ctx), IsLittleEndian(isLittle) {
Chris Lattner9ec375c2010-11-15 04:16:32 +000043 }
44
45 ~PPCMCCodeEmitter() {}
Chris Lattnerd6a07cc2010-11-15 05:19:25 +000046
Chris Lattner0e3461e2010-11-15 06:09:35 +000047 unsigned getDirectBrEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +000048 SmallVectorImpl<MCFixup> &Fixups,
49 const MCSubtargetInfo &STI) const;
Chris Lattner0e3461e2010-11-15 06:09:35 +000050 unsigned getCondBrEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +000051 SmallVectorImpl<MCFixup> &Fixups,
52 const MCSubtargetInfo &STI) const;
Ulrich Weigandb6a30d12013-06-24 11:03:33 +000053 unsigned getAbsDirectBrEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +000054 SmallVectorImpl<MCFixup> &Fixups,
55 const MCSubtargetInfo &STI) const;
Ulrich Weigandb6a30d12013-06-24 11:03:33 +000056 unsigned getAbsCondBrEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +000057 SmallVectorImpl<MCFixup> &Fixups,
58 const MCSubtargetInfo &STI) const;
Ulrich Weigandfd3ad692013-06-26 13:49:15 +000059 unsigned getImm16Encoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +000060 SmallVectorImpl<MCFixup> &Fixups,
61 const MCSubtargetInfo &STI) const;
Chris Lattnerefacb9e2010-11-15 08:22:03 +000062 unsigned getMemRIEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +000063 SmallVectorImpl<MCFixup> &Fixups,
64 const MCSubtargetInfo &STI) const;
Chris Lattner8f4444d2010-11-15 08:02:41 +000065 unsigned getMemRIXEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +000066 SmallVectorImpl<MCFixup> &Fixups,
67 const MCSubtargetInfo &STI) const;
Bill Schmidtca4a0c92012-12-04 16:18:08 +000068 unsigned getTLSRegEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +000069 SmallVectorImpl<MCFixup> &Fixups,
70 const MCSubtargetInfo &STI) const;
Ulrich Weigand5143bab2013-07-02 21:31:04 +000071 unsigned getTLSCallEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +000072 SmallVectorImpl<MCFixup> &Fixups,
73 const MCSubtargetInfo &STI) const;
Chris Lattnerd6a07cc2010-11-15 05:19:25 +000074 unsigned get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +000075 SmallVectorImpl<MCFixup> &Fixups,
76 const MCSubtargetInfo &STI) const;
Chris Lattnerd6a07cc2010-11-15 05:19:25 +000077
Chris Lattner9ec375c2010-11-15 04:16:32 +000078 /// getMachineOpValue - Return binary encoding of operand. If the machine
79 /// operand requires relocation, record the relocation and return zero.
80 unsigned getMachineOpValue(const MCInst &MI,const MCOperand &MO,
David Woodhouse3fa98a62014-01-28 23:13:18 +000081 SmallVectorImpl<MCFixup> &Fixups,
82 const MCSubtargetInfo &STI) const;
Chris Lattner9ec375c2010-11-15 04:16:32 +000083
84 // getBinaryCodeForInstr - TableGen'erated function for getting the
85 // binary encoding for an instruction.
Owen Andersond845d9d2012-01-24 18:37:29 +000086 uint64_t getBinaryCodeForInstr(const MCInst &MI,
David Woodhouse3fa98a62014-01-28 23:13:18 +000087 SmallVectorImpl<MCFixup> &Fixups,
88 const MCSubtargetInfo &STI) const;
Chris Lattner9ec375c2010-11-15 04:16:32 +000089 void EncodeInstruction(const MCInst &MI, raw_ostream &OS,
David Woodhouse9784cef2014-01-28 23:13:07 +000090 SmallVectorImpl<MCFixup> &Fixups,
91 const MCSubtargetInfo &STI) const {
Bill Schmidtc763c222013-09-16 17:25:12 +000092 // For fast-isel, a float COPY_TO_REGCLASS can survive this long.
93 // It's just a nop to keep the register classes happy, so don't
94 // generate anything.
95 unsigned Opcode = MI.getOpcode();
Hal Finkela7bbaf62014-02-02 06:12:27 +000096 const MCInstrDesc &Desc = MCII.get(Opcode);
Bill Schmidtc763c222013-09-16 17:25:12 +000097 if (Opcode == TargetOpcode::COPY_TO_REGCLASS)
98 return;
99
David Woodhouse3fa98a62014-01-28 23:13:18 +0000100 uint64_t Bits = getBinaryCodeForInstr(MI, Fixups, STI);
Adhemerval Zanella1be10dc2012-10-25 14:29:13 +0000101
Ulrich Weigandcae3a172014-03-24 18:16:09 +0000102 // Output the constant in big/little endian byte order.
Hal Finkela7bbaf62014-02-02 06:12:27 +0000103 unsigned Size = Desc.getSize();
Ulrich Weigandcae3a172014-03-24 18:16:09 +0000104 if (IsLittleEndian) {
105 for (unsigned i = 0; i != Size; ++i) {
106 OS << (char)Bits;
107 Bits >>= 8;
108 }
109 } else {
110 int ShiftValue = (Size * 8) - 8;
111 for (unsigned i = 0; i != Size; ++i) {
112 OS << (char)(Bits >> ShiftValue);
113 Bits <<= 8;
114 }
Chris Lattner9ec375c2010-11-15 04:16:32 +0000115 }
116
117 ++MCNumEmitted; // Keep track of the # of mi's emitted.
118 }
119
120};
121
122} // end anonymous namespace
123
Evan Chengc5e6d2f2011-07-11 03:57:24 +0000124MCCodeEmitter *llvm::createPPCMCCodeEmitter(const MCInstrInfo &MCII,
Jim Grosbachc3b04272012-05-15 17:35:52 +0000125 const MCRegisterInfo &MRI,
Evan Chengc5e6d2f2011-07-11 03:57:24 +0000126 const MCSubtargetInfo &STI,
Chris Lattner9ec375c2010-11-15 04:16:32 +0000127 MCContext &Ctx) {
Ulrich Weigandcae3a172014-03-24 18:16:09 +0000128 Triple TT(STI.getTargetTriple());
129 bool IsLittleEndian = TT.getArch() == Triple::ppc64le;
130 return new PPCMCCodeEmitter(MCII, Ctx, IsLittleEndian);
Chris Lattner9ec375c2010-11-15 04:16:32 +0000131}
132
133unsigned PPCMCCodeEmitter::
Chris Lattner0e3461e2010-11-15 06:09:35 +0000134getDirectBrEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000135 SmallVectorImpl<MCFixup> &Fixups,
136 const MCSubtargetInfo &STI) const {
Chris Lattner79fa3712010-11-15 05:57:53 +0000137 const MCOperand &MO = MI.getOperand(OpNo);
David Woodhouse3fa98a62014-01-28 23:13:18 +0000138 if (MO.isReg() || MO.isImm()) return getMachineOpValue(MI, MO, Fixups, STI);
Chris Lattner79fa3712010-11-15 05:57:53 +0000139
140 // Add a fixup for the branch target.
141 Fixups.push_back(MCFixup::Create(0, MO.getExpr(),
142 (MCFixupKind)PPC::fixup_ppc_br24));
143 return 0;
144}
145
Chris Lattner0e3461e2010-11-15 06:09:35 +0000146unsigned PPCMCCodeEmitter::getCondBrEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000147 SmallVectorImpl<MCFixup> &Fixups,
148 const MCSubtargetInfo &STI) const {
Chris Lattner0e3461e2010-11-15 06:09:35 +0000149 const MCOperand &MO = MI.getOperand(OpNo);
David Woodhouse3fa98a62014-01-28 23:13:18 +0000150 if (MO.isReg() || MO.isImm()) return getMachineOpValue(MI, MO, Fixups, STI);
Chris Lattner0e3461e2010-11-15 06:09:35 +0000151
Chris Lattner85e37682010-11-15 06:12:22 +0000152 // Add a fixup for the branch target.
153 Fixups.push_back(MCFixup::Create(0, MO.getExpr(),
154 (MCFixupKind)PPC::fixup_ppc_brcond14));
Chris Lattner0e3461e2010-11-15 06:09:35 +0000155 return 0;
156}
157
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000158unsigned PPCMCCodeEmitter::
159getAbsDirectBrEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000160 SmallVectorImpl<MCFixup> &Fixups,
161 const MCSubtargetInfo &STI) const {
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000162 const MCOperand &MO = MI.getOperand(OpNo);
David Woodhouse3fa98a62014-01-28 23:13:18 +0000163 if (MO.isReg() || MO.isImm()) return getMachineOpValue(MI, MO, Fixups, STI);
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000164
165 // Add a fixup for the branch target.
166 Fixups.push_back(MCFixup::Create(0, MO.getExpr(),
167 (MCFixupKind)PPC::fixup_ppc_br24abs));
168 return 0;
169}
170
171unsigned PPCMCCodeEmitter::
172getAbsCondBrEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000173 SmallVectorImpl<MCFixup> &Fixups,
174 const MCSubtargetInfo &STI) const {
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000175 const MCOperand &MO = MI.getOperand(OpNo);
David Woodhouse3fa98a62014-01-28 23:13:18 +0000176 if (MO.isReg() || MO.isImm()) return getMachineOpValue(MI, MO, Fixups, STI);
Ulrich Weigandb6a30d12013-06-24 11:03:33 +0000177
178 // Add a fixup for the branch target.
179 Fixups.push_back(MCFixup::Create(0, MO.getExpr(),
180 (MCFixupKind)PPC::fixup_ppc_brcond14abs));
181 return 0;
182}
183
Ulrich Weigandfd3ad692013-06-26 13:49:15 +0000184unsigned PPCMCCodeEmitter::getImm16Encoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000185 SmallVectorImpl<MCFixup> &Fixups,
186 const MCSubtargetInfo &STI) const {
Chris Lattner65661122010-11-15 06:33:39 +0000187 const MCOperand &MO = MI.getOperand(OpNo);
David Woodhouse3fa98a62014-01-28 23:13:18 +0000188 if (MO.isReg() || MO.isImm()) return getMachineOpValue(MI, MO, Fixups, STI);
Chris Lattner65661122010-11-15 06:33:39 +0000189
Ulrich Weigandfd3ad692013-06-26 13:49:15 +0000190 // Add a fixup for the immediate field.
Ulrich Weigandcae3a172014-03-24 18:16:09 +0000191 Fixups.push_back(MCFixup::Create(IsLittleEndian? 0 : 2, MO.getExpr(),
Ulrich Weigand6e23ac62013-05-17 12:37:21 +0000192 (MCFixupKind)PPC::fixup_ppc_half16));
Chris Lattner65661122010-11-15 06:33:39 +0000193 return 0;
194}
195
Chris Lattnerefacb9e2010-11-15 08:22:03 +0000196unsigned PPCMCCodeEmitter::getMemRIEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000197 SmallVectorImpl<MCFixup> &Fixups,
198 const MCSubtargetInfo &STI) const {
Chris Lattnerefacb9e2010-11-15 08:22:03 +0000199 // Encode (imm, reg) as a memri, which has the low 16-bits as the
200 // displacement and the next 5 bits as the register #.
201 assert(MI.getOperand(OpNo+1).isReg());
David Woodhouse3fa98a62014-01-28 23:13:18 +0000202 unsigned RegBits = getMachineOpValue(MI, MI.getOperand(OpNo+1), Fixups, STI) << 16;
Chris Lattnerefacb9e2010-11-15 08:22:03 +0000203
204 const MCOperand &MO = MI.getOperand(OpNo);
205 if (MO.isImm())
David Woodhouse3fa98a62014-01-28 23:13:18 +0000206 return (getMachineOpValue(MI, MO, Fixups, STI) & 0xFFFF) | RegBits;
Chris Lattnerefacb9e2010-11-15 08:22:03 +0000207
208 // Add a fixup for the displacement field.
Ulrich Weigandcae3a172014-03-24 18:16:09 +0000209 Fixups.push_back(MCFixup::Create(IsLittleEndian? 0 : 2, MO.getExpr(),
Ulrich Weigand6e23ac62013-05-17 12:37:21 +0000210 (MCFixupKind)PPC::fixup_ppc_half16));
Chris Lattnerefacb9e2010-11-15 08:22:03 +0000211 return RegBits;
212}
213
214
Chris Lattner8f4444d2010-11-15 08:02:41 +0000215unsigned PPCMCCodeEmitter::getMemRIXEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000216 SmallVectorImpl<MCFixup> &Fixups,
217 const MCSubtargetInfo &STI) const {
Chris Lattner8f4444d2010-11-15 08:02:41 +0000218 // Encode (imm, reg) as a memrix, which has the low 14-bits as the
219 // displacement and the next 5 bits as the register #.
Chris Lattnerefacb9e2010-11-15 08:22:03 +0000220 assert(MI.getOperand(OpNo+1).isReg());
David Woodhouse3fa98a62014-01-28 23:13:18 +0000221 unsigned RegBits = getMachineOpValue(MI, MI.getOperand(OpNo+1), Fixups, STI) << 14;
Chris Lattner8f4444d2010-11-15 08:02:41 +0000222
Chris Lattner65661122010-11-15 06:33:39 +0000223 const MCOperand &MO = MI.getOperand(OpNo);
Chris Lattner8f4444d2010-11-15 08:02:41 +0000224 if (MO.isImm())
David Woodhouse3fa98a62014-01-28 23:13:18 +0000225 return ((getMachineOpValue(MI, MO, Fixups, STI) >> 2) & 0x3FFF) | RegBits;
Chris Lattner65661122010-11-15 06:33:39 +0000226
Ulrich Weigand3e186012013-03-26 10:56:47 +0000227 // Add a fixup for the displacement field.
Ulrich Weigandcae3a172014-03-24 18:16:09 +0000228 Fixups.push_back(MCFixup::Create(IsLittleEndian? 0 : 2, MO.getExpr(),
Ulrich Weigand6e23ac62013-05-17 12:37:21 +0000229 (MCFixupKind)PPC::fixup_ppc_half16ds));
Chris Lattner8f4444d2010-11-15 08:02:41 +0000230 return RegBits;
Chris Lattner65661122010-11-15 06:33:39 +0000231}
232
Chris Lattner0e3461e2010-11-15 06:09:35 +0000233
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000234unsigned PPCMCCodeEmitter::getTLSRegEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000235 SmallVectorImpl<MCFixup> &Fixups,
236 const MCSubtargetInfo &STI) const {
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000237 const MCOperand &MO = MI.getOperand(OpNo);
David Woodhouse3fa98a62014-01-28 23:13:18 +0000238 if (MO.isReg()) return getMachineOpValue(MI, MO, Fixups, STI);
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000239
240 // Add a fixup for the TLS register, which simply provides a relocation
241 // hint to the linker that this statement is part of a relocation sequence.
242 // Return the thread-pointer register's encoding.
243 Fixups.push_back(MCFixup::Create(0, MO.getExpr(),
Ulrich Weigand5b427592013-07-05 12:22:36 +0000244 (MCFixupKind)PPC::fixup_ppc_nofixup));
David Woodhoused2cca112014-01-28 23:13:25 +0000245 Triple TT(STI.getTargetTriple());
Roman Divackybc1655b42013-12-22 10:45:37 +0000246 bool isPPC64 = TT.getArch() == Triple::ppc64 || TT.getArch() == Triple::ppc64le;
247 return CTX.getRegisterInfo()->getEncodingValue(isPPC64 ? PPC::X13 : PPC::R2);
Bill Schmidtca4a0c92012-12-04 16:18:08 +0000248}
249
Ulrich Weigand5143bab2013-07-02 21:31:04 +0000250unsigned PPCMCCodeEmitter::getTLSCallEncoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000251 SmallVectorImpl<MCFixup> &Fixups,
252 const MCSubtargetInfo &STI) const {
Ulrich Weigand5143bab2013-07-02 21:31:04 +0000253 // For special TLS calls, we need two fixups; one for the branch target
254 // (__tls_get_addr), which we create via getDirectBrEncoding as usual,
255 // and one for the TLSGD or TLSLD symbol, which is emitted here.
256 const MCOperand &MO = MI.getOperand(OpNo+1);
257 Fixups.push_back(MCFixup::Create(0, MO.getExpr(),
258 (MCFixupKind)PPC::fixup_ppc_nofixup));
David Woodhouse3fa98a62014-01-28 23:13:18 +0000259 return getDirectBrEncoding(MI, OpNo, Fixups, STI);
Ulrich Weigand5143bab2013-07-02 21:31:04 +0000260}
261
Chris Lattner79fa3712010-11-15 05:57:53 +0000262unsigned PPCMCCodeEmitter::
Chris Lattnerd6a07cc2010-11-15 05:19:25 +0000263get_crbitm_encoding(const MCInst &MI, unsigned OpNo,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000264 SmallVectorImpl<MCFixup> &Fixups,
265 const MCSubtargetInfo &STI) const {
Chris Lattnerd6a07cc2010-11-15 05:19:25 +0000266 const MCOperand &MO = MI.getOperand(OpNo);
Ulrich Weigand49f487e2013-07-03 17:59:07 +0000267 assert((MI.getOpcode() == PPC::MTOCRF || MI.getOpcode() == PPC::MTOCRF8 ||
Ulrich Weigandd5ebc622013-07-03 17:05:42 +0000268 MI.getOpcode() == PPC::MFOCRF || MI.getOpcode() == PPC::MFOCRF8) &&
Chris Lattnerd6a07cc2010-11-15 05:19:25 +0000269 (MO.getReg() >= PPC::CR0 && MO.getReg() <= PPC::CR7));
Bill Wendlingbc07a892013-06-18 07:20:20 +0000270 return 0x80 >> CTX.getRegisterInfo()->getEncodingValue(MO.getReg());
Chris Lattnerd6a07cc2010-11-15 05:19:25 +0000271}
272
273
274unsigned PPCMCCodeEmitter::
Chris Lattner9ec375c2010-11-15 04:16:32 +0000275getMachineOpValue(const MCInst &MI, const MCOperand &MO,
David Woodhouse3fa98a62014-01-28 23:13:18 +0000276 SmallVectorImpl<MCFixup> &Fixups,
277 const MCSubtargetInfo &STI) const {
Chris Lattnerd6a07cc2010-11-15 05:19:25 +0000278 if (MO.isReg()) {
Ulrich Weigand49f487e2013-07-03 17:59:07 +0000279 // MTOCRF/MFOCRF should go through get_crbitm_encoding for the CR operand.
Chris Lattner7b25d6f2010-11-16 00:57:32 +0000280 // The GPR operand should come through here though.
Ulrich Weigand49f487e2013-07-03 17:59:07 +0000281 assert((MI.getOpcode() != PPC::MTOCRF && MI.getOpcode() != PPC::MTOCRF8 &&
Ulrich Weigandd5ebc622013-07-03 17:05:42 +0000282 MI.getOpcode() != PPC::MFOCRF && MI.getOpcode() != PPC::MFOCRF8) ||
Chris Lattner73716a62010-11-16 00:55:51 +0000283 MO.getReg() < PPC::CR0 || MO.getReg() > PPC::CR7);
Bill Wendlingbc07a892013-06-18 07:20:20 +0000284 return CTX.getRegisterInfo()->getEncodingValue(MO.getReg());
Chris Lattnerd6a07cc2010-11-15 05:19:25 +0000285 }
Chris Lattnerc877d8f2010-11-15 04:51:55 +0000286
Chris Lattnerefacb9e2010-11-15 08:22:03 +0000287 assert(MO.isImm() &&
288 "Relocation required in an instruction that we cannot encode!");
289 return MO.getImm();
Chris Lattner9ec375c2010-11-15 04:16:32 +0000290}
291
292
293#include "PPCGenMCCodeEmitter.inc"