Skip to content

Commit b770c00

Browse files
author
Jim Grosbach
committed
Reapply 116059, this time without the fatfingered pasto at the top.
''const'ify getMachineOpValue() and associated helpers.' llvm-svn: 116067
1 parent 71dee18 commit b770c00

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

llvm/lib/Target/ARM/ARMCodeEmitter.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ namespace {
150150

151151
/// getMachineOpValue - Return binary encoding of operand. If the machine
152152
/// operand requires relocation, record the relocation and return zero.
153-
unsigned getMachineOpValue(const MachineInstr &MI,const MachineOperand &MO);
154-
unsigned getMachineOpValue(const MachineInstr &MI, unsigned OpIdx) {
153+
unsigned getMachineOpValue(const MachineInstr &MI,
154+
const MachineOperand &MO) const;
155+
unsigned getMachineOpValue(const MachineInstr &MI, unsigned OpIdx) const {
155156
return getMachineOpValue(MI, MI.getOperand(OpIdx));
156157
}
157158

@@ -169,12 +170,12 @@ namespace {
169170
/// fixed up by the relocation stage.
170171
void emitGlobalAddress(const GlobalValue *GV, unsigned Reloc,
171172
bool MayNeedFarStub, bool Indirect,
172-
intptr_t ACPV = 0);
173-
void emitExternalSymbolAddress(const char *ES, unsigned Reloc);
174-
void emitConstPoolAddress(unsigned CPI, unsigned Reloc);
175-
void emitJumpTableAddress(unsigned JTIndex, unsigned Reloc);
173+
intptr_t ACPV = 0) const;
174+
void emitExternalSymbolAddress(const char *ES, unsigned Reloc) const;
175+
void emitConstPoolAddress(unsigned CPI, unsigned Reloc) const;
176+
void emitJumpTableAddress(unsigned JTIndex, unsigned Reloc) const;
176177
void emitMachineBasicBlock(MachineBasicBlock *BB, unsigned Reloc,
177-
intptr_t JTBase = 0);
178+
intptr_t JTBase = 0) const;
178179
};
179180
}
180181

@@ -262,7 +263,7 @@ unsigned ARMCodeEmitter::getMovi32Value(const MachineInstr &MI,
262263
/// getMachineOpValue - Return binary encoding of operand. If the machine
263264
/// operand requires relocation, record the relocation and return zero.
264265
unsigned ARMCodeEmitter::getMachineOpValue(const MachineInstr &MI,
265-
const MachineOperand &MO) {
266+
const MachineOperand &MO) const {
266267
if (MO.isReg())
267268
return getARMRegisterNumbering(MO.getReg());
268269
else if (MO.isImm())
@@ -294,7 +295,7 @@ unsigned ARMCodeEmitter::getMachineOpValue(const MachineInstr &MI,
294295
///
295296
void ARMCodeEmitter::emitGlobalAddress(const GlobalValue *GV, unsigned Reloc,
296297
bool MayNeedFarStub, bool Indirect,
297-
intptr_t ACPV) {
298+
intptr_t ACPV) const {
298299
MachineRelocation MR = Indirect
299300
? MachineRelocation::getIndirectSymbol(MCE.getCurrentPCOffset(), Reloc,
300301
const_cast<GlobalValue *>(GV),
@@ -308,15 +309,16 @@ void ARMCodeEmitter::emitGlobalAddress(const GlobalValue *GV, unsigned Reloc,
308309
/// emitExternalSymbolAddress - Arrange for the address of an external symbol to
309310
/// be emitted to the current location in the function, and allow it to be PC
310311
/// relative.
311-
void ARMCodeEmitter::emitExternalSymbolAddress(const char *ES, unsigned Reloc) {
312+
void ARMCodeEmitter::
313+
emitExternalSymbolAddress(const char *ES, unsigned Reloc) const {
312314
MCE.addRelocation(MachineRelocation::getExtSym(MCE.getCurrentPCOffset(),
313315
Reloc, ES));
314316
}
315317

316318
/// emitConstPoolAddress - Arrange for the address of an constant pool
317319
/// to be emitted to the current location in the function, and allow it to be PC
318320
/// relative.
319-
void ARMCodeEmitter::emitConstPoolAddress(unsigned CPI, unsigned Reloc) {
321+
void ARMCodeEmitter::emitConstPoolAddress(unsigned CPI, unsigned Reloc) const {
320322
// Tell JIT emitter we'll resolve the address.
321323
MCE.addRelocation(MachineRelocation::getConstPool(MCE.getCurrentPCOffset(),
322324
Reloc, CPI, 0, true));
@@ -325,14 +327,16 @@ void ARMCodeEmitter::emitConstPoolAddress(unsigned CPI, unsigned Reloc) {
325327
/// emitJumpTableAddress - Arrange for the address of a jump table to
326328
/// be emitted to the current location in the function, and allow it to be PC
327329
/// relative.
328-
void ARMCodeEmitter::emitJumpTableAddress(unsigned JTIndex, unsigned Reloc) {
330+
void ARMCodeEmitter::
331+
emitJumpTableAddress(unsigned JTIndex, unsigned Reloc) const {
329332
MCE.addRelocation(MachineRelocation::getJumpTable(MCE.getCurrentPCOffset(),
330333
Reloc, JTIndex, 0, true));
331334
}
332335

333336
/// emitMachineBasicBlock - Emit the specified address basic block.
334337
void ARMCodeEmitter::emitMachineBasicBlock(MachineBasicBlock *BB,
335-
unsigned Reloc, intptr_t JTBase) {
338+
unsigned Reloc,
339+
intptr_t JTBase) const {
336340
MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(),
337341
Reloc, BB, JTBase));
338342
}

llvm/lib/Target/ARM/ARMMCCodeEmitter.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class ARMMCCodeEmitter : public MCCodeEmitter {
4444

4545
/// getMachineOpValue - Return binary encoding of operand. If the machine
4646
/// operand requires relocation, record the relocation and return zero.
47-
unsigned getMachineOpValue(const MCInst &MI,const MCOperand &MO);
48-
unsigned getMachineOpValue(const MCInst &MI, unsigned OpIdx) {
47+
unsigned getMachineOpValue(const MCInst &MI,const MCOperand &MO) const;
48+
unsigned getMachineOpValue(const MCInst &MI, unsigned OpIdx) const {
4949
return getMachineOpValue(MI, MI.getOperand(OpIdx));
5050
}
5151

@@ -120,17 +120,13 @@ EncodeInstruction(const MCInst &MI, raw_ostream &OS,
120120
return;
121121

122122
++MCNumEmitted; // Keep track of the # of mi's emitted
123-
switch (TSFlags & ARMII::FormMask) {
124-
case ARMII::BrMiscFrm:
125-
case ARMII::MiscFrm: {
123+
switch (Opcode) {
124+
//FIXME: Any non-pseudos that need special handling, if there are any...
125+
default: {
126126
unsigned Value = getBinaryCodeForInstr(MI);
127127
EmitConstant(Value, 4, CurByte, OS);
128128
break;
129129
}
130-
default: {
131-
llvm_unreachable("Unhandled instruction encoding format!");
132-
break;
133-
}
134130
}
135131
}
136132

0 commit comments

Comments
 (0)