Skip to content

Commit 2f3a362

Browse files
koachanbrad0
authored andcommitted
[SPARC][IAS] Add v9 encoding of %fq
While both SPARCv7/v8 and v9 has a register named %fq, they encode it differently, so we need to differentiate between them. Reviewed By: barannikov88 Differential Revision: https://reviews.llvm.org/D157232
1 parent c6ce32d commit 2f3a362

File tree

4 files changed

+19
-1
lines changed

4 files changed

+19
-1
lines changed

llvm/lib/Target/Sparc/SparcInstrInfo.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,15 @@ let rs2 = 0 in
17691769
def RDPR : F3_1<2, 0b101010,
17701770
(outs IntRegs:$rd), (ins PRRegs:$rs1),
17711771
"rdpr $rs1, $rd", []>;
1772+
1773+
// Special case %fq as the register is also used in V8
1774+
// (albeit with different instructions and encoding).
1775+
// This allows us to reuse the register definition and
1776+
// the "%fq" designation while giving it a different encoding.
1777+
let Uses = [FQ], rs1 = 15, rs2 = 0 in
1778+
def RDFQ : F3_1<2, 0b101010,
1779+
(outs IntRegs:$rd), (ins),
1780+
"rdpr %fq, $rd", []>;
17721781
}
17731782

17741783
// Section A.62 - Write Privileged Register Instructions

llvm/test/MC/Disassembler/Sparc/sparc-special-registers.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@
3737
# CHECK: st %fsr, [%i5]
3838
0xc1 0x2f 0x40 0x00
3939

40-
# CHECK: std %fq, [%i5+%l1]
40+
## The same encoding resolves to different instructions in V8 and V9.
41+
# V8: std %fq, [%i5+%l1]
42+
# V9: stq %f0, [%i5+%l1]
4143
0xc1 0x37 0x40 0x11
4244

4345

llvm/test/MC/Disassembler/Sparc/sparc-v9.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,6 @@
149149

150150
# CHECK: restored
151151
0x83,0x88,0x00,0x00
152+
153+
# CHECK: rdpr %fq, %i5
154+
0xbb,0x53,0xc0,0x00

llvm/test/MC/Sparc/sparcv9-instructions.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,10 @@
416416
! V9: rdpr %wstate, %i5 ! encoding: [0xbb,0x53,0x80,0x00]
417417
rdpr %wstate,%i5
418418

419+
! V8: error: instruction requires a CPU feature not currently enabled
420+
! V8-NEXT: rdpr %fq,%i5
421+
! V9: rdpr %fq, %i5 ! encoding: [0xbb,0x53,0xc0,0x00]
422+
rdpr %fq,%i5
419423
! V8: error: instruction requires a CPU feature not currently enabled
420424
! V8-NEXT: rdpr %ver,%i5
421425
! V9: rdpr %ver, %i5 ! encoding: [0xbb,0x57,0xc0,0x00]

0 commit comments

Comments
 (0)