mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-01 15:40:46 +00:00
[PowerPC] Basic support for P9 atomic loads and stores
This patch corresponds to review: http://reviews.llvm.org/D18032 This patch provides asm implementation for the following instructions: lwat, ldat, stwat, stdat, ldmx, mcrxrx git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265022 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7a8b700c13
commit
5a73f4bec5
@ -163,6 +163,10 @@ def FeatureSlowPOPCNTD : SubtargetFeature<"slow-popcntd","HasPOPCNTD",
|
||||
def DeprecatedDST : SubtargetFeature<"", "DeprecatedDST", "true",
|
||||
"Treat vector data stream cache control instructions as deprecated">;
|
||||
|
||||
def FeatureISA3_0 : SubtargetFeature<"isa-v30-instructions", "IsISA3_0",
|
||||
"true",
|
||||
"Enable instructions added in ISA 3.0.">;
|
||||
|
||||
/* Since new processors generally contain a superset of features of those that
|
||||
came before them, the idea is to make implementations of new processors
|
||||
less error prone and easier to read.
|
||||
|
@ -244,12 +244,22 @@ def LDARX : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
|
||||
// (EH=1 - see Power ISA 2.07 Book II 4.4.2)
|
||||
def LDARXL : XForm_1<31, 84, (outs g8rc:$rD), (ins memrr:$ptr),
|
||||
"ldarx $rD, $ptr, 1", IIC_LdStLDARX, []>, isDOT;
|
||||
|
||||
let hasExtraDefRegAllocReq = 1 in
|
||||
def LDAT : X_RD5_RS5_IM5<31, 614, (outs g8rc:$rD), (ins g8rc:$rA, u5imm:$FC),
|
||||
"ldat $rD, $rA, $FC", IIC_LdStLoad>, isPPC64,
|
||||
Requires<[IsISA3_0]>;
|
||||
}
|
||||
|
||||
let Defs = [CR0], mayStore = 1, hasSideEffects = 0 in
|
||||
def STDCX : XForm_1<31, 214, (outs), (ins g8rc:$rS, memrr:$dst),
|
||||
"stdcx. $rS, $dst", IIC_LdStSTDCX, []>, isDOT;
|
||||
|
||||
let mayStore = 1, hasSideEffects = 0 in
|
||||
def STDAT : X_RD5_RS5_IM5<31, 742, (outs), (ins g8rc:$rS, g8rc:$rA, u5imm:$FC),
|
||||
"stdat $rS, $rA, $FC", IIC_LdStStore>, isPPC64,
|
||||
Requires<[IsISA3_0]>;
|
||||
|
||||
let Interpretation64Bit = 1, isCodeGenOnly = 1 in {
|
||||
let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [RM] in
|
||||
def TCRETURNdi8 :Pseudo< (outs),
|
||||
@ -905,6 +915,10 @@ def LDUX : XForm_1<31, 53, (outs g8rc:$rD, ptr_rc_nor0:$ea_result),
|
||||
"ldux $rD, $addr", IIC_LdStLDUX,
|
||||
[]>, RegConstraint<"$addr.ptrreg = $ea_result">,
|
||||
NoEncode<"$ea_result">, isPPC64;
|
||||
|
||||
def LDMX : XForm_1<31, 309, (outs g8rc:$rD), (ins memrr:$src),
|
||||
"ldmx $rD, $src", IIC_LdStLD, []>, isPPC64,
|
||||
Requires<[IsISA3_0]>;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -800,6 +800,20 @@ class X_RD6_IMM8<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
|
||||
let Inst{31} = XT{5};
|
||||
}
|
||||
|
||||
// XForm_base_r3xo for instructions such as P9 atomics where we don't want
|
||||
// to specify an SDAG pattern for matching.
|
||||
class X_RD5_RS5_IM5<bits<6> opcode, bits<10> xo, dag OOL, dag IOL,
|
||||
string asmstr, InstrItinClass itin>
|
||||
: XForm_base_r3xo<opcode, xo, OOL, IOL, asmstr, itin, []> {
|
||||
}
|
||||
|
||||
class X_BF3<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
|
||||
InstrItinClass itin>
|
||||
: XForm_17<opcode, xo, OOL, IOL, asmstr, itin> {
|
||||
let FRA = 0;
|
||||
let FRB = 0;
|
||||
}
|
||||
|
||||
// XX*-Form (VSX)
|
||||
class XX1Form<bits<6> opcode, bits<10> xo, dag OOL, dag IOL, string asmstr,
|
||||
InstrItinClass itin, list<dag> pattern>
|
||||
|
@ -777,6 +777,7 @@ def NoNaNsFPMath : Predicate<"TM.Options.NoNaNsFPMath">;
|
||||
def NaNsFPMath : Predicate<"!TM.Options.NoNaNsFPMath">;
|
||||
def HasBPERMD : Predicate<"PPCSubTarget->hasBPERMD()">;
|
||||
def HasExtDiv : Predicate<"PPCSubTarget->hasExtDiv()">;
|
||||
def IsISA3_0 : Predicate<"PPCSubTarget->isISA3_0()">;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// PowerPC Multiclass Definitions.
|
||||
@ -1574,6 +1575,13 @@ def LHARXL : XForm_1<31, 116, (outs gprc:$rD), (ins memrr:$src),
|
||||
|
||||
def LWARXL : XForm_1<31, 20, (outs gprc:$rD), (ins memrr:$src),
|
||||
"lwarx $rD, $src, 1", IIC_LdStLWARX, []>, isDOT;
|
||||
|
||||
// The atomic instructions use the destination register as well as the next one
|
||||
// or two registers in order (modulo 31).
|
||||
let hasExtraSrcRegAllocReq = 1 in
|
||||
def LWAT : X_RD5_RS5_IM5<31, 582, (outs gprc:$rD), (ins gprc:$rA, u5imm:$FC),
|
||||
"lwat $rD, $rA, $FC", IIC_LdStLoad>,
|
||||
Requires<[IsISA3_0]>;
|
||||
}
|
||||
|
||||
let Defs = [CR0], mayStore = 1, hasSideEffects = 0 in {
|
||||
@ -1589,6 +1597,11 @@ def STWCX : XForm_1<31, 150, (outs), (ins gprc:$rS, memrr:$dst),
|
||||
"stwcx. $rS, $dst", IIC_LdStSTWCX, []>, isDOT;
|
||||
}
|
||||
|
||||
let mayStore = 1, hasSideEffects = 0 in
|
||||
def STWAT : X_RD5_RS5_IM5<31, 710, (outs), (ins gprc:$rS, gprc:$rA, u5imm:$FC),
|
||||
"stwat $rS, $rA, $FC", IIC_LdStStore>,
|
||||
Requires<[IsISA3_0]>;
|
||||
|
||||
let isTerminator = 1, isBarrier = 1, hasCtrlDep = 1 in
|
||||
def TRAP : XForm_24<31, 4, (outs), (ins), "trap", IIC_LdStLoad, [(trap)]>;
|
||||
|
||||
@ -2359,6 +2372,9 @@ def MFCR : XFXForm_3<31, 19, (outs gprc:$rT), (ins),
|
||||
"mfcr $rT", IIC_SprMFCR>,
|
||||
PPC970_MicroCode, PPC970_Unit_CRU;
|
||||
} // hasExtraSrcRegAllocReq = 1
|
||||
|
||||
def MCRXRX : X_BF3<31, 576, (outs crrc:$BF), (ins),
|
||||
"mcrxrx $BF", IIC_BrMCRX>, Requires<[IsISA3_0]>;
|
||||
} // hasSideEffects = 0
|
||||
|
||||
// Pseudo instruction to perform FADD in round-to-zero mode.
|
||||
|
@ -104,6 +104,7 @@ void PPCSubtarget::initializeEnvironment() {
|
||||
HasHTM = false;
|
||||
HasFusion = false;
|
||||
HasFloat128 = false;
|
||||
IsISA3_0 = false;
|
||||
|
||||
HasPOPCNTD = POPCNTD_Unavailable;
|
||||
}
|
||||
|
@ -130,6 +130,7 @@ protected:
|
||||
bool HasHTM;
|
||||
bool HasFusion;
|
||||
bool HasFloat128;
|
||||
bool IsISA3_0;
|
||||
|
||||
POPCNTDKind HasPOPCNTD;
|
||||
|
||||
@ -272,6 +273,7 @@ public:
|
||||
bool hasHTM() const { return HasHTM; }
|
||||
bool hasFusion() const { return HasFusion; }
|
||||
bool hasFloat128() const { return HasFloat128; }
|
||||
bool isISA3_0() const { return IsISA3_0; }
|
||||
|
||||
POPCNTDKind hasPOPCNTD() const { return HasPOPCNTD; }
|
||||
|
||||
|
@ -558,3 +558,18 @@ VSX:
|
||||
- Load Vector Word & Splat Indexed: lxvwsx
|
||||
. Likely needs an intrinsic
|
||||
. (set v?:$XT, (int_ppc_vsx_lxvwsx xoaddr:$src))
|
||||
|
||||
Atomic operations (l[dw]at, st[dw]at):
|
||||
- Provide custom lowering for common atomic operations to use these
|
||||
instructions with the correct Function Code
|
||||
- Ensure the operands are in the correct register (i.e. RT+1, RT+2)
|
||||
- Provide builtins since not all FC's necessarily have an existing LLVM
|
||||
atomic operation
|
||||
|
||||
Load Doubleword Monitored (ldmx):
|
||||
- Investigate whether there are any uses for this. It seems to be related to
|
||||
Garbage Collection so it isn't likely to be all that useful for most
|
||||
languages we deal with.
|
||||
|
||||
Move to CR from XER Extended (mcrxrx):
|
||||
- Is there a use for this in LLVM?
|
||||
|
@ -33,6 +33,12 @@
|
||||
# CHECK: stdcx. 2, 3, 4
|
||||
0x7c 0x43 0x21 0xad
|
||||
|
||||
# CHECK: stwat 2, 3, 28
|
||||
0x7c 0x43 0xe5 0x8c
|
||||
|
||||
# CHECK: stdat 2, 3, 28
|
||||
0x7c 0x43 0xe5 0xcc
|
||||
|
||||
# CHECK: ptesync
|
||||
0x7c 0x40 0x04 0xac
|
||||
|
||||
@ -72,6 +78,12 @@
|
||||
# CHECK: ldarx 2, 3, 4, 1
|
||||
0x7c 0x43 0x20 0xa9
|
||||
|
||||
# CHECK: lwat 2, 3, 28
|
||||
0x7c 0x43 0xe4 0x8c
|
||||
|
||||
# CHECK: ldat 2, 3, 28
|
||||
0x7c 0x43 0xe4 0xcc
|
||||
|
||||
# CHECK: sync
|
||||
0x7c 0x00 0x04 0xac
|
||||
|
||||
|
@ -151,6 +151,9 @@
|
||||
# CHECK: ldux 2, 3, 4
|
||||
0x7c 0x43 0x20 0x6a
|
||||
|
||||
# CHECK: ldmx 2, 3, 4
|
||||
0x7c 0x43 0x22 0x6a
|
||||
|
||||
# CHECK: stb 2, 128(4)
|
||||
0x98 0x44 0x00 0x80
|
||||
|
||||
@ -658,7 +661,11 @@
|
||||
# CHECK: mfocrf 16, 8
|
||||
0x7e 0x10 0x80 0x26
|
||||
|
||||
# CHECK: mcrxrx 7
|
||||
0x7f 0x80 0x04 0x80
|
||||
|
||||
# CHECK: mtsrin 10, 12
|
||||
0x7d 0x40 0x61 0xe4
|
||||
|
||||
# CHECK: mfsrin 10, 12
|
||||
0x7d 0x40 0x65 0x26
|
||||
|
@ -73,10 +73,19 @@
|
||||
# CHECK-BE: stwcx. 2, 3, 4 # encoding: [0x7c,0x43,0x21,0x2d]
|
||||
# CHECK-LE: stwcx. 2, 3, 4 # encoding: [0x2d,0x21,0x43,0x7c]
|
||||
stwcx. 2, 3, 4
|
||||
|
||||
# CHECK-BE: stdcx. 2, 3, 4 # encoding: [0x7c,0x43,0x21,0xad]
|
||||
# CHECK-LE: stdcx. 2, 3, 4 # encoding: [0xad,0x21,0x43,0x7c]
|
||||
stdcx. 2, 3, 4
|
||||
|
||||
# CHECK-BE: stwat 2, 3, 28 # encoding: [0x7c,0x43,0xe5,0x8c]
|
||||
# CHECK-LE: stwat 2, 3, 28 # encoding: [0x8c,0xe5,0x43,0x7c]
|
||||
stwat 2, 3, 28
|
||||
|
||||
# CHECK-BE: stdat 2, 3, 28 # encoding: [0x7c,0x43,0xe5,0xcc]
|
||||
# CHECK-LE: stdat 2, 3, 28 # encoding: [0xcc,0xe5,0x43,0x7c]
|
||||
stdat 2, 3, 28
|
||||
|
||||
# CHECK-BE: ptesync # encoding: [0x7c,0x40,0x04,0xac]
|
||||
# CHECK-LE: ptesync # encoding: [0xac,0x04,0x40,0x7c]
|
||||
sync 2
|
||||
@ -131,6 +140,14 @@
|
||||
# CHECK-LE: ldarx 2, 3, 4, 1 # encoding: [0xa9,0x20,0x43,0x7c]
|
||||
ldarx 2, 3, 4, 1
|
||||
|
||||
# CHECK-BE: lwat 2, 3, 28 # encoding: [0x7c,0x43,0xe4,0x8c]
|
||||
# CHECK-LE: lwat 2, 3, 28 # encoding: [0x8c,0xe4,0x43,0x7c]
|
||||
lwat 2, 3, 28
|
||||
|
||||
# CHECK-BE: ldat 2, 3, 28 # encoding: [0x7c,0x43,0xe4,0xcc]
|
||||
# CHECK-LE: ldat 2, 3, 28 # encoding: [0xcc,0xe4,0x43,0x7c]
|
||||
ldat 2, 3, 28
|
||||
|
||||
# CHECK-BE: sync # encoding: [0x7c,0x00,0x04,0xac]
|
||||
# CHECK-LE: sync # encoding: [0xac,0x04,0x00,0x7c]
|
||||
sync
|
||||
|
@ -197,6 +197,9 @@
|
||||
# CHECK-BE: ldux 2, 3, 4 # encoding: [0x7c,0x43,0x20,0x6a]
|
||||
# CHECK-LE: ldux 2, 3, 4 # encoding: [0x6a,0x20,0x43,0x7c]
|
||||
ldux 2, 3, 4
|
||||
# CHECK-BE: ldmx 2, 3, 4 # encoding: [0x7c,0x43,0x22,0x6a]
|
||||
# CHECK-LE: ldmx 2, 3, 4 # encoding: [0x6a,0x22,0x43,0x7c]
|
||||
ldmx 2, 3, 4
|
||||
|
||||
# Fixed-point store instructions
|
||||
|
||||
@ -833,6 +836,9 @@
|
||||
# CHECK-BE: mfocrf 16, 8 # encoding: [0x7e,0x10,0x80,0x26]
|
||||
# CHECK-LE: mfocrf 16, 8 # encoding: [0x26,0x80,0x10,0x7e]
|
||||
mfocrf 16, 8
|
||||
# CHECK-BE: mcrxrx 7 # encoding: [0x7f,0x80,0x04,0x80]
|
||||
# CHECK-LE: mcrxrx 7 # encoding: [0x80,0x04,0x80,0x7f]
|
||||
mcrxrx 7
|
||||
|
||||
# Move to/from segment register
|
||||
# CHECK-BE: mtsr 12, 10 # encoding: [0x7d,0x4c,0x01,0xa4]
|
||||
|
Loading…
Reference in New Issue
Block a user