Skip to content

Commit 055192c

Browse files
author
Simon Dardis
committed
[mips] Enable spilling and reloading of the dsp register set.
The dsp register class is an alias of the gpr register class, so we have to define instructions for spilling and reloading. Reviewers: atanasyan Differential Revision: https://reviews.llvm.org/D38038 llvm-svn: 314798
1 parent f8db453 commit 055192c

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

llvm/lib/Target/Mips/MicroMipsDSPInstrInfo.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,13 @@ class BITREV_MM_DESC : ABSQ_S_PH_MM_R2_DESC_BASE<"bitrev", int_mips_bitrev,
415415
class BPOSGE32_MM_DESC : BPOSGE32_DESC_BASE<"bposge32", brtarget_mm,
416416
NoItinerary>;
417417

418+
let DecoderNamespace = "MicroMipsDSP", Arch = "mmdsp",
419+
AdditionalPredicates = [HasDSP, InMicroMips] in {
420+
def LWDSP_MM : Load<"lw", DSPROpnd, null_frag, II_LW>, DspMMRel,
421+
LW_FM_MM<0x3f>;
422+
def SWDSP_MM : Store<"sw", DSPROpnd, null_frag, II_SW>, DspMMRel,
423+
LW_FM_MM<0x3e>;
424+
}
418425
// Instruction defs.
419426
// microMIPS DSP Rev 1
420427
def ADDQ_PH_MM : DspMMRel, ADDQ_PH_MM_ENC, ADDQ_PH_DESC;

llvm/lib/Target/Mips/MipsDSPInstrInfo.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,6 +1284,12 @@ let isPseudo = 1, isCodeGenOnly = 1, hasNoSchedulingInfo = 1 in {
12841284
def STORE_CCOND_DSP : Store<"store_ccond_dsp", DSPCC>;
12851285
}
12861286

1287+
let DecoderNamespace = "MipsDSP", Arch = "dsp",
1288+
AdditionalPredicates = [HasDSP] in {
1289+
def LWDSP : Load<"lw", DSPROpnd, null_frag, II_LW>, DspMMRel, LW_FM<0x23>;
1290+
def SWDSP : Store<"sw", DSPROpnd, null_frag, II_SW>, DspMMRel, LW_FM<0x2b>;
1291+
}
1292+
12871293
// Pseudo CMP and PICK instructions.
12881294
class PseudoCMP<Instruction RealInst> :
12891295
PseudoDSP<(outs DSPCC:$cmp), (ins DSPROpnd:$rs, DSPROpnd:$rt), []>,

llvm/lib/Target/Mips/MipsSEInstrInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ storeRegToStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
226226
Opc = Mips::SW;
227227
else if (Mips::HI64RegClass.hasSubClassEq(RC))
228228
Opc = Mips::SD;
229+
else if (Mips::DSPRRegClass.hasSubClassEq(RC))
230+
Opc = Mips::SWDSP;
229231

230232
// Hi, Lo are normally caller save but they are callee save
231233
// for interrupt handling.
@@ -302,6 +304,8 @@ loadRegFromStack(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
302304
Opc = Mips::LW;
303305
else if (Mips::LO64RegClass.hasSubClassEq(RC))
304306
Opc = Mips::LD;
307+
else if (Mips::DSPRRegClass.hasSubClassEq(RC))
308+
Opc = Mips::LWDSP;
305309

306310
assert(Opc && "Register class not handled!");
307311

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
; RUN: llc -march=mips -mattr=+dsp < %s -asm-show-inst -O0 | FileCheck %s \
2+
; RUN: --check-prefixes=ASM,ALL
3+
; RUN: llc -march=mips -mattr=+dsp,+micromips < %s -O0 -filetype=obj | \
4+
; RUN: llvm-objdump -d - | FileCheck %s --check-prefixes=MM-OBJ,ALL
5+
6+
; Test that spill and reloads use the dsp "variant" instructions. We use -O0
7+
; to use the simple register allocator.
8+
9+
; To test the micromips output, we have to take a round trip through the
10+
; object file encoder/decoder as the instruction mapping tables are used to
11+
; support micromips.
12+
13+
; FIXME: We should be able to get rid of those instructions with the variable
14+
; value registers.
15+
16+
; ALL-LABEL: spill_reload:
17+
18+
define <4 x i8> @spill_reload(<4 x i8> %a, <4 x i8> %b, i32 %g) {
19+
entry:
20+
%c = tail call <4 x i8> @llvm.mips.addu.qb(<4 x i8> %a, <4 x i8> %b)
21+
%cond = icmp eq i32 %g, 0
22+
br i1 %cond, label %true, label %end
23+
24+
; ASM: SWDSP
25+
; ASM: SWDSP
26+
; ASM: SWDSP
27+
28+
; MM-OBJ: sw ${{[0-9]+}}, {{[0-9]+}}($sp)
29+
; MM-OBJ: sw ${{[0-9]+}}, {{[0-9]+}}($sp)
30+
; MM-OBJ: sw ${{[0-9]+}}, {{[0-9]+}}($sp)
31+
; MM-OBJ: sw ${{[0-9]+}}, {{[0-9]+}}($sp)
32+
33+
true:
34+
ret <4 x i8> %c
35+
36+
; ASM: LWDSP
37+
38+
; MM-OBJ: lw ${{[0-9]+}}, {{[0-9]+}}($sp)
39+
40+
end:
41+
%d = tail call <4 x i8> @llvm.mips.addu.qb(<4 x i8> %c, <4 x i8> %a)
42+
ret <4 x i8> %d
43+
44+
; ASM: LWDSP
45+
; ASM: LWDSP
46+
47+
; MM-OBJ: lw ${{[0-9]+}}, {{[0-9]+}}($sp)
48+
; MM-OBJ: lw ${{[0-9]+}}, {{[0-9]+}}($sp)
49+
50+
}
51+
52+
declare <4 x i8> @llvm.mips.addu.qb(<4 x i8>, <4 x i8>) nounwind

0 commit comments

Comments
 (0)