Skip to content

Commit cf19c6b

Browse files
authored
[SPARC][IAS] Add definitions for UA 2007 instructions
Reviewers: rorth, s-barannikov, brad0 Reviewed By: s-barannikov Pull Request: #138401
1 parent 9e44f0d commit cf19c6b

File tree

6 files changed

+96
-4
lines changed

6 files changed

+96
-4
lines changed

llvm/lib/Target/Sparc/Sparc.td

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ def FeatureVIS3
5252
def FeatureUA2005
5353
: SubtargetFeature<"ua2005", "IsUA2005", "true",
5454
"Enable UltraSPARC Architecture 2005 extensions">;
55+
def FeatureUA2007
56+
: SubtargetFeature<"ua2007", "IsUA2007", "true",
57+
"Enable UltraSPARC Architecture 2007 extensions">;
5558
def FeatureLeon
5659
: SubtargetFeature<"leon", "IsLeon", "true",
5760
"Enable LEON extensions">;
@@ -160,10 +163,10 @@ def : Proc<"niagara2", [FeatureV9, FeatureV8Deprecated, UsePopc,
160163
FeatureVIS, FeatureVIS2, FeatureUA2005]>;
161164
def : Proc<"niagara3", [FeatureV9, FeatureV8Deprecated, UsePopc,
162165
FeatureVIS, FeatureVIS2, FeatureVIS3,
163-
FeatureUA2005]>;
166+
FeatureUA2005, FeatureUA2007]>;
164167
def : Proc<"niagara4", [FeatureV9, FeatureV8Deprecated, UsePopc,
165168
FeatureVIS, FeatureVIS2, FeatureVIS3,
166-
FeatureUA2005]>;
169+
FeatureUA2005, FeatureUA2007]>;
167170

168171
// LEON 2 FT generic
169172
def : Processor<"leon2", LEON2Itineraries,

llvm/lib/Target/Sparc/SparcInstrFormats.td

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,23 @@ multiclass F3_S<string OpcStr, bits<6> Op3Val, bit XVal, SDNode OpNode,
260260
itin>;
261261
}
262262

263+
// 4-operand instructions.
264+
class F3_4<bits<6> op3val, bits<4> op5val, dag outs, dag ins,
265+
string asmstr, list<dag> pattern = [], InstrItinClass itin = NoItinerary>
266+
: F3<outs, ins, asmstr, pattern, itin> {
267+
bits<4> op5;
268+
bits<5> rs3;
269+
bits<5> rs2;
270+
271+
let op = 2;
272+
let op3 = op3val;
273+
let op5 = op5val;
274+
275+
let Inst{13-9} = rs3;
276+
let Inst{8-5} = op5;
277+
let Inst{4-0} = rs2;
278+
}
279+
263280
class F4<bits<6> op3, dag outs, dag ins, string asmstr, list<dag> pattern,
264281
InstrItinClass itin = NoItinerary>
265282
: InstSP<outs, ins, asmstr, pattern, itin> {

llvm/lib/Target/Sparc/SparcInstrInfo.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ def HasVIS3 : Predicate<"Subtarget->isVIS3()">,
5151
def HasUA2005 : Predicate<"Subtarget->isUA2005()">,
5252
AssemblerPredicate<(all_of FeatureUA2005)>;
5353

54+
// HasUA2007 - This is true when the target processor has UA 2007 extensions.
55+
def HasUA2007 : Predicate<"Subtarget->isUA2007()">,
56+
AssemblerPredicate<(all_of FeatureUA2007)>;
57+
5458
// HasHardQuad - This is true when the target processor supports quad floating
5559
// point instructions.
5660
def HasHardQuad : Predicate<"Subtarget->hasHardQuad()">;

llvm/lib/Target/Sparc/SparcInstrUAOSA.td

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//===----------------------------------------------------------------------===//
88
//
99
// This file contains instruction formats, definitions and patterns needed for
10-
// UA 2005 instructions on SPARC.
10+
// UA 2005 and UA 2007 instructions on SPARC.
1111
//===----------------------------------------------------------------------===//
1212

1313
class UA2005RegWin<string asmstr, bits<5> fcn>
@@ -17,6 +17,12 @@ class UA2005RegWin<string asmstr, bits<5> fcn>
1717
let rs2 = 0;
1818
}
1919

20+
// Convenience template for 4-operand instructions
21+
class FourOp<string OpcStr, bits<6> op3val, bits<4> op5val,
22+
RegisterClass RC>
23+
: F3_4<op3val, op5val, (outs RC:$rd), (ins RC:$rs1, RC:$rs2, RC:$rs3),
24+
!strconcat(OpcStr, " $rs1, $rs2, $rs3, $rd")>;
25+
2026
// UltraSPARC Architecture 2005 Instructions
2127
let Predicates = [HasUA2005] in {
2228
let hasSideEffects = 1 in {
@@ -26,3 +32,16 @@ def NORMALW : UA2005RegWin<"normalw", 0b00100>;
2632
def OTHERW : UA2005RegWin<"otherw", 0b00011>;
2733
}
2834
} // Predicates = [HasUA2005]
35+
36+
// UltraSPARC Architecture 2007 Instructions
37+
let Predicates = [HasUA2007] in {
38+
def FMADDS : FourOp<"fmadds", 0b110111, 0b0001, FPRegs>;
39+
def FMADDD : FourOp<"fmaddd", 0b110111, 0b0010, DFPRegs>;
40+
def FMSUBS : FourOp<"fmsubs", 0b110111, 0b0101, FPRegs>;
41+
def FMSUBD : FourOp<"fmsubd", 0b110111, 0b0110, DFPRegs>;
42+
43+
def FNMADDS : FourOp<"fnmadds", 0b110111, 0b1101, FPRegs>;
44+
def FNMADDD : FourOp<"fnmaddd", 0b110111, 0b1110, DFPRegs>;
45+
def FNMSUBS : FourOp<"fnmsubs", 0b110111, 0b1001, FPRegs>;
46+
def FNMSUBD : FourOp<"fnmsubd", 0b110111, 0b1010, DFPRegs>;
47+
} // Predicates = [HasUA2007]

llvm/test/MC/Disassembler/Sparc/sparc-ua-osa.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RUN: llvm-mc --disassemble %s -triple=sparcv9-unknown-linux -mattr=+ua2005 | FileCheck %s
1+
# RUN: llvm-mc --disassemble %s -triple=sparcv9-unknown-linux -mattr=+ua2005,+ua2007 | FileCheck %s
22

33
## UA 2005 instructions.
44

@@ -10,3 +10,22 @@
1010
0x87,0x88,0x00,0x00
1111
# CHECK: normalw
1212
0x89,0x88,0x00,0x00
13+
14+
## UA 2007 instructions.
15+
16+
# CHECK: fmadds %f1, %f3, %f5, %f7
17+
0x8f,0xb8,0x4a,0x23
18+
# CHECK: fmaddd %f0, %f2, %f4, %f6
19+
0x8d,0xb8,0x08,0x42
20+
# CHECK: fmsubs %f1, %f3, %f5, %f7
21+
0x8f,0xb8,0x4a,0xa3
22+
# CHECK: fmsubd %f0, %f2, %f4, %f6
23+
0x8d,0xb8,0x08,0xc2
24+
# CHECK: fnmadds %f1, %f3, %f5, %f7
25+
0x8f,0xb8,0x4b,0xa3
26+
# CHECK: fnmaddd %f0, %f2, %f4, %f6
27+
0x8d,0xb8,0x09,0xc2
28+
# CHECK: fnmsubs %f1, %f3, %f5, %f7
29+
0x8f,0xb8,0x4b,0x23
30+
# CHECK: fnmsubd %f0, %f2, %f4, %f6
31+
0x8d,0xb8,0x09,0x42

llvm/test/MC/Sparc/sparc-ua2007.s

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
! RUN: not llvm-mc %s -triple=sparcv9 -show-encoding 2>&1 | FileCheck %s --check-prefixes=NO-UA2007 --implicit-check-not=error:
2+
! RUN: llvm-mc %s -triple=sparcv9 -mattr=+ua2007 -show-encoding | FileCheck %s --check-prefixes=UA2007
3+
4+
!! UA 2007 instructions.
5+
6+
! NO-UA2007: error: instruction requires a CPU feature not currently enabled
7+
! UA2007: fmadds %f1, %f3, %f5, %f7 ! encoding: [0x8f,0xb8,0x4a,0x23]
8+
fmadds %f1, %f3, %f5, %f7
9+
! NO-UA2007: error: instruction requires a CPU feature not currently enabled
10+
! UA2007: fmaddd %f0, %f2, %f4, %f6 ! encoding: [0x8d,0xb8,0x08,0x42]
11+
fmaddd %f0, %f2, %f4, %f6
12+
! NO-UA2007: error: instruction requires a CPU feature not currently enabled
13+
! UA2007: fmsubs %f1, %f3, %f5, %f7 ! encoding: [0x8f,0xb8,0x4a,0xa3]
14+
fmsubs %f1, %f3, %f5, %f7
15+
! NO-UA2007: error: instruction requires a CPU feature not currently enabled
16+
! UA2007: fmsubd %f0, %f2, %f4, %f6 ! encoding: [0x8d,0xb8,0x08,0xc2]
17+
fmsubd %f0, %f2, %f4, %f6
18+
19+
! NO-UA2007: error: instruction requires a CPU feature not currently enabled
20+
! UA2007: fnmadds %f1, %f3, %f5, %f7 ! encoding: [0x8f,0xb8,0x4b,0xa3]
21+
fnmadds %f1, %f3, %f5, %f7
22+
! NO-UA2007: error: instruction requires a CPU feature not currently enabled
23+
! UA2007: fnmaddd %f0, %f2, %f4, %f6 ! encoding: [0x8d,0xb8,0x09,0xc2]
24+
fnmaddd %f0, %f2, %f4, %f6
25+
! NO-UA2007: error: instruction requires a CPU feature not currently enabled
26+
! UA2007: fnmsubs %f1, %f3, %f5, %f7 ! encoding: [0x8f,0xb8,0x4b,0x23]
27+
fnmsubs %f1, %f3, %f5, %f7
28+
! NO-UA2007: error: instruction requires a CPU feature not currently enabled
29+
! UA2007: fnmsubd %f0, %f2, %f4, %f6 ! encoding: [0x8d,0xb8,0x09,0x42]
30+
fnmsubd %f0, %f2, %f4, %f6

0 commit comments

Comments
 (0)