Skip to content

Commit

Permalink
[SystemZ] Support load-and-zero-rightmost-byte facility
Browse files Browse the repository at this point in the history
This adds support for the LZRF/LZRG/LLZRGF instructions that were
added on z13, and uses them for code generation were appropriate.

SystemZDAGToDAGISel::tryRISBGZero is updated again to prefer LLZRGF
over RISBG where both would be possible.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286586 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
uweigand committed Nov 11, 2016
1 parent 9035357 commit 864946f
Show file tree
Hide file tree
Showing 10 changed files with 507 additions and 3 deletions.
6 changes: 6 additions & 0 deletions lib/Target/SystemZ/SystemZFeatures.td
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ def Arch10NewFeatures : SystemZFeatureList<[
//
//===----------------------------------------------------------------------===//

def FeatureLoadAndZeroRightmostByte : SystemZFeature<
"load-and-zero-rightmost-byte", "LoadAndZeroRightmostByte",
"Assume that the load-and-zero-rightmost-byte facility is installed"
>;

def FeatureLoadStoreOnCond2 : SystemZFeature<
"load-store-on-cond-2", "LoadStoreOnCond2",
"Assume that the load/store-on-condition facility 2 is installed"
Expand All @@ -123,6 +128,7 @@ def FeatureVector : SystemZFeature<
def FeatureNoVector : SystemZMissingFeature<"Vector">;

def Arch11NewFeatures : SystemZFeatureList<[
FeatureLoadAndZeroRightmostByte,
FeatureLoadStoreOnCond2,
FeatureVector
]>;
Expand Down
10 changes: 10 additions & 0 deletions lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,16 @@ bool SystemZDAGToDAGISel::tryRISBGZero(SDNode *N) {
SystemZ::isImmLF(~RISBG.Mask) ||
SystemZ::isImmHF(~RISBG.Mask))
PreferAnd = true;
// And likewise for the LLZRGF instruction, which doesn't have a register
// to register version.
else if (auto *Load = dyn_cast<LoadSDNode>(RISBG.Input)) {
if (Load->getMemoryVT() == MVT::i32 &&
(Load->getExtensionType() == ISD::EXTLOAD ||
Load->getExtensionType() == ISD::ZEXTLOAD) &&
RISBG.Mask == 0xffffff00 &&
Subtarget->hasLoadAndZeroRightmostByte())
PreferAnd = true;
}
if (PreferAnd) {
// Replace the current node with an AND. Note that the current node
// might already be that same AND, in which case it is already CSE'd
Expand Down
17 changes: 17 additions & 0 deletions lib/Target/SystemZ/SystemZInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,16 @@ let canFoldAsLoad = 1 in {
def LGRL : UnaryRILPC<"lgrl", 0xC48, aligned_load, GR64>;
}

// Load and zero rightmost byte.
let Predicates = [FeatureLoadAndZeroRightmostByte] in {
def LZRF : UnaryRXY<"lzrf", 0xE33B, null_frag, GR32, 4>;
def LZRG : UnaryRXY<"lzrg", 0xE32A, null_frag, GR64, 8>;
def : Pat<(and (i32 (load bdxaddr20only:$src)), 0xffffff00),
(LZRF bdxaddr20only:$src)>;
def : Pat<(and (i64 (load bdxaddr20only:$src)), 0xffffffffffffff00),
(LZRG bdxaddr20only:$src)>;
}

// Register stores.
let SimpleBDXStore = 1 in {
// Expands to ST, STY or STFH, depending on the choice of register.
Expand Down Expand Up @@ -583,6 +593,13 @@ def : Pat<(and GR64:$src, 0x7fffffff),
def : Pat<(and (i64 (azextloadi32 bdxaddr20only:$src)), 0x7fffffff),
(LLGT bdxaddr20only:$src)>;

// Load and zero rightmost byte.
let Predicates = [FeatureLoadAndZeroRightmostByte] in {
def LLZRGF : UnaryRXY<"llzrgf", 0xE33A, null_frag, GR64, 4>;
def : Pat<(and (i64 (azextloadi32 bdxaddr20only:$src)), 0xffffff00),
(LLZRGF bdxaddr20only:$src)>;
}

//===----------------------------------------------------------------------===//
// Truncations
//===----------------------------------------------------------------------===//
Expand Down
6 changes: 6 additions & 0 deletions lib/Target/SystemZ/SystemZScheduleZ13.td
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ def : InstRW<[FXa], (instregex "LG(F|H)I$")>;
def : InstRW<[FXa], (instregex "LHI(Mux)?$")>;
def : InstRW<[FXa], (instregex "LR(Mux)?$")>;

// Load and zero rightmost byte
def : InstRW<[LSU], (instregex "LZR(F|G)$")>;

// Load and test
def : InstRW<[FXa, LSU, Lat5], (instregex "LT(G)?$")>;
def : InstRW<[FXa], (instregex "LT(G)?R$")>;
Expand Down Expand Up @@ -244,6 +247,9 @@ def : InstRW<[FXa, LSU, Lat5], (instregex "LL(C|H)H$")>;
def : InstRW<[LSU], (instregex "LLHRL$")>;
def : InstRW<[LSU], (instregex "LLG(C|H|F|T|HRL|FRL)$")>;

// Load and zero rightmost byte
def : InstRW<[LSU], (instregex "LLZRGF$")>;

//===----------------------------------------------------------------------===//
// Truncations
//===----------------------------------------------------------------------===//
Expand Down
7 changes: 4 additions & 3 deletions lib/Target/SystemZ/SystemZSubtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ SystemZSubtarget::SystemZSubtarget(const Triple &TT, const std::string &CPU,
HasPopulationCount(false), HasFastSerialization(false),
HasInterlockedAccess1(false), HasMiscellaneousExtensions(false),
HasTransactionalExecution(false), HasProcessorAssist(false),
HasVector(false), HasLoadStoreOnCond2(false), TargetTriple(TT),
InstrInfo(initializeSubtargetDependencies(CPU, FS)), TLInfo(TM, *this),
TSInfo(), FrameLowering() {}
HasVector(false), HasLoadStoreOnCond2(false),
HasLoadAndZeroRightmostByte(false),
TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
TLInfo(TM, *this), TSInfo(), FrameLowering() {}

bool SystemZSubtarget::isPC32DBLSymbol(const GlobalValue *GV,
CodeModel::Model CM) const {
Expand Down
6 changes: 6 additions & 0 deletions lib/Target/SystemZ/SystemZSubtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class SystemZSubtarget : public SystemZGenSubtargetInfo {
bool HasProcessorAssist;
bool HasVector;
bool HasLoadStoreOnCond2;
bool HasLoadAndZeroRightmostByte;

private:
Triple TargetTriple;
Expand Down Expand Up @@ -115,6 +116,11 @@ class SystemZSubtarget : public SystemZGenSubtargetInfo {
// Return true if the target has the processor-assist facility.
bool hasProcessorAssist() const { return HasProcessorAssist; }

// Return true if the target has the load-and-zero-rightmost-byte facility.
bool hasLoadAndZeroRightmostByte() const {
return HasLoadAndZeroRightmostByte;
}

// Return true if the target has the vector facility.
bool hasVector() const { return HasVector; }

Expand Down
Loading

0 comments on commit 864946f

Please sign in to comment.