Skip to content

Commit db89573

Browse files
committedMar 25, 2025
[SystemZ] Implement basic isCopyInstrImpl
As a first step toward implementing SystemZ support for instr-ref-based debug info tracking, this commit adds a basic implementation for the previously absent `SystemZInstrInfo::isCopyInstrImpl`. This is accomplished by adding a new flag called `isMoveReg` on the relevant instructions and calling upon that bit of information to implement the function. Which instructions to add the flag to was based on the implementation of `SystemZInstrInfo::copyPhysReg`. The full list of instructions is as follows: +General-Purpose Registers - `lr` - `lgr` +Floating Point Registers - `ler` - `ldr` - `lxr` +Vector Registers - `vlr`
1 parent 6477945 commit db89573

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed
 

‎llvm/lib/Target/SystemZ/SystemZInstrFP.td

+8-6
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ let isAsCheapAsAMove = 1, isMoveImm = 1 in {
4242
}
4343

4444
// Moves between two floating-point registers.
45-
def LER : UnaryRR <"ler", 0x38, null_frag, FP32, FP32>;
46-
def LDR : UnaryRR <"ldr", 0x28, null_frag, FP64, FP64>;
47-
def LXR : UnaryRRE<"lxr", 0xB365, null_frag, FP128, FP128>;
45+
let isMoveReg = 1 in {
46+
def LER : UnaryRR <"ler", 0x38, null_frag, FP32, FP32>;
47+
def LDR : UnaryRR <"ldr", 0x28, null_frag, FP64, FP64>;
48+
def LXR : UnaryRRE<"lxr", 0xB365, null_frag, FP128, FP128>;
49+
// For z13 we prefer LDR over LER to avoid partial register dependencies.
50+
let isCodeGenOnly = 1 in
51+
def LDR32 : UnaryRR<"ldr", 0x28, null_frag, FP32, FP32>;
52+
}
4853

49-
// For z13 we prefer LDR over LER to avoid partial register dependencies.
50-
let isCodeGenOnly = 1 in
51-
def LDR32 : UnaryRR<"ldr", 0x28, null_frag, FP32, FP32>;
5254

5355
// Moves between two floating-point registers that also set the condition
5456
// codes. Note that these instructions will turn SNaNs into QNaNs and should

‎llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -2316,3 +2316,12 @@ bool SystemZInstrInfo::getConstValDefinedInReg(const MachineInstr &MI,
23162316

23172317
return false;
23182318
}
2319+
2320+
std::optional<DestSourcePair>
2321+
SystemZInstrInfo::isCopyInstrImpl(const MachineInstr &MI) const {
2322+
// if MI is a simple single-register copy operation, return operand pair
2323+
if (MI.isMoveReg())
2324+
return DestSourcePair(MI.getOperand(0), MI.getOperand(1));
2325+
2326+
return std::nullopt;
2327+
}

‎llvm/lib/Target/SystemZ/SystemZInstrInfo.h

+3
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ class SystemZInstrInfo : public SystemZGenInstrInfo {
386386

387387
bool getConstValDefinedInReg(const MachineInstr &MI, const Register Reg,
388388
int64_t &ImmVal) const override;
389+
390+
std::optional<DestSourcePair>
391+
isCopyInstrImpl(const MachineInstr &MI) const override;
389392
};
390393

391394
} // end namespace llvm

‎llvm/lib/Target/SystemZ/SystemZInstrInfo.td

+4-2
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,10 @@ defm CondStore64 : CondStores<GR64, simple_store,
424424
//===----------------------------------------------------------------------===//
425425

426426
// Register moves.
427-
def LR : UnaryRR <"lr", 0x18, null_frag, GR32, GR32>;
428-
def LGR : UnaryRRE<"lgr", 0xB904, null_frag, GR64, GR64>;
427+
let isMoveReg = 1 in {
428+
def LR : UnaryRR <"lr", 0x18, null_frag, GR32, GR32>;
429+
def LGR : UnaryRRE<"lgr", 0xB904, null_frag, GR64, GR64>;
430+
}
429431

430432
let Defs = [CC], CCValues = 0xE, CompareZeroCCMask = 0xE in {
431433
def LTR : UnaryRR <"ltr", 0x12, null_frag, GR32, GR32>;

‎llvm/lib/Target/SystemZ/SystemZInstrVector.td

+5-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212

1313
let Predicates = [FeatureVector] in {
1414
// Register move.
15-
def VLR : UnaryVRRa<"vlr", 0xE756, null_frag, v128any, v128any>;
16-
def VLR32 : UnaryAliasVRR<null_frag, v32sb, v32sb>;
17-
def VLR64 : UnaryAliasVRR<null_frag, v64db, v64db>;
15+
let isMoveReg = 1 in {
16+
def VLR : UnaryVRRa<"vlr", 0xE756, null_frag, v128any, v128any>;
17+
def VLR32 : UnaryAliasVRR<null_frag, v32sb, v32sb>;
18+
def VLR64 : UnaryAliasVRR<null_frag, v64db, v64db>;
19+
}
1820

1921
// Load GR from VR element.
2022
def VLGV : BinaryVRScGeneric<"vlgv", 0xE721>;

0 commit comments

Comments
 (0)
Failed to load comments.