Skip to content

Commit f46084c

Browse files
[SystemZ] Allow MAY(R)? to accept the high components of register pairs
The HFP instructions MAY and MAYR, unlike any other floating point instruction, allow the specification of a 128bit register pair by either the lower-numbered or the higher-numbered component register. In order to support this, the existing MAY(R)? definition is changed to simply accept a 64bit floating point register in place of the 128bit one. Since the instruction is currently not used for code generation, this is safe. A comment is added to ensure that this is taken into account if and when these instructions are enabled for CodeGen. The corresponding assembly tests that checked the register specification rule that this commit removes from MAY(R)? are also deleted, and conversely, tests to check for the acceptance of the previously forbidden encodings are added.
1 parent 5ed5d72 commit f46084c

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

llvm/lib/Target/SystemZ/SystemZInstrHFP.td

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,23 @@ def MYH : BinaryRXF<"myh", 0xED3D, null_frag, FP64, FP64, z_load, 8>;
209209
def MYL : BinaryRXF<"myl", 0xED39, null_frag, FP64, FP64, z_load, 8>;
210210

211211
// Fused multiply-add (unnormalized).
212-
def MAYR : TernaryRRD<"mayr", 0xB33A, null_frag, FP128, FP64>;
213212
def MAYHR : TernaryRRD<"mayhr", 0xB33C, null_frag, FP64, FP64>;
214213
def MAYLR : TernaryRRD<"maylr", 0xB338, null_frag, FP64, FP64>;
215-
def MAY : TernaryRXF<"may", 0xED3A, null_frag, FP128, FP64, z_load, 8>;
216214
def MAYH : TernaryRXF<"mayh", 0xED3C, null_frag, FP64, FP64, z_load, 8>;
217215
def MAYL : TernaryRXF<"mayl", 0xED38, null_frag, FP64, FP64, z_load, 8>;
218216

217+
// MAY and MAYR allow the user to specify the floating point register pair
218+
// making up the FP128 register by either the lower-numbered register or the
219+
// higher-numbered register, in contrast to all other floating point
220+
// instructions.
221+
// For this reason, the defs below accept `FP64,FP64` instead of `FP128,FP64`.
222+
// This is ok since these instructions are not used in code generation.
223+
// If and when code generation is enabled, the code gen variants should be
224+
// split out from this and use the proper register classes, while these should
225+
// remain for the Assembler and Disassembler to remain compliant with the POP.
226+
def MAY : TernaryRXF<"may", 0xED3A, null_frag, FP64, FP64, z_load, 8>;
227+
def MAYR : TernaryRRD<"mayr", 0xB33A, null_frag, FP64, FP64>;
228+
219229
// Division.
220230
def DER : BinaryRR <"der", 0x3D, null_frag, FP32, FP32>;
221231
def DDR : BinaryRR <"ddr", 0x2D, null_frag, FP64, FP64>;

llvm/test/MC/SystemZ/insn-bad.s

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4176,12 +4176,9 @@
41764176
#CHECK: may %f0, %f0, -1
41774177
#CHECK: error: invalid operand
41784178
#CHECK: may %f0, %f0, 4096
4179-
#CHECK: error: invalid register pair
4180-
#CHECK: may %f2, %f0, 0
41814179

41824180
may %f0, %f0, -1
41834181
may %f0, %f0, 4096
4184-
may %f2, %f0, 0
41854182

41864183
#CHECK: error: invalid operand
41874184
#CHECK: mayh %f0, %f0, -1
@@ -4199,11 +4196,6 @@
41994196
mayl %f0, %f0, -1
42004197
mayl %f0, %f0, 4096
42014198

4202-
#CHECK: error: invalid register pair
4203-
#CHECK: mayr %f2, %f0, %f0
4204-
4205-
mayr %f2, %f0, %f0
4206-
42074199
#CHECK: error: invalid operand
42084200
#CHECK: mc -1, 0
42094201
#CHECK: error: invalid operand

llvm/test/MC/SystemZ/insn-good.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11517,6 +11517,7 @@
1151711517
#CHECK: may %f0, %f15, 0 # encoding: [0xed,0xf0,0x00,0x00,0x00,0x3a]
1151811518
#CHECK: may %f13, %f0, 0 # encoding: [0xed,0x00,0x00,0x00,0xd0,0x3a]
1151911519
#CHECK: may %f13, %f15, 0 # encoding: [0xed,0xf0,0x00,0x00,0xd0,0x3a]
11520+
#CHECK: may %f2, %f0, 0 # encoding: [0xed,0x00,0x00,0x00,0x20,0x3a]
1152011521

1152111522
may %f0, %f0, 0
1152211523
may %f0, %f0, 4095
@@ -11527,6 +11528,7 @@
1152711528
may %f0, %f15, 0
1152811529
may %f13, %f0, 0
1152911530
may %f13, %f15, 0
11531+
may %f2, %f0, 0
1153011532

1153111533
#CHECK: mayh %f0, %f0, 0 # encoding: [0xed,0x00,0x00,0x00,0x00,0x3c]
1153211534
#CHECK: mayh %f0, %f0, 4095 # encoding: [0xed,0x00,0x0f,0xff,0x00,0x3c]
@@ -11602,13 +11604,15 @@
1160211604
#CHECK: mayr %f13, %f0, %f0 # encoding: [0xb3,0x3a,0xd0,0x00]
1160311605
#CHECK: mayr %f5, %f8, %f9 # encoding: [0xb3,0x3a,0x50,0x89]
1160411606
#CHECK: mayr %f13, %f15, %f15 # encoding: [0xb3,0x3a,0xd0,0xff]
11607+
#CHECK: mayr %f2, %f0, %f0 # encoding: [0xb3,0x3a,0x20,0x00]
1160511608

1160611609
mayr %f0, %f0, %f0
1160711610
mayr %f0, %f0, %f15
1160811611
mayr %f0, %f15, %f0
1160911612
mayr %f13, %f0, %f0
1161011613
mayr %f5, %f8, %f9
1161111614
mayr %f13, %f15, %f15
11615+
mayr %f2, %f0, %f0
1161211616

1161311617
#CHECK: mc 0, 0 # encoding: [0xaf,0x00,0x00,0x00]
1161411618
#CHECK: mc 4095, 0 # encoding: [0xaf,0x00,0x0f,0xff]

0 commit comments

Comments
 (0)