@@ -85,7 +85,7 @@ class MipsCodeEmitter : public MachineFunctionPass {
85
85
86
86
private:
87
87
88
- void emitWordLE (unsigned Word);
88
+ void emitWord (unsigned Word);
89
89
90
90
// / Routines that handle operands which add machine relocations which are
91
91
// / fixed up by the relocation stage.
@@ -112,12 +112,6 @@ class MipsCodeEmitter : public MachineFunctionPass {
112
112
unsigned getSizeExtEncoding (const MachineInstr &MI, unsigned OpNo) const ;
113
113
unsigned getSizeInsEncoding (const MachineInstr &MI, unsigned OpNo) const ;
114
114
115
- int emitULW (const MachineInstr &MI);
116
- int emitUSW (const MachineInstr &MI);
117
- int emitULH (const MachineInstr &MI);
118
- int emitULHu (const MachineInstr &MI);
119
- int emitUSH (const MachineInstr &MI);
120
-
121
115
void emitGlobalAddressUnaligned (const GlobalValue *GV, unsigned Reloc,
122
116
int Offset) const ;
123
117
};
@@ -133,7 +127,7 @@ bool MipsCodeEmitter::runOnMachineFunction(MachineFunction &MF) {
133
127
MCPEs = &MF.getConstantPool ()->getConstants ();
134
128
MJTEs = 0 ;
135
129
if (MF.getJumpTableInfo ()) MJTEs = &MF.getJumpTableInfo ()->getJumpTables ();
136
- JTI->Initialize (MF, IsPIC);
130
+ JTI->Initialize (MF, IsPIC, Subtarget-> isLittle () );
137
131
MCE.setModuleInfo (&getAnalysis<MachineModuleInfo> ());
138
132
139
133
do {
@@ -271,103 +265,6 @@ void MipsCodeEmitter::emitMachineBasicBlock(MachineBasicBlock *BB,
271
265
Reloc, BB));
272
266
}
273
267
274
- int MipsCodeEmitter::emitUSW (const MachineInstr &MI) {
275
- unsigned src = getMachineOpValue (MI, MI.getOperand (0 ));
276
- unsigned base = getMachineOpValue (MI, MI.getOperand (1 ));
277
- unsigned offset = getMachineOpValue (MI, MI.getOperand (2 ));
278
- // swr src, offset(base)
279
- // swl src, offset+3(base)
280
- MCE.emitWordLE (
281
- (0x2e << 26 ) | (base << 21 ) | (src << 16 ) | (offset & 0xffff ));
282
- MCE.emitWordLE (
283
- (0x2a << 26 ) | (base << 21 ) | (src << 16 ) | ((offset+3 ) & 0xffff ));
284
- return 2 ;
285
- }
286
-
287
- int MipsCodeEmitter::emitULW (const MachineInstr &MI) {
288
- unsigned dst = getMachineOpValue (MI, MI.getOperand (0 ));
289
- unsigned base = getMachineOpValue (MI, MI.getOperand (1 ));
290
- unsigned offset = getMachineOpValue (MI, MI.getOperand (2 ));
291
- unsigned at = 1 ;
292
- if (dst != base) {
293
- // lwr dst, offset(base)
294
- // lwl dst, offset+3(base)
295
- MCE.emitWordLE (
296
- (0x26 << 26 ) | (base << 21 ) | (dst << 16 ) | (offset & 0xffff ));
297
- MCE.emitWordLE (
298
- (0x22 << 26 ) | (base << 21 ) | (dst << 16 ) | ((offset+3 ) & 0xffff ));
299
- return 2 ;
300
- } else {
301
- // lwr at, offset(base)
302
- // lwl at, offset+3(base)
303
- // addu dst, at, $zero
304
- MCE.emitWordLE (
305
- (0x26 << 26 ) | (base << 21 ) | (at << 16 ) | (offset & 0xffff ));
306
- MCE.emitWordLE (
307
- (0x22 << 26 ) | (base << 21 ) | (at << 16 ) | ((offset+3 ) & 0xffff ));
308
- MCE.emitWordLE (
309
- (0x0 << 26 ) | (at << 21 ) | (0x0 << 16 ) | (dst << 11 ) | (0x0 << 6 ) | 0x21 );
310
- return 3 ;
311
- }
312
- }
313
-
314
- int MipsCodeEmitter::emitUSH (const MachineInstr &MI) {
315
- unsigned src = getMachineOpValue (MI, MI.getOperand (0 ));
316
- unsigned base = getMachineOpValue (MI, MI.getOperand (1 ));
317
- unsigned offset = getMachineOpValue (MI, MI.getOperand (2 ));
318
- unsigned at = 1 ;
319
- // sb src, offset(base)
320
- // srl at,src,8
321
- // sb at, offset+1(base)
322
- MCE.emitWordLE (
323
- (0x28 << 26 ) | (base << 21 ) | (src << 16 ) | (offset & 0xffff ));
324
- MCE.emitWordLE (
325
- (0x0 << 26 ) | (0x0 << 21 ) | (src << 16 ) | (at << 11 ) | (0x8 << 6 ) | 0x2 );
326
- MCE.emitWordLE (
327
- (0x28 << 26 ) | (base << 21 ) | (at << 16 ) | ((offset+1 ) & 0xffff ));
328
- return 3 ;
329
- }
330
-
331
- int MipsCodeEmitter::emitULH (const MachineInstr &MI) {
332
- unsigned dst = getMachineOpValue (MI, MI.getOperand (0 ));
333
- unsigned base = getMachineOpValue (MI, MI.getOperand (1 ));
334
- unsigned offset = getMachineOpValue (MI, MI.getOperand (2 ));
335
- unsigned at = 1 ;
336
- // lbu at, offset(base)
337
- // lb dst, offset+1(base)
338
- // sll dst,dst,8
339
- // or dst,dst,at
340
- MCE.emitWordLE (
341
- (0x24 << 26 ) | (base << 21 ) | (at << 16 ) | (offset & 0xffff ));
342
- MCE.emitWordLE (
343
- (0x20 << 26 ) | (base << 21 ) | (dst << 16 ) | ((offset+1 ) & 0xffff ));
344
- MCE.emitWordLE (
345
- (0x0 << 26 ) | (0x0 << 21 ) | (dst << 16 ) | (dst << 11 ) | (0x8 << 6 ) | 0x0 );
346
- MCE.emitWordLE (
347
- (0x0 << 26 ) | (dst << 21 ) | (at << 16 ) | (dst << 11 ) | (0x0 << 6 ) | 0x25 );
348
- return 4 ;
349
- }
350
-
351
- int MipsCodeEmitter::emitULHu (const MachineInstr &MI) {
352
- unsigned dst = getMachineOpValue (MI, MI.getOperand (0 ));
353
- unsigned base = getMachineOpValue (MI, MI.getOperand (1 ));
354
- unsigned offset = getMachineOpValue (MI, MI.getOperand (2 ));
355
- unsigned at = 1 ;
356
- // lbu at, offset(base)
357
- // lbu dst, offset+1(base)
358
- // sll dst,dst,8
359
- // or dst,dst,at
360
- MCE.emitWordLE (
361
- (0x24 << 26 ) | (base << 21 ) | (at << 16 ) | (offset & 0xffff ));
362
- MCE.emitWordLE (
363
- (0x24 << 26 ) | (base << 21 ) | (dst << 16 ) | ((offset+1 ) & 0xffff ));
364
- MCE.emitWordLE (
365
- (0x0 << 26 ) | (0x0 << 21 ) | (dst << 16 ) | (dst << 11 ) | (0x8 << 6 ) | 0x0 );
366
- MCE.emitWordLE (
367
- (0x0 << 26 ) | (dst << 21 ) | (at << 16 ) | (dst << 11 ) | (0x0 << 6 ) | 0x25 );
368
- return 4 ;
369
- }
370
-
371
268
void MipsCodeEmitter::emitInstruction (const MachineInstr &MI) {
372
269
DEBUG (errs () << " JIT: " << (void *)MCE.getCurrentPCValue () << " :\t " << MI);
373
270
@@ -377,16 +274,19 @@ void MipsCodeEmitter::emitInstruction(const MachineInstr &MI) {
377
274
if ((MI.getDesc ().TSFlags & MipsII::FormMask) == MipsII::Pseudo)
378
275
return ;
379
276
380
- emitWordLE (getBinaryCodeForInstr (MI));
277
+ emitWord (getBinaryCodeForInstr (MI));
381
278
++NumEmitted; // Keep track of the # of mi's emitted
382
279
383
280
MCE.processDebugLoc (MI.getDebugLoc (), false );
384
281
}
385
282
386
- void MipsCodeEmitter::emitWordLE (unsigned Word) {
283
+ void MipsCodeEmitter::emitWord (unsigned Word) {
387
284
DEBUG (errs () << " 0x" ;
388
285
errs ().write_hex (Word) << " \n " );
389
- MCE.emitWordLE (Word);
286
+ if (Subtarget->isLittle ())
287
+ MCE.emitWordLE (Word);
288
+ else
289
+ MCE.emitWordBE (Word);
390
290
}
391
291
392
292
// / createMipsJITCodeEmitterPass - Return a pass that emits the collected Mips
0 commit comments